Skip to content

Commit

Permalink
fix(backend): better handle invalid multipolygon geoms
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jul 17, 2024
1 parent c688e11 commit 35e1f60
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/backend/app/db/postgis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,12 @@ def multipolygon_to_polygon(features: Union[Feature, FeatCol, MultiPolygon, Poly

for feature in features:
properties = feature["properties"]
geom = shape(feature["geometry"])
try:
geom = shape(feature["geometry"])
except ValueError:
log.warning(f"Geometry is not valid, so was skipped: {feature['geometry']}")
continue

if geom.geom_type == "Polygon":
geojson_feature.append(
geojson.Feature(geometry=geom, properties=properties)
Expand Down

0 comments on commit 35e1f60

Please sign in to comment.