Skip to content

Commit f2a384e

Browse files
soxofaanPeter Van Bouwel
authored and
Peter Van Bouwel
committed
Issue Open-EO#346 port linear_scale_range to ProcessArgs
1 parent 5940044 commit f2a384e

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

openeo_driver/ProcessGraphDeserializer.py

+11-14
Original file line numberDiff line numberDiff line change
@@ -1670,20 +1670,17 @@ def run_udf(args: dict, env: EvalEnv):
16701670

16711671

16721672
@process
1673-
def linear_scale_range(args: dict, env: EvalEnv) -> DriverDataCube:
1674-
image_collection = extract_arg(args, 'x')
1675-
1676-
inputMin = extract_arg(args, "inputMin")
1677-
inputMax = extract_arg(args, "inputMax")
1678-
outputMax = args.get("outputMax", 1.0)
1679-
outputMin = args.get("outputMin", 0.0)
1680-
if not isinstance(image_collection, DriverDataCube):
1681-
raise ProcessParameterInvalidException(
1682-
parameter="data", process="linear_scale_range",
1683-
reason=f"Invalid data type {type(image_collection)!r} expected raster-cube."
1684-
)
1685-
1686-
return image_collection.linear_scale_range(inputMin, inputMax, outputMin, outputMax)
1673+
def linear_scale_range(args: ProcessArgs, env: EvalEnv) -> DriverDataCube:
1674+
# TODO: eliminate this top-level linear_scale_range process implementation (should be used as `apply` callback)
1675+
_log.warning("DEPRECATED: linear_scale_range usage directly on cube is deprecated/non-standard.")
1676+
cube: DriverDataCube = args.get_required("x", expected_type=DriverDataCube)
1677+
# Note: non-standard camelCase parameter names (https://github.com/Open-EO/openeo-processes/issues/302)
1678+
input_min = args.get_required("inputMin")
1679+
input_max = args.get_required("inputMax")
1680+
output_min = args.get_optional("outputMin", default=0.0)
1681+
output_max = args.get_optional("outputMax", default=1.0)
1682+
# TODO linear_scale_range is defined on GeopysparkDataCube, but not on DriverDataCube
1683+
return cube.linear_scale_range(input_min, input_max, output_min, output_max)
16871684

16881685

16891686
@process

0 commit comments

Comments
 (0)