Skip to content

Commit

Permalink
added support for compound CRS
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed Aug 31, 2024
1 parent 547f9a8 commit 3b62692
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
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.8'
__version__ = '1.2.9'
__author__ = '[email protected]'
__license__ = 'LGPLv3 license'
__copyright__ = 'Copyright (c) 2024, University of New Hampshire, Center for Coastal and Ocean Mapping'
12 changes: 12 additions & 0 deletions hyo2/bag/bag.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ def uncertainty_greater_than(self, th: float) -> list[list[int | float]]:

in_srs = osr.SpatialReference()
in_srs.ImportFromWkt(self.meta.wkt_srs)
if in_srs.IsCompound():
in_srs.StripVertical()
out_srs = osr.SpatialReference()
out_srs.ImportFromEPSG(4326)
out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
Expand Down Expand Up @@ -342,6 +344,8 @@ def uncertainty_has_depth(self) -> list[list[int | float]]:

in_srs = osr.SpatialReference()
in_srs.ImportFromWkt(self.meta.wkt_srs)
if in_srs.IsCompound():
in_srs.StripVertical()
out_srs = osr.SpatialReference()
out_srs.ImportFromEPSG(4326)
out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
Expand Down Expand Up @@ -394,6 +398,8 @@ def depth_has_uncertainty(self) -> list[list[int | float]]:

in_srs = osr.SpatialReference()
in_srs.ImportFromWkt(self.meta.wkt_srs)
if in_srs.IsCompound():
in_srs.StripVertical()
out_srs = osr.SpatialReference()
out_srs.ImportFromEPSG(4326)
out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
Expand Down Expand Up @@ -458,6 +464,8 @@ def vr_uncertainty_greater_than(self, th: float) -> list[list[int | float]]:

in_srs = osr.SpatialReference()
in_srs.ImportFromWkt(self.meta.wkt_srs)
if in_srs.IsCompound():
in_srs.StripVertical()
out_srs = osr.SpatialReference()
out_srs.ImportFromEPSG(4326)
out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
Expand Down Expand Up @@ -515,6 +523,8 @@ def vr_depth_has_uncertainty(self) -> list[list[int | float]]:

in_srs = osr.SpatialReference()
in_srs.ImportFromWkt(self.meta.wkt_srs)
if in_srs.IsCompound():
in_srs.StripVertical()
out_srs = osr.SpatialReference()
out_srs.ImportFromEPSG(4326)
out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
Expand Down Expand Up @@ -576,6 +586,8 @@ def vr_uncertainty_has_depth(self) -> list[list[int | float]]:

in_srs = osr.SpatialReference()
in_srs.ImportFromWkt(self.meta.wkt_srs)
if in_srs.IsCompound():
in_srs.StripVertical()
out_srs = osr.SpatialReference()
out_srs.ImportFromEPSG(4326)
out_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)
Expand Down
2 changes: 2 additions & 0 deletions hyo2/bag/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def __init__(self, bag_density: np.ndarray, bag_meta: Meta, fmt="geotiff", out_f
self.srs.ImportFromWkt(self.bag_meta.wkt_srs)
else:
logger.warning("unable to recover valid spatial reference info")
if self.srs.IsCompound():
self.srs.StripVertical()
self.rst.SetProjection(self.srs.ExportToWkt())
self.bnd.FlushCache()

Expand Down
2 changes: 2 additions & 0 deletions hyo2/bag/elevation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(self, bag_elevation: np.ndarray, bag_meta: Meta, fmt="geotiff", out
self.srs.ImportFromWkt(self.bag_meta.wkt_srs)
else:
logger.warning("unable to recover valid spatial reference info")
if self.srs.IsCompound():
self.srs.StripVertical()
self.rst.SetProjection(self.srs.ExportToWkt())
self.bnd.FlushCache()

Expand Down
2 changes: 2 additions & 0 deletions hyo2/bag/uncertainty.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(self, bag_uncertainty: np.ndarray, bag_meta: Meta, fmt="geotiff", o
self.srs.ImportFromWkt(self.bag_meta.wkt_srs)
else:
logger.warning("unable to recover valid spatial reference info")
if self.srs.IsCompound():
self.srs.StripVertical()
self.rst.SetProjection(self.srs.ExportToWkt())
self.bnd.FlushCache()

Expand Down

0 comments on commit 3b62692

Please sign in to comment.