|
15 | 15 | from openeo_aggregator.utils import BoundingBox
|
16 | 16 |
|
17 | 17 |
|
18 |
| -def test_tile_grid_spec_from_string(): |
19 |
| - assert TileGrid.from_string("wgs84-1degree") == TileGrid(crs_type="wgs84", size=1, unit="degree") |
20 |
| - assert TileGrid.from_string("utm-10km") == TileGrid(crs_type="utm", size=10, unit="km") |
| 18 | +class TestTileGrid: |
| 19 | + def test_tile_grid_spec_from_string(self): |
| 20 | + assert TileGrid.from_string("wgs84-1degree") == TileGrid(crs_type="wgs84", size=1, unit="degree") |
| 21 | + assert TileGrid.from_string("utm-10km") == TileGrid(crs_type="utm", size=10, unit="km") |
| 22 | + |
| 23 | + def test_get_tiles_wgs84_simple(self): |
| 24 | + tile_grid = TileGrid(crs_type="wgs84", size=1, unit="degree") |
| 25 | + bbox = BoundingBox(west=0.2, south=0.3, east=0.6, north=0.8, crs="epsg:4326") |
| 26 | + assert tile_grid.get_tiles(bbox=bbox) == [ |
| 27 | + BoundingBox(west=0, south=0, east=1, north=1, crs="epsg:4326"), |
| 28 | + ] |
| 29 | + |
| 30 | + def test_get_tiles_wgs84_basic(self): |
| 31 | + tile_grid = TileGrid(crs_type="wgs84", size=1, unit="degree") |
| 32 | + bbox = BoundingBox(west=1.2, south=2.3, east=2.6, north=4.8, crs="epsg:4326") |
| 33 | + assert tile_grid.get_tiles(bbox=bbox) == [ |
| 34 | + BoundingBox(west=1, south=2, east=2, north=3, crs="epsg:4326"), |
| 35 | + BoundingBox(west=1, south=3, east=2, north=4, crs="epsg:4326"), |
| 36 | + BoundingBox(west=1, south=4, east=2, north=5, crs="epsg:4326"), |
| 37 | + BoundingBox(west=2, south=2, east=3, north=3, crs="epsg:4326"), |
| 38 | + BoundingBox(west=2, south=3, east=3, north=4, crs="epsg:4326"), |
| 39 | + BoundingBox(west=2, south=4, east=3, north=5, crs="epsg:4326"), |
| 40 | + ] |
| 41 | + |
| 42 | + def test_get_get_tiles_wgs84_perfect_alignment(self): |
| 43 | + tile_grid = TileGrid(crs_type="wgs84", size=1, unit="degree") |
| 44 | + bbox = BoundingBox(west=0, south=2, east=1, north=3, crs="epsg:4326") |
| 45 | + assert tile_grid.get_tiles(bbox=bbox) == [ |
| 46 | + BoundingBox(west=0, south=2, east=1, north=3, crs="epsg:4326"), |
| 47 | + ] |
| 48 | + |
| 49 | + def test_get_tiles_utm_simple(self): |
| 50 | + tile_grid = TileGrid.from_string("utm-10km") |
| 51 | + bbox = BoundingBox(west=500_100, south=5_672_000, east=503_000, north=5_677_000, crs="epsg:32631") |
| 52 | + assert tile_grid.get_tiles(bbox=bbox) == [ |
| 53 | + BoundingBox(west=500_000, south=5_670_000, east=510_000, north=5_680_000, crs="epsg:32631"), |
| 54 | + ] |
| 55 | + |
| 56 | + @pytest.mark.parametrize( |
| 57 | + ["tile_grid", "expected"], |
| 58 | + [ |
| 59 | + ( |
| 60 | + "utm-10km", |
| 61 | + [ |
| 62 | + BoundingBox(west=640000, south=5660000, east=650000, north=5670000, crs="epsg:32631"), |
| 63 | + BoundingBox(west=640000, south=5670000, east=650000, north=5680000, crs="epsg:32631"), |
| 64 | + BoundingBox(west=650000, south=5660000, east=660000, north=5670000, crs="epsg:32631"), |
| 65 | + BoundingBox(west=650000, south=5670000, east=660000, north=5680000, crs="epsg:32631"), |
| 66 | + ], |
| 67 | + ), |
| 68 | + ( |
| 69 | + "utm-100km", |
| 70 | + [ |
| 71 | + BoundingBox(west=600000, south=5600000, east=700000, north=5700000, crs="epsg:32631"), |
| 72 | + ], |
| 73 | + ), |
| 74 | + ], |
| 75 | + ) |
| 76 | + def test_get_tiles_wgs84_to_utm_basic(self, tile_grid, expected): |
| 77 | + tile_grid = TileGrid.from_string(tile_grid) |
| 78 | + bbox = BoundingBox(west=5.10, south=51.10, east=5.25, north=51.20, crs="epsg:4326") |
| 79 | + assert tile_grid.get_tiles(bbox=bbox) == expected |
21 | 80 |
|
22 | 81 |
|
23 | 82 | def test_flimsy_splitter(multi_backend_connection, catalog):
|
|
0 commit comments