Skip to content

Commit

Permalink
Add traits for each geometry type.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Jan 24, 2017
1 parent 6dee3a2 commit 04c96e9
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,49 @@ pub trait ToGeo<T: Float>
{
fn to_geo(&self) -> Geometry<T>;
}

pub trait Point {
fn x(&self) -> f64;
fn y(&self) -> f64;
fn opt_z(&self) -> Option<f64> {
None
}
fn opt_m(&self) -> Option<f64> {
None
}
}

pub trait LineString<'a> {
type ItemType: 'a + Point;
type Iter: Iterator<Item=&'a Self::ItemType>;

fn points(&'a self) -> Self::Iter;
}

pub trait Polygon<'a> {
type ItemType: 'a + LineString<'a>;
type Iter: Iterator<Item=&'a Self::ItemType>;

fn rings(&'a self) -> Self::Iter;
}

pub trait MultiPoint<'a> {
type ItemType: 'a + Point;
type Iter: Iterator<Item=&'a Self::ItemType>;

fn points(&'a self) -> Self::Iter;
}

pub trait MultiLineString<'a> {
type ItemType: 'a + LineString<'a>;
type Iter: Iterator<Item=&'a Self::ItemType>;

fn lines(&'a self) -> Self::Iter;
}

pub trait MultiPolygon<'a> {
type ItemType: 'a + Polygon<'a>;
type Iter: Iterator<Item=&'a Self::ItemType>;

fn polygons(&'a self) -> Self::Iter;
}

0 comments on commit 04c96e9

Please sign in to comment.