#mapbox #serde #tilejson

tilejson

Library for serializing the TileJSON file format

2 unstable releases

new 0.2.0 Oct 9, 2019
0.1.0 Nov 27, 2017

#199 in Encoding

Download history 13/week @ 2019-06-26 20/week @ 2019-07-03 6/week @ 2019-07-10 1/week @ 2019-07-17 3/week @ 2019-07-24 2/week @ 2019-07-31 7/week @ 2019-08-07 12/week @ 2019-08-14 13/week @ 2019-08-21 15/week @ 2019-08-28 18/week @ 2019-09-04 7/week @ 2019-09-11 27/week @ 2019-09-18 243/week @ 2019-09-25 121/week @ 2019-10-02

158 downloads per month

MIT license

9KB
196 lines

rust-tilejson

Build Status tilejson on Crates.io

Documentation

Library for serializing the TileJSON file format

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);
}

Dependencies

~1.1–1.6MB
~36K SLoC