diff --git a/app/broadcast_areas/polygons.py b/app/broadcast_areas/polygons.py
index 53cdf32fa..f6fcd328f 100644
--- a/app/broadcast_areas/polygons.py
+++ b/app/broadcast_areas/polygons.py
@@ -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):
diff --git a/app/templates/views/broadcast/macros/area-map.html b/app/templates/views/broadcast/macros/area-map.html
new file mode 100644
index 000000000..67d0cce94
--- /dev/null
+++ b/app/templates/views/broadcast/macros/area-map.html
@@ -0,0 +1,23 @@
+{% macro map(broadcast_message) %}
+
+
+ -
+
+ An area of {{ "{:,.1f}".format(broadcast_message.simple_polygons.estimated_area) }} square miles
+
+ Will get
+ the
+ alert
+
+ -
+
+ An extra area of {{ "{:,.1f}".format(broadcast_message.simple_polygons.bleed.estimated_area - broadcast_message.simple_polygons.estimated_area) }} square miles is
+
+ Likely to get
+
+ the
+
+ alert
+
+
+{% endmacro %}
diff --git a/app/templates/views/broadcast/preview-areas.html b/app/templates/views/broadcast/preview-areas.html
index 83a231876..9e1efad65 100644
--- a/app/templates/views/broadcast/preview-areas.html
+++ b/app/templates/views/broadcast/preview-areas.html
@@ -1,6 +1,7 @@
{% from "components/button/macro.njk" import govukButton %}
{% from "components/page-header.html" import page_header %}
{% from "components/page-footer.html" import page_footer %}
+{% from "views/broadcast/macros/area-map.html" import map %}
{% extends "withnav_template.html" %}
@@ -51,15 +52,7 @@
{% endfor %}
{% if broadcast_message.areas %}
-
-
-
- Will get alert
-
-
- Likely to get alert
-
-
+ {{ map(broadcast_message) }}
diff --git a/app/templates/views/broadcast/view-message.html b/app/templates/views/broadcast/view-message.html
index 29db61202..236090bc5 100644
--- a/app/templates/views/broadcast/view-message.html
+++ b/app/templates/views/broadcast/view-message.html
@@ -5,6 +5,7 @@
{% from "components/banner.html" import banner %}
{% from "components/page-header.html" import page_header %}
{% from "components/page-footer.html" import page_footer %}
+{% from "views/broadcast/macros/area-map.html" import map %}
{% extends "withnav_template.html" %}
@@ -139,7 +140,7 @@
{{ govukDetails({
"summaryText": "Show map",
- "html": ''
+ "html": map(broadcast_message)
}) }}
{{ broadcast_message.template|string }}
diff --git a/tests/app/main/views/test_broadcast.py b/tests/app/main/views/test_broadcast.py
index 37b8d7ce6..41bbde824 100644
--- a/tests/app/main/views/test_broadcast.py
+++ b/tests/app/main/views/test_broadcast.py
@@ -331,12 +331,30 @@ def test_preview_broadcast_areas_page(
mock_get_draft_broadcast_message,
):
service_one['permissions'] += ['broadcast']
- client_request.get(
+ page = client_request.get(
'.preview_broadcast_areas',
service_id=SERVICE_ONE_ID,
broadcast_message_id=fake_uuid,
)
+ assert [
+ normalize_spaces(item.text)
+ for item in page.select('ul.area-list li.area-list-item')
+ ] == [
+ 'England remove',
+ 'Scotland remove',
+ ]
+
+ assert len(page.select('#map')) == 1
+
+ assert [
+ normalize_spaces(item.text)
+ for item in page.select('ul li.area-key')
+ ] == [
+ 'An area of 176,714.9 square miles Will get the alert',
+ 'An extra area of 3,052.8 square miles is Likely to get the alert',
+ ]
+
def test_choose_broadcast_library_page(
client_request,