Skip to content

Commit 3030e90

Browse files
committed
fixes
1 parent cabfe82 commit 3030e90

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

geotessera/cli.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def point_to_tile_bbox(lon: float, lat: float) -> tuple:
123123
"""Convert a point to the bounding box of its containing tile.
124124
125125
Tiles are 0.1x0.1 degree squares centered at 0.05-degree offsets.
126+
Returns a point bbox at the tile center, which the registry query
127+
will expand by 0.05 degrees to match exactly one tile.
126128
127129
Args:
128130
lon: Longitude in decimal degrees
@@ -132,8 +134,9 @@ def point_to_tile_bbox(lon: float, lat: float) -> tuple:
132134
Tuple of (min_lon, min_lat, max_lon, max_lat) for the containing tile
133135
"""
134136
tile_lon, tile_lat = tile_from_world(lon, lat)
135-
# Tile center ± 0.05 degrees
136-
return (tile_lon - 0.05, tile_lat - 0.05, tile_lon + 0.05, tile_lat + 0.05)
137+
# Return point bbox at tile center - registry expands by 0.05 degrees
138+
# which will match exactly this one tile
139+
return (tile_lon, tile_lat, tile_lon, tile_lat)
137140

138141

139142
app = typer.Typer(
@@ -659,7 +662,7 @@ def coverage(
659662
tile_center = tile_from_world(lon, lat)
660663
region_bbox = point_to_tile_bbox(lon, lat)
661664
rprint(
662-
f"[green]Point ({lon}, {lat}) tile "
665+
f"[green]Point ({lon}, {lat}) -> tile "
663666
f"grid_{tile_center[0]:.2f}_{tile_center[1]:.2f}[/green]"
664667
)
665668
rprint(f"[green]Region bounding box:[/green] {format_bbox(region_bbox)}")
@@ -675,7 +678,7 @@ def coverage(
675678
tile_center = tile_from_world(lon, lat)
676679
region_bbox = point_to_tile_bbox(lon, lat)
677680
rprint(
678-
f"[green]Point ({lon}, {lat}) tile "
681+
f"[green]Point ({lon}, {lat}) -> tile "
679682
f"grid_{tile_center[0]:.2f}_{tile_center[1]:.2f}[/green]"
680683
)
681684
elif len(bbox_coords) == 4:
@@ -1109,7 +1112,7 @@ def download(
11091112
tile_center = tile_from_world(lon, lat)
11101113
bbox_coords = point_to_tile_bbox(lon, lat)
11111114
rprint(
1112-
f"[green]Point ({lon}, {lat}) tile "
1115+
f"[green]Point ({lon}, {lat}) -> tile "
11131116
f"grid_{tile_center[0]:.2f}_{tile_center[1]:.2f}[/green]"
11141117
)
11151118
rprint(f"[green]Using bounding box:[/green] {format_bbox(bbox_coords)}")
@@ -1125,7 +1128,7 @@ def download(
11251128
tile_center = tile_from_world(lon, lat)
11261129
bbox_coords = point_to_tile_bbox(lon, lat)
11271130
rprint(
1128-
f"[green]Point ({lon}, {lat}) tile "
1131+
f"[green]Point ({lon}, {lat}) -> tile "
11291132
f"grid_{tile_center[0]:.2f}_{tile_center[1]:.2f}[/green]"
11301133
)
11311134
rprint(f"[green]Using bounding box:[/green] {format_bbox(bbox_coords)}")

tests/cli.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Test the info command without arguments to see library information.
3535
We just verify key information is present, ignoring formatting:
3636

3737
$ geotessera info --dataset-version v1 2>&1 | grep -E 'Available years'
38-
Available years: 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025
38+
Available years: 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025
3939

4040
Test: Download Dry Run for UK Tile
4141
-----------------------------------

tests/tile.t

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ The point (0.17, 52.23) should resolve to tile grid_0.15_52.25:
3232
> --format tiff \
3333
> --dry-run \
3434
> --dataset-version v1 2>&1 | grep -E '(Point|tile grid_|Found|Files to download|Tiles in region)'
35-
Point (0.17, 52.23) .* tile grid_0.15_52.25 (re)
35+
Point (0.17, 52.23) -> tile grid_0.15_52.25
3636
Found 1 tiles for region in year 2024
37-
Files to download: 1
38-
Tiles in region: 1
37+
Files to download: 1
38+
Tiles in region: 1
3939

4040
Test: Single Tile with 2-coord --bbox (Dry Run)
4141
-----------------------------------------------
@@ -49,10 +49,10 @@ This should behave identically to --tile:
4949
> --format tiff \
5050
> --dry-run \
5151
> --dataset-version v1 2>&1 | grep -E '(Point|tile grid_|Found|Files to download|Tiles in region)'
52-
Point (0.17, 52.23) .* tile grid_0.15_52.25 (re)
52+
Point (0.17, 52.23) -> tile grid_0.15_52.25
5353
Found 1 tiles for region in year 2024
54-
Files to download: 1
55-
Tiles in region: 1
54+
Files to download: 1
55+
Tiles in region: 1
5656

5757
Test: Mutual Exclusivity of Region Options
5858
------------------------------------------
@@ -64,8 +64,8 @@ Test that specifying multiple region options produces an error:
6464
> --bbox "-0.1,51.3,0.1,51.5" \
6565
> --year 2024 \
6666
> --dry-run \
67-
> --dataset-version v1 2>&1 | grep -E 'Error.*multiple region'
68-
Error: Cannot specify multiple region options. Choose one of: --bbox, --tile, --region-file, --country
67+
> --dataset-version v1 2>&1 | grep -E 'Cannot specify multiple region'
68+
Error: Cannot specify multiple region options. Choose one of: --bbox, --tile,
6969

7070
Test: Invalid --tile Format (Wrong Number of Coords)
7171
-----------------------------------------------------
@@ -102,7 +102,7 @@ Download a single tile using --tile option:
102102
> --format tiff \
103103
> --output "$TESTDIR/single_tile_tiff" \
104104
> --dataset-version v1 2>&1 | grep -E '(Point|SUCCESS)' | sed 's/ *$//'
105-
Point (0.17, 52.23) .* tile grid_0.15_52.25 (re)
105+
Point (0.17, 52.23) -> tile grid_0.15_52.25
106106
SUCCESS: Exported 1 GeoTIFF files
107107

108108
Verify that exactly one TIFF file was created:
@@ -118,17 +118,11 @@ Verify the tile is named correctly (grid_0.15_52.25):
118118
Test: Coverage Command with --tile Option
119119
-----------------------------------------
120120

121-
Test that coverage command also accepts --tile option:
121+
Test that coverage command also accepts --tile option and parses the tile correctly:
122122

123123
$ geotessera coverage \
124124
> --tile "0.17,52.23" \
125125
> --output "$TESTDIR/single_tile_coverage.png" \
126-
> --dataset-version v1 2>&1 | grep -E '(Point|tile grid_|Region bounding box)'
127-
Point (0.17, 52.23) .* tile grid_0.15_52.25 (re)
128-
Region bounding box: .* (re)
129-
130-
Verify coverage image was created:
131-
132-
$ test -f "$TESTDIR/single_tile_coverage.png" && echo "Coverage PNG created"
133-
Coverage PNG created
134-
126+
> --dataset-version v1 2>&1 | head -2
127+
Point (0.17, 52.23) -> tile grid_0.15_52.25
128+
Region bounding box: [0.150000\xc2\xb0E, 52.250000\xc2\xb0N] - [0.150000\xc2\xb0E, 52.250000\xc2\xb0N] (esc)

0 commit comments

Comments
 (0)