Skip to content

Instantly share code, notes, and snippets.

Created May 11, 2017 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a6ba7c1052489afc8ceae0005ef03139 to your computer and use it in GitHub Desktop.
Save anonymous/a6ba7c1052489afc8ceae0005ef03139 to your computer and use it in GitHub Desktop.
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