NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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's gravatar image

06pboivin06
11224
accept rate: 0%


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.

permanent link

answered 17 Jan '17, 16:36

scai's gravatar image

scai ♦
33.3k21309459
accept rate: 23%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×1

question asked: 17 Jan '17, 15:57

question was seen: 1,322 times

last updated: 17 Jan '17, 16:36

Related questions

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum