mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Pass polygons through if they’re small already
If a polygon is smaller than the largest polygon in our dataset of simplified polygons then we’re only throwing away useful detail by simplifying it. We should still simplify larger polygons as a fallback, to avoid sending anything to the CBC that we’re not sure it will like. The thresholds here are low: we can raise them as we test and experiment more. Here’s some data about the Flood Warning Service polygons Percentile | 80% | 90% | 95% | 98% | 99% | 99.9% -----------|-----|-------|--------|---------|---------|--------- Point count| 226 | 401.9 | 640.45 | 1015.38 | 1389.07 | 3008.609 Percentile | 80% | 90% | 95% | 98% | 99% | 99.9% --------------|-----|-------|--------|---------|---------|--------- Polygon count |2----|3------|5-------|8--------|10-------|40.469
This commit is contained in:
@@ -29,5 +29,5 @@ def cap_xml_polygon_to_list(polygon_string):
|
||||
[
|
||||
float(coordinate) for coordinate in pair.split(',')
|
||||
]
|
||||
for pair in polygon_string.split(' ')
|
||||
for pair in polygon_string.strip().split(' ')
|
||||
]
|
||||
|
||||
@@ -50,6 +50,11 @@ def create_broadcast():
|
||||
] for area in broadcast_json['areas']
|
||||
))))
|
||||
|
||||
if len(polygons) > 12 or polygons.point_count > 250:
|
||||
simple_polygons = polygons.smooth.simplify
|
||||
else:
|
||||
simple_polygons = polygons
|
||||
|
||||
broadcast_message = BroadcastMessage(
|
||||
service_id=authenticated_service.id,
|
||||
content=broadcast_json['content'],
|
||||
@@ -59,7 +64,7 @@ def create_broadcast():
|
||||
'names': [
|
||||
area['name'] for area in broadcast_json['areas']
|
||||
],
|
||||
'simple_polygons': polygons.smooth.simplify.as_coordinate_pairs_lat_long,
|
||||
'simple_polygons': simple_polygons.as_coordinate_pairs_lat_long,
|
||||
},
|
||||
status=BroadcastStatusType.PENDING_APPROVAL,
|
||||
api_key_id=api_user.id,
|
||||
|
||||
Reference in New Issue
Block a user