# osmpbfreader-rs [![Build status](https://travis-ci.org/TeXitoi/osmpbfreader-rs.svg?branch=master)](https://travis-ci.org/TeXitoi/osmpbfreader-rs) [![](https://img.shields.io/crates/v/osmpbfreader.svg)](https://crates.io/crates/osmpbfreader) [![](https://docs.rs/osmpbfreader/badge.svg)](https://docs.rs/osmpbfreader)
Read [OpenStreetMap PBF
files](http://wiki.openstreetmap.org/wiki/PBF_Format) with
[rust](http://www.rust-lang.org) in an easy and effective way.
The main inspiration of this library is
[libosmpbfreader](https://github.com/CanalTP/libosmpbfreader).
## Documentation
Find it on [Docs.rs](https://docs.rs/osmpbfreader)
## Using this lib
This crate works with Cargo and is on
[crates.io](https://crates.io/crates/osmpbfreader). The package is regularly
updated. Add it to your `Cargo.toml` like so:
```toml
[dependencies]
osmpbfreader = "0.6"
```
For complete example, you can see the [examples](examples/).
You can find OSM PBF files at [Geofabrik's free download server](http://download.geofabrik.de/).
## Performances
Using the [count](examples/count.rs) example compiled in release mode:
```
$ rustc --version
rustc 1.14.0 (e8a012324 2016-12-16)
$ ls -sh ile-de-france-latest.osm.pbf
232M ile-de-france-latest.osm.pbf
$ time ./target/release/examples/count ile-de-france-latest.osm.pbf admin_level 8
counting objects with tags["admin_level"] = "8"...
4 nodes, mean coord: 48.795432325, 2.3825434.
3941 ways, mean |nodes|: 37.275310834813496
1423 relations, mean |references|: 8.586788475052705
real 0m19.923s
user 0m19.700s
sys 0m0.208s
```
## 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](https://github.com/scrosby/OSM-binary) under the LGPLv3.
## TODO
TODO list:
- document until `#![deny(missing_docs)]` can be added;
- read pbf header to check that we support all needed features;
- do something better than `borrowed_iter`.