[OSM-dev] OSM binary format (pbf) 1.0 is in osmosis trunk.

Scott Crosby scrosby at cs.rice.edu
Sun Oct 17 04:02:04 BST 2010

On Sat, Oct 16, 2010 at 8:42 AM, Frederik Ramm <frederik at remote.org> wrote:

> Hi,
> On 10/16/2010 03:25 PM, Stefan de Konink wrote:
>> Also, can you give me the URL for the source code for pbf2osm to check
>>> that a few edge-cases are correctly handled?
>> http://git.openstreetmap.nl/index.cgi/pbf2osm.git/
> I'm hoping to take that, fix it up a bit (so that the resulting binary is
> not called "test" any more etc ;) and put in in the OSM SVN together with a
> set of Debian scripts that automatically build the protobuf stuff and
> produce a statically linked Debian package with little no dependencies. I
> think that should further reduce the hurdle to using it.

Looks pretty good. I liked the coding style. Very simple, short, and
concise. I have a few things to note.

When parsing the header:

    if (state == osmheader) {
        HeaderBlock *hmsg = header_block__unpack (NULL, bmsg->raw_size,
        if (hmsg == NULL) {
            fprintf(stderr, "Error unpacking HeaderBlock message\n");
            return 1;

        if (verbose) fprintf(stderr, "%s\n", hmsg->required_features[0]);

        header_block__free_unpacked (hmsg, &protobuf_c_system_allocator);

The full array of required features should be checked and your program
should error out if any required feature other than "OsmSchema-V0.6"
or "DenseNodes" appears.

When parsing timestamps:

#define printtimestamp(attribute, timestamp) \
    char tsbuf[21]; \
    deltatime2timestamp(timestamp * (pmsg->date_granularity / 1000), tsbuf);
    fputs_unlocked(" "attribute"=\"", stdout); \
    fputs_unlocked(tsbuf, stdout); \
    fputc_unlocked('"', stdout);

The formula is:
    (timestamp*date_granularity) / 1000

In the comments, you mention that the Nodes stuff is untested. You can build
a file that uses Nodes instead of DenseNodes by invoking osmosis with
'--write-pbf file=foo.osm.pbf usedense=false'.

Thanks, I enjoyed looking at your code and style of coding.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20101016/71ee2dbc/attachment.html>

More information about the dev mailing list