[OSM-dev] Parsing OSM-XML: Order of node / way / relation

Andy Allan gravitystorm at gmail.com
Wed Sep 24 17:13:31 BST 2008


On Wed, Sep 24, 2008 at 2:41 PM, Dominik Spies <kontakt at dspies.de> wrote:
> Hi,
>
> I'm trying to write a stream parser for OSM-XML in C# and have a minor problem..
> The DTD for 0.5 does not specify any order of nodes, ways or
> relations. So, it could be possible that a way references a node which
> isn't parsed yet. In this case, I can't add the pointer to the node
> (of my node-object) to the way (or node to relation etc.).
>
> BUT in every case I have seen the nodes are in front of the ways and
> these a in front of the relations. But can I rely on that?

Kind of. It's an accepted convention in OSM, even though it's not
strictly certain. I think lots of things would stop working if nodes
didn't come before ways in map calls etc.

It's worth pointing out as well that the DTD doesn't define the API,
it's the other way around - so if they aren't in agreement, it's the
DTD that's wrong!

> With relations it's a bit more complicated, because relations can
> contain relations. Is there any protection from circular relations?

Circular relations are permitted.

Cheers,
Andy




More information about the dev mailing list