This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

What is Geolocation 0.2.2?

Geolocation is a simple and clever application which uses google maps api.

  1. Geocode Module allows you to easily and quickly get information about given location.
Geocode Module returns such information as:
  • country,
  • country short form,
  • city,
  • route/street,
  • street number,
  • postal code,
  • formatted address,
  • administrative areas,
  • lat,
  • lng.
  1. Distance Module allows you to get information about travel distance and time for a matrix of origins and destinations.
Distance Module returns such information as:
  • origin address,
  • destination address,
  • duration,
  • distance: kilometers, meters, miles.

Python2 or Python3?

Both!. Currently it supports python 2.7, 3.3 and 3.4.

What do You need?

To use this application you need to have Google API key.
Google Maps Documentation
  1. Open APIs console.
  1. Turn On Geocode API.
  1. Turn On Distance Matrix API.
  1. Get your API Key.

How to install it?

pip install geolocation-python

How to use Geocode Module?

# -- coding: utf-8 --

from geolocation.main import GoogleMaps from geolocation.distance_matrix.client import DistanceMatrixApiClient

address = “New York City Wall Street 12”

google_maps = GoogleMaps(api_key=’your_google_maps_key’)

location = google_maps.search(location=address) # sends search to Google Maps.

print(location.all()) # returns all locations.

my_location = location.first() # returns only first location.

print(my_location.city) print(my_location.route) print(my_location.street_number) print(my_location.postal_code)

for administrative_area in my_location.administrative_area:
print(“{}: {} ({})”.format(administrative_area.area_type,
administrative_area.name, administrative_area.short_name))

print(my_location.country) print(my_location.country_shortcut)

print(my_location.formatted_address)

print(my_location.lat) print(my_location.lng)

# reverse geocode

lat = 40.7060008 lng = -74.0088189

my_location = google_maps.search(lat=lat, lng=lng).first()

How to use Distance Module?

Mode parameter — specifies the mode of transport to use when calculating directions.

Valid values are: * driving (default) indicates standard driving directions using the road network. * walking requests walking directions via pedestrian paths & sidewalks (where available). * bicycling requests bicycling directions via bicycle paths & preferred streets (currently only available in the US and some Canadian cities). * transit requests distance calculation via public transit routes (where available).

Avoid parameter - Directions may be calculated that adhere to certain restrictions. Restrictions are indicated by use of the avoid parameter, and an argument to that parameter indicating the restriction to avoid.

The following restrictions are supported:
  • avoid=tolls

  • avoid=highways

  • avoid=ferries

    # -- coding: utf-8 --

    from geolocation.main import GoogleMaps from geolocation.distance_matrix.client import DistanceMatrixApiClient

    origins = [‘rybnik’, ‘oslo’] destinations = [‘zagrzeb’]

    google_maps = GoogleMaps(api_key=’your_google_maps_key’)

    items = google_maps.distance(origins, destinations).all() # default mode parameter is DistanceMatrixApiClient.MODE_DRIVING.

    for item in items:

    print(‘origin: %s’ % item.origin)

    print(‘destination: %s’ % item.destination)

    print(‘km: %s’ % item.distance.kilometers)

    print(‘m: %s’ % item.distance.meters)

    print(‘miles: %s’ % item.distance.miles)

    print(‘duration: %s’ % item.duration) # returns string.

    print(‘duration datetime: %s’ % item.duration.datetime) # returns datetime.

    # you can also get items from duration, returns int() values. print(‘duration days: %s’ % item.duration.days)

    print(‘duration hours: %s’ % item.duration.hours)

    print(‘duration minutes: %s’ % item.duration.minutes)

    print(‘duration seconds: %s’ % item.duration.seconds)

Mode Bicycling:

items = google_maps.distance(origins, destinations, DistanceMatrixApiClient.MODE_BICYCLING).all()

for item in items:

print(‘origin: %s’ % item.origin)

print(‘destination: %s’ % item.destination)

print(‘km: %s’ % item.distance.kilometers)

print(‘m: %s’ % item.distance.meters)

print(‘miles: %s’ % item.distance.miles)

print(‘duration: %s’ % item.duration)

Mode Walking:

items = google_maps.distance(origins, destinations, DistanceMatrixApiClient.MODE_WALKING).all()

for item in items:

print(‘origin: %s’ % item.origin)

print(‘destination: %s’ % item.destination)

print(‘km: %s’ % item.distance.kilometers)

print(‘m: %s’ % item.distance.meters)

print(‘miles: %s’ % item.distance.miles)

print(‘duration: %s’ % item.duration)

Mode Transit:

items = google_maps.distance(origins, destinations, DistanceMatrixApiClient.MODE_TRANSIT).all()

for item in items:

print(‘origin: %s’ % item.origin)

print(‘destination: %s’ % item.destination)

print(‘km: %s’ % item.distance.kilometers)

print(‘m: %s’ % item.distance.meters)

print(‘miles: %s’ % item.distance.miles)

print(‘duration: %s’ % item.duration)

Mode Highway:

items = google_maps.distance(origins, destinations, avoid=DistanceMatrixApiClient.AVOID_HIGHWAYS).all()

for item in items:

print(‘origin: %s’ % item.origin)

print(‘destination: %s’ % item.destination)

print(‘km: %s’ % item.distance.kilometers)

print(‘m: %s’ % item.distance.meters)

print(‘miles: %s’ % item.distance.miles)

print(‘duration: %s’ % item.duration)

Avoid Ferries:

items = google_maps.distance(origins, destinations, avoid=DistanceMatrixApiClient.AVOID_FERRIES).all()

for item in items:

print(‘origin: %s’ % item.origin)

print(‘destination: %s’ % item.destination)

print(‘km: %s’ % item.distance.kilometers)

print(‘m: %s’ % item.distance.meters)

print(‘miles: %s’ % item.distance.miles)

print(‘duration: %s’ % item.duration)

Avoid Tolls:

items = google_maps.distance(origins, destinations, avoid=DistanceMatrixApiClient.AVOID_TOLLS).all()

for item in items:

print(‘origin: %s’ % item.origin)

print(‘destination: %s’ % item.destination)

print(‘km: %s’ % item.distance.kilometers)

print(‘m: %s’ % item.distance.meters)

print(‘miles: %s’ % item.distance.miles)

print(‘duration: %s’ % item.duration)

More examples you should find here .

Release History

Release History

0.2.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2c

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2b

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1a

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2d

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
geolocation-python-0.2.2.tar.gz (8.4 kB) Copy SHA256 Checksum SHA256 Source Dec 27, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting