I've extracted a number of streets out of OpenStreetMap. I've found that some streets are great to work with, and others cannot be displayed in a polyline format because their coordinates are out of order. Here's an example of a good street: The line (on the left, obviously) matches the coordinates (on the right), and looks the way you'd expect it to. Here's an example of a bad street: The coordinates (on the bottom left) seem just fine, but once I try to make a polyline out of them (top right) things go crazy. I think it's because the coordinates (the node entries, from OpenStreetMap) are out of order. Is this a common issue? Is there a way to correct it? (The imgur link for the image set is http://imgur.com/a/dvD3M - I'm not sure if the individual image links used above will ever change.) asked 31 Oct '15, 00:25 JamesChevalier |
As user_5359 suggests, nodes are only ordered within each Openstreetmap way. Your lower image contains multiple ways starting with http://www.openstreetmap.org/way/8766694 in the north, then http://www.openstreetmap.org/way/8767452 http://www.openstreetmap.org/way/101458166 http://www.openstreetmap.org/way/101458163 http://www.openstreetmap.org/way/8768186 after which it gets a bit more complicated as there are dual carriageway sections with one way in each direction (both of which join to that last way I mentioned). http://www.openstreetmap.org/way/8767828 http://www.openstreetmap.org/way/33824767 If you are trying to draw a route you will need to select the ways that are needed depending on direction of travel, in the correct order, and depending which way the way nodes are ordered you may need to reverse the list for individual ways. In the above example if you were heading north from the one way section you might also want to exclude the section of way 8768186 that you wouldn't travel on when you turn left onto it (most routers pre-process the data I believe). answered 31 Oct '15, 07:50 EdLoach ♦ 1
That's the problem! I imported all the individual ways into my database as one one single street object. That works perfectly for my underlying use case, but really jams things up when I try to display them on a map. I kept the OSM ID for each node ... I wonder if there's a way for me to piece together the separate sections with that data ...
(31 Oct '15, 20:10)
JamesChevalier
2
You really have to reassemble street objects from OSM ways: you cant just treat them as a multilinestring. They need to be manipulated as a graph (which is what most routing software does).
(31 Oct '15, 20:28)
SK53 ♦
|
Is that really just one OSM way? The nodes are sorted only within an OSM way. Can you tell us the OSM Way ID, please? answered 31 Oct '15, 04:16 user_5359 |