Read OpenStreetMap PBF files with rust. The main inspiration of this library is libosmpbfreader.
http://texitoi.github.io/osmpbfreader-rs/
This crate works with Cargo and is on
crates.io. The package is regularly
updated. Add it to your Cargo.toml
like so:
[dependencies]
osmpbfreader = "0.3"
For complete example, you can see the examples.
You can find OSM PBF files at Geofabrik's free download server.
Using the count example compiled in release mode:
$ cat /proc/cpuinfo | grep name | head -1
model name : Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz
$ rustc --version
rustc 0.13.0-nightly (fac5a0767 2014-11-26 22:37:06 +0000)
$ ls -sh france-latest.osm.pbf
2,9G france-latest.osm.pbf
$ time ./target/release/count-osm france-latest.osm.pbf admin_level 8
counting objects with tags["admin_level"] = "8"...
51 nodes, mean coord: 46.337052, 2.832865.
105306 ways, mean |nodes|: 75.646221
37229 relations, mean |references|: 8.220446
real 5m30.785s
user 5m18.264s
sys 0m11.944s
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 LGPLv3.
TODO list:
- document until
#![deny(missing_docs)]
can be added; - provide a high level function that, given a
|&OsmObject| -> bool
, returns a structure with all the filtered objects plus their dependencies; - read header to check that we support all needed features.