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

Loading…
Cancel
Save