How Far 2 Home
This function was designed as a proof of concept and will return the estimated driving distance the device (using owntracks here) is from the GPS coordinates specified in the functions file
For example;
2014-03-24 15:45:00,484 INFO [log] matthew iphone is 38mins away from home
Requiements
- mqttwarn https://github.com/jpmens/mqttwarn
- Owntracks https://github.com/owntracks
- google api key, https://code.google.com/apis/console/ (With 'Distance Matrix API' turned ON)
NOTE's
- Unfortuantely it doesn't return the travel time including the current traffic! You need the 'google maps api for business' i believe to do this (need to confirm this!)
- As it has been pointed out.... (Use at own risk!)... Use of the Distance Matrix API must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited. https://developers.google.com/maps/documentation/distancematrix/
I suggest looking at other map services api's and see if they have similar restrictions.
Future, or you could easily do it yourself
- Intergrate my other fucntion, reverse geo, https://gist.github.com/matbor/9381893
- change to another api that doesn't have the restriction that google maps does! Maybe checkout openstreetmap to see if it is ok!