2009/12/15 Lorenzo Macchiavelli <lmacchiave...@gmail.com> > Ciao > Siccome ho avuto la stessa problematica tempo fa > c'è questo che troverai di sicura utilità!!! > > http://darcas.net/index.php/2008/10/12/calcolo-della-distanza-tra-due-punti-geografici/ >
Se poi vuoi sapere le coordinate partendo da un indirizzo usa lo script python che allego in fondo. Ciao. Marco. -- http://ThinkCode.TV - Screencast e videocorsi di programmazione http://stacktrace.it - Aperiodico di resistenza informatica http://beri.it - Blog di una testina di vitello ############################### # gmaps.py ############################### import urllib try: from django.utils.http import urlencode except ImportError: from textutils import unicode_urlencode as urlencode from time import sleep key = "<qui ci metti la tua chiave per le API di Google>" def location2latlong( query, key=key ): """Get the ( latitute, longitude ) coordinates corresponding to the query. If something goes wrong return None.""" output = 'csv' params = { } params[ 'key' ] = key params[ 'output' ] = output params[ 'q' ] = query params = urlencode( params ) try: f = urllib.urlopen("http://maps.google.com/maps/geo?%s" % params ) except IOError: # maybe some local problem at google? let's try again sleep( 3 ) try: f = urllib.urlopen("http://maps.google.com/maps/geo?%s" % params ) except IOError: # okay we give up return None response = f.read( ).split(',') f.close( ) try: status = response[0] accuracy = response[1] latitude = response[2] longitude = response[3] except: return None if status != '200': return None else: return latitude, longitude if __name__ == '__main__': import sys try: q = sys.argv[1] except: print 'Usage: python gmaps.py query' sys.exit( 1 ) r = location2latlong( q ) if r is not None: print r else: print 'Something went wrong.'
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python