def geocode_address(permit_location): if permit_location in ADDRESS_CACHE: return ADDRESS_CACHE[permit_location] if type(permit_location) is not str: return address = permit_location.upper().strip() for scrubber in SCRUBBERS: address = address.replace(scrubber, ' ') address = '{}, Austin, TX'.format(address) geocoded_address = geocoder.mapzen(address, key=secrets.MAPZEN_API_KEY) ADDRESS_CACHE[permit_location] = geocoded_address time.sleep(SLEEP_TIME) return geocoded_address
def test_mapzen(): with pytest.raises(DeprecationWarning) as e: g = geocoder.mapzen(location)
def test_multi_results(): with pytest.raises(DeprecationWarning) as e: g = geocoder.mapzen(location, maxRows=3)
def test_mapzen_reverse(): with pytest.raises(DeprecationWarning) as e: g = geocoder.mapzen("45.4049053 -75.7077965", method='reverse')
def test_mapzen(): g = geocoder.mapzen(location) assert g.ok
def test_mapzen(): g = geocoder.mapzen(location) assert g.ok osm_count, fields_count = g.debug()[0] assert osm_count >= 3 assert fields_count >= 12
def test_mapzen_reverse(): g = geocoder.mapzen("45.4049053 -75.7077965", method='reverse') assert g.ok
def geocode_mapzen(address1, maps_api_key): '''mapzen expects max 6 requests per second''' time.sleep(.17) return (geocoder.mapzen(address1, key=maps_api_key))
query = session.query(Geocode).filter_by(location=location, **kwargs).order_by(Geocode.id.desc()).first() # Return result to user in JSON format if query: return json.loads(query[output]) return {} if __name__ == "__main__": import geocoder """ How to Use ========== """ # User Variables location = "London" # Geocode Address g = geocoder.mapzen(location, result=1) # Create Cache Databse cache = Cache("sqlite:///:memory:") # Insert into Database values = {"location": location} cache.insert(g) # Find results with a Query print(cache.find(location))
def test_mapzen(): g = geocoder.mapzen(location) assert g.ok osm_count, fields_count = g.debug()[0] assert osm_count == 3 assert fields_count == 12
def test_multi_results(): g = geocoder.mapzen(location, maxRows=3) assert len(g) == 3
def geocode1(address): print("mapzen") g = geocoder.mapzen(address) latlng = g.latlng return latlng
# Return result to user in JSON format if query: return json.loads(query[output]) return {} if __name__ == '__main__': import geocoder """ How to Use ========== """ # User Variables location = 'London' # Geocode Address g = geocoder.mapzen(location,result=1) # Create Cache Databse cache = Cache('sqlite:///:memory:') # Insert into Database values = { 'location': location, } cache.insert(g) # Find results with a Query print(cache.find(location))
def geocode1(address): g = geocoder.mapzen(address) latlng = g.latlng return latlng