#maplibre #mapbox #serde #tilejson

tilejson

Library for serializing the TileJSON file format

9 releases

0.3.2 Oct 30, 2022
0.3.1 May 29, 2022
0.2.4 Oct 11, 2021
0.2.2 Sep 12, 2020
0.1.0 Nov 27, 2017

#178 in Parser implementations

Download history 237/week @ 2023-02-14 230/week @ 2023-02-21 178/week @ 2023-02-28 198/week @ 2023-03-07 250/week @ 2023-03-14 317/week @ 2023-03-21 547/week @ 2023-03-28 148/week @ 2023-04-04 104/week @ 2023-04-11 231/week @ 2023-04-18 140/week @ 2023-04-25 95/week @ 2023-05-02 194/week @ 2023-05-09 209/week @ 2023-05-16 457/week @ 2023-05-23 705/week @ 2023-05-30

1,572 downloads per month
Used in 4 crates

MIT/Apache

41KB
537 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

~1.3–1.9MB
~45K SLoC