From 4f6a433b1bdc30402fdfcde4cd595b33a610a1b3 Mon Sep 17 00:00:00 2001 From: dsamaey Date: Wed, 21 May 2025 13:31:54 +0200 Subject: [PATCH 1/2] Issue #1128 avoid realignment for resolutions > 20m --- openeo_driver/ProcessGraphDeserializer.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/openeo_driver/ProcessGraphDeserializer.py b/openeo_driver/ProcessGraphDeserializer.py index 280b8a08..7511395e 100644 --- a/openeo_driver/ProcessGraphDeserializer.py +++ b/openeo_driver/ProcessGraphDeserializer.py @@ -546,10 +546,11 @@ def _collection_crs(collection_id, env) -> str: metadata = env.backend_implementation.catalog.get_collection_metadata(collection_id) except CollectionNotFoundException: return None - crs = metadata.get('cube:dimensions', {}).get('x', {}).get('reference_system', None) + crs = metadata.get("cube:dimensions", {}).get("x", {}).get("reference_system", None) return crs -def _collection_resolution(collection_id, env) -> str: + +def _collection_resolution(collection_id, env) -> Optional[List[int]]: try: metadata = env.backend_implementation.catalog.get_collection_metadata(collection_id) except CollectionNotFoundException: @@ -583,14 +584,17 @@ def _align_extent(extent,collection_id,env,target_resolution=None): if (target_resolution == None and collection_resolution == None): return extent - - if ( crs == 4326 - and extent.get('crs','') == "EPSG:4326" - and "extent" in x and "extent" in y - and (target_resolution == None or target_resolution == collection_resolution) + if ( + crs == 4326 + and extent.get("crs", "") == "EPSG:4326" + and "extent" in x + and "extent" in y + and (target_resolution is None or target_resolution == collection_resolution) + and collection_resolution[0] <= 20 ): - #only align to collection resolution + # only align to collection resolution target_resolution = collection_resolution + def align(v, dimension, rounding, resolution): range = dimension.get('extent', []) if v < range[0]: From a6c76cc18393435de94fc51b666be61d25d33e47 Mon Sep 17 00:00:00 2001 From: dsamaey Date: Fri, 23 May 2025 11:37:01 +0200 Subject: [PATCH 2/2] Issue #1128 avoid realignment for resolutions > 20m --- openeo_driver/ProcessGraphDeserializer.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/openeo_driver/ProcessGraphDeserializer.py b/openeo_driver/ProcessGraphDeserializer.py index 7511395e..0a2a31da 100644 --- a/openeo_driver/ProcessGraphDeserializer.py +++ b/openeo_driver/ProcessGraphDeserializer.py @@ -590,7 +590,6 @@ def _align_extent(extent,collection_id,env,target_resolution=None): and "extent" in x and "extent" in y and (target_resolution is None or target_resolution == collection_resolution) - and collection_resolution[0] <= 20 ): # only align to collection resolution target_resolution = collection_resolution @@ -616,15 +615,20 @@ def align(v, dimension, rounding, resolution): _log.info(f"Realigned input extent {extent} into {new_extent}") return new_extent - elif(isUTM): - bbox = BoundingBox.from_dict(extent,default_crs=4326) - bbox_utm = bbox.reproject_to_best_utm() + elif isUTM: + if collection_resolution[0] <= 20: + bbox = BoundingBox.from_dict(extent, default_crs=4326) + bbox_utm = bbox.reproject_to_best_utm() - new_extent = bbox_utm.round_to_resolution(target_resolution[0],target_resolution[1]) + new_extent = bbox_utm.round_to_resolution(target_resolution[0], target_resolution[1]) - _log.info(f"Realigned input extent {extent} into {new_extent}") - return new_extent.as_dict() + _log.info(f"Realigned input extent {extent} into {new_extent}") + return new_extent.as_dict() + else: + _log.info(f"Not realigning input extent {extent} because crs is UTM and resolution > 20m") + return extent else: + _log.info(f"Not realigning input extent {extent} (collection crs: {crs}, resolution: {collection_resolution})") return extent def _extract_load_parameters(env: EvalEnv, source_id: tuple) -> LoadParameters: