Adapted to Mercator's JSON API format

This commit is contained in:
2019-09-03 15:52:58 +02:00
parent 58d3e1f0a7
commit 8e8ec73395

View File

@@ -3,26 +3,21 @@ use std::io::BufWriter;
use serde::Serialize;
#[derive(Clone, Debug, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Space {
pub name: String,
pub system: CoordinateSystem,
}
#[derive(Clone, Debug, Serialize)]
pub struct CoordinateSystem {
pub origin: Vec<f64>,
pub axes: Vec<Axis>,
}
#[derive(Clone, Debug, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Axis {
pub measurement_unit: String,
pub graduation: Graduation,
pub unit_vector: Vec<f64>,
}
#[derive(Clone, Debug, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Graduation {
pub set: String,
pub minimum: f64,
@@ -30,12 +25,30 @@ pub struct Graduation {
pub steps: u64,
}
#[derive(Clone, Debug, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SpatialObject {
pub properties: Properties,
pub shapes: Vec<Shape>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Shape {
#[serde(rename = "type")]
pub type_name: String,
#[serde(rename = "space")]
pub reference_space: String,
pub vertices: Vec<Point>,
}
type Point = Vec<f64>;
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Properties {
#[serde(rename = "type")]
pub type_name: String,
pub id: String,
}
impl SpatialObject {
pub fn new(shapes: Vec<Shape>, id: String) -> Self {
SpatialObject {
@@ -48,24 +61,6 @@ impl SpatialObject {
}
}
#[derive(Clone, Debug, Serialize)]
pub struct Shape {
#[serde(rename = "type")]
pub type_name: String,
#[serde(rename = "space")]
pub reference_space: String,
pub vertices: Vec<Point>,
}
type Point = Vec<f64>;
#[derive(Clone, Debug, Serialize)]
pub struct Properties {
#[serde(rename = "type")]
pub type_name: String,
pub id: String,
}
mod json {
use super::*;