Crate geojson [] [src]

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 std::collections::HashMap;
use rustc_serialize::json::ToJson;
use geojson::{Feature, GeoJson, Geometry, Value};

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

let mut properties = HashMap::new();
properties.insert(
    String::from("name"),
    "Firestone Grill".to_json(),
);

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

let geojson_string = geojson.to_string();

Structs

Error

Error when reading a GeoJSON object from a str or Object

Feature

Feature Objects

FeatureCollection

Feature Collection Objects

Geometry

Geometry Objects

Enums

Crs

Coordinate Reference System Objects

GeoJson

GeoJSON Objects

Value

The underlying Geometry value

Type Definitions

Bbox

Bounding Boxes

LineStringType
PointType
PolygonType
Position

Positions