Skip to content

Commit

Permalink
Remove GeoJSON, WKT geometry output from custom profile
Browse files Browse the repository at this point in the history
  • Loading branch information
benjwadams committed Mar 23, 2020
1 parent 099ec91 commit ec04c10
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions ckanext/ioos_theme/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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()
Expand All @@ -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] +
Expand Down

0 comments on commit ec04c10

Please sign in to comment.