Associate sensored GPS location to path from direction API

410 views Asked by At

I have the following question: is there any way to associate GPS location data to a previously downloaded route from the google directions API? I know that there is the Snap-to-roads API but I want to force it to associate to a point on that specific route, moreover snap to roads does not have a "walking" mode. Any ideas on how to do this map matching? Best regards

2

There are 2 answers

0
Pablo Baxter On

Disclaimer: I work for Pathsense.

We've have, and continue to work on, a location provider to give realtime (or slightly delayed, depending on how you set it), map-matched location updates for Android. However:

  • It uses GPS and sensors to ensure it remains in the proper road, so it can use a little more power than GPS, if you don't manage it properly (just like any location provider).

  • Although setting it to 0 still does a better job at map-matching than GPS, if the user drives in an area with a lot of tall buildings, the location update can still go down the wrong road for a short time. The delay feature is important if you don't require an immediate update, as it gives the library more time to determine the correct road the user is on.

Pathsense demo repo:
https://github.com/pathsense/pathsense-samples-android/tree/master/pathsense-invehiclelocationdemo-app

However, if you just need to have a map matched path that isn't realtime or close to it, and Google's Snap to Road doesn't suit you, I did find this cool library that may be helpful. I haven't tried it myself yet, so I can't say how well it works, but might be an interesting thing to look into.

GraphHopper library repo:
https://github.com/graphhopper/graphhopper

0
piotrpo On

The route simply polyline (set of segments). You simply have to find the closest point of polyline. That means one of two possibilities closest segment's end or closest projection point to any of segments. Then you need some threshold (usually based on GPS receiver reported accuracy) work. For calculations definitely you should look for some geospatial library working with java and Android. For small areas (let's say if the route's minimum bounding box is smaller that 100 x 100 miles) it's possible to use euclidean calculations instead of geodetic ones. Just remember to scale the length of one degree of longitude (one degree of latitude is always 60 Nm).