mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-26 17:58:29 -04:00
Make calculating overlapping areas faster
By using the simplified polygons instead of the full resolutions ones we: - query less data from SQLite - pass less data around - give Shapely a less complicated shape to do its calculations on This makes it faster to calculate how much of each electoral ward a custom area overlaps. For the two areas in our tests: Place represented by custom area | Before | After ---------------------------------|--------|-------- Bristol | 0.07s | 0.02s Skye | 0.02s | 0.01s
This commit is contained in:
@@ -171,7 +171,7 @@ class CustomBroadcastArea(BaseBroadcastArea):
|
||||
@cached_property
|
||||
def count_of_phones(self):
|
||||
return sum(
|
||||
area.polygons.ratio_of_intersection_with(self.polygons) * area.count_of_phones
|
||||
area.simple_polygons.ratio_of_intersection_with(self.polygons) * area.count_of_phones
|
||||
for area in self.overlapping_areas
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user