/// Coordinate reference system.
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct CoordinateSystem {
#[serde(flatten)]
pub base: super::IdentifiedObject,
/// A Uniform Resource Name (URN) for the coordinate reference system (crs) used to define 'Location.PositionPoints'. An example would be the European Petroleum Survey Group (EPSG) code for a coordinate reference system, defined in URN under the Open Geospatial Consortium (OGC) namespace as: urn:ogc:def:crs:EPSG::XXXX, where XXXX is an EPSG code (a full list of codes can be found at the EPSG Registry web site http://www.epsg-registry.org/). To define the coordinate system as being WGS84 (latitude, longitude) using an EPSG OGC, this attribute would be urn:ogc:def:crs:EPSG::4236. A profile should limit this code to a set of allowed URNs agreed to by all sending and receiving parties.
pub crs_urn: String,
}
impl crate::base::CimElement for CoordinateSystem {
fn mrid(&self) -> &str { &self.base.id }
fn type_name(&self) -> &'static str { "CoordinateSystem" }
fn as_any(&self) -> &dyn std::any::Any { self }
fn to_json_value(&self) -> serde_json::Value {
serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
}
fn to_block(&self) -> crate::base::RdfBlock {
let mut block = self.base.to_block();
block.type_name = "CoordinateSystem".to_string();
if !self.crs_urn.is_empty() {
block.fields.insert("CoordinateSystem.crsUrn".into(), crate::base::FieldValue::Text(self.crs_urn.clone()));
}
block
}
}
impl CoordinateSystem {
pub fn from_block(b: &crate::base::RdfBlock) -> Self {
let mut obj = Self::default();
obj.base.id.clone_from(&b.mrid);
for (key, val) in &b.fields {
match key.as_str() {
"CoordinateSystem.crsUrn" => {
match val {
crate::base::FieldValue::Text(sv) => { obj.crs_urn = sv.clone(); }
crate::base::FieldValue::TextList(svs) => {
if let Some(sv) = svs.last() { obj.crs_urn = sv.clone(); }
}
_ => {}
}
}
"IdentifiedObject.description" => {
match val {
crate::base::FieldValue::Text(sv) => { obj.base.description = sv.clone(); }
crate::base::FieldValue::TextList(svs) => {
if let Some(sv) = svs.last() { obj.base.description = sv.clone(); }
}
_ => {}
}
}
"IdentifiedObject.energyIdentCodeEic" => {
match val {
crate::base::FieldValue::Text(sv) => { obj.base.energy_ident_code_eic = sv.clone(); }
crate::base::FieldValue::TextList(svs) => {
if let Some(sv) = svs.last() { obj.base.energy_ident_code_eic = sv.clone(); }
}
_ => {}
}
}
"IdentifiedObject.mRID" => {
match val {
crate::base::FieldValue::Text(sv) => { obj.base.m_rid = sv.clone(); }
crate::base::FieldValue::TextList(svs) => {
if let Some(sv) = svs.last() { obj.base.m_rid = sv.clone(); }
}
_ => {}
}
}
"IdentifiedObject.name" => {
match val {
crate::base::FieldValue::Text(sv) => { obj.base.name = sv.clone(); }
crate::base::FieldValue::TextList(svs) => {
if let Some(sv) = svs.last() { obj.base.name = sv.clone(); }
}
_ => {}
}
}
"IdentifiedObject.shortName" => {
match val {
crate::base::FieldValue::Text(sv) => { obj.base.short_name = sv.clone(); }
crate::base::FieldValue::TextList(svs) => {
if let Some(sv) = svs.last() { obj.base.short_name = sv.clone(); }
}
_ => {}
}
}
_ => {}
}
}
obj
}
}