From ec04c103868366e2b19dec66cc62d4d716307a97 Mon Sep 17 00:00:00 2001 From: Benjamin Adams Date: Mon, 23 Mar 2020 13:46:24 -0400 Subject: [PATCH] Remove GeoJSON, WKT geometry output from custom profile --- ckanext/ioos_theme/profiles.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/ckanext/ioos_theme/profiles.py b/ckanext/ioos_theme/profiles.py index 3dced22..218d4d5 100644 --- a/ckanext/ioos_theme/profiles.py +++ b/ckanext/ioos_theme/profiles.py @@ -65,6 +65,20 @@ def graph_from_dataset(self, dataset_dict, dataset_ref): g.add((dataset_ref, SCHEMA.variableMeasured, Literal(standard_name))) + + spatial_uri = self._get_dataset_value(dataset_dict, 'spatial_uri') + spatial_text = self._get_dataset_value(dataset_dict, 'spatial_text') + + if spatial_uri: + spatial_ref = URIRef(spatial_uri) + else: + spatial_ref = BNode() + + if spatial_text: + g.add((dataset_ref, DCT.spatial, spatial_ref)) + g.add((spatial_ref, RDF.type, DCT.Location)) + g.add((spatial_ref, RDFS.label, Literal(spatial_text))) + spatial_uri = self._get_dataset_value(dataset_dict, 'spatial_uri') spatial_text = self._get_dataset_value(dataset_dict, 'spatial_text') spatial_geom = self._get_dataset_value(dataset_dict, 'spatial') @@ -82,19 +96,6 @@ def graph_from_dataset(self, dataset_dict, dataset_ref): g.add((spatial_ref, SKOS.prefLabel, Literal(spatial_text))) if spatial_geom: - # GeoJSON - g.add((spatial_ref, - LOCN.geometry, - Literal(spatial_geom, datatype=GEOJSON_IMT))) - # WKT, because GeoDCAT-AP says so - try: - g.add((spatial_ref, - LOCN.geometry, - Literal(wkt.dumps(json.loads(spatial_geom), - decimals=4), - datatype=GSP.wktLiteral))) - except (TypeError, ValueError, InvalidGeoJSONException): - pass try: gj = geojson.loads(spatial_geom) geo_shape = BNode() @@ -105,10 +106,6 @@ def graph_from_dataset(self, dataset_dict, dataset_ref): bbox = [min(all_features[1]), min(all_features[0]), max(all_features[3]), max(all_features[2])] - g.add((place, RDF.type)) - - - g.add((spatial_ref, SCHEMA.geom, place)) else: bounds = shape(gj).bounds bbox = [str(bound) for bound in bounds[1::-1] +