0

I have a problem like this: I have a list of latitude, longitude pairs and for each one of those, I would like to know which type of road was it generated on. All the points are from GPS units of cars driving on public roads.

I have downloaded OpenStreetMap .osm export, where the roads are stored in a format as follows:

<way id="88596345" visible="true" version="9" changeset="453983438" timestamp="2017-05-04T15:47:48Z" user="wegavision" uid="453845">
  <nd ref="456877786"/>
  <nd ref="3335483999"/>
  <nd ref="248335839"/>
  <nd ref="406453920"/>
  <nd ref="25808860"/>
  <tag k="destination" v="abcd"/>
  <tag k="highway" v="secondary"/>
  <tag k="lanes" v="1"/>
  <tag k="lit" v="yes"/>
  <tag k="maxspeed" v="30"/>
  <tag k="oneway" v="yes"/>
  <tag k="ref" v="M54"/>
  <tag k="sidewalk" v="left"/>
  <tag k="smoothness" v="good"/>
  <tag k="surface" v="asphalt"/>
 </way>

Now my question is, is there any tool to find a match between GPS coordinates and this way ids? How is this done using OpenStreetMaps?

Erhan
  • 157
  • 4
  • 16
  • 2
    This is know map matching and there are various open source tools like valhalla, GraphHopper and OSRM – Karussell Apr 21 '18 at 12:34
  • Thanks for the response. I think Overpass suits my needs best. However there is an issue with speed. The HTTP requests just take too long to synchronize a large dataset. Is it possible to make Overpass query a local db (created from a local .osm export for example)? – Erhan Apr 23 '18 at 09:04
  • Or maybe do you suggest any other tool? – Erhan Apr 23 '18 at 09:05
  • You can [install a local Overpass instance](https://overpass-api.de/no_frills.html). – scai Apr 23 '18 at 14:08
  • Overpass API is really not the best option for Map Matching. I would also recommend the options mentioned by @Karussell above. The reason why you can't process many points via Overpass API is the rate limiting to avoid excessive usage of the public servers. – mmd Apr 24 '18 at 11:51

1 Answers1

0

Okay, so in the end I figured it out as follows:

First, I have installed an Overpass API on my Ubuntu machine and loaded the downloaded .osm there. Then I could query the loaded .osm file like this:

/some_path/osm-3s_v0.7.54/bin/osm3s_query --db-dir=/some_path/osm-3s_v0.7.54/mydb <<< "way['highway'](around:10,'_GPSLAT_,_GPSLON_');out;"

This returned an XML string where I could parse for a way id.

The major issue with this approach is that when your GPS point is close to multiple roads, you get an XML response with multiple way ids. In my solution I have totally neglected this and I am fine with any error this might give. Since my dataset is very large and dense I assume the error made would not be significant and early experiments proved me right.

Erhan
  • 157
  • 4
  • 16