Refactor coordinate processing into Polygons class

We have a bunch of stuff for doing lat/long transformation in the
`BroadcastMessage` class. This is not a good separation of concerns, now
that we have a separate class for dealing with polygons and coordinates.
This commit is contained in:
Chris Hill-Scott
2020-08-25 16:55:09 +01:00
parent c49a6338af
commit 3d9d663b27
7 changed files with 52 additions and 83 deletions

View File

@@ -1,3 +1,4 @@
import itertools
from datetime import datetime, timedelta
from notifications_utils.template import BroadcastPreviewTemplate
@@ -74,17 +75,17 @@ class BroadcastMessage(JSONModel):
@cached_property
def polygons(self):
return Polygons(
broadcast_area_libraries.get_polygons_for_areas_lat_long(
*self._dict['areas']
)
list(itertools.chain(*(
area.polygons for area in self.areas
)))
)
@cached_property
def simple_polygons(self):
polygons = Polygons(
broadcast_area_libraries.get_simple_polygons_for_areas_lat_long(
*self._dict['areas']
)
list(itertools.chain(*(
area.simple_polygons for area in self.areas
)))
)
# If weve added multiple areas then we need to re-simplify the
# combined shapes to keep the point count down