Skip to content

Commit

Permalink
added retrieval of EPSG code is used
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed Dec 19, 2024
1 parent d6cf1a9 commit ecb89f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hyo2/bag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

name = 'BAG'
__version__ = '1.2.9'
__version__ = '1.2.10'
__author__ = '[email protected]'
__license__ = 'LGPLv3 license'
__copyright__ = 'Copyright (c) 2024, University of New Hampshire, Center for Coastal and Ocean Mapping'
10 changes: 8 additions & 2 deletions hyo2/bag/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ def __init__(self, meta_xml: bytes | str) -> None:
# wkt projection
self.wkt_srs: str | None = None
self.xml_srs: str | None = None
self.wkt_srs_epsg_code: str | None = None
self._read_wkt_prj()

# wkt vertical datum
self.wkt_vertical_datum: str | None = None
self.xml_vertical_datum: str | None = None
self.wkt_vertical_datum_epsg_code: str | None = None
self._read_wkt_vertical_datum()

# bbox
Expand Down Expand Up @@ -249,10 +251,12 @@ def _read_wkt_prj(self):
# logger.info("codeSpace: %s" % space[0].text)

if space[0].text == "EPSG":
self.wkt_srs_epsg_code = int(ret[0].text)
sr = osr.SpatialReference()
sr.ImportFromEPSG(int(ret[0].text))
sr.ImportFromEPSG(self.wkt_srs_epsg_code)
self.wkt_srs = sr.ExportToWkt()
else:
self.wkt_srs_epsg_code = None
self.wkt_srs = ret[0].text

except (ValueError, IndexError) as e:
Expand Down Expand Up @@ -292,10 +296,12 @@ def _read_wkt_vertical_datum(self):
# logger.info("codeSpace: %s" % space[0].text)

if space[1].text == "EPSG":
self.wkt_vertical_datum_epsg_code = int(ret[1].text)
sr = osr.SpatialReference()
sr.ImportFromEPSG(int(ret[1].text))
sr.ImportFromEPSG(self.wkt_vertical_datum_epsg_code)
self.wkt_vertical_datum = sr.ExportToWkt()
else:
self.wkt_vertical_datum_epsg_code = None
self.wkt_vertical_datum = ret[1].text

except (ValueError, IndexError) as e:
Expand Down

0 comments on commit ecb89f3

Please sign in to comment.