diff --git a/src/traits.rs b/src/traits.rs index ae0eb84348..1695920591 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -6,3 +6,49 @@ pub trait ToGeo { fn to_geo(&self) -> Geometry; } + +pub trait Point { + fn x(&self) -> f64; + fn y(&self) -> f64; + fn opt_z(&self) -> Option { + None + } + fn opt_m(&self) -> Option { + None + } +} + +pub trait LineString<'a> { + type ItemType: 'a + Point; + type Iter: Iterator; + + fn points(&'a self) -> Self::Iter; +} + +pub trait Polygon<'a> { + type ItemType: 'a + LineString<'a>; + type Iter: Iterator; + + fn rings(&'a self) -> Self::Iter; +} + +pub trait MultiPoint<'a> { + type ItemType: 'a + Point; + type Iter: Iterator; + + fn points(&'a self) -> Self::Iter; +} + +pub trait MultiLineString<'a> { + type ItemType: 'a + LineString<'a>; + type Iter: Iterator; + + fn lines(&'a self) -> Self::Iter; +} + +pub trait MultiPolygon<'a> { + type ItemType: 'a + Polygon<'a>; + type Iter: Iterator; + + fn polygons(&'a self) -> Self::Iter; +}