let non-negative longitudes slide and normalize district numbers
git-svn-id: https://polipoly.googlecode.com/svn/trunk@15 1885ebd5-0a40-0410-88a4-770918bee656
This commit is contained in:
parent
d7a1f2a537
commit
96527c801d
13
polipoly.py
13
polipoly.py
@ -287,9 +287,16 @@ class AddressToDistrictService(object):
|
|||||||
|
|
||||||
def lat_long_to_district(self, lat, lng):
|
def lat_long_to_district(self, lat, lng):
|
||||||
""" Obtain the district containing a given latitude and longitude."""
|
""" Obtain the district containing a given latitude and longitude."""
|
||||||
flat, flng = float(lat), float(lng)
|
flat, flng = float(lat), -abs(float(lng))
|
||||||
return lat, lng, [(cb.state, cb.district) for cb in self.boundaries
|
districts = []
|
||||||
if cb.contains((flng,flat))]
|
for cb in self.boundaries:
|
||||||
|
if cb.contains((flng,flat)):
|
||||||
|
if cb.district == '98':
|
||||||
|
cb.district = '00'
|
||||||
|
elif cb.district[0] == '0':
|
||||||
|
cb.district = cb.district[1]
|
||||||
|
districts.append((cb.state, cb.district))
|
||||||
|
return lat, lng, districts
|
||||||
|
|
||||||
def address_to_district(self, address):
|
def address_to_district(self, address):
|
||||||
"""Given an address returns the congressional district it lies within.
|
"""Given an address returns the congressional district it lies within.
|
||||||
|
Loading…
Reference in New Issue
Block a user