@@ -198,6 +198,40 @@ def test_spatial(self):
198198 wkt_cent = wkt .dumps (json .loads (extras ['spatial_centroid' ]), decimals = 4 )
199199 assert self ._triple (g , spatial , DCAT .centroid , wkt_cent , GSP .wktLiteral )
200200
201+ def test_spatial_input_in_wkt (self ):
202+ dataset = {
203+ 'id' : '4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6' ,
204+ 'name' : 'test-dataset' ,
205+ 'extras' : [
206+ {'key' : 'spatial_uri' , 'value' : 'http://sws.geonames.org/6361390/' },
207+ {'key' : 'spatial_text' , 'value' : 'Tarragona' },
208+ {'key' : 'spatial' , 'value' : 'POLYGON ((1.1871 41.0786, 1.1871 41.1655, 1.3752 41.1655, 1.3752 41.0786, 1.1871 41.0786))' },
209+ {'key' : 'spatial_bbox' , 'value' : 'POLYGON ((1.1871 41.0786, 1.1871 41.1655, 1.3752 41.1655, 1.3752 41.0786, 1.1871 41.0786))' },
210+ {'key' : 'spatial_centroid' , 'value' : 'POINT (2.2811 42.122)' },
211+
212+ ]
213+ }
214+ extras = self ._extras (dataset )
215+
216+ s = RDFSerializer (profiles = DCAT_AP_PROFILES )
217+ g = s .g
218+
219+ dataset_ref = s .graph_from_dataset (dataset )
220+
221+ spatial = self ._triple (g , dataset_ref , DCT .spatial , None )[2 ]
222+ assert spatial
223+ assert str (spatial ) == extras ['spatial_uri' ]
224+ assert self ._triple (g , spatial , RDF .type , DCT .Location )
225+ assert self ._triple (g , spatial , SKOS .prefLabel , extras ['spatial_text' ])
226+
227+ assert len ([t for t in g .triples ((spatial , LOCN .geometry , None ))]) == 1
228+ assert len ([t for t in g .triples ((spatial , DCAT .bbox , None ))]) == 1
229+ assert len ([t for t in g .triples ((spatial , DCAT .centroid , None ))]) == 1
230+
231+ assert self ._triple (g , spatial , LOCN .geometry , extras ['spatial' ], GSP .wktLiteral )
232+ assert self ._triple (g , spatial , DCAT .bbox , extras ['spatial_bbox' ], GSP .wktLiteral )
233+ assert self ._triple (g , spatial , DCAT .centroid , extras ['spatial_centroid' ], GSP .wktLiteral )
234+
201235 @pytest .mark .ckan_config ("ckanext.dcat.output_spatial_format" , "geojson" )
202236 def test_spatial_geojson (self ):
203237 dataset = {
0 commit comments