pokealarm / pokealarm

PokeAlarm is a highly configurable application designed to give you complete control over your PokémonGO notifications.
GNU Affero General Public License v3.0
308 stars 323 forks source link

[ENHANCEMENT] Google Maps walking distance calculation #74

Closed fgnn closed 8 years ago

fgnn commented 8 years ago

By using the google map api to get directions from your location to the pokemons location, you can get an accurate walking distance and time. While at work, I can see at a glance whether I can walk to the pokemon in time or not without having to open the link.

The code in the fork works and I've been using it for a few days. Unfortunately I am a subversion guy and don't understand git at all. Something went very wrong with the commit and pull request... Hopefully someone can do a proper update of the code. Its now a few commits behind master since I waited a day. https://github.com/fgnn/PokeAlarm/commit/dbe284d0dd22d374eb8ecc154e0f1a75255e7f68

features:

fgnn commented 8 years ago

<walk/dont walk>[]

screenshot_2016-08-09-21-44-53

jameson167 commented 8 years ago

Wow this is incredible, would love to see it integrated

kvangent commented 8 years ago

@fgnn If you could provide me the snippet of the code you used, I will look into this.

brettgus commented 8 years ago

Yeah this would be awesome! It looks like @fgnn cited his commits... maybe I'm blind but I don't see the changes there?

The DistanceMatrix Googlemaps API is what we should use. However, while in the docs they say an API key is a required paremeter, it seems that data is returned without one.

If an API key was needed though, it'd be a bit of a non-starter, as every poke alarm would result in an API call which would count against the quote.

It's as easy as querying here for a json and change the paremeters accordingly: https://maps.googleapis.com/maps/api/distancematrix/json?origins=43.041780,-87.909758&destinations=43.043215,-87.903911&mode=walking&units=imperial

There's actually a python package, googlemaps, that will query this. However, the constructor refuses to work without an API key being supplied.

import googlemaps
gmaps = googlemaps.Client(key="YOURKEYHERE")
dist = gmaps.distance_matrix((43.041780,-87.909758),(43.043215,-87.903911), 'walking')
print "%s" % dist.get("rows")[0].get("elements")[0].get("duration").get("text")
fgnn commented 8 years ago

That's exactly how I implemented it.

I looked at my fork again and it looks like I messed up even more than I thought and the code didn't get uploaded at all.

Tonight I will take another stab at attempting to get it uploaded.

fgnn commented 8 years ago

Finally figured out how to use git!

Pull request located here:

https://github.com/kvangent/PokeAlarm/pull/113

kvangent commented 8 years ago

This should now be implimented as of commit fc60ddc7231c1ce515f2d343022eb33ebf80464d. You can add in the following options

<walk_time> or <walk_dist> <bike_time> or <bike_dist> <drive_time> or <drive_dist>