#mapbox #serde #tilejson

tilejson

Library for serializing the TileJSON file format

6 releases

0.2.4 Oct 11, 2021
0.2.3 Oct 10, 2021
0.2.2 Sep 12, 2020
0.2.1 Oct 10, 2019
0.1.0 Nov 27, 2017

#144 in Parser implementations

Download history 31/week @ 2021-07-06 80/week @ 2021-07-13 102/week @ 2021-07-20 114/week @ 2021-07-27 27/week @ 2021-08-03 29/week @ 2021-08-10 71/week @ 2021-08-17 70/week @ 2021-08-24 9/week @ 2021-08-31 40/week @ 2021-09-07 64/week @ 2021-09-14 7/week @ 2021-09-21 51/week @ 2021-09-28 217/week @ 2021-10-05 260/week @ 2021-10-12 90/week @ 2021-10-19

282 downloads per month
Used in martin

MIT/Apache

14KB
213 lines

tilejson

Build Status tilejson on Crates.io

Documentation

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

Examples

Reading

extern crate tilejson;
extern crate serde_json;

use tilejson::TileJSON;

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

    let tilejson: TileJSON = serde_json::from_str(&tilejson_str).unwrap();
    println!("{:?}", tilejson);
}

Writing

Using builder pattern

extern crate tilejson;
extern crate serde_json;

use tilejson::TileJSONBuilder;

fn main() {
    let mut tilejson_builder = TileJSONBuilder::new();

    tilejson_builder.name("tileset name");
    tilejson_builder.description("some description");

    let tiles = vec!["http://localhost:8888/admin/1.0.0/world-light,broadband/{z}/{x}/{y}.png"];
    tilejson_builder.tiles(tiles);

    let tilejson = tilejson_builder.finalize();
    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.9–1.6MB
~38K SLoC