#geojson #gis #json #geo

geojson

Library for serializing the GeoJSON vector GIS file format

34 releases (16 breaking)

✓ Uses Rust 2018 edition

0.16.0 May 5, 2019
0.15.0 Feb 17, 2019
0.14.0 Jan 13, 2019
0.13.0 Nov 11, 2018
0.0.1 Dec 4, 2014

#21 in Encoding

Download history 328/week @ 2019-01-21 320/week @ 2019-01-28 303/week @ 2019-02-04 209/week @ 2019-02-11 278/week @ 2019-02-18 300/week @ 2019-02-25 366/week @ 2019-03-04 218/week @ 2019-03-11 365/week @ 2019-03-18 893/week @ 2019-03-25 318/week @ 2019-04-01 397/week @ 2019-04-08 343/week @ 2019-04-15 310/week @ 2019-04-22 276/week @ 2019-04-29

1,487 downloads per month
Used in 24 crates (18 directly)

MIT/Apache

149KB
2K SLoC

geojson

Documentation

Library for serializing the GeoJSON vector GIS file format

Minimum Rust Version

This library requires a minimum Rust version of 1.34 (released April 11 2019)

Examples

Reading

use geojson::GeoJson;

let geojson_str = r#"
{
    "type": "Feature",
    "properties": {
        "name": "Firestone Grill"
    },
    "geometry": {
        "type": "Point",
        "coordinates": [-120.66029,35.2812]
    }
}
"#;

let geojson = geojson_str.parse::<GeoJson>().unwrap();

Writing

use geojson::{Feature, GeoJson, Geometry, Value};
use serde_json::{Map, to_value};

let geometry = Geometry::new(
    Value::Point(vec![-120.66029,35.2812])
);

let mut properties = Map::new();
properties.insert(
    String::from("name"),
    to_value("Firestone Grill").unwrap(),
);

let geojson = GeoJson::Feature(Feature {
    bbox: None,
    geometry: Some(geometry),
    id: None,
    properties: Some(properties),
    foreign_members: None,
});

let geojson_string = geojson.to_string();

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

~1MB
~17K SLoC