|
9 | 9 | import pytest
|
10 | 10 | from pytest import approx
|
11 | 11 |
|
12 |
| -from odc.geo import CRS, res_, resyx_, xy_, yx_ |
| 12 | +from odc.geo import CRS, res_, resyx_, xy_, yx_, XY |
13 | 13 | from odc.geo.geom import polygon
|
14 | 14 | from odc.geo.gridspec import GridSpec
|
15 | 15 | from odc.geo.testutils import SAMPLE_WKT_WITHOUT_AUTHORITY
|
|
18 | 18 | # pylint: disable=comparison-with-itself,unnecessary-comprehension
|
19 | 19 |
|
20 | 20 |
|
| 21 | +def test_gridspec_small(): |
| 22 | + print("Starting test for GridSpec") |
| 23 | + WGS84GRID30 = GridSpec( |
| 24 | + "EPSG:4326", tile_shape=(5000, 5000), resolution=0.0003, origin=XY(-180, -90) |
| 25 | + ) |
| 26 | + |
| 27 | + assert WGS84GRID30.tile_shape == (5000, 5000) |
| 28 | + assert WGS84GRID30.tile_size == XY(1.5, 1.5) |
| 29 | + |
| 30 | + # Tile is at (-180 + 50*1.5) and (-90 + 50*1.5) |
| 31 | + tile = (50, 50) |
| 32 | + geobox = WGS84GRID30.tile_geobox(tile) |
| 33 | + affine = geobox.affine |
| 34 | + |
| 35 | + # Affine should be like this: (0.0003, 0, -105.0, 0, -0.0003, -13.5) |
| 36 | + assert affine.a == 0.0003 |
| 37 | + assert affine.c == -105.0 # -180 + 50 * 1.5 * 0.0003 |
| 38 | + assert affine.f == -13.50 # -90 + 50 * 1.5 * 0.0003 |
| 39 | + |
| 40 | + # Tile is at (-180 + 200*1.5) and (-90 + 75*1.5) |
| 41 | + tile = (200, 75) |
| 42 | + geobox = WGS84GRID30.tile_geobox(tile) |
| 43 | + affine = geobox.affine |
| 44 | + |
| 45 | + # Affine should be like this: (0.0003, 0, 120.0, 0, -0.0003, 24.0) |
| 46 | + assert affine.a == 0.0003 |
| 47 | + assert affine.c == 120.0 # -180 + 200 * 1.5 * 0.0003 |
| 48 | + assert affine.f == 24.0 # -90 + 75 * 1.5 * 0.0003 |
| 49 | + |
| 50 | + |
21 | 51 | def test_gridspec():
|
22 | 52 | gs = GridSpec(
|
23 | 53 | crs=CRS("EPSG:4326"),
|
|
0 commit comments