Skip to content

Commit

Permalink
Update CHANGELOG.rst, __init__.py, and 2 more files...
Browse files Browse the repository at this point in the history
  • Loading branch information
jokiefer committed Nov 30, 2023
1 parent d868a8c commit 0c925aa
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 43 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

[v0.12.0] - 2023-11-30
---------------------

Changed
~~~~~~~

* renamed `dataset_id` and `dataset_id_code_space` to `code` and `code_space` and use it for service metadata mapper too


[v0.11.3] - 2023-11-22
---------------------

Expand Down
2 changes: 1 addition & 1 deletion ows_lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.11.3"
__version__ = "0.12.0"
VERSION = __version__ # synonym
71 changes: 36 additions & 35 deletions ows_lib/xml_mapper/iso_metadata/iso_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,13 @@ class BasicInformation(BaseIsoMetadata):
keywords = xmlmap.NodeListField(xpath="gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword",
node_class=Keyword)

is_broken = False # flag to signal that this metadata object has integrity error


class MdDataIdentification(BasicInformation):
ROOT_NAME = "MD_DataIdentification"
equivalent_scale = xmlmap.FloatField(
xpath="gmd:spatialResolution/gmd:MD_Resolution/gmd:equivalentScale/gmd:MD_RepresentativeFraction/gmd:denominator/gco:Integer")
ground_res = xmlmap.FloatField(
xpath="gmd:spatialResolution/gmd:MD_Resolution/gmd:distance/gmd:Distance")
categories = xmlmap.NodeListField(xpath="gmd:topicCategory/gmd:MD_TopicCategoryCode",
node_class=Category)
bbox_lat_lon_list = xmlmap.NodeListField(xpath="gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox",
node_class=EXGeographicBoundingBox)
bounding_polygon_list = xmlmap.NodeListField(xpath="gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon",
node_class=EXBoundingPolygon)
dimensions = xmlmap.NodeListField(xpath="gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent",
node_class=Dimension)
_code_md = xmlmap.StringField(
xpath="gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString")

is_broken = False # flag to signal that this metadata object has integrity error

def _parse_identifier(self):
_dataset_id = ""
_code = ""
_code_space = ""
if self._code_md:
# new implementation:
Expand All @@ -230,27 +215,43 @@ def _parse_identifier(self):
parsed_url = urllib.parse.urlsplit(self._code_md)
if parsed_url.scheme == "http" or parsed_url.scheme == "https" and "/" in parsed_url.path:
tmp = self._code_md.split("/")
_dataset_id = tmp[len(tmp) - 1]
_code_space = self._code_md.replace(_dataset_id, "")
_code = tmp[len(tmp) - 1]
_code_space = self._code_md.replace(_code, "")
elif parsed_url.scheme == "http" or parsed_url.scheme == "https" and "#" in self._code_md:
tmp = self._code_md.split("#")
_dataset_id = tmp[1]
_code = tmp[1]
_code_space = tmp[0]
else:
_dataset_id = self._code_md
_code = self._code_md
_code_space = ""

return _dataset_id.replace('\n', '').strip(), _code_space.replace('\n', '').strip()
return _code.replace('\n', '').strip(), _code_space.replace('\n', '').strip()

@property
def dataset_id(self) -> str:
def code(self) -> str:
return self._parse_identifier()[0]

@property
def dataset_id_code_space(self) -> str:
def code_space(self) -> str:
return self._parse_identifier()[1]


class MdDataIdentification(BasicInformation):
ROOT_NAME = "MD_DataIdentification"
equivalent_scale = xmlmap.FloatField(
xpath="gmd:spatialResolution/gmd:MD_Resolution/gmd:equivalentScale/gmd:MD_RepresentativeFraction/gmd:denominator/gco:Integer")
ground_res = xmlmap.FloatField(
xpath="gmd:spatialResolution/gmd:MD_Resolution/gmd:distance/gmd:Distance")
categories = xmlmap.NodeListField(xpath="gmd:topicCategory/gmd:MD_TopicCategoryCode",
node_class=Category)
bbox_lat_lon_list = xmlmap.NodeListField(xpath="gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox",
node_class=EXGeographicBoundingBox)
bounding_polygon_list = xmlmap.NodeListField(xpath="gmd:extent/gmd:EX_Extent/gmd:geographicElement/gmd:EX_BoundingPolygon",
node_class=EXBoundingPolygon)
dimensions = xmlmap.NodeListField(xpath="gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent",
node_class=Dimension)


class SvOperationMetadata(BaseIsoMetadata):
ROOT_NS = SRV_NAMESPACE
ROOT_NAME = "SV_OperationMetadata"
Expand Down Expand Up @@ -408,16 +409,16 @@ def spatial_res_value(self, value):
raise NotImplementedError()

@property
def dataset_id(self) -> str:
def code(self) -> str:
child = self._get_child_identification()
if child and hasattr(child, "dataset_id"):
return child.dataset_id
if child and hasattr(child, "code"):
return child.code

@property
def dataset_id_code_space(self) -> str:
def code_space(self) -> str:
child = self._get_child_identification()
if child and hasattr(child, "dataset_id_code_space"):
return child.dataset_id_code_space
if child and hasattr(child, "code_space"):
return child.code_space

@property
def keywords(self) -> List[str]:
Expand Down Expand Up @@ -460,10 +461,10 @@ def transform_to_model(self) -> Dict:
attr = super().transform_to_model()
if self.date_stamp:
attr.update({"date_stamp": self.date_stamp})
if self.dataset_id:
attr.update({"dataset_id": self.dataset_id})
if self.dataset_id_code_space:
attr.update({"dataset_id_code_space": self.dataset_id_code_space})
if self.code:
attr.update({"code": self.code})
if self.code_space:
attr.update({"code_space": self.code_space})
if self.spatial_res_value:
attr.update({"spatial_res_value": self.spatial_res_value})
if self.bounding_geometry:
Expand Down
14 changes: 7 additions & 7 deletions tests/xml_mapper/iso_metadata/test_md_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def test_abstract(self):
"Messwerte der Windgeschwindigkeit an den DWD Stationen im Regional Basic Synoptic Network der WMO. Erweitert um weitere Stationen der Grundversorgung."
)

def test_dataset_id(self):
def test_code(self):
self.assertEqual(
self.parsed_metadata.dataset_id,
self.parsed_metadata.code,
"de.dwd.geoserver.fach.RBSN_FF"
)

def test_dataset_id_code_space(self):
def test_code_space(self):
self.assertEqual(
self.parsed_metadata.dataset_id_code_space,
self.parsed_metadata.code_space,
"https://registry.gdi-de.org/id/de.bund.dwd/"
)

Expand Down Expand Up @@ -106,8 +106,8 @@ def test_field_dict(self):
expected = {
'file_identifier': 'de.dwd.geoserver.fach.RBSN_FF',
'date_stamp': datetime.fromisoformat("2019-05-16T12:55:18"),
'dataset_id': 'de.dwd.geoserver.fach.RBSN_FF',
'dataset_id_code_space': 'https://registry.gdi-de.org/id/de.bund.dwd/',
'code': 'de.dwd.geoserver.fach.RBSN_FF',
'code_space': 'https://registry.gdi-de.org/id/de.bund.dwd/',
'bounding_geometry': b_g,
'title': "Windgeschwindigkeit an RBSN Stationen",
'abstract': "Messwerte der Windgeschwindigkeit an den DWD Stationen im Regional Basic Synoptic Network der WMO. Erweitert um weitere Stationen der Grundversorgung."
Expand Down Expand Up @@ -232,7 +232,7 @@ def test_field_dict(self):
expected = {
'file_identifier': '80b250a6-4dda-481d-8568-162e20c1cb7a',
'date_stamp': datetime(2023, 9, 12, 6, 49, 23),
'dataset_id': 'LK2022',
'code': 'LK2022',
'bounding_geometry': GeosPolygon.from_ewkt("MULTIPOLYGON (((9.87 50.2, 9.87 51.64, 12.65 51.64, 12.65 50.2, 9.87 50.2)))"),
'title': 'Lärmkartierung 2022',
'abstract': 'Lärmkartierung von Hauptverkehrsstraßen gemäß EU-Umgebungslärmrichtlinie, Aktualisierungszyklus: 4. Stufe'
Expand Down

0 comments on commit 0c925aa

Please sign in to comment.