193193}
194194
195195
196- def _get_normalizable_crs_inputs ():
197- """
198- Dynamic (proj version based) generation of supported CRS inputs (to normalize).
199- :return:
200- """
201- yield "EPSG:32631"
202- yield 32631
203- yield "32631"
204- yield "+proj=utm +zone=31 +datum=WGS84 +units=m +no_defs" # is also EPSG:32631, in proj format
205- yield WKT2_FOR_EPSG23631
206-
207196
208197def _get_leaf_node (cube : DataCube ) -> dict :
209198 """Get leaf node (node with result=True), supporting old and new style of graph building."""
@@ -561,7 +550,18 @@ def test_aggregate_spatial_types(con100: Connection, polygon, expected_geometrie
561550 }
562551
563552
564- @pytest .mark .parametrize ("crs" , _get_normalizable_crs_inputs ())
553+ @pytest .mark .parametrize (
554+ "crs" ,
555+ [
556+ "EPSG:32631" ,
557+ 32631 ,
558+ "32631" ,
559+ "+proj=utm +zone=31 +datum=WGS84 +units=m +no_defs" , # is also EPSG:32631, in proj format
560+ WKT2_FOR_EPSG23631 ,
561+ PROJJSON_FOR_EPSG23631 ,
562+ json .dumps (PROJJSON_FOR_EPSG23631 ),
563+ ],
564+ )
565565def test_aggregate_spatial_with_crs (con100 : Connection , recwarn , crs : str ):
566566 img = con100 .load_collection ("S2" )
567567 polygon = shapely .geometry .box (0 , 0 , 1 , 1 )
@@ -588,36 +588,6 @@ def test_aggregate_spatial_with_crs(con100: Connection, recwarn, crs: str):
588588 }
589589
590590
591- @pytest .mark .skipif (
592- pyproj .__version__ < ComparableVersion ("3.3.0" ), # TODO #717
593- reason = "PROJJSON format support requires pyproj 3.3.0 or higher" ,
594- )
595- @pytest .mark .parametrize ("crs" , [PROJJSON_FOR_EPSG23631 , json .dumps (PROJJSON_FOR_EPSG23631 )])
596- def test_aggregate_spatial_with_crs_as_projjson (con100 : Connection , recwarn , crs ):
597- """Separate test coverage for PROJJSON, so we can skip it for Python versions below 3.8""" # TODO #717
598- img = con100 .load_collection ("S2" )
599- polygon = shapely .geometry .box (0 , 0 , 1 , 1 )
600- masked = img .aggregate_spatial (geometries = polygon , reducer = "mean" , crs = crs )
601- warnings = [str (w .message ) for w in recwarn ]
602- assert f"Geometry with non-Lon-Lat CRS { crs !r} is only supported by specific back-ends." in warnings
603- assert sorted (masked .flat_graph ().keys ()) == ["aggregatespatial1" , "loadcollection1" ]
604- assert masked .flat_graph ()["aggregatespatial1" ] == {
605- "process_id" : "aggregate_spatial" ,
606- "arguments" : {
607- "data" : {"from_node" : "loadcollection1" },
608- "geometries" : {
609- "type" : "Polygon" ,
610- "coordinates" : (((1.0 , 0.0 ), (1.0 , 1.0 ), (0.0 , 1.0 ), (0.0 , 0.0 ), (1.0 , 0.0 )),),
611- "crs" : {"properties" : {"name" : "EPSG:32631" }, "type" : "name" },
612- },
613- "reducer" : {
614- "process_graph" : {
615- "mean1" : {"process_id" : "mean" , "arguments" : {"data" : {"from_parameter" : "data" }}, "result" : True }
616- }
617- },
618- },
619- "result" : True ,
620- }
621591
622592
623593@pytest .mark .parametrize (
@@ -906,7 +876,18 @@ def test_mask_polygon_types(con100: Connection, polygon, expected_mask):
906876 }
907877
908878
909- @pytest .mark .parametrize ("crs" , _get_normalizable_crs_inputs ())
879+ @pytest .mark .parametrize (
880+ "crs" ,
881+ [
882+ "EPSG:32631" ,
883+ 32631 ,
884+ "32631" ,
885+ "+proj=utm +zone=31 +datum=WGS84 +units=m +no_defs" , # is also EPSG:32631, in proj format
886+ WKT2_FOR_EPSG23631 ,
887+ PROJJSON_FOR_EPSG23631 ,
888+ json .dumps (PROJJSON_FOR_EPSG23631 ),
889+ ],
890+ )
910891def test_mask_polygon_with_crs (con100 : Connection , recwarn , crs : str ):
911892 img = con100 .load_collection ("S2" )
912893 polygon = shapely .geometry .box (0 , 0 , 1 , 1 )
@@ -929,33 +910,6 @@ def test_mask_polygon_with_crs(con100: Connection, recwarn, crs: str):
929910 }
930911
931912
932- @pytest .mark .skipif (
933- pyproj .__version__ < ComparableVersion ("3.3.0" ), # TODO #717
934- reason = "PROJJSON format support requires pyproj 3.3.0 or higher" ,
935- )
936- @pytest .mark .parametrize ("crs" , [PROJJSON_FOR_EPSG23631 , json .dumps (PROJJSON_FOR_EPSG23631 )])
937- def test_mask_polygon_with_crs_as_projjson (con100 : Connection , recwarn , crs ):
938- """Separate test coverage for PROJJSON, so we can skip it for Python versions below 3.8""" # TODO #717
939- img = con100 .load_collection ("S2" )
940- polygon = shapely .geometry .box (0 , 0 , 1 , 1 )
941- masked = img .mask_polygon (mask = polygon , srs = crs )
942- warnings = [str (w .message ) for w in recwarn ]
943- assert f"Geometry with non-Lon-Lat CRS { crs !r} is only supported by specific back-ends." in warnings
944- assert sorted (masked .flat_graph ().keys ()) == ["loadcollection1" , "maskpolygon1" ]
945- assert masked .flat_graph ()["maskpolygon1" ] == {
946- "process_id" : "mask_polygon" ,
947- "arguments" : {
948- "data" : {"from_node" : "loadcollection1" },
949- "mask" : {
950- "type" : "Polygon" ,
951- "coordinates" : (((1.0 , 0.0 ), (1.0 , 1.0 ), (0.0 , 1.0 ), (0.0 , 0.0 ), (1.0 , 0.0 )),),
952- # All listed test inputs for crs should be converted to "EPSG:32631"
953- "crs" : {"type" : "name" , "properties" : {"name" : "EPSG:32631" }},
954- },
955- },
956- "result" : True ,
957- }
958-
959913
960914def test_mask_polygon_parameter (con100 : Connection ):
961915 img = con100 .load_collection ("S2" )
0 commit comments