Add estimated areas for non-visual users

Since the key relies on visual association between the shapes on the
maps and the styling of the key, it won’t work for non-visual users.
An alternative way of giving them the same information is by providing
the size of the area numerically.
This commit is contained in:
Chris Hill-Scott
2020-09-08 16:56:39 +01:00
parent 0369472a76
commit f553158846
5 changed files with 55 additions and 11 deletions
+9
View File
@@ -14,6 +14,9 @@ class Polygons():
approx_metres_to_degree = 111_320
approx_square_metres_to_square_degree = approx_metres_to_degree ** 2
square_degrees_to_square_miles = (
approx_square_metres_to_square_degree / (1000 * 1000) * 0.386102
)
# Estimated amount of bleed into neigbouring areas based on typical
# range/separation of cell towers.
@@ -161,6 +164,12 @@ class Polygons():
def point_count(self):
return len(list(itertools.chain(*self.as_coordinate_pairs_long_lat)))
@property
def estimated_area(self):
return sum(
polygon.area for polygon in self
) * self.square_degrees_to_square_miles
def flatten_polygons(polygons):
if isinstance(polygons, GeometryCollection):