@@ -137,31 +137,70 @@ def test_load_collection_connectionless_temporal_extent_shortcut(self):
137
137
}
138
138
}
139
139
140
- def test_load_collection_connectionless_shapely_spatial_extent (self ):
141
- polygon = shapely .geometry .Polygon (((0.0 , 1.0 ), (2.0 , 1.0 ), (3.0 , 2.0 ), (1.5 , 0.0 ), (0.0 , 1.0 )))
142
- cube = DataCube .load_collection ("T3" , spatial_extent = polygon )
143
- assert cube .flat_graph () == {
144
- "loadcollection1" : {
145
- "arguments" : {"id" : "T3" , "spatial_extent" :
146
- {'coordinates' : (((0.0 ,1.0 ),(2.0 ,1.0 ),(3.0 ,2.0 ),(1.5 ,0.0 ),(0.0 ,1.0 )),),'type' : 'Polygon' },
147
- "temporal_extent" : None },
148
- "process_id" : "load_collection" ,
149
- "result" : True ,
150
- }
140
+ def test_load_collection_spatial_extent_bbox (self , dummy_backend ):
141
+ spatial_extent = {"west" : 1 , "south" : 2 , "east" : 3 , "north" : 4 }
142
+ cube = DataCube .load_collection ("S2" , spatial_extent = spatial_extent , connection = dummy_backend .connection )
143
+ cube .execute ()
144
+ assert dummy_backend .get_sync_pg ()["loadcollection1" ]["arguments" ] == {
145
+ "id" : "S2" ,
146
+ "spatial_extent" : {"west" : 1 , "south" : 2 , "east" : 3 , "north" : 4 },
147
+ "temporal_extent" : None ,
148
+ }
149
+
150
+ def test_load_collection_spatial_extent_shapely (self , dummy_backend ):
151
+ polygon = shapely .geometry .Polygon ([(3 , 51 ), (4 , 51 ), (4 , 52 ), (3 , 52 )])
152
+ cube = DataCube .load_collection ("S2" , spatial_extent = polygon , connection = dummy_backend .connection )
153
+ cube .execute ()
154
+ assert dummy_backend .get_sync_pg ()["loadcollection1" ]["arguments" ] == {
155
+ "id" : "S2" ,
156
+ "spatial_extent" : {
157
+ "type" : "Polygon" ,
158
+ "coordinates" : [[[3 , 51 ], [4 , 51 ], [4 , 52 ], [3 , 52 ], [3 , 51 ]]],
159
+ },
160
+ "temporal_extent" : None ,
151
161
}
152
162
153
163
@pytest .mark .parametrize ("path_factory" , [str , pathlib .Path ])
154
- def test_load_collection_connectionless_local_path_spatial_extent (self , path_factory , test_data ):
164
+ def test_load_collection_spatial_extent_local_path (self , dummy_backend , path_factory , test_data ):
155
165
path = path_factory (test_data .get_path ("geojson/polygon02.json" ))
156
- cube = DataCube .load_collection ("T3" , spatial_extent = path )
157
- assert cube .flat_graph () == {
166
+ cube = DataCube .load_collection ("S2" , spatial_extent = path , connection = dummy_backend .connection )
167
+ cube .execute ()
168
+ assert dummy_backend .get_sync_pg ()["loadcollection1" ]["arguments" ] == {
169
+ "id" : "S2" ,
170
+ "spatial_extent" : {"type" : "Polygon" , "coordinates" : [[[3 , 50 ], [4 , 50 ], [4 , 51 ], [3 , 50 ]]]},
171
+ "temporal_extent" : None ,
172
+ }
173
+
174
+ def test_load_collection_spatial_extent_url (self , dummy_backend ):
175
+ cube = DataCube .load_collection (
176
+ "S2" , spatial_extent = "https://geo.test/geometry.json" , connection = dummy_backend .connection
177
+ )
178
+ cube .execute ()
179
+ assert dummy_backend .get_sync_pg () == {
180
+ "loadurl1" : {
181
+ "process_id" : "load_url" ,
182
+ "arguments" : {"format" : "GeoJSON" , "url" : "https://geo.test/geometry.json" },
183
+ },
158
184
"loadcollection1" : {
159
- "arguments" : {"id" : "T3" , "spatial_extent" :
160
- {"type" : "Polygon" , "coordinates" : [[[3 , 50 ], [4 , 50 ], [4 , 51 ], [3 , 50 ]]]},
161
- "temporal_extent" : None },
162
185
"process_id" : "load_collection" ,
186
+ "arguments" : {
187
+ "id" : "S2" ,
188
+ "spatial_extent" : {"from_node" : "loadurl1" },
189
+ "temporal_extent" : None ,
190
+ },
163
191
"result" : True ,
164
- }
192
+ },
193
+ }
194
+
195
+ def test_load_collection_spatial_extent_parameter (self , dummy_backend ):
196
+ cube = DataCube .load_collection (
197
+ "S2" , spatial_extent = Parameter .geojson ("zpatial_extent" ), connection = dummy_backend .connection
198
+ )
199
+ cube .execute ()
200
+ assert dummy_backend .get_sync_pg ()["loadcollection1" ]["arguments" ] == {
201
+ "id" : "S2" ,
202
+ "spatial_extent" : {"from_parameter" : "zpatial_extent" },
203
+ "temporal_extent" : None ,
165
204
}
166
205
167
206
def test_load_collection_connectionless_save_result (self ):
@@ -206,6 +245,71 @@ def test_load_stac_connectionless_save_result(self):
206
245
},
207
246
}
208
247
248
+ def test_load_stac_spatial_extent_bbox (self , dummy_backend ):
249
+ spatial_extent = {"west" : 1 , "south" : 2 , "east" : 3 , "north" : 4 }
250
+ cube = DataCube .load_stac (
251
+ "https://stac.test/data" , spatial_extent = spatial_extent , connection = dummy_backend .connection
252
+ )
253
+ cube .execute ()
254
+ assert dummy_backend .get_sync_pg ()["loadstac1" ]["arguments" ] == {
255
+ "url" : "https://stac.test/data" ,
256
+ "spatial_extent" : {"west" : 1 , "south" : 2 , "east" : 3 , "north" : 4 },
257
+ }
258
+
259
+ def test_load_stac_spatial_extent_shapely (self , dummy_backend ):
260
+ polygon = shapely .geometry .Polygon ([(3 , 51 ), (4 , 51 ), (4 , 52 ), (3 , 52 )])
261
+ cube = DataCube .load_stac ("https://stac.test/data" , spatial_extent = polygon , connection = dummy_backend .connection )
262
+ cube .execute ()
263
+ assert dummy_backend .get_sync_pg ()["loadstac1" ]["arguments" ] == {
264
+ "url" : "https://stac.test/data" ,
265
+ "spatial_extent" : {
266
+ "type" : "Polygon" ,
267
+ "coordinates" : [[[3 , 51 ], [4 , 51 ], [4 , 52 ], [3 , 52 ], [3 , 51 ]]],
268
+ },
269
+ }
270
+
271
+ @pytest .mark .parametrize ("path_factory" , [str , pathlib .Path ])
272
+ def test_load_stac_spatial_extent_local_path (self , dummy_backend , path_factory , test_data ):
273
+ path = path_factory (test_data .get_path ("geojson/polygon02.json" ))
274
+ cube = DataCube .load_stac ("https://stac.test/data" , spatial_extent = path , connection = dummy_backend .connection )
275
+ cube .execute ()
276
+ assert dummy_backend .get_sync_pg ()["loadstac1" ]["arguments" ] == {
277
+ "url" : "https://stac.test/data" ,
278
+ "spatial_extent" : {"type" : "Polygon" , "coordinates" : [[[3 , 50 ], [4 , 50 ], [4 , 51 ], [3 , 50 ]]]},
279
+ }
280
+
281
+ def test_load_stac_spatial_extent_url (self , dummy_backend ):
282
+ cube = DataCube .load_stac (
283
+ "https://stac.test/data" ,
284
+ spatial_extent = "https://geo.test/geometry.json" ,
285
+ connection = dummy_backend .connection ,
286
+ )
287
+ cube .execute ()
288
+ assert dummy_backend .get_sync_pg () == {
289
+ "loadurl1" : {
290
+ "process_id" : "load_url" ,
291
+ "arguments" : {"format" : "GeoJSON" , "url" : "https://geo.test/geometry.json" },
292
+ },
293
+ "loadstac1" : {
294
+ "process_id" : "load_stac" ,
295
+ "arguments" : {
296
+ "url" : "https://stac.test/data" ,
297
+ "spatial_extent" : {"from_node" : "loadurl1" },
298
+ },
299
+ "result" : True ,
300
+ },
301
+ }
302
+
303
+ def test_load_stac_spatial_extent_parameter (self , dummy_backend ):
304
+ spatial_extent = Parameter .geojson ("zpatial_extent" )
305
+ cube = DataCube .load_stac (
306
+ "https://stac.test/data" , spatial_extent = spatial_extent , connection = dummy_backend .connection
307
+ )
308
+ cube .execute ()
309
+ assert dummy_backend .get_sync_pg ()["loadstac1" ]["arguments" ] == {
310
+ "url" : "https://stac.test/data" ,
311
+ "spatial_extent" : {"from_parameter" : "zpatial_extent" },
312
+ }
209
313
210
314
def test_filter_temporal_basic_positional_args (s2cube ):
211
315
im = s2cube .filter_temporal ("2016-01-01" , "2016-03-10" )
0 commit comments