Skip to content

Commit

Permalink
another attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
george-silva committed Apr 2, 2024
1 parent 4fec697 commit 4142813
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/planscape/planning/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.contrib.gis.geos import GEOSGeometry
from planning.models import PlanningArea, Scenario, ScenarioResultStatus
from stands.models import StandSizeChoices, area_from_size
from utils.geometry import to_multi


def zip_directory(file_obj, source_dir):
Expand Down Expand Up @@ -135,6 +136,8 @@ def export_to_shapefile(scenario: Scenario) -> Path:
schema=schema,
) as c:
for feature in geojson.get("features", []):
geometry = to_multi(feature.get("geometry"))
feature = {**feature, "geometry": geometry}
c.write(feature)

return shapefile_folder
10 changes: 10 additions & 0 deletions src/planscape/utils/geometry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def to_multi(geometry):
if geometry["type"].startswith("Multi"):
return geometry

new_coordinates = [geometry.get("coordinates")]
new_type = f'Multi{geometry["type"]}'
return {
"type": new_type,
"coordinates": new_coordinates,
}

0 comments on commit 4142813

Please sign in to comment.