Created
May 26, 2020 00:36
-
-
Save anacrolix/92b6e343dd8f0e80685e1314256c3e6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 crate::common::*; | |
use serde::Deserialize; | |
pub fn decode(path: &str) -> Result<Vec<LatLonBox>> { | |
let f = std::fs::File::open(path)?; | |
let mut zip_archive = zip::ZipArchive::new(f)?; | |
let doc_file = zip_archive.by_name("doc.kml")?; | |
let doc: KmlDoc = serde_xml_rs::from_reader(doc_file)?; | |
Ok(doc | |
.document | |
.ground_overlay | |
.into_iter() | |
.map(|x| x.lat_lon_box) | |
.collect()) | |
} | |
#[derive(Deserialize, Debug)] | |
pub struct LatLonBox { | |
north: f64, | |
south: f64, | |
east: f64, | |
west: f64, | |
} | |
#[derive(Deserialize)] | |
#[serde(rename_all = "PascalCase")] | |
struct KmlDoc { | |
document: Document, | |
} | |
#[derive(Deserialize)] | |
#[serde(rename_all = "PascalCase")] | |
struct Document { | |
ground_overlay: Vec<GroundOverlay>, | |
} | |
#[derive(Deserialize)] | |
#[serde(rename_all = "PascalCase")] | |
struct GroundOverlay { | |
lat_lon_box: LatLonBox, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment