pull/745/head
Yuri Astrakhan 1 year ago
parent a5392a42b2
commit 58914523a2
  1. 17
      lib/oxsdatatypes/src/geopoint.rs

@ -1,5 +1,6 @@
use std::str::FromStr;
use wkt::Wkt;
use wkt::{Geometry, Wkt};
// use std::time::Geo as StdDuration;
/// [XML Schema `duration` datatype](https://www.w3.org/TR/xmlschema11-2/#duration)
@ -10,6 +11,12 @@ pub struct GeoPoint {
geom: wkt::Wkt<f64>,
}
#[derive(Error, Debug)]
enum GeoPointError {
#[error("WKT type {0} is not supported")]
UnsupportedWktType(String),
}
type WktError = &'static str;
impl GeoPoint {
@ -23,9 +30,11 @@ impl FromStr for GeoPoint {
type Err = WktError;
fn from_str(input: &str) -> Result<Self, Self::Err> {
Ok(Self {
geom: Wkt::from_str(input)?,
})
let geo = Wkt::from_str(input)?;
let Geometry::Point(point) = geo.item else {
return Err("Not a point");
}
Ok(Self { geom: geo })
}
}
//

Loading…
Cancel
Save