Skip to content

Commit 3ee2e3d

Browse files
committed
refactor definition name to module-level variable
transition consumers to load the definition by name instead of making another function call to mds_feature_point_definition
1 parent 64bae6f commit 3ee2e3d

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

schema/common.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
COMMON_DEFINITIONS = {}
1212

1313

14+
MDS_FEATURE_POINT = "MDS_Feature_Point"
15+
16+
1417
def load_json(path):
1518
"""
1619
Load a JSON file from disk.
@@ -132,14 +135,12 @@ def mds_feature_point_definition():
132135
"""
133136
Create a customized definition of the GeoJSON Feature schema for MDS Points.
134137
"""
135-
name = "MDS_Feature_Point"
136-
137138
# Get the canonical Feature schema
138139
feature = requests.get("http://geojson.org/schema/Feature.json").json()
139140

140141
# Modify metadata
141142
feature.pop("$schema")
142-
feature["$id"] = definition_id(name)
143+
feature["$id"] = definition_id(MDS_FEATURE_POINT)
143144
feature["title"] = "MDS GeoJSON Feature Point"
144145

145146
# Only allow GeoJSON Point feature geometry
@@ -163,7 +164,7 @@ def mds_feature_point_definition():
163164
}
164165
}
165166

166-
return {name: feature}
167+
return {MDS_FEATURE_POINT: feature}
167168

168169

169170
def stop_definitions():
@@ -177,9 +178,9 @@ def stop_definitions():
177178
"timestamp",
178179
"uuid",
179180
"uuid_array",
180-
"vehicle_type_counts"
181+
"vehicle_type_counts",
182+
MDS_FEATURE_POINT
181183
)
182-
definitions.update(mds_feature_point_definition())
183184

184185
return definitions
185186

schema/provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def endpoint_schema(endpoint, extra_definitions={}):
4848
"string",
4949
"timestamp",
5050
"uuid",
51-
"version"
51+
"version",
52+
common.MDS_FEATURE_POINT
5253
)
5354
definitions.update(common.point_definition())
54-
definitions.update(common.mds_feature_point_definition())
5555
definitions.update(extra_definitions)
5656

5757
endpoint_schema = common.load_json(f"./templates/provider/{endpoint}.json")

0 commit comments

Comments
 (0)