Crates.io | georender-pack |
lib.rs | georender-pack |
version | 2.1.1 |
source | src |
created_at | 2021-01-14 00:02:49.625357 |
updated_at | 2021-06-15 02:22:16.001499 |
description | Pack osm data into a buffer based on the peermaps buffer schema |
homepage | https://github.com/peermaps/georender-pack.rs |
repository | https://github.com/peermaps/georender-pack.rs |
max_upload_size | |
id | 341645 |
size | 111,522 |
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! :tada:
In Cargo.toml
georender-pack = "x.x.x" # latest version
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>
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
cargo test
There is a limited test suite on creating and encoding new PeerLine, PeerNode, and PeerArea objects.
MIT