Skip to content

Commit

Permalink
fix: handle 50k imagery filenames TDE-1014 (#845)
Browse files Browse the repository at this point in the history
* fix: handle 50k imagery filenames

* fix: remove extraneous lines

* docs: clarify scales supported
  • Loading branch information
amfage authored Feb 12, 2024
1 parent e69cdc5 commit 07a7af5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions scripts/tile/tests/tile_index_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def test_get_bounds_from_name() -> None:
assert expected_bounds == bounds


def test_get_bounds_from_50k_name() -> None:
expected_bounds = Bounds(Point(x=1180000, y=4758000), Size(width=24_000, height=36_000))
bounds = get_bounds_from_name("CK08")
assert expected_bounds == bounds


@pytest.mark.dependency()
def test_get_tile_offset() -> None:
expected_bounds = Bounds(Point(x=8640, y=28440), Size(width=240, height=360))
Expand Down
15 changes: 12 additions & 3 deletions scripts/tile/tile_index.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import NamedTuple, Union

from scripts.tile.util import charcodeat
Expand Down Expand Up @@ -42,6 +43,14 @@ def get_bounds_from_name(tile_name: str) -> Bounds:
Returns:
a `Bounds` object
"""
# check for 50k imagery
if re.match(r"^[A-Z]{2}\d{2}$", tile_name):
origin = get_mapsheet_offset(tile_name)
return Bounds(
Point(x=origin.x, y=origin.y),
Size(SHEET_WIDTH, SHEET_HEIGHT),
)

name_parts = tile_name.split("_")
map_sheet = name_parts[0]
# should be in [10_000, 5_000, 2_000, 1_000, 500]
Expand Down Expand Up @@ -104,9 +113,9 @@ def get_tile_offset(grid_size: int, x: int, y: int) -> Bounds:
"""Get the tile offset from its coordinate and the grid size
Args:
grid_size: a size from in [10_000, 5_000, 2_000, 1_000, 500]
x: upper left cooridinate x
y: upper left cooridinate y
grid_size: a size in [10_000, 5_000, 2_000, 1_000, 500]
x: upper left coordinate x
y: upper left coordinate y
Returns:
a `Bounds` object
Expand Down

0 comments on commit 07a7af5

Please sign in to comment.