Created
May 11, 2017 13:37
-
-
Save anonymous/a6ba7c1052489afc8ceae0005ef03139 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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