mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 10:38:25 -04:00
Handle areas which don’t have population data
If an area has a `count_of_phones` value of `0` it means we don’t have data about the population. This means we can’t do the maths to work out the estimated bleed. So we should return the default amount of bleed of 1,500m instead, which is something in between what we’d expect for a built up area and a rural area.
This commit is contained in:
@@ -74,12 +74,14 @@ class BroadcastArea(SortableMixin):
|
||||
# https://www.pivotaltracker.com/story/show/174837293
|
||||
return self._count_of_phones or 0
|
||||
|
||||
@property
|
||||
@cached_property
|
||||
def phone_density(self):
|
||||
return self.count_of_phones / self.polygons.estimated_area
|
||||
|
||||
@property
|
||||
def estimated_bleed_in_m(self):
|
||||
if self.phone_density < 1:
|
||||
return Polygons.approx_bleed_in_degrees * Polygons.approx_metres_to_degree
|
||||
estimated_bleed = 5_900 - (math.log(self.phone_density, 10) * 1_250)
|
||||
return max(500, min(estimated_bleed, 5000))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user