File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 11
11
from shapely .geometry import MultiPolygon , Polygon
12
12
from shapely .geometry .base import BaseGeometry
13
13
14
+ from openeo .util import repr_truncate
14
15
from openeo_driver .errors import OpenEOApiException
15
16
from openeo_driver .util .utm import auto_utm_epsg , auto_utm_epsg_for_geometry
16
17
@@ -78,7 +79,7 @@ def validate_geojson_basic(
78
79
return []
79
80
80
81
81
- def validate_geojson_coordinates (geojson ):
82
+ def validate_geojson_coordinates (geojson : dict ):
82
83
def _validate_coordinates (coordinates , initial_run = True ):
83
84
max_evaluations = 20
84
85
message = f"Failed to parse Geojson. Coordinates are invalid."
@@ -120,6 +121,11 @@ def _validate_feature_collection(geojson):
120
121
else :
121
122
_validate_coordinates (feature ["geometry" ]["coordinates" ])
122
123
124
+ if not isinstance (geojson , dict ):
125
+ raise ValueError (f"Invalid GeoJSON: not a dict: { repr_truncate (geojson )} " )
126
+ if "type" not in geojson :
127
+ raise ValueError (f"Invalid GeoJSON: missing 'type' field: { repr_truncate (geojson )} " )
128
+
123
129
if geojson ["type" ] == "Feature" :
124
130
geojson = geojson ["geometry" ]
125
131
You can’t perform that action at this time.
0 commit comments