#pbf #openstreetmap #osm #geocoding #file-format

pbf-reader

Fast openstreetmap PBF file format reader. Reads Nodes, Ways, Relations. It uses mpsc::channell and multiple threads to do job as fast as possible.

9 releases

Uses old Rust 2015

0.1.9 Sep 5, 2019
0.1.8 Nov 26, 2018
0.1.7 Oct 18, 2018
0.1.4 Jan 2, 2018
0.0.4 Feb 22, 2016

#230 in Geospatial

25 downloads per month

Custom license

45KB
1K SLoC

Simple Openstreetmap PBF file format reader. http://wiki.openstreetmap.org/wiki/PBF_Format

pipeline status

This lib uses multithreaded approach for reading data and optimized for speed :D.

Serial read can be achieved by restricting number of additional concurent threads to 0.

For example usate see src/lib.rs tests. There is GUI example which can be run using cargo run --release --example paint

DONE:

  • reading Nodes, Ways, Relatons, Tags

TODO:

  • build index for faster read access.
  • filtered read.
  • documentation and examples.
  • template float and ID types for tunable storage precision.

*** Thanks Gitlab.com team for allowing editing this file online!

Principle #1 User can't catch more than ~5mb of text+vector data from a 4"-6" screen.


lib.rs:

The pbf-reader crate provides function to parse pbf osm format http://wiki.openstreetmap.org/wiki/PBF_Format extern crate pbf_reader; use *; use std::sync::mpsc; // create communication channel let (mut node_tx, node_rx) = mpsc::channel::(); // start read in background thread let h = thread::spawn(move || { // allow usage of 4 additional threads to current one. let threads = 4; let result = read_pbf(&"src/sample.pbf".to_string(), threads, &mut node_tx); result.unwrap(); }); let mut count = 0; loop { if let PBFData::ParseEnd = node_rx.recv().unwrap() { break; } count = count + 1; } assert_eq!(count, 338); h.join().unwrap();

Dependencies

~1.6–3MB
~52K SLoC