NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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


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

accept rate: 0%

edited 16 Apr '13, 23:11

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.

permanent link

answered 17 Apr '13, 07:37

Roland%20Olbricht's gravatar image

Roland Olbricht
accept rate: 36%

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]( "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: 16 Apr '13, 23:06

question was seen: 3,322 times

last updated: 17 Apr '13, 07:37

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum