Skip to content

Commit

Permalink
fix: changed single polygon to merged polygon POI if uploaded multi p…
Browse files Browse the repository at this point in the history
…olygon during project area edit
  • Loading branch information
sujanadh committed Sep 12, 2023
1 parent 3a8778c commit 970d056
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/backend/app/projects/project_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,15 +830,20 @@ def remove_z_dimension(coord):
)

""" Apply the lambda function to each coordinate in its geometry """
multi_polygons = []
for feature in features:
list(map(remove_z_dimension, feature["geometry"]["coordinates"][0]))
if feature["geometry"]["type"] == "MultiPolygon":
multi_polygons.append(Polygon(feature["geometry"]["coordinates"][0][0]))


"""Update the boundary polyon on the database."""
outline = shape(features[0]["geometry"])

# If the outline is a multipolygon, use the first polygon
if isinstance(outline, MultiPolygon):
outline = outline.geoms[0]
if multi_polygons:
outline = multi_polygons[0]
for geom in multi_polygons[1:]:
outline = outline.union(geom)
else:
outline = shape(features[0]["geometry"])

db_project.outline = outline.wkt
db_project.centroid = outline.centroid.wkt
Expand Down

0 comments on commit 970d056

Please sign in to comment.