Skip to content

Commit

Permalink
fix: generic dem tile names for SW hemisphere
Browse files Browse the repository at this point in the history
  • Loading branch information
edparris committed Dec 22, 2024
1 parent 795ab0e commit 8ae9226
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/aws/osml/photogrammetry/generic_dem_tile_set.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}}"
8 changes: 8 additions & 0 deletions test/aws/osml/photogrammetry/test_generic_dem_tile_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 8ae9226

Please sign in to comment.