Skip to content

Commit

Permalink
convert to multipolygon
Browse files Browse the repository at this point in the history
  • Loading branch information
george-silva committed Apr 3, 2024
1 parent 4479bbb commit c2d6d85
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/planscape/planning/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from base.region_name import display_name_to_region
from django.conf import settings
from django.contrib.gis.geos import GEOSGeometry
from django.contrib.gis.geos import GEOSGeometry, MultiPolygon
from django.db import IntegrityError
from django.db.models import Count, Max
from django.db.models.functions import Coalesce
Expand Down Expand Up @@ -60,7 +60,10 @@ def _convert_polygon_to_multipolygon(geometry: dict):
if geom["type"] == "Polygon":
geom["type"] = "MultiPolygon"
geom["coordinates"] = [feature["geometry"]["coordinates"]]
actual_geometry = GEOSGeometry(json.dumps(geom)).buffer(0).unary_union

actual_geometry = MultiPolygon(
[GEOSGeometry(json.dumps(geom)).buffer(0).unary_union]
)

if not actual_geometry.valid:
raise ValueError("Geometry is invalid and cannot be used.")
Expand Down

0 comments on commit c2d6d85

Please sign in to comment.