pub trait CoordsIter<'a> {
    type Iter: Iterator<Item = Coord<Self::Scalar>>;
    type ExteriorIter: Iterator<Item = Coord<Self::Scalar>>;
    type Scalar: CoordNum;

    // Required methods
    fn coords_iter(&'a self) -> Self::Iter;
    fn coords_count(&'a self) -> usize;
    fn exterior_coords_iter(&'a self) -> Self::ExteriorIter;
}
Expand description

Iterate over geometry coordinates.

Required Associated Types§

Required Methods§

source

fn coords_iter(&'a self) -> Self::Iter

Iterate over all exterior and (if any) interior coordinates of a geometry.

Examples
use geo::coords_iter::CoordsIter;

let multi_point = geo::MultiPoint::new(vec![
    geo::point!(x: -10., y: 0.),
    geo::point!(x: 20., y: 20.),
    geo::point!(x: 30., y: 40.),
]);

let mut iter = multi_point.coords_iter();
assert_eq!(Some(geo::coord! { x: -10., y: 0. }), iter.next());
assert_eq!(Some(geo::coord! { x: 20., y: 20. }), iter.next());
assert_eq!(Some(geo::coord! { x: 30., y: 40. }), iter.next());
assert_eq!(None, iter.next());
source

fn coords_count(&'a self) -> usize

Return the number of coordinates in a geometry.

Examples
use geo::coords_iter::CoordsIter;
use geo::line_string;

let ls = line_string![
    (x: 1., y: 2.),
    (x: 23., y: 82.),
    (x: -1., y: 0.),
];

assert_eq!(3, ls.coords_count());
source

fn exterior_coords_iter(&'a self) -> Self::ExteriorIter

Iterate over all exterior coordinates of a geometry.

Examples
use geo::coords_iter::CoordsIter;
use geo::polygon;

// a diamond shape
let polygon = polygon![
    exterior: [
        (x: 1.0, y: 0.0),
        (x: 2.0, y: 1.0),
        (x: 1.0, y: 2.0),
        (x: 0.0, y: 1.0),
        (x: 1.0, y: 0.0),
    ],
    interiors: [
        [
            (x: 1.0, y: 0.5),
            (x: 0.5, y: 1.0),
            (x: 1.0, y: 1.5),
            (x: 1.5, y: 1.0),
            (x: 1.0, y: 0.5),
        ],
    ],
];

let mut iter = polygon.exterior_coords_iter();
assert_eq!(Some(geo::coord! { x: 1., y: 0. }), iter.next());
assert_eq!(Some(geo::coord! { x: 2., y: 1. }), iter.next());
assert_eq!(Some(geo::coord! { x: 1., y: 2. }), iter.next());
assert_eq!(Some(geo::coord! { x: 0., y: 1. }), iter.next());
assert_eq!(Some(geo::coord! { x: 1., y: 0. }), iter.next());
assert_eq!(None, iter.next());

Implementors§

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for Geometry<T>

§

type Iter = GeometryCoordsIter<'a, T>

§

type ExteriorIter = GeometryExteriorCoordsIter<'a, T>

§

type Scalar = T

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for GeometryCollection<T>

§

type Iter = Box<dyn Iterator<Item = Coord<T>> + 'a, Global>

§

type ExteriorIter = Box<dyn Iterator<Item = Coord<T>> + 'a, Global>

§

type Scalar = T

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for LineString<T>

§

type Iter = Copied<Iter<'a, Coord<T>>>

§

type ExteriorIter = <LineString<T> as CoordsIter<'a>>::Iter

§

type Scalar = T

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for MultiLineString<T>

§

type Iter = Flatten<MapCoordsIter<'a, T, Iter<'a, LineString<T>>, LineString<T>>>

§

type ExteriorIter = <MultiLineString<T> as CoordsIter<'a>>::Iter

§

type Scalar = T

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for MultiPoint<T>

§

type Iter = Flatten<MapCoordsIter<'a, T, Iter<'a, Point<T>>, Point<T>>>

§

type ExteriorIter = <MultiPoint<T> as CoordsIter<'a>>::Iter

§

type Scalar = T

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for MultiPolygon<T>

§

type Iter = Flatten<MapCoordsIter<'a, T, Iter<'a, Polygon<T>>, Polygon<T>>>

§

type ExteriorIter = Flatten<MapExteriorCoordsIter<'a, T, Iter<'a, Polygon<T>>, Polygon<T>>>

§

type Scalar = T

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for Polygon<T>

§

type Iter = Chain<Copied<Iter<'a, Coord<T>>>, Flatten<MapCoordsIter<'a, T, Iter<'a, LineString<T>>, LineString<T>>>>

§

type ExteriorIter = Copied<Iter<'a, Coord<T>>>

§

type Scalar = T

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for Rect<T>

§

type Iter = Chain<Chain<Chain<Once<Coord<T>>, Once<Coord<T>>>, Once<Coord<T>>>, Once<Coord<T>>>

§

type ExteriorIter = <Rect<T> as CoordsIter<'a>>::Iter

§

type Scalar = T

source§

impl<'a, T: CoordNum + 'a> CoordsIter<'a> for Triangle<T>

§

type Iter = Chain<Chain<Once<Coord<T>>, Once<Coord<T>>>, Once<Coord<T>>>

§

type ExteriorIter = <Triangle<T> as CoordsIter<'a>>::Iter

§

type Scalar = T

source§

impl<'a, T: CoordNum> CoordsIter<'a> for Line<T>

§

type Iter = Chain<Once<Coord<T>>, Once<Coord<T>>>

§

type ExteriorIter = <Line<T> as CoordsIter<'a>>::Iter

§

type Scalar = T

source§

impl<'a, T: CoordNum> CoordsIter<'a> for Point<T>

§

type Iter = Once<Coord<T>>

§

type ExteriorIter = <Point<T> as CoordsIter<'a>>::Iter

§

type Scalar = T