MCPcopy Index your code
hub / github.com/TeXitoi/osmpbfreader-rs

github.com/TeXitoi/osmpbfreader-rs @v0.16.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.16.1 ↗ · + Follow
87 symbols 165 edges 12 files 31 documented · 36% updated 3mo ago★ 1321 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

osmpbfreader-rs Build status

Read OpenStreetMap PBF files with rust in an easy and effective way. The main inspiration of this library is libosmpbfreader.

Documentation

Find it on Docs.rs

Using this lib

This crate works with Cargo and is on crates.io. The package is regularly updated.

For complete example, you can see the examples.

You can find OSM PBF files at Geofabrik's free download server.

Performances

Using the different examples compiled in release mode:

$ grep CPU /proc/cpuinfo | uniq -c
      8 model name  : Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz
$ rustc --version
rustc 1.14.0 (e8a012324 2016-12-16)
$ ls -sh france-latest.osm.pbf
3,3G france-latest.osm.pbf
$ time ./target/release/examples/tutorial france-latest.osm.pbf
416483839 objects in "france-latest.osm.pbf"

real    4m24.784s
user    4m18.476s
sys 0m6.164s
$ time ./target/release/examples/count france-latest.osm.pbf admin_level 8
counting objects with tags["admin_level"] = "8"...
53 nodes, mean coord: 46.25862766415095, 2.9082348867924517.
108190 ways, mean |nodes|: 72.09304926518162
35984 relations, mean |references|: 8.705369052912406

real    1m10.117s
user    8m16.164s
sys 0m23.120s
$ time ./target/release/examples/count_with_deps france-latest.osm.pbf admin_level 8
counting objects with tags["admin_level"] = "8" and their depedencies...
9497221 nodes, mean coord: 46.69071931974348, 2.2632424769587915.
136950 ways, mean |nodes|: 70.35282949981745
36408 relations, mean |references|: 8.771121731487586

real    5m9.814s
user    33m52.820s
sys 0m28.624s

License

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.

Note that src/fileformat.proto and src/osmformat.proto come from OSM-binary under the MIT.

Extension points exported contracts — how you extend this code

StoreObjs (Interface)
Trait to allow generic objects (not just BTreeMap) in some methods. [1 implementers]
src/reader.rs

Core symbols most depended-on inside this repo

iter
called by 20
src/reader.rs
make_string
called by 5
src/groups.rs
insert
called by 4
src/reader.rs
contains_key
called by 4
src/reader.rs
id
called by 4
src/objects.rs
make_tags
called by 3
src/groups.rs
blobs
called by 3
src/reader.rs
contains
called by 3
src/objects.rs

Shape

Method 42
Function 25
Class 15
Enum 4
Interface 1

Languages

Rust100%

Modules by API surface

src/objects.rs30 symbols
src/reader.rs20 symbols
src/groups.rs16 symbols
src/blobs.rs5 symbols
src/error.rs4 symbols
src/blocks.rs4 symbols
examples/relation.rs2 symbols
examples/count_with_deps.rs2 symbols
examples/count.rs2 symbols
examples/tutorial.rs1 symbols
build.rs1 symbols

For agents

$ claude mcp add osmpbfreader-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact