
from gvsig import *
import geopy

def main(*args):
    #Info
    #http://geopy.readthedocs.org/en/latest/#module-geopy.geocoders

    print "\n\n Test 01: Geocode"
    from geopy.geocoders import GoogleV3
    geolocator = GoogleV3()
    location = geolocator.geocode("175 5th Avenue NYC")
    print(location.address)
    print((location.latitude, location.longitude))
    print(location.raw)

    print "\n\n Test 02: Reverse geocode"
    from geopy.geocoders import GoogleV3
    geolocator = GoogleV3()
    location = geolocator.reverse("52.509669, 13.376294")
    print location
    print(location[0].address)
    print((location[0].latitude, location[0].longitude))
    print(location[0].raw)

    print "\n\n Test 03: Mesouring distance"
    from geopy.distance import vincenty
    newport_ri = (41.49008, -71.312796)
    cleveland_oh = (41.499498, -81.695391)
    print(vincenty(newport_ri, cleveland_oh).miles)

    from geopy.distance import great_circle
    newport_ri = (41.49008, -71.312796)
    cleveland_oh = (41.499498, -81.695391)
    print(great_circle(newport_ri, cleveland_oh).miles)
 
    pass
