Skip to content

Parsing of nd ref fails when not all version information is present #4

Description

@skinkie

Consider:

<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' upload='true' generator='JOSM'>
  <node id='7' lat='0.00579413357' lon='-0.01967310472' />
  <node id='10' lat='0.00570430204' lon='-0.0025152828' />
  <way id='11' version='1'>
    <nd ref='7' />
    <nd ref='10' />
  </way>
</osm>

When parsing this (I'm using here the branch of @Hemofektik but it also happens in vanilla).

Breakpoint 2, o5mreader_iterateNds (pReader=0xa05950, nodeId=0x7fffffffdbb0) at o5mreader.c:424
424             pReader->wayNodeId += wayNodeId;
(gdb) p wayNodeId
$8 = -9

When version='1' from the input .osm file is removed, o5mreader presents the correct wayNodeId.

I have validated if the conversion is correct by converting o5m back to osm:

<?xml version='1.0' encoding='UTF-8'?>
<osm version="0.6" generator="osmconvert 0.8.5">
        <node id="7" lat="0.0057941" lon="-0.0196731"/>
        <node id="10" lat="0.0057043" lon="-0.0025152"/>
        <way id="11" version="1">
                <nd ref="7"/>
                <nd ref="10"/>
        </way>
</osm>

The strange thing is that when extra attributes are added such as timestamp, changeset, etc. the reference again becomes "correct". But it seems to be dependent on the length that was added. Within pReader->offsetNd is different. My hunch was to go for o5mreader_readVersion.

https://github.com/bigr/o5mreader/blob/master/src/o5mreader.c#L272

First an unsigned int is read, after which a signed int is read. Which looks like something as a version and changeset, or a version and a uid. From the documentation http://wiki.openstreetmap.org/wiki/O5m#Way

So I now know that I should use specially crafted o5m files, but should this be considered a bug since a converter program may create such files? Or is the convertor at fault?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions