Giter Site home page Giter Site logo

slawek87 / geolocation-python Goto Github PK

View Code? Open in Web Editor NEW
97.0 97.0 44.0 385 KB

Geolocation is a straightforward Google Maps API designed for Python users. With this app, you can easily access location-based information such as country, city, street, reverse geocode, street number, latitude, longitude, and travel distance and time for a range of origins and destinations.

Home Page: http://slawek87.github.io/geolocation-python/

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
distance distance-matrix-api geocode-api geocoder geolocation python travel-distances

geolocation-python's People

Contributors

alexandre avatar benediktziegler avatar brendanebers avatar gitter-badger avatar niknow avatar slawek87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geolocation-python's Issues

Reverse Geocoding

Reverse geocoding not yet implemented. Would be very thankful if it were. Thank you

Does't work for Google GEO replies only with sublocality (without city)

Hello!

There are a lot of geo params for Airport query, but a lot of geolocation-python decoding results are without locations. It happens because validation func does not pass locations without city.

For example:
https://maps.googleapis.com/maps/api/geocode/json?address=United%20States%20New%20York%20John%20F%20Kennedy%20International%20Airport

Google return «sublocality» for JFK and does not have any data about «city».
Sometimes it happens. I do recommend make validation by more than one param. I did it because for me it working correct.

I thank you for your service ) Eugene

Reverse Geocoding

@alexandre we get mail:

'First I wanted to apologize for the unsolicited email. I'm working on a project in python which requires Geocoding and Reverse Geocoding. I stumbled upon your application and think it would work rather well, however I can't seem to locate a reverse geocoding feature and was wondering if you could help me. Have I either missed it or has that feature simply not been implemented yet?
Thank you for your time and once again sorry to bother you.
David'

I'll implement this option on friday nigth. I'm going to add this to master branch. What do you think about it?

problem with tar on pypi

Hi,

I just installed your package from pypi (I had to download the tar rather than using pip due to using a proxy, and install it manually by running python setup.py install)... it seemed to install fine but fails when running the example codes as it fails to find the distance_matrix module...

... That's when I realised that the pypi tar does not actually contains the distance_matrix module nor the geocode folder, only the top level files are there.

Is this me or there is an problem here when the tar was build?

No longer working

The application at my work stopped working a couple of months ago.

I tested the API key using the URL request given by Google and it still works:

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=API-KEY-HERE

However, the following code in 2.7.9 returns a "Python Request Denied" error using the same address and API:

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

address = "1600 Amphitheatre Parkway, Mountain View, CA"

google_maps = GoogleMaps(api_key="API-KEY-HERE")

location = google_maps.search(location=address)

print location.all()

my_location = location.first()

print my_location.postal_code

Create new branch geolocation-0.2.0

First of all we have to create new branch. Name of this branch should be geolocation-0.2.0

Every time when we will do something new or fix bugs we should create separate branches. i.e. geolocation-0.2.0-issue-4 (number of the issue/task).

Refactoring - google_maps.py

  • Remove variable _location and method set_location() from GoogleMaps- we don't need it on this class.
  • Create method search() - it should have code from method query().
  • On method query() call search() + give information something like This method is deprecated. You should call search() method.. For this message use logging.info or logging.warning .
  • Update README file. Now we will use google_maps.search(location=address). In my opinion it's more userfriendly :)

Problem with Google maps geolocation API key

As i have seen in the example codes, i made a function to take the exactly latitude and longitude, taking the adress as a parameter.

def geo_codificacion(direccion):

address=direccion
google_maps = GoogleMaps(api_key='My_API_key' )
location = google_maps.search(location=address)
my_location = location.first()

latitud=my_location.lat
longitud=my_location.lng
res=[latitud,longitud]

return res

But it isnt using the api key, so i tried to put the api key directly on the example code with same result.

Refactoring - api.py

  • Rename _get_json_data() to _query().
  • Create class BaseApi.
  • On class BaseApi create variables: STATUS_OK = 'OK', _json_api_address = None.
  • On class BaseApi create methods: _prepare_request(), _get_status_code() and _query().. with return raise 'Method not implemented' . When we create child class and we don't implement this methods we have to get info about it.
  • Create @proeprty json_api_address. It should returns raise with information json_api_address is empy. or something like this when _json_api_address is None. Maybe we should rename this variable to api_address??
  • Class GeocodeApi should be child of class BaseApi.
  • On GeocodeApi call property json_api_address - not variable _json_api_adress.

Keep a unique branch to python2 and python3

I thinking about it now...with the "pattern" that we will create a branch for issues, I think we could use a unique branch for python3 and python2 and to have another branches just to solve issues. What do you think?

[ ]'s

Bug in parsing distances when distances are small

Hi,

I've noticed that the following minimum example

from geolocation.google_maps import GoogleMaps
origins = ['51.515934,-0.168877']
destinations = ['51.523572,-0.126562']
google_maps = GoogleMaps(api_key='your_google_maps_key')
items = google_maps.distance(origins, destinations).all()

results in a crash:

geolocation\distance_matrix\models.py", line 57, in distance
unit = re.match(pattern, value).group('unit')
AttributeError: 'NoneType' object has no attribute 'group'

However, changing origin and destination to:

origins = ['oslo']
destinations = ['zagrzeb']

the problem does not occur. In the first case, the distance between origin and destination is reported by the Google API as '3.9 km', where in the second case it is reported as '2,069 km'.

Trying to figure out what goes wrong, one should notice that

import re
value = u'2,069 km' 
pattern = r'(?P<value>[\d,]+)\s(?P<unit>km|m)$'
unit = re.match(pattern, value).group('unit')
value = re.match(pattern, value).group('value').replace(',', '').replace('.', ',')
kilometers = float(value)

yields a correct float in kilometer, however the .replace('.', ',') does nothing. The same script with value = u'3.9 km' crashes, because the pattern does not parse the . correctly. Therefore, I'm proposing to change pattern and value to:

pattern = r'(?P<value>[\d,.]+)\s(?P<unit>km|m)$'
value = re.match(pattern, value).group('value').replace(',', '')

Compatibility of examples with Python 3

Hi,

I've noticed that the README.md states that the project is compatible with Python 2 and Python 3. However, the scripts in the examples are not compatible with Python 3. As far as I can see, this is mainly due to the print statements and should be easy to fix.

Unless of course there is a reason you sticked to the Python 2 syntax? In case not, would you be happy if I fix that and make another pull request?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.