Repository: Informasjonsforvaltning/datacatalogtordf

Issue:
spatialCoverage property name should be spatial. Confform dct:spatial DCAT specification and property should be a list

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/Informasjonsforvaltning/datacatalogtordf/pull/64?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Informasjonsforvaltning) Report
> Merging [#64](https://codecov.io/gh/Informasjonsforvaltning/datacatalogtordf/pull/64?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Informasjonsforvaltning) (d39600a) into [main](https://codecov.io/gh/Informasjonsforvaltning/datacatalogtordf/commit/95d8a9af3843dab23cd5e8bff47c72c33cd7c54d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Informasjonsforvaltning) (95d8a9a) will **not change** coverage.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff            @@
##              main       #64   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines         1442      1443    +1     
=========================================
+ Hits          1442      1443    +1     
```


| [Impacted Files](https://codecov.io/gh/Informasjonsforvaltning/datacatalogtordf/pull/64?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Informasjonsforvaltning) | Coverage Δ | |
|---|---|---|
| [src/datacatalogtordf/dataset.py](https://codecov.io/gh/Informasjonsforvaltning/datacatalogtordf/pull/64/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Informasjonsforvaltning#diff-c3JjL2RhdGFjYXRhbG9ndG9yZGYvZGF0YXNldC5weQ==) | `100.00% <100.00%> (ø)` | |

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. [Learn more](https://about.codecov.io/product/feature/runtime-insights/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Informasjonsforvaltning)


Patch:
diff --git a/src/datacatalogtordf/dataset.py b/src/datacatalogtordf/dataset.py
index cbeef12..419f9be 100644
--- a/src/datacatalogtordf/dataset.py
+++ b/src/datacatalogtordf/dataset.py
@@ -50,7 +50,7 @@ class Dataset(Resource):
         distributions (List[Distribution]): A list of distributions of the dataset
         frequency (URI): A link to resource describing the frequency at\
             which dataset is published.
-        spatial_coverage (Location): The geographical area covered by the dataset.
+        spatial (List[Location]): A list of geographical areas covered by the dataset.
         spatial_resolution (Decimal): Minimum spatial separation resolvable \
             in a dataset, measured in meters.
         temporal_coverage (PeriodOfTime): The temporal period that the dataset covers.
@@ -67,7 +67,7 @@ class Dataset(Resource):
         "_distributions",
         "_type",
         "_frequency",
-        "_spatial_coverage",
+        "_spatial",
         "_spatial_resolution",
         "_temporal_coverage",
         "_temporal_resolution",
@@ -79,7 +79,7 @@ class Dataset(Resource):
     # Types
     _distributions: List[Distribution]
     _frequency: URI
-    _spatial_coverage: Union[Location, str]
+    _spatial: List[Union[Location, str]]
     _spatial_resolution: Decimal
     _temporal_coverage: PeriodOfTime
     _temporal_resolution: str
@@ -116,13 +116,13 @@ class Dataset(Resource):
         self._frequency = URI(frequency)
 
     @property
-    def spatial_coverage(self: Dataset) -> Union[Location, str]:
-        """Get/set for spatial_coverage."""
-        return self._spatial_coverage
+    def spatial(self: Dataset) -> List[Union[Location, str]]:
+        """Get/set for spatial."""
+        return self._spatial
 
-    @spatial_coverage.setter
-    def spatial_coverage(self: Dataset, spatial_coverage: Union[Location, str]) -> None:
-        self._spatial_coverage = spatial_coverage
+    @spatial.setter
+    def spatial(self: Dataset, spatial: List[Union[Location, str]]) -> None:
+        self._spatial = spatial
 
     @property
     def spatial_resolution(self: Dataset) -> Decimal:
@@ -223,7 +223,7 @@ class Dataset(Resource):
         self._dct_identifier_to_graph()
         self._distributions_to_graph()
         self._frequency_to_graph()
-        self._spatial_coverage_to_graph()
+        self._spatial_to_graph()
         self._spatial_resolution_to_graph()
         self._temporal_coverage_to_graph()
         self._temporal_resolution_to_graph()
@@ -272,25 +272,26 @@ class Dataset(Resource):
                 )
             )
 
-    def _spatial_coverage_to_graph(self: Dataset) -> None:
-        if getattr(self, "spatial_coverage", None):
-            _location: Identifier
-            if isinstance(self.spatial_coverage, Location):
+    def _spatial_to_graph(self: Dataset) -> None:
+        if getattr(self, "spatial", None):
+            for spatial in self.spatial:
+                _location: Identifier
+                if isinstance(spatial, Location):
 
-                if not getattr(self.spatial_coverage, "identifier", None):
-                    _location = BNode()
-                else:
-                    _location = URIRef(self.spatial_coverage.identifier)  # type: ignore
+                    if not getattr(spatial, "identifier", None):
+                        _location = BNode()
+                    else:
+                        _location = URIRef(spatial.identifier)  # type: ignore
 
-                for _s, p, o in self.spatial_coverage._to_graph().triples(  # type: ignore
-                    (None, None, None)
-                ):
-                    self._g.add((_location, p, o))
+                    for _s, p, o in spatial._to_graph().triples(  # type: ignore
+                        (None, None, None)
+                    ):
+                        self._g.add((_location, p, o))
 
-            elif isinstance(self.spatial_coverage, str):
-                _location = URIRef(self.spatial_coverage)
+                elif isinstance(spatial, str):
+                    _location = URIRef(spatial)
 
-            self._g.add((URIRef(self.identifier), DCT.spatial, _location))
+                self._g.add((URIRef(self.identifier), DCT.spatial, _location))
 
     def _spatial_resolution_to_graph(self: Dataset) -> None:
         if getattr(self, "spatial_resolution", None):


Test patch:
diff --git a/tests/test_dataset.py b/tests/test_dataset.py
index f965f35..0a8c0c9 100644
--- a/tests/test_dataset.py
+++ b/tests/test_dataset.py
@@ -210,7 +210,7 @@ def test_to_graph_should_return_frequency() -> None:
     assert _isomorphic
 
 
-def test_to_graph_should_return_spatial_coverage() -> None:
+def test_to_graph_should_return_spatial() -> None:
     """It returns a spatial coverage graph isomorphic to spec."""
     dataset = Dataset()
     dataset.identifier = "http://example.com/datasets/1"
@@ -218,7 +218,7 @@ def test_to_graph_should_return_spatial_coverage() -> None:
     location = Location()
     location.centroid = "POINT(4.88412 52.37509)"
     # Add location to dataset:
-    dataset.spatial_coverage = location
+    dataset.spatial = [location]
 
     src = """
     @prefix dct: <http://purl.org/dc/terms/> .
@@ -390,13 +390,13 @@ def test_to_graph_should_return_access_rights_comment() -> None:
     assert _isomorphic
 
 
-def test_to_graph_should_return_link_to_spatial_coverage() -> None:
+def test_to_graph_should_return_link_to_spatial() -> None:
     """It returns a spatial coverage graph isomorphic to spec."""
     dataset = Dataset()
     dataset.identifier = "http://example.com/datasets/1"
     # Add link to location:
     location = "http://publications.europa.eu/resource/authority/country/NOR"
-    dataset.spatial_coverage = location
+    dataset.spatial = [location]
 
     src = """
     @prefix dct: <http://purl.org/dc/terms/> .
@@ -419,7 +419,7 @@ def test_to_graph_should_return_link_to_spatial_coverage() -> None:
     assert _isomorphic
 
 
-def test_to_graph_should_return_link_to_spatial_coverage_with_location_triple() -> None:
+def test_to_graph_should_return_link_to_spatial_with_location_triple() -> None:
     """It returns a spatial coverage graph isomorphic to spec."""
     dataset = Dataset()
     dataset.identifier = "http://example.com/datasets/1"
@@ -428,7 +428,7 @@ def test_to_graph_should_return_link_to_spatial_coverage_with_location_triple()
     location.identifier = "http://example.com/locations/1"
     location.centroid = "POINT(4.88412 52.37509)"
     # Add location to dataset:
-    dataset.spatial_coverage = location
+    dataset.spatial = [location]
 
     src = """
     @prefix dct: <http://purl.org/dc/terms/> .