Crates.io | osmnodecache |
lib.rs | osmnodecache |
version | |
source | src |
created_at | 2021-11-24 23:22:54.044508+00 |
updated_at | 2025-02-12 19:32:58.595503+00 |
description | Flat file OSM node cache to store (latitude,longitude) pairs as indexed entries |
homepage | |
repository | https://github.com/nyurik/osm-node-cache |
max_upload_size | |
id | 487345 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Flat file node cache stores lat,lon coordinate pairs as u64
values with their index being the position in the file. In
other words - 0th u64 value is stored as the first 8 bytes, etc.
The library allows multithreaded access to the cache, and can dynamically grow the cache file.
// This example uses osmpbf crate
use std::path::PathBuf;
use rayon::iter::{ParallelBridge, ParallelIterator};
use osmnodecache::{DenseFileCache, CacheStore as _};
use osmpbf::{BlobReader, BlobDecode};
fn main() {
let reader = BlobReader::from_path("planet.osm.pbf").unwrap();
let file_cache = DenseFileCache::new(PathBuf::from("node.cache")).unwrap();
reader.par_bridge().for_each_with(
file_cache,
|fc, blob| {
let mut cache = fc.get_accessor();
if let BlobDecode::OsmData(block) = blob.unwrap().decode().unwrap() {
for node in block.groups().flat_map(|g| g.dense_nodes()) {
cache.set_lat_lon(node.id as usize, node.lat(), node.lon());
}
};
});
}
make
.
Install it with cargo install just
.just
.just test
.Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.