use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReferenceSystem {
pub reference_system_identifier: Option<Identifier>,
pub reference_system_type: Option<ReferenceSystemType>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Identifier {
pub code: String,
pub code_space: Option<String>,
pub version: Option<String>,
pub authority: Option<String>,
}
impl Identifier {
pub fn new(code: impl Into<String>) -> Self {
Self {
code: code.into(),
code_space: None,
version: None,
authority: None,
}
}
pub fn epsg(code: u32) -> Self {
Self {
code: code.to_string(),
code_space: Some("EPSG".to_string()),
version: None,
authority: Some("EPSG".to_string()),
}
}
pub fn wkt(wkt: impl Into<String>) -> Self {
Self {
code: wkt.into(),
code_space: Some("WKT".to_string()),
version: None,
authority: None,
}
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum ReferenceSystemType {
Compound,
Engineering,
Geographic2D,
Geographic3D,
Geocentric,
Projected,
Temporal,
Vertical,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CoordinateSystemAxis {
pub axis_abbreviation: String,
pub axis_direction: AxisDirection,
pub axis_unit: String,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum AxisDirection {
East,
West,
North,
South,
Up,
Down,
Future,
Past,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Datum {
pub name: String,
pub datum_type: DatumType,
pub anchor_point: Option<String>,
pub realization_epoch: Option<chrono::DateTime<chrono::Utc>>,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum DatumType {
Geodetic,
Vertical,
Engineering,
Temporal,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Ellipsoid {
pub name: String,
pub semi_major_axis: f64,
pub second_defining_parameter: SecondDefiningParameter,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum SecondDefiningParameter {
SemiMinorAxis(f64),
InverseFlattening(f64),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PrimeMeridian {
pub name: String,
pub greenwich_longitude: f64,
}
impl Default for PrimeMeridian {
fn default() -> Self {
Self {
name: "Greenwich".to_string(),
greenwich_longitude: 0.0,
}
}
}