@@ -1050,15 +1050,35 @@ def aggregate_spatial(args: dict, env: EvalEnv) -> DriverDataCube:
1050
1050
if isinstance (geoms , DriverVectorCube ):
1051
1051
geoms = geoms
1052
1052
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
+ )
1062
1082
elif isinstance (geoms , DelayedVector ):
1063
1083
geoms = geoms .path
1064
1084
else :
0 commit comments