@@ -195,59 +195,71 @@ def geojson2jsonld(cls, data: dict, dataset: str,
195195 context = linked_data .get ('context' , []).copy ()
196196 templates = cls .get_dataset_templates (dataset )
197197
198- defaultVocabulary = {
199- 'schema' : 'https://schema.org/' ,
200- 'gsp' : 'http://www.opengis.net/ont/geosparql#' ,
201- 'type' : '@type'
202- }
203-
204- if identifier :
205- # Expand properties block
206- data .update (data .pop ('properties' ))
207-
208- # Include multiple geometry encodings
209- if (data .get ('geometry' ) is not None ):
210- jsonldify_geometry (data )
211-
212- data ['@id' ] = identifier
213-
198+ if (identifier and context
199+ and linked_data .get ('inject_verbatim_context' , False )):
200+ ldjsonData = {
201+ '@context' : context ,
202+ ** data
203+ }
204+ if replace_id_field := linked_data .get ('replace_id_field' ):
205+ ldjsonData [replace_id_field ] = identifier
214206 else :
215- # Collection of jsonld
216- defaultVocabulary .update ({
217- 'features' : 'schema:itemListElement' ,
218- 'FeatureCollection' : 'schema:itemList'
219- })
220-
221- ds_url = url_join (cls .get_collections_url (), dataset )
222- data ['@id' ] = ds_url
223-
224- for i , feature in enumerate (data ['features' ]):
225- # Get URI for each feature
226- identifier_ = feature .get (id_field ,
227- feature ['properties' ].get (id_field , '' ))
228- if not is_url (str (identifier_ )):
229- identifier_ = f"{ ds_url } /items/{ feature ['id' ]} " # noqa
230207
231- # Include multiple geometry encodings
232- if feature .get ('geometry' ) is not None :
233- jsonldify_geometry (feature )
234-
235- data ['features' ][i ] = {
236- '@id' : identifier_ ,
237- 'type' : 'schema:Place' ,
238- ** feature .pop ('properties' ),
239- ** feature
240- }
241-
242- if data .get ('timeStamp' , False ):
243- data ['https://schema.org/sdDatePublished' ] = data .pop ('timeStamp' )
208+ defaultVocabulary = {
209+ 'schema' : 'https://schema.org/' ,
210+ 'gsp' : 'http://www.opengis.net/ont/geosparql#' ,
211+ 'type' : '@type'
212+ }
244213
245- data ['links' ] = data .pop ('links' )
214+ if identifier :
215+ # Expand properties block
216+ data .update (data .pop ('properties' ))
246217
247- ldjsonData = {
248- '@context' : [defaultVocabulary , * (context or [])],
249- ** data
250- }
218+ # Include multiple geometry encodings
219+ if (data .get ('geometry' ) is not None ):
220+ jsonldify_geometry (data )
221+
222+ data ['@id' ] = identifier
223+
224+ else :
225+ # Collection of jsonld
226+ defaultVocabulary .update ({
227+ 'features' : 'schema:itemListElement' ,
228+ 'FeatureCollection' : 'schema:itemList'
229+ })
230+
231+ ds_url = url_join (cls .get_collections_url (), dataset )
232+ data ['@id' ] = ds_url
233+
234+ for i , feature in enumerate (data ['features' ]):
235+ # Get URI for each feature
236+ identifier_ = feature .get (
237+ id_field ,
238+ feature ['properties' ].get (id_field , '' )
239+ )
240+ if not is_url (str (identifier_ )):
241+ identifier_ = f"{ ds_url } /items/{ feature ['id' ]} " # noqa
242+
243+ # Include multiple geometry encodings
244+ if feature .get ('geometry' ) is not None :
245+ jsonldify_geometry (feature )
246+
247+ data ['features' ][i ] = {
248+ '@id' : identifier_ ,
249+ 'type' : 'schema:Place' ,
250+ ** feature .pop ('properties' ),
251+ ** feature
252+ }
253+
254+ if data .get ('timeStamp' , False ):
255+ data ['https://schema.org/sdDatePublished' ] = data .pop ('timeStamp' )
256+
257+ data ['links' ] = data .pop ('links' )
258+
259+ ldjsonData = {
260+ '@context' : [defaultVocabulary , * (context or [])],
261+ ** data
262+ }
251263
252264 if identifier :
253265 # Render jsonld template for single item
0 commit comments