Skip to content

Commit

Permalink
Added an option to override the max. protected radius for a protected
Browse files Browse the repository at this point in the history
entity when creating the bounding box.
  • Loading branch information
kate-harrison committed Jan 28, 2015
1 parent ef5e8b5 commit 1104d63
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions west/protected_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,25 @@ def add_to_kml(self, kml):
"""
return

def _create_bounding_box(self):
def _create_bounding_box(self, override_max_protected_radius_km=None):
"""
Generate a bounding box for the ProtectedEntity. The width and height
are set by
:meth:`protected_entities.ProtectedEntities.get_max_protected_radius_km`.
Generate a bounding box for the ProtectedEntity. The width is set by
:meth:`protected_entities.ProtectedEntities.get_max_protected_radius_km`
but can be overridden with ``override_max_protected_radius_km``.
"""
bb = {'min_lat': float('inf'),
'max_lat': -float('inf'),
'min_lon': float('inf'),
'max_lon': -float('inf')
}

width_km = override_max_protected_radius_km or \
self.container.get_max_protected_radius_km()

location = Point(self._latitude, self._longitude)
for bearing in [0, 90, 180, 270, 360]:
destination = VincentyDistance(kilometers=self.container.get_max_protected_radius_km()).destination(location, bearing)
destination = VincentyDistance(kilometers=width_km).destination(
location, bearing)
lat, lon = destination.latitude, destination.longitude
if lat < bb['min_lat']:
bb['min_lat'] = lat
Expand Down

0 comments on commit 1104d63

Please sign in to comment.