mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 08:28:15 -04:00
Store CRS to avoid costly lookup
Looking up the coordinate reference system for a given polygon’s bounds is surprisingly expensive. We can make things run faster by precomputing it at the time of generating the simplified polygons, then storing it in the SQLite database alongside the polygon data.
This commit is contained in:
@@ -95,20 +95,27 @@ class BroadcastArea(BaseBroadcastArea, SortableMixin):
|
||||
@classmethod
|
||||
def from_row_with_simple_polygons(cls, row):
|
||||
instance = cls(row[:4])
|
||||
instance.simple_polygons = Polygons(row[4])
|
||||
instance.simple_polygons = Polygons(
|
||||
row[4],
|
||||
utm_crs=row[5],
|
||||
)
|
||||
return instance
|
||||
|
||||
@cached_property
|
||||
def polygons(self):
|
||||
polygons, utm_crs = BroadcastAreasRepository().get_polygons_for_area(self.id)
|
||||
return Polygons(
|
||||
BroadcastAreasRepository().get_polygons_for_area(self.id)
|
||||
polygons, utm_crs=utm_crs
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def simple_polygons(self):
|
||||
return Polygons(
|
||||
simple_polygons, utm_crs = (
|
||||
BroadcastAreasRepository().get_simple_polygons_for_area(self.id)
|
||||
)
|
||||
return Polygons(
|
||||
simple_polygons, utm_crs=utm_crs
|
||||
).utm_polygons
|
||||
|
||||
@cached_property
|
||||
def sub_areas(self):
|
||||
|
||||
Reference in New Issue
Block a user