Skip to content

Commit

Permalink
to_scl_dilation_mask: use defaults from spec
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Mar 11, 2024
1 parent d165cc9 commit de7e659
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions openeo_driver/ProcessGraphDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1993,23 +1993,24 @@ def mask_scl_dilation(args: Dict, env: EvalEnv):

@process_registry_100.add_function(spec=read_spec("openeo-processes/experimental/to_scl_dilation_mask.json"))
@process_registry_2xx.add_function(spec=read_spec("openeo-processes/experimental/to_scl_dilation_mask.json"))
def to_scl_dilation_mask(args: Dict, env: EvalEnv):
cube: DriverDataCube = extract_arg(args, "data")
if not isinstance(cube, DriverDataCube):
raise ProcessParameterInvalidException(
parameter="data",
process="to_scl_dilation_mask",
reason=f"Invalid data type {type(cube)!r} expected raster-cube.",
)
def to_scl_dilation_mask(args: ProcessArgs, env: EvalEnv):
cube: DriverDataCube = args.get_required("data", expected_type=DriverDataCube)

if hasattr(cube, "to_scl_dilation_mask"):
erosion_kernel_size = args.get("erosion_kernel_size", 0)
mask1_values = args.get("mask1_values", [2, 4, 5, 6, 7])
mask2_values = args.get("mask2_values", [3, 8, 9, 10, 11])
kernel1_size = args.get("kernel1_size", 17)
kernel2_size = args.get("kernel2_size", 201)
return cube.to_scl_dilation_mask(erosion_kernel_size, mask1_values, mask2_values, kernel1_size, kernel2_size)
spec = read_spec("openeo-processes/experimental/to_scl_dilation_mask.json")
optionals = {
arg: args.get_optional(arg, default=spec["parameters"][arg]["default"])
for arg in [
"erosion_kernel_size",
"mask1_values",
"mask2_values",
"kernel1_size",
"kernel2_size",
]
}
return cube.to_scl_dilation_mask(**optionals)
else:
return cube
raise FeatureUnsupportedException(message="to_scl_dilation_mask is not supported")


@process_registry_100.add_function(spec=read_spec("openeo-processes/experimental/mask_l1c.json"))
Expand Down

0 comments on commit de7e659

Please sign in to comment.