Skip to content

Commit 4927eee

Browse files
committed
fixup! Issue #114/#141 temporarily roll back automatic conversion of inline Point GeoJSON to VectorCube in aggregate_spatial
1 parent c3b4318 commit 4927eee

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

openeo_driver/ProcessGraphDeserializer.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,15 +1050,35 @@ def aggregate_spatial(args: dict, env: EvalEnv) -> DriverDataCube:
10501050
if isinstance(geoms, DriverVectorCube):
10511051
geoms = geoms
10521052
elif isinstance(geoms, dict):
1053-
if geoms.get("type") == "Point":
1054-
# TODO #114 migrate Point handling to DriverVectorCube too
1055-
geoms = geojson_to_geometry(geoms)
1056-
elif geoms.get("type") == "GeometryCollection" and any(g.get("type") == "Point" for g in geoms.get("geometries", [])):
1057-
# TODO #114 migrate Point handling to DriverVectorCube too
1058-
geoms = geojson_to_geometry(geoms)
1059-
else:
1060-
# Automatically convert inline GeoJSON to a vector cube #114/#141
1061-
geoms = env.backend_implementation.vector_cube_cls.from_geojson(geoms)
1053+
try:
1054+
if (
1055+
# Don't convert point geometries to DriverVectorCube
1056+
# TODO #114 migrate Point handling to DriverVectorCube too
1057+
geoms["type"] == "Point"
1058+
or (geoms["type"] == "Feature" and geoms["geometry"]["type"] == "Point")
1059+
or (
1060+
geoms["type"] == "FeatureCollection"
1061+
and any(f["geometry"]["type"] == "Point" for f in geoms["features"])
1062+
)
1063+
or (
1064+
geoms["type"] == "GeometryCollection"
1065+
and any(g["type"] == "Point" for g in geoms["geometries"])
1066+
)
1067+
):
1068+
geoms = geojson_to_geometry(geoms)
1069+
else:
1070+
# Automatically convert inline GeoJSON to a vector cube #114/#141
1071+
geoms = env.backend_implementation.vector_cube_cls.from_geojson(geoms)
1072+
except Exception as e:
1073+
_log.error(
1074+
f"Failed to parse inline GeoJSON geometries in aggregate_spatial: {e!r}",
1075+
exc_info=True,
1076+
)
1077+
raise ProcessParameterInvalidException(
1078+
parameter="geometries",
1079+
process="aggregate_spatial",
1080+
reason="Failed to parse inline GeoJSON",
1081+
)
10621082
elif isinstance(geoms, DelayedVector):
10631083
geoms = geoms.path
10641084
else:

0 commit comments

Comments
 (0)