@@ -2680,7 +2680,165 @@ def test_unified_asset_keys(tmp_path, separate_asset_per_band, expected_tiff_fil
2680
2680
print (f"items={ json .dumps (items , indent = 2 )} " )
2681
2681
2682
2682
assert len (items ) == 2
2683
+ assert len ({item ["id" ] for item in items }) == 2
2683
2684
assert {item ["properties" ]["datetime" ] for item in items } == {"2025-04-05T00:00:00Z" , "2025-04-15T00:00:00Z" }
2684
2685
2685
2686
for item in items :
2686
2687
assert set (item ["assets" ].keys ()) == expected_asset_keys
2688
+
2689
+
2690
+ def test_unified_asset_keys_tile_grid (tmp_path ):
2691
+ process_graph = {
2692
+ "load2" : {
2693
+ "process_id" : "load_collection" ,
2694
+ "arguments" : {
2695
+ "bands" : [
2696
+ "Flat:0" ,
2697
+ "Flat:1" ,
2698
+ "Flat:2" ,
2699
+ ],
2700
+ "id" : "TestCollection-LonLat16x16" ,
2701
+ "spatial_extent" : {
2702
+ "west" : 0 ,
2703
+ "south" : 50 ,
2704
+ "east" : 2 ,
2705
+ "north" : 51 ,
2706
+ },
2707
+ "temporal_extent" : ["2025-04-01" , "2025-04-21" ],
2708
+ },
2709
+ },
2710
+ "save1" : {
2711
+ "process_id" : "save_result" ,
2712
+ "arguments" : {
2713
+ "data" : {"from_node" : "load2" },
2714
+ "format" : "GTIFF" ,
2715
+ "options" : {"tile_grid" : "wgs84-1degree" },
2716
+ },
2717
+ "result" : True ,
2718
+ },
2719
+ }
2720
+
2721
+ process = {
2722
+ "process_graph" : process_graph ,
2723
+ }
2724
+
2725
+ job_dir = tmp_path
2726
+ metadata_file = job_dir / "job_metadata.json"
2727
+
2728
+ run_job (
2729
+ process ,
2730
+ output_file = job_dir / "out" ,
2731
+ metadata_file = metadata_file ,
2732
+ api_version = "2.0.0" ,
2733
+ job_dir = job_dir ,
2734
+ dependencies = [],
2735
+ )
2736
+
2737
+ tiff_files = {file for file in os .listdir (job_dir ) if file .endswith (".tif" )}
2738
+ assert tiff_files == {
2739
+ "openEO_2025-04-05Z_N50E000.tif" ,
2740
+ "openEO_2025-04-05Z_N50E001.tif" ,
2741
+ "openEO_2025-04-15Z_N50E000.tif" ,
2742
+ "openEO_2025-04-15Z_N50E001.tif" ,
2743
+ }
2744
+
2745
+ with open (metadata_file ) as f :
2746
+ items = json .load (f )["items" ]
2747
+
2748
+ print (f"items={ json .dumps (items , indent = 2 )} " )
2749
+
2750
+ assert len (items ) == 4
2751
+ assert len ({item ["id" ] for item in items }) == 4
2752
+ assert {item ["properties" ]["datetime" ] for item in items } == {"2025-04-05T00:00:00Z" , "2025-04-15T00:00:00Z" }
2753
+
2754
+ for item in items :
2755
+ assert set (item ["assets" ].keys ()) == {"openEO" }
2756
+
2757
+
2758
+ def test_unified_asset_keys_sample_by_feature (tmp_path ):
2759
+ process_graph = {
2760
+ "load2" : {
2761
+ "process_id" : "load_collection" ,
2762
+ "arguments" : {
2763
+ "bands" : [
2764
+ "Flat:0" ,
2765
+ "Flat:1" ,
2766
+ "Flat:2" ,
2767
+ ],
2768
+ "id" : "TestCollection-LonLat16x16" ,
2769
+ "temporal_extent" : ["2025-04-01" , "2025-04-21" ],
2770
+ },
2771
+ },
2772
+ "filterspatial1" : {
2773
+ "process_id" : "filter_spatial" ,
2774
+ "arguments" : {
2775
+ "data" : {"from_node" : "load2" },
2776
+ "geometries" : {
2777
+ "type" : "FeatureCollection" ,
2778
+ "features" : [
2779
+ {
2780
+ "type" : "Feature" ,
2781
+ "properties" : {},
2782
+ "geometry" : {
2783
+ "type" : "Polygon" ,
2784
+ "coordinates" : [[[0 , 50 ], [0 , 51 ], [1 , 51 ], [1 , 50 ], [0 , 50 ]]],
2785
+ },
2786
+ },
2787
+ {
2788
+ "type" : "Feature" ,
2789
+ "properties" : {},
2790
+ "geometry" : {
2791
+ "type" : "Polygon" ,
2792
+ "coordinates" : [[[1 , 50 ], [1 , 51 ], [2 , 51 ], [2 , 50 ], [1 , 50 ]]],
2793
+ },
2794
+ },
2795
+ ],
2796
+ },
2797
+ },
2798
+ },
2799
+ "save1" : {
2800
+ "process_id" : "save_result" ,
2801
+ "arguments" : {
2802
+ "data" : {"from_node" : "filterspatial1" },
2803
+ "format" : "GTIFF" ,
2804
+ "options" : {"sample_by_feature" : True },
2805
+ },
2806
+ "result" : True ,
2807
+ },
2808
+ }
2809
+
2810
+ process = {
2811
+ "process_graph" : process_graph ,
2812
+ }
2813
+
2814
+ job_dir = tmp_path
2815
+ metadata_file = job_dir / "job_metadata.json"
2816
+
2817
+ run_job (
2818
+ process ,
2819
+ output_file = job_dir / "out" ,
2820
+ metadata_file = metadata_file ,
2821
+ api_version = "2.0.0" ,
2822
+ job_dir = job_dir ,
2823
+ dependencies = [],
2824
+ )
2825
+
2826
+ tiff_files = {file for file in os .listdir (job_dir ) if file .endswith (".tif" )}
2827
+ assert tiff_files == {
2828
+ "openEO_2025-04-05Z_0.tif" ,
2829
+ "openEO_2025-04-05Z_1.tif" ,
2830
+ "openEO_2025-04-15Z_0.tif" ,
2831
+ "openEO_2025-04-15Z_1.tif" ,
2832
+ }
2833
+
2834
+ with open (metadata_file ) as f :
2835
+ items = json .load (f )["items" ]
2836
+
2837
+ print (f"items={ json .dumps (items , indent = 2 )} " )
2838
+
2839
+ assert len (items ) == 4
2840
+ assert len ({item ["id" ] for item in items }) == 4
2841
+ assert {item ["properties" ]["datetime" ] for item in items } == {"2025-04-05T00:00:00Z" , "2025-04-15T00:00:00Z" }
2842
+
2843
+ for item in items :
2844
+ assert set (item ["assets" ].keys ()) == {"openEO" }
0 commit comments