#decentralized #osm #p2p #maps #peermaps

nightly georender-pack

Pack osm data into a buffer based on the peermaps buffer schema

5 stable releases

3.0.0 Apr 26, 2021
2.1.1 Jun 15, 2021
2.1.0 Apr 8, 2021
2.0.0 Mar 15, 2021
1.0.0 Jan 14, 2021

#958 in Database interfaces

46 downloads per month
Used in peermaps-ingest

MIT/Apache

86KB
2.5K SLoC

georender-pack.rs

Pack osm data into a buffer based on the peermaps buffer schema. This is part of the peermaps pipeline.

If you want to decode these buffers, use the Node.js version of this library or open a pull request here! 🎉

Installation

In Cargo.toml

georender-pack = "x.x.x" # latest version

Usage

encode::node

Signature

encode::node(
    id: u64,
    point: (f64, f64),
    tags: Vec<(&str, &str)>
) -> Result<Vec<u8>, Error>

Example

use georender_pack::encode;
use failure::Error;

let id = 1831881213;
let lon = 12.253938100000001;
let lat = 54.09006660000001;
let tags = vec![("name", "Neu Broderstorf"), ("traffic_sign", "city_limit")];

let bytes = encode::node(id (lon, lat), &tags).unwrap();

encode::way

Signature

encode::way(
    id: u64,
    tags: Vec<(&str, &str)>,
    refs: Vec<u64>,
    deps: &HashMap<u64, (f32, f32)>
) -> Result<Vec<u8>, Error>

Example

use failure::Error;
use georender_pack::encode;

let tags = vec![("source", "bing"), ("highway", "residential")];
let refs = vec![1, 5, 3];
let mut deps = HashMap::new();
deps.insert(1, (31.184799400000003, 29.897739500000004));
deps.insert(5, (31.184888100000002, 29.898801400000004));
deps.insert(3, (31.184858400000003, 29.8983899));
let bytes = encode::way(234941233, tags, refs, &deps).unwrap();

encode::way_from_parsed

Signature

encode::way(
    id: u64,
    feature_type: u64,
    is_area: bool,
    labels: &[u8],
    refs: &[u64],
    deps: &HashMap<u64, (f32, f32)>,
) -> Result<Vec<u8>, Error>

encode::relation

Signature

encode::relation(
    id: u64,
    tags: &Vec<(&str, &str)>,
    members: &Vec<Member>,
    nodes: &HashMap<u64, (f32, f32)>,
    ways: &HashMap<u64, Vec<u64>>
) -> Result<Vec<u8>, Error>

encode::relation_from_parsed

Signature

encode::relation_from_parsed(
    id: u64,
    feature_type: u64,
    is_area: bool,
    labels: &[u8],
    members: &[Member],
    nodes: &HashMap<u64, (f32, f32)>,
    ways: &HashMap<u64, Vec<u64>>,
) -> Result<Vec<u8>, Error>

Example

For example usage with the osmpbf Rust crate for parsing PBF files, see example/osmpbf/main.rs.

cargo run --example osmpbf /path/to/my.pbf

Development

cargo test

There is a limited test suite on creating and encoding new PeerLine, PeerNode, and PeerArea objects.

License

MIT

Dependencies

~4MB
~60K SLoC