Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: generic dem tile names for SW hemisphere #63

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading