This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Overpass output to kml = shape zigzagged

0

I'm producing an interpreter file using the command from another question.

That file I then parse with php... Iterate relation, then in the order the ways are printed I read their ref, take the referenced way, then I iterate the nodes of the way and read each node in the order it was printed.

The lon and lat of each node I then put into a string like that

lon1,lat1,0
lon2,lat2,0 
lon3,lat3,0

and so forth

This I then put into the coordinates tag of a kml file.

Now it seems that the order of the coordinates isn't correct, because the created shape in google maps is not closed but zigzagged :( (not all of it though, most part is correct)

Is this normal ? What should I do ?

asked 16 Apr '13, 23:06

SeWo's gravatar image

SeWo
31224
accept rate: 0%

edited 16 Apr '13, 23:11


One Answer:

1

In general, you first must stich the ways one to another. One possible way to do so is to keep an associative array of all first and last node ids in each way and to construct a single consecutive path by traversing the nodes of the ways this way. It is in general not guaranteed that the ways are in order or have the right orientation, but it is quite safe to assume that a valid area passes each node only once.

I'm sorry that this is somehow vague, but I'm not familiar with PHP. But as even JavaScript has associative arrays, I'm quite sure they exist in PHP.

answered 17 Apr '13, 07:37

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

Source code available on GitHub .