Skip to content

Commit

Permalink
Default government unit intersection distance to headquarters to 5km
Browse files Browse the repository at this point in the history
see #494
  • Loading branch information
meilinger committed Oct 12, 2018
1 parent 8a05db3 commit bcb89b0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions firecares/firestation/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import math
import ogr
import os
import osr
Expand Down Expand Up @@ -229,7 +230,9 @@ def _associated_government_unit_ids(self, model_type):
def get_context_data(self, **kwargs):
context = super(DepartmentUpdateGovernmentUnits, self).get_context_data(**kwargs)

geom = self.object.headquarters_geom.buffer(0.01)
og = self.object.headquarters_geom.clone()
# 5km-ish
geom = og.buffer(5000 / 40000000. * 360. / math.cos(og.y / 360. * math.pi))

context['user_can_change'] = self.object.is_curator(self.request.user)
context['user_can_admin'] = self.object.is_admin(self.request.user)
Expand Down Expand Up @@ -438,7 +441,7 @@ def limit_queryset(self, limit):
if limit:
self.paginate_by = limit

except:
except Exception:
return

def get_queryset(self):
Expand Down Expand Up @@ -533,7 +536,7 @@ def handle_search(self, queryset):
from django.db.models import Q
queryset = queryset.filter(Q(**{field + '__lte': Max}) | Q(**{field + '__isnull': True}))

except:
except Exception:
pass
return queryset

Expand Down Expand Up @@ -622,7 +625,7 @@ def form_valid(self, form):
self.station = station
return super(AddStationView, self).form_valid(form)

except:
except Exception:
print 'Geocoding Problem'
return "Geocode Error"

Expand Down

0 comments on commit bcb89b0

Please sign in to comment.