OSM PBF showcase

The same statistics tool for OpenStreetMap’s planet file format, written twice - once per decode model, in separate files so each reads on its own:

Both print identical statistics (counts, tags, bbox, top tag keys) on stdout; a CTest holds them to a hand-derived golden on testdata/mini.osm.pbf, which in turn must reproduce byte-for-byte from testdata/make_fixture.py. Timing goes to stderr: read / inflate / decode / walk from the arena program, read / inflate / decode+walk from the streaming one.

The manual’s OSM PBF page walks through the format and what each program demonstrates about its model.

The schema (proto/fileformat.proto, proto/osmformat.proto) is vendored from OSM-binary v1.7.0. Both files are MIT (Scott A. Crosby); the license text is in each file’s header and in the repository’s THIRD_PARTY_NOTICES.md.

Building and running

Needs zlib - a dependency of this example, not of RapidProto; without it the example skips itself. In-tree (the default when the RapidProto tests are enabled):

cmake --preset release && cmake --build --preset release --target osmstat-arena osmstat-stream
ctest --test-dir build/release -R rapidproto_osmstat    # the fixture test

Real data comes from Geofabrik, e.g. the ~20 MB Bremen extract:

curl -O https://download.geofabrik.de/europe/germany/bremen-latest.osm.pbf
./build/release/examples/osm-pbf/osmstat-arena bremen-latest.osm.pbf

Standalone against an installed RapidProto, like the consumer example:

cmake -S examples/osm-pbf -B osm-build -DCMAKE_PREFIX_PATH=<prefix>
cmake --build osm-build && ctest --test-dir osm-build