1

I'm trying to create a Minecraft map of the Ernst Reuter Platz in Berlin. For this purpose, I'm using OpenStreetMap data.

This is what the place looks like on a 2D map:

Image

When I render the roads and the buildings into a Minecraft map, I'm doing something wrong. Here you can find a zoomable preview of the map.

Image 2

Gray blocks represent streets (from highways to footways) and reddish-brown ones - contour of the buildings.

As you can see, there is some error in the renderer. For example at a certain location there is a building, where the lines seem to be drawn in the wrong order.

Rendering error

Is there an algorithm, which I can use in order to sort the points of the OSM polygons so that they result in a nice shape (like a real building) ? If yes, what is it called?

Update 1 (30.09.2015 08:38 MSK): One possible approach is to use convex hull algorithm.

Update 2: Sample definition of a building

<way id="103989044" visible="true" version="4" changeset="34001855" timestamp="2015-09-13T15:17:07Z" user="species" uid="321042">
    <nd ref="1200207407"/>
    <nd ref="1200207412"/>
    <nd ref="1772686869"/>
    <nd ref="1119746578"/>
    <nd ref="1119746577"/>
    <nd ref="1772676000"/>
    <nd ref="1200207407"/>
    <tag k="addr:city" v="Berlin"/>
    <tag k="addr:country" v="DE"/>
    <tag k="building" v="yes"/>
    <tag k="layer" v="1"/>
    <tag k="min_level" v="1"/>
    <tag k="source" v="Bing"/>
</way>
3

I found the error. In one crucial part of the code a set (unordered collection) was used instead of a list (ordered collection).

| improve this answer | |
1

There is no need to "sort" nodes. I guess you already have an error in your parser. How are you reading/storing the nodes and their order?

Let's assume you are reading in an OSM XML file. The order in which the nodes appear in this XML file is completely irrelevant. Instead you have to look at the order in which these nodes are referenced by the corresponding way, i.e. the order of the <nd ref="NODE-ID"/> elements. This becomes pretty clear when realizing that a single node can be part of multiple ways and can even be part of the same way multiple times.

| improve this answer | |
  • Thanks. All data are available at dl.dropboxusercontent.com/u/11776689/… . In update 2 above I pasted a sample definition of a building. Is it correct that I have to draw the lines in the following order: 1200207407 - 1200207412 - 1772686869 - 1119746578 - 1119746577 - 1772676000 - 1200207407 ? – Mentiflectax Sep 30 '15 at 8:14
  • 1
    Yes, that's the correct order for way 103989044. Also note that this way appears twice in your file, with version 4 and version 5. You can ignore the older version. No idea why your file contains multiple versions of the same object. – scai Sep 30 '15 at 8:18
  • Thanks for the hint with the version. I didn't know that. Maybe that's causing the problems - I'll figure it out in the evening. – Mentiflectax Sep 30 '15 at 8:33
  • Are you sure about way 103989044 appearing twice in the file dl.dropboxusercontent.com/u/11776689/… ? I can't find the second appearance of it? – Mentiflectax Sep 30 '15 at 8:49
  • Ooops, I was wrong. Sorry. It does appear just once. I noticed that node 1200207407 appears in multiple ways (way 103989044 and 96687355) and thought it's the same way with just a different version. But the ways are different, they just share this node. – scai Sep 30 '15 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.