From 814aef7a71ccc73647058cce17131794efee4224 Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 7 Nov 2024 09:50:56 -0700 Subject: [PATCH] fix geojson/jsonld export issue (#11588) * fixes jsonld export issue for geojson features * Adds test --- .../core/geojson_feature_collection.py | 3 ++- releases/7.6.3.md | 3 +++ tests/exporter/datatype_to_rdf_tests.py | 25 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/arches/app/datatypes/core/geojson_feature_collection.py b/arches/app/datatypes/core/geojson_feature_collection.py index 1242f306282..84337ef7fa3 100644 --- a/arches/app/datatypes/core/geojson_feature_collection.py +++ b/arches/app/datatypes/core/geojson_feature_collection.py @@ -412,7 +412,8 @@ def to_rdf(self, edge_info, edge): data = edge_info["range_tile_data"] if data["type"] == "FeatureCollection": for f in data["features"]: - del f["id"] + if "id" in f: + del f["id"] del f["properties"] g.add( ( diff --git a/releases/7.6.3.md b/releases/7.6.3.md index 915978a4cde..73b46e8bdc8 100644 --- a/releases/7.6.3.md +++ b/releases/7.6.3.md @@ -4,6 +4,8 @@ - Fixes bug that prevented some Arches Application front-end components from being loaded #[11561](https://github.com/archesproject/arches/issues/11561) +- Fix issue with JSON-LD export failing when geojson features have no "id". [11587](https://github.com/archesproject/arches/issues/11587) + ### Dependency changes: ``` @@ -20,6 +22,7 @@ JavaScript: 1. Upgrade to version 7.6.0 before proceeding by following the upgrade process in the [Version 7.6.0 release notes](https://github.com/archesproject/arches/blob/dev/7.6.x/releases/7.6.0.md) 2. Upgrade to Arches 7.6.3 + ``` pip install --upgrade arches==7.6.3 ``` diff --git a/tests/exporter/datatype_to_rdf_tests.py b/tests/exporter/datatype_to_rdf_tests.py index d3e6c161e0e..86a4cfccf3c 100644 --- a/tests/exporter/datatype_to_rdf_tests.py +++ b/tests/exporter/datatype_to_rdf_tests.py @@ -261,6 +261,31 @@ def test_rdf_concept(self): in graph ) + def test_rdf_geojson(self): + dt = self.DT.get_instance("geojson-feature-collection") + edge_info = {} + edge_info["range_tile_data"] = { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "id": "1", + "geometry": { + "type": "Point", + "coordinates": [13.400257324930152, 52.50578474077699], + }, + "properties": {}, + } + ], + } + edge_info["r_uri"] = URIRef("http://vocab.getty.edu/aat/300047196") + edge_info["d_uri"] = URIRef("http://vocab.getty.edu/aat/300047196") + edge = Mock() + edge.ontologyproperty = CIDOC_NS["P2_has_type"] + edge.rangenode.ontologyclass = CIDOC_NS["E55_Type"] + graph = dt.to_rdf(edge_info, edge) + self.assertTrue("13.400257324930152" in str(graph.serialize())) + def test_rdf_concept_list(self): dt = self.DT.get_instance("concept-list") concept_list = [