vortex_geo/extension/
mod.rs1pub(crate) mod coordinate;
5mod point;
6mod wkb;
7
8use std::fmt::Display;
9
10pub use point::*;
11pub use wkb::*;
12
13#[derive(Clone, PartialEq, Eq, Hash, prost::Message)]
19pub struct GeoMetadata {
20 #[prost(optional, string, tag = "1")]
21 pub crs: Option<String>,
22}
23
24impl Display for GeoMetadata {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 match self.crs.as_ref() {
27 Some(crs) => write!(f, "Geometry(crs={crs})"),
28 None => write!(f, "Geometry(unreferenced)"),
29 }
30 }
31}
32
33#[cfg(test)]
34mod tests {
35 use prost::Message;
36
37 use crate::extension::GeoMetadata;
38
39 #[test]
40 fn test_metadata() {
41 let meta = GeoMetadata {
42 crs: Some("EPSG:4326".to_string()),
43 };
44
45 assert_eq!(meta.to_string(), "Geometry(crs=EPSG:4326)");
46 let bytes = meta.encode_to_vec();
48 let decoded = GeoMetadata::decode(bytes.as_slice()).unwrap();
49 assert_eq!(decoded, meta);
50 }
51}