13 releases

0.4.1 Dec 9, 2023
0.4.0 Nov 20, 2023
0.3.4 Nov 17, 2023
0.3.2 Oct 30, 2022
0.1.0 Nov 27, 2017

#98 in Geospatial

Download history 233/week @ 2024-08-22 287/week @ 2024-08-29 311/week @ 2024-09-05 300/week @ 2024-09-12 307/week @ 2024-09-19 294/week @ 2024-09-26 288/week @ 2024-10-03 236/week @ 2024-10-10 442/week @ 2024-10-17 346/week @ 2024-10-24 276/week @ 2024-10-31 326/week @ 2024-11-07 482/week @ 2024-11-14 671/week @ 2024-11-21 1974/week @ 2024-11-28 596/week @ 2024-12-05

3,766 downloads per month
Used in 8 crates (7 directly)

MIT/Apache

46KB
608 lines

tilejson

Build Status tilejson on crates.io API Docs

tilejson is a crate for serializing/deserializing the TileJSON format — an open standard for representing map metadata.

Examples

Reading

use tilejson::TileJSON;

fn main() {
    let tilejson_str = r#"{
        "tilejson": "3.0.0",
        "name": "compositing",
        "scheme": "tms",
        "tiles": [
            "http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png"
        ]
    }"#;

    // Parse JSON
    let mut tilejson: TileJSON = serde_json::from_str(&tilejson_str).unwrap();
    println!("{tilejson:?}");
   
    // Add missing default values per TileJSON specification
    tilejson.set_missing_defaults();
    println!("{tilejson:?}");
}

Writing

use tilejson::tilejson;

fn main() {
    let tilejson = tilejson! {
        "http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png".to_string(),
        name: "tileset name".to_string(),
        description: "some description".to_string(),
    };

    let serialized_tilejson = serde_json::to_string(&tilejson).unwrap();

    println!("{serialized_tilejson}");
}

Contributing

Contributions are welcome! Have a look at the issues, and open a pull request if you'd like to add an algorithm or some functionality.

License

Licensed under either of

at your option.

Contribution

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.

Dependencies

~0.7–1.6MB
~34K SLoC