@@ -128,66 +128,43 @@ def point_definition():
128128 }
129129
130130
131- def feature_schema ( id = None , title = None , geometry = None , properties = None , required = None ):
131+ def mds_feature_point_definition ( ):
132132 """
133- Get the canonical schema for a GeoJSON Feature,
134- and make any given modifications.
135-
136- :id: overrides the `$id` metadata
137- :title: overrides the `title` metadata
138- :geometry: overrides the allowed `geometry` for the Feature
139- :properties: overrides the `properties` definitions for this Feature
140- :required: is a list of required :properties:
133+ Create a customized definition of the GeoJSON Feature schema for MDS Points.
141134 """
135+ name = "MDS_Feature_Point"
136+
142137 # Get the canonical Feature schema
143138 feature = requests .get ("http://geojson.org/schema/Feature.json" ).json ()
144139
145- # Modify some metadata
140+ # Modify metadata
146141 feature .pop ("$schema" )
147- if id is not None :
148- feature ["$id" ] = id
149- if title is not None :
150- feature ["title" ] = title
142+ feature ["$id" ] = definition_id (name )
143+ feature ["title" ] = "MDS GeoJSON Feature Point"
151144
152- if geometry is not None :
153- feature ["properties" ]["geometry" ] = geometry
145+ # Only allow GeoJSON Point feature geometry
146+ feature ["properties" ]["geometry" ] = { "$ref" : definition_id ( "Point" ) }
154147
148+ # Modfy properties definition/requirements
155149 f_properties = feature ["properties" ]["properties" ]
156- if required is not None :
157- del f_properties ["oneOf" ]
158- f_properties ["type" ] = "object"
159- f_properties ["required" ] = required
160- if properties is not None :
161- f_properties ["properties" ] = properties
162-
163- return feature
150+ del f_properties ["oneOf" ]
151+ f_properties ["type" ] = "object"
164152
153+ # Point features must include the timestamp
154+ f_properties ["required" ] = ["timestamp" ]
165155
166- def mds_feature_point_definition ():
167- """
168- Create a customized definition of the GeoJSON Feature schema for MDS Points.
169- """
170- name = "MDS_Feature_Point"
171- return {
172- name : feature_schema (
173- id = definition_id (name ),
174- title = "MDS GeoJSON Feature Point" ,
175- # Only allow GeoJSON Point feature geometry
176- geometry = { "$ref" : definition_id ("Point" ) },
177- properties = {
178- "timestamp" : {
179- "$ref" : definition_id ("timestamp" )
180- },
181- # Locations corresponding to Stops must include a `stop_id` reference
182- "stop_id" : {
183- "$ref" : definition_id ("uuid" )
184- }
185- },
186- # Point features *must* include the `timestamp`
187- required = ["timestamp" ]
188- )
156+ f_properties ["properties" ] = {
157+ "timestamp" : {
158+ "$ref" : definition_id ("timestamp" )
159+ },
160+ # Locations corresponding to Stops must include a stop_id reference
161+ "stop_id" : {
162+ "$ref" : definition_id ("uuid" )
163+ }
189164 }
190165
166+ return {name : feature }
167+
191168
192169def stop_definitions ():
193170 """
0 commit comments