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')
示例#5
0
def test_mapzen():
    g = geocoder.mapzen(location)
    assert g.ok
示例#6
0
def test_mapzen():
    g = geocoder.mapzen(location)
    assert g.ok
示例#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
示例#8
0
def test_mapzen_reverse():
    g = geocoder.mapzen("45.4049053 -75.7077965", method='reverse')
    assert g.ok
示例#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))
示例#10
0
文件: cache.py 项目: porn/geocoder
        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))
示例#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
示例#12
0
def test_multi_results():
    g = geocoder.mapzen(location, maxRows=3)
    assert len(g) == 3
示例#13
0
def test_mapzen_reverse():
    g = geocoder.mapzen("45.4049053 -75.7077965", method='reverse')
    assert g.ok
示例#14
0
def geocode1(address):
  print("mapzen")
  g = geocoder.mapzen(address)
  latlng = g.latlng
  return latlng
示例#15
0
def test_multi_results():
    g = geocoder.mapzen(location, maxRows=3)
    assert len(g) == 3
示例#16
0
文件: cache.py 项目: porn/geocoder
        # 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))
示例#17
0
def geocode1(address):
  g = geocoder.mapzen(address)
  latlng = g.latlng
  return latlng