|
8 | 8 | split_area, |
9 | 9 | ) |
10 | 10 |
|
| 11 | +# TODO: using fixtures for these simple objects is a bit overkill, makes the test harder to follow, and undermines opportunity to parameterize |
11 | 12 |
|
12 | 13 | @pytest.fixture |
13 | 14 | def mock_polygon_wgs(): |
@@ -89,54 +90,54 @@ def test_as_polygon(self): |
89 | 90 |
|
90 | 91 | class TestSizeBasedTileGrid: |
91 | 92 | def test_from_size_projection(self): |
92 | | - splitter = _SizeBasedTileGrid.from_size_projection(0.1, "EPSG:4326") |
| 93 | + splitter = _SizeBasedTileGrid.from_size_projection(size=0.1, projection="EPSG:4326") |
93 | 94 | assert splitter.epsg == 4326 |
94 | 95 | assert splitter.size == 0.1 |
95 | 96 |
|
96 | 97 | def test_get_tiles_raises_exception(self): |
97 | 98 | """test get_tiles when the input geometry is not a dict or shapely.geometry.Polygon""" |
98 | | - tile_grid = _SizeBasedTileGrid.from_size_projection(0.1, "EPSG:4326") |
| 99 | + tile_grid = _SizeBasedTileGrid.from_size_projection(size=0.1, projection="EPSG:4326") |
99 | 100 | with pytest.raises(JobSplittingFailure): |
100 | 101 | tile_grid.get_tiles("invalid_geometry") |
101 | 102 |
|
102 | 103 | def test_simple_get_tiles_dict(self, mock_dict_with_crs_utm, mock_polygon_utm): |
103 | 104 | """test get_tiles when the the tile grid size is equal to the size of the input geometry. The original geometry should be returned as polygon.""" |
104 | | - tile_grid = _SizeBasedTileGrid.from_size_projection(100_000, "EPSG:3857") |
| 105 | + tile_grid = _SizeBasedTileGrid.from_size_projection(size=100_000, projection="EPSG:3857") |
105 | 106 | tiles = tile_grid.get_tiles(mock_dict_with_crs_utm) |
106 | 107 | assert len(tiles) == 1 |
107 | 108 | assert tiles[0] == mock_polygon_utm |
108 | 109 |
|
109 | 110 | def test_multiple_get_tile_dict(self, mock_dict_with_crs_utm): |
110 | 111 | """test get_tiles when the the tile grid size is smaller than the size of the input geometry. The input geometry should be split into multiple tiles.""" |
111 | | - tile_grid = _SizeBasedTileGrid.from_size_projection(20_000, "EPSG:3857") |
| 112 | + tile_grid = _SizeBasedTileGrid.from_size_projection(size=20_000, projection="EPSG:3857") |
112 | 113 | tiles = tile_grid.get_tiles(mock_dict_with_crs_utm) |
113 | 114 | assert len(tiles) == 25 |
114 | 115 | assert tiles[0] == shapely.geometry.box(0.0, 0.0, 20_000.0, 20_000.0) |
115 | 116 |
|
116 | 117 | def test_larger_get_tile_dict(self, mock_dict_with_crs_utm, mock_polygon_utm): |
117 | 118 | """test get_tiles when the the tile grid size is larger than the size of the input geometry. The original geometry should be returned.""" |
118 | | - tile_grid = _SizeBasedTileGrid.from_size_projection(200_000, "EPSG:3857") |
| 119 | + tile_grid = _SizeBasedTileGrid.from_size_projection(size=200_000, projection="EPSG:3857") |
119 | 120 | tiles = tile_grid.get_tiles(mock_dict_with_crs_utm) |
120 | 121 | assert len(tiles) == 1 |
121 | 122 | assert tiles[0] == mock_polygon_utm |
122 | 123 |
|
123 | 124 | def test_get_tiles_polygon_wgs(self, mock_polygon_wgs): |
124 | 125 | """test get_tiles when the input geometry is a polygon in wgs and the tile grid is in wgs""" |
125 | | - tile_grid = _SizeBasedTileGrid.from_size_projection(0.1, "EPSG:4326") |
| 126 | + tile_grid = _SizeBasedTileGrid.from_size_projection(size=0.1, projection="EPSG:4326") |
126 | 127 | tiles = tile_grid.get_tiles(mock_polygon_wgs) |
127 | 128 | assert len(tiles) == 100 |
128 | 129 | assert tiles[0] == shapely.geometry.box(0.0, 0.0, 0.1, 0.1) |
129 | 130 |
|
130 | 131 | def test_simple_get_tiles_polygon(self, mock_polygon_utm): |
131 | 132 | """test get_tiles when the the tile grid size is equal to the size of the input geometry. The original geometry should be returned.""" |
132 | | - tile_grid = _SizeBasedTileGrid.from_size_projection(100_000.0, "EPSG:3857") |
| 133 | + tile_grid = _SizeBasedTileGrid.from_size_projection(size=100_000.0, projection="EPSG:3857") |
133 | 134 | tiles = tile_grid.get_tiles(mock_polygon_utm) |
134 | 135 | assert len(tiles) == 1 |
135 | 136 | assert tiles[0] == mock_polygon_utm |
136 | 137 |
|
137 | 138 | def test_larger_get_tiles_polygon(self, mock_polygon_utm): |
138 | 139 | """test get_tiles when the the tile grid size is larger than the size of the input geometry. The original geometry should be returned.""" |
139 | | - tile_grid = _SizeBasedTileGrid.from_size_projection(200_000.0, "EPSG:3857") |
| 140 | + tile_grid = _SizeBasedTileGrid.from_size_projection(size=200_000.0, projection="EPSG:3857") |
140 | 141 | tiles = tile_grid.get_tiles(mock_polygon_utm) |
141 | 142 | assert len(tiles) == 1 |
142 | 143 | assert tiles[0] == mock_polygon_utm |
|
0 commit comments