From 8ae9226ceaf2191f15a1fc77a83beddec4ce33f0 Mon Sep 17 00:00:00 2001 From: edparris Date: Fri, 20 Dec 2024 17:05:51 -0500 Subject: [PATCH] fix: generic dem tile names for SW hemisphere --- src/aws/osml/photogrammetry/generic_dem_tile_set.py | 13 +++++++------ .../photogrammetry/test_generic_dem_tile_set.py | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/aws/osml/photogrammetry/generic_dem_tile_set.py b/src/aws/osml/photogrammetry/generic_dem_tile_set.py index 76531c6..0b47e2f 100644 --- a/src/aws/osml/photogrammetry/generic_dem_tile_set.py +++ b/src/aws/osml/photogrammetry/generic_dem_tile_set.py @@ -1,6 +1,6 @@ # Copyright 2023-2024 Amazon.com, Inc. or its affiliates. -from math import degrees, floor +from math import degrees, floor, radians from typing import Optional from .coordinates import GeodeticWorldCoordinate @@ -22,10 +22,10 @@ def __init__( ) -> None: """ Construct a tile set from a limited collection of configurable parameters. This implementation uses the - custom formatting directives supplied with GeodeticWorldCoordinate to allow users to create tile IDs - that match a variety of situations. For example the default format_spec of '%od%oh/%ld%lh.dt2' will - generate tile ids like: '115e/45s.dt2' which would match some common 1-degree cell based DEM file - hierarchies. + custom formatting directives %od (longitude degrees), %oh (longitude hemisphere), %ld (latitude degrees), + and %lh (latitude hemisphere) to allow users to create tile IDs that match a variety of situations. + For example the default format_spec of '%od%oh/%ld%lh.dt2' will generate tile ids like: '115e/45s.dt2' + which would match some common 1-degree cell based DEM file hierarchies. :param format_spec: the format specification for the GeodeteticWorldCoordinate @@ -60,4 +60,5 @@ def find_tile_id(self, geodetic_world_coordinate: GeodeticWorldCoordinate) -> Op ): return None - return f"{geodetic_world_coordinate:{self.format_string}}" + ul_coordinate = GeodeticWorldCoordinate([radians(longitude_degrees), radians(latitude_degrees), 0.0]) + return f"{ul_coordinate:{self.format_string}}" diff --git a/test/aws/osml/photogrammetry/test_generic_dem_tile_set.py b/test/aws/osml/photogrammetry/test_generic_dem_tile_set.py index 5b05657..3436eab 100644 --- a/test/aws/osml/photogrammetry/test_generic_dem_tile_set.py +++ b/test/aws/osml/photogrammetry/test_generic_dem_tile_set.py @@ -13,6 +13,14 @@ def test_default_format_spec(self): tile_path = tile_set.find_tile_id(GeodeticWorldCoordinate([radians(142), radians(3), 0.0])) assert "142e/03n.dt2" == tile_path + def test_sw_hemisphere(self): + from aws.osml.photogrammetry.coordinates import GeodeticWorldCoordinate + from aws.osml.photogrammetry.generic_dem_tile_set import GenericDEMTileSet + + tile_set = GenericDEMTileSet(format_spec="dted/%oh%od/%lh%ld.dt2") + tile_path = tile_set.find_tile_id(GeodeticWorldCoordinate([radians(-43.648601), radians(-22.999056), 42.0])) + assert "dted/w044/s23.dt2" == tile_path + if __name__ == "__main__": unittest.main()