Skip to content

Commit

Permalink
fix: first coordinate check when check_crs geojson
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Feb 15, 2024
1 parent a9b7569 commit b61c727
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/backend/app/db/postgis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,24 +325,14 @@ def is_valid_coordinate(coord):
)
elif input_geojson_type == "Feature":
coordinates = input_geojson.get("geometry", {}).get("coordinates", [])

geometry_type = (
features[0].get("geometry", {}).get("type")
if input_geojson_type == "FeatureCollection" and features
else input_geojson.get("geometry", {}).get("type", "")
)
if geometry_type == "MultiPolygon":
first_coordinate = (
coordinates[0][0][0] if coordinates and coordinates[0] else None
)
elif geometry_type == "Point":
first_coordinate = coordinates if coordinates else None

elif geometry_type == "LineString":
first_coordinate = coordinates[0] if coordinates else None

else:
first_coordinate = coordinates[0][0] if coordinates else None # type polygon
coordinates = input_geojson.get("coordinates", {})

first_coordinate = None
if coordinates:
while isinstance(coordinates, list):
first_coordinate = coordinates
coordinates = coordinates[0]

if not is_valid_coordinate(first_coordinate):
log.error(error_message)
Expand Down

0 comments on commit b61c727

Please sign in to comment.