#geojson #gis #json #geo

geojson

Library for serializing the GeoJSON vector GIS file format

33 releases (15 breaking)

0.15.0 Feb 17, 2019
0.13.0 Nov 11, 2018
0.11.1 Jul 8, 2018
0.9.1 Nov 29, 2017
0.0.1 Dec 4, 2014

#7 in Science

Download history 462/week @ 2018-11-04 735/week @ 2018-11-11 316/week @ 2018-11-18 389/week @ 2018-11-25 434/week @ 2018-12-02 359/week @ 2018-12-09 268/week @ 2018-12-16 279/week @ 2018-12-23 74/week @ 2018-12-30 259/week @ 2019-01-06 284/week @ 2019-01-13 281/week @ 2019-01-20 344/week @ 2019-01-27 309/week @ 2019-02-03 205/week @ 2019-02-10

1,253 downloads per month
Used in 22 crates (17 directly)

MIT/Apache

129KB
1.5K SLoC

geojson

Build Status geojson on Crates.io

Documentation

Library for serializing the GeoJSON vector GIS file format

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
~19K SLoC