Giter VIP home page Giter VIP logo

osmflat-rs's Introduction

osmflat

berlin-features

Flat OpenStreetMap (OSM) data format providing an efficient random data access through memory mapped files.

The data format is described and implemented in flatdata. The schema describes the fundamental OSM data structures: nodes, ways, relations and tags as simple non-nested data structures. The relations between these are expressed through indexes.

Compiler

Besides the library for working with osmflat archives, the crate osmflatc contains an OSM pbf format to osmflat data compiler.

To compile OSM data from pbf to osmflat use:

cargo run --release -- input.osm.pbf output.osm.flatdata

The output is a flatdata which is a directory consisting of several files. The schema is also part of the archive. It is checked every time the archive is opened. This guarantees that the compiler which was used to produce the archive fits to the schema used for reading it. The archive data is not compressed.

Using data

You can use any flatdata supported language for reading an osmflat archive. For reading the data in Rust, we provide the osmflat crate.

First, add this to your Cargo.toml:

[dependencies]
osmflat = "0.1.0"

Now, you can open an osmflat archive as any other flatdata archive and read its data:

use osmflat::{FileResourceStorage, Osm};

fn main() {
    let storage = FileResourceStorage::new("path/to/archive.osm.flatdata");
    let archive = Osm::open(storage).unwrap();

    for node in archive.nodes().iter() {
        println!("{:?}", node);
    }
}

Examples

Check the osmflat/examples directory. Feel free to add another example, if you have an idea what to do with the amazing OSM data in few lines of code. ๐Ÿ˜

The above map was rendered by osmflat/examples/roads2png.rs in ~ 170 loc from the osmflat archive based on the latest Berlin OSM data.

License

The files src/proto/fileformat.proto and src/proto/osmformat.proto are copies from the OSM-binary project and are under the LGPLv3 license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this document by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

osmflat-rs's People

Contributors

boxdot avatar veaac avatar gferon avatar hallahan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.