Skip to content

Commit

Permalink
Merge pull request #15 from mrmap-community/feature/field-dict-on-mdm…
Browse files Browse the repository at this point in the history
…etadata

Update CHANGELOG.rst, __init__.py, and 6 more files...
  • Loading branch information
jokiefer authored Sep 14, 2023
2 parents 0373532 + 67a294e commit 52a6ed8
Show file tree
Hide file tree
Showing 8 changed files with 564 additions and 10 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0




[v0.5.0] - 2023-09-14
---------------------

Changed
~~~~~~~

* call `super().transform_to_model()` in all child objects to get the default `field_dict`

Added
~~~~~

* custom `transform_to_model` function on `MdMetadata` mapper to push in the collected values


[v0.4.2] - 2023-09-14
---------------------

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.4.2"
__version__ = "0.5.0"
VERSION = __version__ # synonym
4 changes: 2 additions & 2 deletions ows_lib/xml_mapper/capabilities/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def mime_types(self, value: List[str]):
self._callback(self)

def transform_to_model(self) -> Dict:
attr = {}
attr = super().transform_to_model()
if self.operation:
attr.update({"operation": self.operation})
if self.url:
Expand Down Expand Up @@ -120,7 +120,7 @@ def prefix(self, new_prefix) -> None:
self._ref_system = f"{new_prefix}:{self._code}"

def transform_to_model(self) -> Dict:
attr = {}
attr = super().transform_to_model()
if self.prefix:
attr.update({"prefix": self.prefix})
if self.code:
Expand Down
2 changes: 1 addition & 1 deletion ows_lib/xml_mapper/capabilities/wms/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __str__(self) -> str:
return f"{self.start} | {self.stop} | {self.resolution}"

def transform_to_model(self) -> Dict:
attr = {}
attr = super().transform_to_model()
if self.start:
attr.update({"start": self.start})
if self.stop:
Expand Down
23 changes: 20 additions & 3 deletions ows_lib/xml_mapper/iso_metadata/iso_metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import urllib
from typing import Dict

from django.contrib.gis.geos import MultiPolygon
from django.contrib.gis.geos import Polygon as GeosPolygon
Expand Down Expand Up @@ -357,12 +358,13 @@ def get_spatial_res(self):
if child:
if child.equivalent_scale is not None and child.equivalent_scale > 0:
return child.equivalent_scale, "scaleDenominator"
elif self.ground_res is not None and self.ground_res > 0:
elif child.ground_res is not None and child.ground_res > 0:
return child.ground_res, "groundDistance"

@property
def spatial_res_type(self):
return self.get_spatial_res()[0]
res = self.get_spatial_res()
return res[0] if res else None

@spatial_res_type.setter
def spatial_res_type(self, value):
Expand All @@ -371,7 +373,8 @@ def spatial_res_type(self, value):

@property
def spatial_res_value(self):
return self.get_spatial_res()[1]
res = self.get_spatial_res()
return res[1] if res else None

@spatial_res_value.setter
def spatial_res_value(self, value):
Expand All @@ -390,6 +393,20 @@ def dataset_id_code_space(self) -> str:
if child:
return child.dataset_id_code_space

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.spatial_res_value:
attr.update({"spatial_res_value": self.spatial_res_value})
if self.bounding_geometry:
attr.update({"bounding_geometry": self.bounding_geometry})
return attr


class WrappedIsoMetadata(xmlmap.XmlObject):
"""Helper class to parse wrapped IsoMetadata objects.
Expand Down
Loading

0 comments on commit 52a6ed8

Please sign in to comment.