Skip to content

Commit 610f493

Browse files
committed
fix(spp_mis_demo_v2): use ORM Shapely geometry for coordinate generation
The _generate_coordinates method tried to read area.geo_polygon.data and pass it through wkbloads(), but the spp_gis ORM field already returns a Shapely geometry object which has no .data attribute. This caused a silent AttributeError for every area, resulting in zero coordinates generated for any registrant. Use the Shapely geometry directly instead of trying to re-parse it.
1 parent 310f648 commit 610f493

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

spp_mis_demo_v2/models/mis_demo_generator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3811,7 +3811,6 @@ def _generate_coordinates(self, stats):
38113811

38123812
try:
38133813
from shapely.geometry import shape
3814-
from shapely.wkb import loads as wkbloads
38153814
except ImportError:
38163815
_logger.warning("[spp.mis.demo] shapely not available, skipping coordinate generation")
38173816
stats["coordinates_generated"] = 0
@@ -3854,8 +3853,8 @@ def _generate_coordinates(self, stats):
38543853
continue
38553854

38563855
try:
3857-
# Convert WKB to shapely polygon
3858-
polygon = wkbloads(bytes(area.geo_polygon.data))
3856+
# The ORM returns geo_polygon as a Shapely geometry object
3857+
polygon = area.geo_polygon
38593858

38603859
# Generate random points for all registrants in this area
38613860
minx, miny, maxx, maxy = polygon.bounds

0 commit comments

Comments
 (0)