@@ -1148,6 +1148,41 @@ def test_auto_align(dry_run_env, dry_run_tracer):
11481148 } == load_params .global_extent
11491149
11501150
1151+ def test_no_auto_align_when_resampling (dry_run_env , dry_run_tracer ):
1152+ polygon = {"type" : "Polygon" , "coordinates" : [[(0.1 , 0.1 ), (3 , 5 ), (8 , 2 ), (0.1 , 0.1 )]]}
1153+ cube = DataCube (PGNode ("load_collection" , id = "ESA_WORLDCOVER_10M_2020_V1" ), connection = None )
1154+ cube = cube .filter_spatial (geometries = polygon )
1155+ cube = cube .resample_spatial (resolution = 0.001 )
1156+
1157+ pg = cube .flat_graph ()
1158+ res = evaluate (pg , env = dry_run_env )
1159+
1160+ source_constraints = dry_run_tracer .get_source_constraints (merge = True )
1161+ assert len (source_constraints ) == 1
1162+ src , constraints = source_constraints [0 ]
1163+ assert src == ("load_collection" , ("ESA_WORLDCOVER_10M_2020_V1" , ()))
1164+ (geometries ,) = dry_run_tracer .get_geometries (operation = "filter_spatial" )
1165+ assert constraints == {
1166+ 'resample' : {'method' : 'near' ,
1167+ 'resolution' : (0.001 , 0.001 ),
1168+ 'target_crs' : None },
1169+ "spatial_extent" : {"crs" : "EPSG:4326" , "east" : 8.0 , "north" : 5.0 , "south" : 0.1 , "west" : 0.1 },
1170+ "filter_spatial" : {"geometries" : DummyVectorCube .from_geometry (shapely .geometry .shape (polygon ))},
1171+ "weak_spatial_extent" : {"west" : 0.1 , "south" : 0.1 , "east" : 8.0 , "north" : 5.0 , "crs" : "EPSG:4326" },
1172+ }
1173+ assert isinstance (geometries , DummyVectorCube )
1174+ assert shapely .geometry .mapping (geometries .to_multipolygon ()) == {
1175+ "type" : "Polygon" ,
1176+ "coordinates" : (((0.1 , 0.1 ), (3.0 , 5.0 ), (8.0 , 2.0 ), (0.1 , 0.1 )),),
1177+ }
1178+ # source_constraints = dry_run_tracer.get_source_constraints()
1179+ dry_run_env = dry_run_env .push ({ENV_SOURCE_CONSTRAINTS : source_constraints })
1180+ load_params = _extract_load_parameters (
1181+ dry_run_env , source_id = ("load_collection" , ("ESA_WORLDCOVER_10M_2020_V1" , ()))
1182+ )
1183+ assert {'crs' : 'EPSG:4326' , 'east' : 8.0 , 'north' : 5.0 , 'south' : 0.1 , 'west' : 0.1 } == load_params .global_extent
1184+
1185+
11511186def test_global_bounds_from_weak_spatial_extent (dry_run_env , dry_run_tracer ):
11521187 # The global extent is the union from the spatial extent and the weak spatial extent.
11531188 bbox = {"west" : 1 , "south" : 1 , "east" : 3 , "north" : 3 , "crs" : "EPSG:4326" }
0 commit comments