Hi, I'm trying to find the motorway and direction from a GPS coordinate of a car driving on a motorway in France. For example for [47.980539, 3.190048], I want to be able to determine that the driver is on motorway called A6 towards city called Lyon. Initially I tried to use the nearest service but the data returned is not always populated and I could not trust it. As a result, the only solution I found was to call the route/v1/driving service by feeding it the driver's GPS coordinate and some far GPS position (in my case: close to Spain border). Then from the JSON object returned I take routes[0]->legs[0]->steps[0]->Ref which gives me the motorway on which the user is. Then for direction I use again route/v1/driving to compute the route distance between beginning location of the motorway and driver and then from driver to end of the motorway and I compare it to a the real length of the motorway. If I find a close match for 1 of the 2 directions, I assume the driver is driving in this direction. It's a bit complicated and not always reliable. Is there a better way to retrieve such information ? asked 17 Jan '17, 15:57 06pboivin06 |
A single location won't suffice. Ideally you should wait until having obtained multiple locations. Then use these locations to calculate the driving direction and the most plausible way(s) the driver is on. You can also go through the source of one of the many open source routing engines for OSM. See routing as well as the list of online routers and offline routers for various examples. answered 17 Jan '17, 16:36 scai ♦ |