mod layer;
mod pwd;
pub use layer::{
ElementKey, GEO_LAYER_EXTENSION, GEO_LAYER_VERSION, GeoApplyReport, GeoApplyTarget, GeoFeature,
GeoGeometry, GeoLayer, GeoParsed, GeoTarget, apply_geo_features,
};
pub use pwd::{
PWD_MERCATOR_K, apply_substation_points, geo_layer_from_pwd, pwd_mercator_to_lonlat,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct Location {
pub x: f64,
pub y: f64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub kind: Option<CoordsKind>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum CoordsKind {
Source,
Synthetic,
Manual,
Derived,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct GeoMeta {
#[serde(flatten)]
pub space: CoordinateSpace,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub kind: Option<CoordsKind>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(tag = "space", rename_all = "snake_case")]
#[non_exhaustive]
pub enum CoordinateSpace {
Geographic {
#[serde(default, skip_serializing_if = "Option::is_none")]
crs: Option<String>,
},
Projected {
#[serde(default, skip_serializing_if = "Option::is_none")]
crs: Option<String>,
},
Diagram {
#[serde(default, skip_serializing_if = "Option::is_none")]
canvas: Option<Canvas>,
},
Unknown,
}
impl CoordinateSpace {
#[must_use]
pub fn token(&self) -> &'static str {
match self {
CoordinateSpace::Geographic { .. } => "geographic",
CoordinateSpace::Projected { .. } => "projected",
CoordinateSpace::Diagram { .. } => "diagram",
_ => "unknown",
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct Canvas {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub width: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub height: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub units: Option<String>,
}