Skip to content

Commit

Permalink
Update CHANGELOG.rst, iso_metadata.py, and test_md_metadata.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jokiefer committed Nov 22, 2023
1 parent c70852a commit d7a95de
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Fixed
~~~~~

* missing `title` and `abstract` property on iso metadata mapper.
* iso service metadata mapper


[v0.11.0] - 2023-11-21
Expand Down
10 changes: 6 additions & 4 deletions ows_lib/xml_mapper/iso_metadata/iso_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class MdDataIdentification(BasicInformation):
node_class=Dimension)


class SvOperationMetadata(BasicInformation):
class SvOperationMetadata(BaseIsoMetadata):
ROOT_NS = SRV_NAMESPACE
ROOT_NAME = "SV_OperationMetadata"
ROOT_NAMESPACES = {
Expand All @@ -274,7 +274,7 @@ class SvOperationMetadata(BasicInformation):
xpath="srv:connectPoint/gmd:CI_OnlineResource/gmd:linkage/gmd:URL")


class SvServiceIdentification(BaseIsoMetadata):
class SvServiceIdentification(BasicInformation):
ROOT_NS = GMD_NAMESPACE
ROOT_NAME = "SV_ServiceIdentification"
ROOT_NAMESPACES = {
Expand Down Expand Up @@ -315,7 +315,8 @@ class MdMetadata(BaseIsoMetadata):
ROOT_NS = GMD_NAMESPACE
ROOT_NAMESPACES = {
"gmd": GMD_NAMESPACE,
"gco": GCO_NAMESPACE
"gco": GCO_NAMESPACE,
"srv": SRV_NAMESPACE,
}

file_identifier = xmlmap.StringField(
Expand All @@ -340,7 +341,7 @@ class MdMetadata(BaseIsoMetadata):

_md_data_identification = xmlmap.NodeField(xpath="gmd:identificationInfo/gmd:MD_DataIdentification",
node_class=MdDataIdentification)
_sv_service_identification = xmlmap.NodeField(xpath="gmd:identificationInfo/gmd:SV_ServiceIdentification",
_sv_service_identification = xmlmap.NodeField(xpath="gmd:identificationInfo/srv:SV_ServiceIdentification",
node_class=SvServiceIdentification)

def _get_child_identification(self):
Expand Down Expand Up @@ -428,6 +429,7 @@ def keywords(self) -> List[str]:
child = self._get_child_identification()
if child:
return child.keywords
return []

@keywords.setter
def keywords(self, value):
Expand Down
99 changes: 98 additions & 1 deletion tests/xml_mapper/iso_metadata/test_md_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tests.settings import DJANGO_TEST_ROOT_DIR


class MDMetadataTestCase(SimpleTestCase):
class MDMetadataDatasetTestCase(SimpleTestCase):

path = os.path.join(DJANGO_TEST_ROOT_DIR,
"test_data/iso_metadata/dataset.xml")
Expand Down Expand Up @@ -91,6 +91,103 @@ def test_bounding_geometry_getter(self):
)


class MDMetadataServiceTestCase(SimpleTestCase):

path = os.path.join(DJANGO_TEST_ROOT_DIR,
"test_data/iso_metadata/service.xml")

def setUp(self) -> None:
self.parsed_metadata: MdMetadata = load_xmlobject_from_file(
self.path, xmlclass=MdMetadata)
self.maxDiff = None

def test_file_identifier(self):
self.assertEqual(
self.parsed_metadata.file_identifier,
"c824eab2-5226-46c2-b4ae-3e5c518a9be7"
)

def test_title(self):
self.assertEqual(
self.parsed_metadata.title,
"WFS XPlanung BPL „Vorderdorf Unterdorf 5. Änderung Erweiterung“"
)

def test_abstract(self):
self.assertEqual(
self.parsed_metadata.abstract,
"WFS-Dienst des Bebauungsplans „Vorderdorf Unterdorf 5. Änderung Erweiterung“ der Gemeinde Weilheim aus XPlanung 5.0. Beschreibung: MD, WA, GBF Schule, VF."
)

def test_date_stamp(self):
self.assertEqual(
self.parsed_metadata.date_stamp,
datetime.fromisoformat("2021-12-07").date()
)

def test_keywords(self):
self.assertEqual(
[kw.keyword for kw in self.parsed_metadata.keywords],
[
"Bodennutzung",
"Vorderdorf Unterdorf 5. Änderung Erweiterung",
'infoFeatureAccessService',
'Bauplätze',
'Gemeinde Weilheim',
'Bebauungsplan',
'Bauleitplan',
'XPlanGML',
'B-Plan',
'Bauvorschrift',
'Bauplatz',
'Bebauungspläne',
'XPlanung 5.0',
'Bauleitpläne',
'727',
'XPlanung',
'GDI-BW'
]
)

def test_ref_system(self):

self.assertEqual(
[ref_system.transform_to_model()
for ref_system in self.parsed_metadata.reference_systems],
[ReferenceSystem(code="EPSG:25832").transform_to_model(),
ReferenceSystem(code="EPSG:31467").transform_to_model(),
ReferenceSystem(code="EPSG:4326").transform_to_model(),
ReferenceSystem(code="EPSG:4258").transform_to_model()]
)

def test_bounding_geometry_getter(self):
min_x = 8.21574798943722
max_x = 8.218752644527196
min_y = 47.69179998723602
max_y = 47.694387077303475

self.assertEqual(
self.parsed_metadata.bounding_geometry,

MultiPolygon(GeosPolygon(((min_x, min_y),
(min_x, max_y),
(max_x, max_y),
(max_x, min_y),
(min_x, min_y))))
)

def test_field_dict(self):
field_dict = self.parsed_metadata.transform_to_model()
expected = {
'file_identifier': 'c824eab2-5226-46c2-b4ae-3e5c518a9be7',
'date_stamp': datetime.fromisoformat("2021-12-07").date(),
'bounding_geometry': GeosPolygon.from_ewkt("MULTIPOLYGON (((8.21574798943722 47.69179998723602, 8.21574798943722 47.694387077303475, 8.218752644527196 47.694387077303475, 8.218752644527196 47.69179998723602, 8.21574798943722 47.69179998723602)))"),
'title': "WFS XPlanung BPL „Vorderdorf Unterdorf 5. Änderung Erweiterung“",
'abstract': "WFS-Dienst des Bebauungsplans „Vorderdorf Unterdorf 5. Änderung Erweiterung“ der Gemeinde Weilheim aus XPlanung 5.0. Beschreibung: MD, WA, GBF Schule, VF."
}
self.assertEqual(field_dict, expected)


class WrappedMDMetadataTestCase(SimpleTestCase):

path = os.path.join(DJANGO_TEST_ROOT_DIR,
Expand Down

0 comments on commit d7a95de

Please sign in to comment.