@@ -734,17 +734,33 @@ def test_aggregate_spatial(api):
734
734
"2015-07-06T00:00:00Z" : [[2.345 ]],
735
735
"2015-08-22T00:00:00Z" : [[None ]]
736
736
}
737
- params = dummy_backend .last_load_collection_call ('S2_FAPAR_CLOUDCOVER' )
738
- assert params ["spatial_extent" ] == {"west" : 7.02 , "south" : 51.29 , "east" : 7.65 , "north" : 51.75 , "crs" : 'EPSG:4326' }
739
- assert params ["aggregate_spatial_geometries" ] == shapely .geometry .shape ({
740
- "type" : "Polygon" ,
741
- "coordinates" : [[[7.02 , 51.75 ], [7.65 , 51.74 ], [7.65 , 51.29 ], [7.04 , 51.31 ], [7.02 , 51.75 ]]]
742
- })
737
+ params = dummy_backend .last_load_collection_call ("S2_FAPAR_CLOUDCOVER" )
738
+ assert params ["spatial_extent" ] == {
739
+ "west" : 7.02 ,
740
+ "south" : 51.29 ,
741
+ "east" : 7.65 ,
742
+ "north" : 51.75 ,
743
+ "crs" : "EPSG:4326" ,
744
+ }
745
+ assert params ["aggregate_spatial_geometries" ] == DriverVectorCube .from_geojson (
746
+ {
747
+ "type" : "Polygon" ,
748
+ "coordinates" : [
749
+ [
750
+ [7.02 , 51.75 ],
751
+ [7.65 , 51.74 ],
752
+ [7.65 , 51.29 ],
753
+ [7.04 , 51.31 ],
754
+ [7.02 , 51.75 ],
755
+ ]
756
+ ],
757
+ }
758
+ )
743
759
744
760
745
761
def test_execute_aggregate_spatial_spatial_cube (api100 ):
746
762
resp = api100 .check_result ("aggregate_spatial_spatial_cube.json" )
747
- assert resp .json == [[100.0 , 100.1 ], [101 .0 , 101.1 ]]
763
+ assert resp .json == [[2.345 , None ], [2 .0 , 3.0 ]]
748
764
749
765
750
766
@pytest .mark .parametrize (["geometries" , "expected" ], [
@@ -789,37 +805,51 @@ def test_aggregate_spatial_vector_cube_basic(api100, feature_collection_test_pat
789
805
assert params ["spatial_extent" ] == {"west" : 1 , "south" : 1 , "east" : 5 , "north" : 4 , "crs" : "EPSG:4326" }
790
806
assert isinstance (params ["aggregate_spatial_geometries" ], DriverVectorCube )
791
807
792
- assert res .json == DictSubSet ({
793
- "type" : "FeatureCollection" ,
794
- "features" : [
795
- DictSubSet ({
796
- "type" : "Feature" ,
797
- "geometry" : {"type" : "Polygon" , "coordinates" : [[[1 , 1 ], [3 , 1 ], [2 , 3 ], [1 , 1 ]]]},
798
- "properties" : {
799
- "id" : "first" , "pop" : 1234 ,
800
- "agg~2015-07-06T00:00:00Z~B02" : 0 ,
801
- "agg~2015-07-06T00:00:00Z~B03" : 1 ,
802
- "agg~2015-07-06T00:00:00Z~B04" : 2 ,
803
- "agg~2015-08-22T00:00:00Z~B02" : 3 ,
804
- "agg~2015-08-22T00:00:00Z~B03" : 4 ,
805
- "agg~2015-08-22T00:00:00Z~B04" : 5 ,
806
- },
807
- }),
808
- DictSubSet ({
809
- "type" : "Feature" ,
810
- "geometry" : {"type" : "Polygon" , "coordinates" : [[[4 , 2 ], [5 , 4 ], [3 , 4 ], [4 , 2 ]]]},
811
- "properties" : {
812
- "id" : "second" , "pop" : 5678 ,
813
- "agg~2015-07-06T00:00:00Z~B02" : 6 ,
814
- "agg~2015-07-06T00:00:00Z~B03" : 7 ,
815
- "agg~2015-07-06T00:00:00Z~B04" : 8 ,
816
- "agg~2015-08-22T00:00:00Z~B02" : 9 ,
817
- "agg~2015-08-22T00:00:00Z~B03" : 10 ,
818
- "agg~2015-08-22T00:00:00Z~B04" : 11 ,
819
- },
820
- }),
821
- ]
822
- })
808
+ assert res .json == DictSubSet (
809
+ {
810
+ "type" : "FeatureCollection" ,
811
+ "features" : [
812
+ DictSubSet (
813
+ {
814
+ "type" : "Feature" ,
815
+ "geometry" : {
816
+ "type" : "Polygon" ,
817
+ "coordinates" : [[[1 , 1 ], [3 , 1 ], [2 , 3 ], [1 , 1 ]]],
818
+ },
819
+ "properties" : {
820
+ "id" : "first" ,
821
+ "pop" : 1234 ,
822
+ "agg~2015-07-06T00:00:00Z~B02" : 2.345 ,
823
+ "agg~2015-07-06T00:00:00Z~B03" : None ,
824
+ "agg~2015-07-06T00:00:00Z~B04" : 2.0 ,
825
+ "agg~2015-08-22T00:00:00Z~B02" : 3.0 ,
826
+ "agg~2015-08-22T00:00:00Z~B03" : 4.0 ,
827
+ "agg~2015-08-22T00:00:00Z~B04" : 5.0 ,
828
+ },
829
+ }
830
+ ),
831
+ DictSubSet (
832
+ {
833
+ "type" : "Feature" ,
834
+ "geometry" : {
835
+ "type" : "Polygon" ,
836
+ "coordinates" : [[[4 , 2 ], [5 , 4 ], [3 , 4 ], [4 , 2 ]]],
837
+ },
838
+ "properties" : {
839
+ "id" : "second" ,
840
+ "pop" : 5678 ,
841
+ "agg~2015-07-06T00:00:00Z~B02" : 6.0 ,
842
+ "agg~2015-07-06T00:00:00Z~B03" : 7.0 ,
843
+ "agg~2015-07-06T00:00:00Z~B04" : 8.0 ,
844
+ "agg~2015-08-22T00:00:00Z~B02" : 9.0 ,
845
+ "agg~2015-08-22T00:00:00Z~B03" : 10.0 ,
846
+ "agg~2015-08-22T00:00:00Z~B04" : 11.0 ,
847
+ },
848
+ }
849
+ ),
850
+ ],
851
+ }
852
+ )
823
853
824
854
825
855
@pytest .mark .parametrize (["info" , "preprocess_pg" , "aggregate_data" , "p1_properties" , "p2_properties" ], [
@@ -828,9 +858,14 @@ def test_aggregate_spatial_vector_cube_basic(api100, feature_collection_test_pat
828
858
{},
829
859
"lc" ,
830
860
{
831
- "id" : "first" , "pop" : 1234 ,
832
- "agg~2015-07-06T00:00:00Z~B02" : 0 , "agg~2015-07-06T00:00:00Z~B03" : 1 , "agg~2015-07-06T00:00:00Z~B04" : 2 ,
833
- "agg~2015-08-22T00:00:00Z~B02" : 3 , "agg~2015-08-22T00:00:00Z~B03" : 4 , "agg~2015-08-22T00:00:00Z~B04" : 5 ,
861
+ "id" : "first" ,
862
+ "pop" : 1234 ,
863
+ "agg~2015-07-06T00:00:00Z~B02" : 2.345 ,
864
+ "agg~2015-07-06T00:00:00Z~B03" : None ,
865
+ "agg~2015-07-06T00:00:00Z~B04" : 2 ,
866
+ "agg~2015-08-22T00:00:00Z~B02" : 3 ,
867
+ "agg~2015-08-22T00:00:00Z~B03" : 4 ,
868
+ "agg~2015-08-22T00:00:00Z~B04" : 5 ,
834
869
},
835
870
{
836
871
"id" : "second" , "pop" : 5678 ,
@@ -850,7 +885,13 @@ def test_aggregate_spatial_vector_cube_basic(api100, feature_collection_test_pat
850
885
}},
851
886
},
852
887
"r" ,
853
- {"id" : "first" , "pop" : 1234 , "agg~B02" : 0 , "agg~B03" : 1 , "agg~B04" : 2 },
888
+ {
889
+ "id" : "first" ,
890
+ "pop" : 1234 ,
891
+ "agg~B02" : 2.345 ,
892
+ "agg~B03" : None ,
893
+ "agg~B04" : 2 ,
894
+ },
854
895
{"id" : "second" , "pop" : 5678 , "agg~B02" : 3 , "agg~B03" : 4 , "agg~B04" : 5 },
855
896
),
856
897
(
@@ -865,10 +906,20 @@ def test_aggregate_spatial_vector_cube_basic(api100, feature_collection_test_pat
865
906
}}
866
907
},
867
908
"r" ,
868
- {"id" : "first" , "pop" : 1234 , "agg~2015-07-06T00:00:00Z" : 0 , "agg~2015-08-22T00:00:00Z" : 1 },
869
- {"id" : "second" , "pop" : 5678 , "agg~2015-07-06T00:00:00Z" : 2 , "agg~2015-08-22T00:00:00Z" : 3 },
870
- ),
871
- (
909
+ {
910
+ "id" : "first" ,
911
+ "pop" : 1234 ,
912
+ "agg~2015-07-06T00:00:00Z" : 2.345 ,
913
+ "agg~2015-08-22T00:00:00Z" : None ,
914
+ },
915
+ {
916
+ "id" : "second" ,
917
+ "pop" : 5678 ,
918
+ "agg~2015-07-06T00:00:00Z" : 2 ,
919
+ "agg~2015-08-22T00:00:00Z" : 3 ,
920
+ },
921
+ ),
922
+ (
872
923
"no-time-nor-bands" ,
873
924
{
874
925
"r1" : {"process_id" : "reduce_dimension" , "arguments" : {
@@ -887,8 +938,8 @@ def test_aggregate_spatial_vector_cube_basic(api100, feature_collection_test_pat
887
938
}},
888
939
},
889
940
"r2" ,
890
- {"id" : "first" , "pop" : 1234 , "agg" : 0 },
891
- {"id" : "second" , "pop" : 5678 , "agg" : 1 },
941
+ {"id" : "first" , "pop" : 1234 , "agg" : 2.345 },
942
+ {"id" : "second" , "pop" : 5678 , "agg" : None },
892
943
),
893
944
])
894
945
def test_aggregate_spatial_vector_cube_dimensions (
0 commit comments