More

What error am I doing when rendering OpenStreetMap roads and buildings in Minecraft?

What error am I doing when rendering OpenStreetMap roads and buildings in Minecraft?


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:

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.

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.

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

             

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


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 theelements. 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.