From 4feb3fdc108275105e62f477ec404e0dcb7a7e4f Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 18 Aug 2021 17:22:35 +0100 Subject: [PATCH] Bump utils This new version of utils implements the transformation of our polygons to a Cartesian plane. In other words, it converts them from being defined in spherical degrees to metres. For the API this means our simplification will be slightly more accurate. --- app/v2/broadcast/post_broadcast.py | 7 +++++-- requirements.in | 2 +- requirements.txt | 8 ++++++-- tests/app/v2/broadcast/test_post_broadcast.py | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/v2/broadcast/post_broadcast.py b/app/v2/broadcast/post_broadcast.py index c52f68e65..38864c386 100644 --- a/app/v2/broadcast/post_broadcast.py +++ b/app/v2/broadcast/post_broadcast.py @@ -44,7 +44,10 @@ def create_broadcast(): _validate_template(broadcast_json) polygons = Polygons(list(chain.from_iterable(( - area['polygons'] for area in broadcast_json['areas'] + [ + [[y, x] for x, y in polygon] + for polygon in area['polygons'] + ] for area in broadcast_json['areas'] )))) broadcast_message = BroadcastMessage( @@ -56,7 +59,7 @@ def create_broadcast(): 'names': [ area['name'] for area in broadcast_json['areas'] ], - 'simple_polygons': polygons.smooth.simplify.as_coordinate_pairs_long_lat, + 'simple_polygons': polygons.smooth.simplify.as_coordinate_pairs_lat_long, }, status=BroadcastStatusType.PENDING_APPROVAL, api_key_id=api_user.id, diff --git a/requirements.in b/requirements.in index 88c942024..da80a8584 100644 --- a/requirements.in +++ b/requirements.in @@ -36,7 +36,7 @@ notifications-python-client==6.0.2 # PaaS awscli-cwlogs==1.4.6 -git+https://github.com/alphagov/notifications-utils.git@48.1.0#egg=notifications-utils==48.1.0 +git+https://github.com/alphagov/notifications-utils.git@49.0.0#egg=notifications-utils==49.0.0 # gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains prometheus-client==0.10.1 diff --git a/requirements.txt b/requirements.txt index 9a7c79e83..45d576669 100644 --- a/requirements.txt +++ b/requirements.txt @@ -40,7 +40,9 @@ cachetools==4.2.1 celery[sqs]==5.2.0 # via -r requirements.in certifi==2021.10.8 - # via requests + # via + # pyproj + # requests cffi==1.14.5 # via # -r requirements.in @@ -151,7 +153,7 @@ mistune==0.8.4 # via notifications-utils notifications-python-client==6.0.2 # via -r requirements.in -notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@48.1.0 +notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@49.0.0 # via -r requirements.in orderedset==2.0.3 # via notifications-utils @@ -179,6 +181,8 @@ pyparsing==3.0.1 # via packaging pypdf2==1.26.0 # via notifications-utils +pyproj==3.2.1 + # via notifications-utils pyrsistent==0.18.0 # via jsonschema python-dateutil==2.8.2 diff --git a/tests/app/v2/broadcast/test_post_broadcast.py b/tests/app/v2/broadcast/test_post_broadcast.py index 7b43897c2..c65619923 100644 --- a/tests/app/v2/broadcast/test_post_broadcast.py +++ b/tests/app/v2/broadcast/test_post_broadcast.py @@ -105,7 +105,7 @@ def test_valid_post_cap_xml_broadcast_returns_201( assert response_json['service_id'] == str(sample_broadcast_service.id) assert len(response_json['areas']['simple_polygons']) == 1 - assert len(response_json['areas']['simple_polygons'][0]) == 22 + assert len(response_json['areas']['simple_polygons'][0]) == 27 assert response_json['areas']['simple_polygons'][0][0] == [53.10562, 0.244127] assert response_json['areas']['simple_polygons'][0][-1] == [53.10562, 0.244127] assert response_json['areas']['names'] == ['River Steeping in Wainfleet All Saints']