9 releases (breaking)
0.8.0 | Mar 23, 2023 |
---|---|
0.7.0 | Feb 10, 2022 |
0.6.1 | Feb 10, 2022 |
0.6.0 | Dec 17, 2021 |
0.2.0 | Nov 28, 2021 |
#73 in Caching
35 downloads per month
26KB
622 lines
osm-node-cache
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.
// Libraries: osmpbf, rayon
fn main() {
let reader = BlobReader::from_path("planet.osm.pbf").unwrap();
let file_cache = DenseFileCache::new(PathBuf::from("node.cache"))?;
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());
}
};
});
}
License
You may use this library under MIT or Apache 2.0 license
Dependencies
~1.9–7.5MB
~125K SLoC