Skip to content

Issue #1128 avoid realignment for resolutions > 20m #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions openeo_driver/ProcessGraphDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -583,14 +584,16 @@ 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)
):
#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]:
Expand All @@ -612,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:
Expand Down