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

I'm looking to develop an application that requires a database of nodes and relations (intersections) of roads in an area. I don't need to specifically pick out the roads within a map segment, however having the upcoming intersections in a road given GPS coordinates is a must.

I've been looking into OSM and a few of its add-ons however I haven't been able to pinpoint the one that's right for me. Could anyone shed some light on which tool to use?

NOTE: I do not need to render maps graphically. It's a simple question of being given a point and knowing the locations of upcoming relations in the road.

I've looked into osmosis + osm2pgsql, however the latter doesn't seem to be ideal for routing purposes. I'm also looking into pgRouting, however once again I'm not entirely sure I'll be able to get the right info. If anyone with similar experience could push me in the right direction that would be awesome!

(Also, is there any preferred DBMS for OSM purposes? I'm usually a MSSQL guy, however I haven't heard of any particular benefits in using MySQL or any other system for this use. )

asked 19 Nov '12, 08:08

JuZeeMan's gravatar image

JuZeeMan
41336
accept rate: 0%


A relatively simple way to achieve your goal could be downloading a suitable shape file from http://download.geofabrik.de/ (provided there is one for your area), then take the roads layer and import it into a spatial database of your choice. Then use a couple SQL queries to determine intersections (i.e. anything where two road geometries intersect and neither has the bridge/tunnel flag), and take it from there. This means you'll unnecessarily reverse-engineer the intersections (the presence of which could have been detected from looking at the OSM raw data, where both roads would share the same node) but it works without any extra importing software - apart from some shapefile importer which any spatial database will come equipped with.

permanent link

answered 19 Nov '12, 09:17

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Sounds like a great and simple approach! I was going to try loading an osm file of my region into (PostGreSQL +)PostGIS to work with that but I'm not too sure what the difference in data would be tbh. Any specific differences you may know of?

So far, for the scope of this project, it seems that as long as I have road data then I should be safe, though I suppose having extra data might come in handy in the future.

(25 Nov '12, 15:21) JuZeeMan

Looking further into this approach...though I can't really make heads or tails of the rows added to the DB.

In the meantime I've given NETCONVERT within the SUMO simulator a go, however, once again I'm not sure how to read this output into a DB. The problem here is that SUMO maps the coordinates onto a new map, resetting all the coordinates according to its own X and Y coordinates.

I have loaded the roads layer as you suggested, and indeed! I have managed to get a table of node ids (osm_id). Filtering out the intersections will be a tad trickier but I'll give that a shot. Thanks again!

(02 Dec '12, 17:08) JuZeeMan

Interesting project :-). However, I don't think there's existing software which does exactly that, so you'll need to roll your own. You can, however, use some infrastructure for parsing & processing the data. Osmosis e.g. may help.

You will probably need to download the OSM data, and then simplify it. You apparently only need roads, so you can filter out all the rest (boundaries, POIs etc.). Then you could do something like:

  • input: GPS coordinates
  • find the nearest road (that's probably where you are)
  • find direction of movement/driving
  • move along the road in driving direction until you hit an intersection

In OSM data, intersections are simply OSM nodes which are members of more than one road. Take care, however, that longer roads are usually split into multiple OSM ways, so it may be non-trivial to decide if something is an intersection. Also, you may want to discard crossing foot-paths etc...

(Also, is there any preferred DBMS for OSM purposes? I'm usually a MSSQL guy, however I haven't heard of any particular benefits in using MySQL or any other system for this use. )

Most OSM software uses PostGreSQL (specifically, PostGIS). But the best DB will depend on which software you use.

permanent link

answered 19 Nov '12, 08:55

sleske's gravatar image

sleske
4.1k135678
accept rate: 24%

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:

×223
×118
×12

question asked: 19 Nov '12, 08:08

question was seen: 5,964 times

last updated: 02 Dec '12, 17:08

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