Hello all! I am programatically reading an osm file and save the nodes and ways and ways to node relationsship in a sql server database. I have a need to be able to split a way into multiple ways, depending if they intersect another way. If a way intersects two other ways, then I need to split it into three differnt ways. From starting point to the intersection point of the first way it intersect. from the intersection point of the first way it intersections to the intersection point of the second way it intersects and then from the intersection point with the second way to the end of the way.

My question is this. Is there any tags for a given way or the nodes that make it up that tell me it is an intersection point? I dont recognize any node tags. Has anyone done this?


asked 07 Nov '12, 21:15

kcjailbirds's gravatar image

accept rate: 0%

I am assuming that you want to detect actual intersection nodes, i.e. nodes that are shared between more than one way and are not the start or end node for the ways that share the node.

Without pre-processing, there is no way to detect those, because the way objects do not possess geometry, only the nodes do. So you would at least keep all the node IDs in memory or in a temporary file and then check for each way member node whether that node is also used by another way.

If you import your OSM file into an Osmosis schema PostGIS database, you will find the way_nodes table useful for checking intersections.

permanent link

answered 07 Nov '12, 22:48

mvexel's gravatar image

accept rate: 0%

Thank you. I am looking for actual intersections were some could be at the end or begining of a way and some could be in the middle. You suggestion is just what I was thinking to do. Just wanted to see if there was an easier way.

(08 Nov '12, 00:50) kcjailbirds

Assume you have extracted/created all the poly-lines in accordance with ways-nodes relations. From that point your question may be understood more generally than the former answer is suggesting. Namely, you are looking for a function that converts a set of poly-lines into a set of simple poly-lines (a simple poly-line has no common point with any other poly-line except maybe the end-points). But then, if a crossing point can be anywhere on poly-lines the issue is more complex and complicated. I am not shore you can find standard and open-source solution to it (you know, any computer calculated crossing of two vectors/straight line segments is never on any of them except maybe in some trivial cases). At the same time, the mentioned function is essential in vector map data preparation phase (e.g. finding a simple area coverage for complicated area structures with overlaps or like a hole having a common border section with container/outer border, or even slightly crossing it, or when recognizing wrong/not tagged roundabouts in a road class and so on). So, if you don’t mind, here is a model how I/we handle your issue: First, we decompose all poly-lines into single (independent) vectors. Next, any crossing or overlapping vectors are divided into none-crossing and none overlapping vectors. So, neighboring vectors (those having one and only one common end-point) are linear-connected to (simple) poly-lines again. Finally, there are some cosmetic updates regarding orientations, name assignments, rule assignments and so on. Now, these poly-lines are what you are looking for. The whole poly_lines-to-simple-poly_lines (how we call it) process takes some seconds or minutes (in case of huge data-sets like the Planet forests, river-lines…) on a medium strong laptop.

permanent link

answered 08 Nov '12, 11:53

sanser's gravatar image

accept rate: 5%

Thank you for the detailed explaination. This solution seems very complicated but it might be the only way to go! Do you have any sample code on how you have or would do this?

(08 Nov '12, 16:30) kcjailbirds

Pretty interested in this as well, if you're willing to share any code examples...cheers!

(09 Nov '12, 13:55) Csc
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](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:


question asked: 07 Nov '12, 21:15

question was seen: 7,331 times

last updated: 13 Nov '12, 15:17

powered by OSQA