Skip to content

Instantly share code, notes, and snippets.

Created May 11, 2017
Embed
What would you like to do?
Rust code shared from the playground
use std::collections::BTreeMap as Map;
pub type Canada = FeatureCollection;
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct FeatureCollection {
#[serde(rename = "type")]
pub obj_type: ObjType,
pub features: Vec<Feature>,
}
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Feature {
#[serde(rename = "type")]
pub obj_type: ObjType,
pub properties: Map<String, String>,
pub geometry: Geometry,
}
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Geometry {
#[serde(rename = "type")]
pub obj_type: ObjType,
pub coordinates: Vec<Vec<(Latitude, Longitude)>>
}
pub type Latitude = f32;
pub type Longitude = f32;
#[derive(Serialize, Deserialize)]
pub enum ObjType {
FeatureCollection,
Feature,
Polygon,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment