|
40 | 40 | Processing,
|
41 | 41 | OpenEoBackendImplementation,
|
42 | 42 | )
|
| 43 | +from openeo_driver.constants import RESAMPLE_SPATIAL_METHODS, RESAMPLE_SPATIAL_ALIGNS |
43 | 44 | from openeo_driver.datacube import (
|
44 | 45 | DriverDataCube,
|
45 | 46 | DriverVectorCube,
|
@@ -1582,24 +1583,23 @@ def ndvi(args: dict, env: EvalEnv) -> DriverDataCube:
|
1582 | 1583 | @process
|
1583 | 1584 | def resample_spatial(args: ProcessArgs, env: EvalEnv) -> DriverDataCube:
|
1584 | 1585 | cube: DriverDataCube = args.get_required("data", expected_type=DriverDataCube)
|
1585 |
| - resolution = args.get_optional("resolution", 0) |
1586 |
| - projection = args.get_optional("projection", None) |
1587 |
| - method = args.get_optional("method", "near") |
1588 |
| - align = args.get_optional("align", "upper-left") |
| 1586 | + resolution = args.get_optional( |
| 1587 | + "resolution", |
| 1588 | + default=0, |
| 1589 | + validator=lambda v: isinstance(v, (int, float)) or (isinstance(v, (tuple, list)) and len(v) == 2), |
| 1590 | + ) |
| 1591 | + projection = args.get_optional("projection", default=None) |
| 1592 | + method = args.get_enum("method", options=RESAMPLE_SPATIAL_METHODS, default="near") |
| 1593 | + align = args.get_enum("align", options=RESAMPLE_SPATIAL_ALIGNS, default="upper-left") |
1589 | 1594 | return cube.resample_spatial(resolution=resolution, projection=projection, method=method, align=align)
|
1590 | 1595 |
|
1591 | 1596 |
|
1592 | 1597 | @process
|
1593 |
| -def resample_cube_spatial(args: dict, env: EvalEnv) -> DriverDataCube: |
1594 |
| - image_collection = extract_arg(args, 'data') |
1595 |
| - target_image_collection = extract_arg(args, 'target') |
1596 |
| - method = args.get('method', 'near') |
1597 |
| - if not isinstance(image_collection, DriverDataCube): |
1598 |
| - raise ProcessParameterInvalidException( |
1599 |
| - parameter="data", process="resample_cube_spatial", |
1600 |
| - reason=f"Invalid data type {type(image_collection)!r} expected raster-cube." |
1601 |
| - ) |
1602 |
| - return image_collection.resample_cube_spatial(target=target_image_collection, method=method) |
| 1598 | +def resample_cube_spatial(args: ProcessArgs, env: EvalEnv) -> DriverDataCube: |
| 1599 | + cube: DriverDataCube = args.get_required("data", expected_type=DriverDataCube) |
| 1600 | + target: DriverDataCube = args.get_required("target", expected_type=DriverDataCube) |
| 1601 | + method = args.get_enum("method", options=RESAMPLE_SPATIAL_METHODS, default="near") |
| 1602 | + return cube.resample_cube_spatial(target=target, method=method) |
1603 | 1603 |
|
1604 | 1604 |
|
1605 | 1605 | @process
|
|
0 commit comments