In my project, a driving app, I want to traverse the OSM road network as the user is driving. There's no routing at all and I don't need geometry. I just want to be able to display info about where the user is driving (road name and administrative area names like city, county, and state) and what the max speed is for the current road segment. What's the best way to approach this without constantly reverse geocoding?

asked 18 Apr '20, 19:47

jbjb00's gravatar image

accept rate: 0%

This is effectively "map matching", where you take a GPS trace and work out the most likely route from it. Most routing engines, such as OSRM and Graphhopper, provide a map matching feature.

This does mean that you have to run an instance of a routing engine. Unfortunately, running a simple proximity search without a routing engine is less likely to work, because it won't know which road you're on at junctions or other situations where there's more than one road in the area. You could try building some logic which is "sticky" to the current road, but that's likely to be problematic in urban areas where the road network is dense, GPS reception is poor, and you might be making numerous turns.

permanent link

answered 19 Apr '20, 09:31

Richard's gravatar image

Richard ♦
accept rate: 19%

Thank you for the answer, Richard. Do you have any suggestions for implementing map matching in the way that I've described? An example to start with, that is. I've looked at OSRM, and it can easily provide snap-to-road functionality given a few GPS locations, but it doesn't give any administrative info or max speed, and there doesn't appear to be any way I could effectively cache results for "random" location inputs (e.g. I could drive the same road 1,000,000 times and never get the same set of GPS locations twice). I've also taken a cursory look at Graphhopper, but its map matching is buried in so much other stuff that I don't need.

(21 Apr '20, 18:18) jbjb00

Mapbox (who maintained OSRM until recently) have a "route annotator" which is designed to work with OSRM. You feed it the node ids returned from OSRM, and it supplied the OSM way properties. I don't have any experience with it but have seen reports that it works.

For administrative areas, you could try doing just a simple polygon lookup - i.e. download boundary polygons and then just do a point-in-polygon lookup. This is much simpler than map matching.

(21 Apr '20, 20:42) Richard ♦
Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 18 Apr '20, 19:47

question was seen: 441 times

last updated: 21 Apr '20, 20:42

powered by OSQA