Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of spatial properties when using scheming #327

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ckanext/dcat/profiles/euro_dcat_ap_scheming.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def _parse_list_value(data_dict, field_name):
_parse_list_value(resource_dict, field_name)

# Repeating subfields
new_fields_mapping = {"temporal_coverage": "temporal"}
new_fields_mapping = {
"spatial_coverage": "spatial",
"temporal_coverage": "temporal",
}
for schema_field in self._dataset_schema["dataset_fields"]:
if "repeating_subfields" in schema_field:
# Check if existing extras need to be migrated
Expand All @@ -94,6 +97,9 @@ def _parse_list_value(data_dict, field_name):
new_dict[subfield] = extra["value"]
else:
new_extras.append(extra)
elif extra["key"] == "spatial" and field_name == "spatial_coverage":
# Special case, spatial geom
new_dict["geom"] = extra["value"]
else:
new_extras.append(extra)
if new_dict:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,12 @@ def test_e2e_dcat_to_ckan(self):
assert dataset["temporal_coverage"][0]["start"] == "1905-03-01"
assert dataset["temporal_coverage"][0]["end"] == "2013-01-05"

assert (
dataset["spatial_coverage"][0]["uri"]
== "http://publications.europa.eu/mdr/authority/country/ZWE"
)
assert dataset["spatial_coverage"][0]["geom"]

resource = dataset["resources"][0]

# Resources: core fields
Expand Down
6 changes: 6 additions & 0 deletions examples/dcat/dataset.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:adms="http://www.w3.org/ns/adms#"
xmlns:schema="http://schema.org/"
xmlns:vcard="http://www.w3.org/2006/vcard/ns#"
xmlns:locn="http://www.w3.org/ns/locn#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:spdx="http://spdx.org/rdf/terms#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
Expand Down Expand Up @@ -38,6 +39,11 @@
<dct:conformsTo>Standard 2</dct:conformsTo>
<dct:license rdf:resource="https://data.some.org/link/to/license"/>
<dct:spatial rdf:resource="http://publications.europa.eu/mdr/authority/country/ZWE"/>
<dct:spatial>
<dct:Location>
<locn:geometry rdf:datatype="http://www.opengis.net/ont/geosparql#wktLiteral">POLYGON ((11.9936 54.0486, 11.9936 54.2466, 12.3045 54.2466, 12.3045 54.0486, 11.9936 54.0486))</locn:geometry>
</dct:Location>
</dct:spatial>
<dcat:spatialResolutionInMeters rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">1.5</dcat:spatialResolutionInMeters>
<dct:accrualPeriodicity rdf:resource="http://purl.org/cld/freq/daily"/>
<dct:accessRights>public</dct:accessRights>
Expand Down
Loading