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
Esempio n. 2
0
def test_mapzen():
    with pytest.raises(DeprecationWarning) as e:
        g = geocoder.mapzen(location)
Esempio n. 3
0
def test_multi_results():
    with pytest.raises(DeprecationWarning) as e:
        g = geocoder.mapzen(location, maxRows=3)
Esempio n. 4
0
def test_mapzen_reverse():
    with pytest.raises(DeprecationWarning) as e:
        g = geocoder.mapzen("45.4049053 -75.7077965", method='reverse')
Esempio n. 5
0
def test_mapzen():
    g = geocoder.mapzen(location)
    assert g.ok
Esempio n. 6
0
def test_mapzen():
    g = geocoder.mapzen(location)
    assert g.ok
Esempio n. 7
0
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
Esempio n. 8
0
def test_mapzen_reverse():
    g = geocoder.mapzen("45.4049053 -75.7077965", method='reverse')
    assert g.ok
Esempio n. 9
0
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))
Esempio n. 10
0
        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))
Esempio n. 11
0
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
Esempio n. 12
0
def test_multi_results():
    g = geocoder.mapzen(location, maxRows=3)
    assert len(g) == 3
Esempio n. 13
0
def test_mapzen_reverse():
    g = geocoder.mapzen("45.4049053 -75.7077965", method='reverse')
    assert g.ok
Esempio n. 14
0
def geocode1(address):
  print("mapzen")
  g = geocoder.mapzen(address)
  latlng = g.latlng
  return latlng
Esempio n. 15
0
def test_multi_results():
    g = geocoder.mapzen(location, maxRows=3)
    assert len(g) == 3
Esempio n. 16
0
        # 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))
Esempio n. 17
0
def geocode1(address):
  g = geocoder.mapzen(address)
  latlng = g.latlng
  return latlng