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

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

Iterate over geometry coordinates.

Required Associated Types§

source

type Iter<'a>: Iterator<Item = Coord<Self::Scalar>> where Self: 'a

source

type ExteriorIter<'a>: Iterator<Item = Coord<Self::Scalar>> where Self: 'a

source

type Scalar: CoordNum

Required Methods§

source

fn coords_iter(&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(&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(&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());

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, T: CoordNum> CoordsIter for &'a [Coord<T>]

§

type Iter<'b> = Copied<Iter<'b, Coord<T>>> where T: 'b, 'a: 'b

§

type ExteriorIter<'b> = <&'a [Coord<T>] as CoordsIter>::Iter<'b> where T: 'b, 'a: 'b

§

type Scalar = T

source§

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

source§

fn coords_count(&self) -> usize

source§

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

source§

impl<const N: usize, T: CoordNum> CoordsIter for [Coord<T>; N]

§

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

§

type ExteriorIter<'a> = <[Coord<T>; N] as CoordsIter>::Iter<'a> where T: 'a

§

type Scalar = T

source§

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

source§

fn coords_count(&self) -> usize

source§

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

Implementors§

source§

impl<T: CoordNum> CoordsIter for Geometry<T>

§

type Iter<'a> = GeometryCoordsIter<'a, T> where T: 'a

§

type ExteriorIter<'a> = GeometryExteriorCoordsIter<'a, T> where T: 'a

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for GeometryCollection<T>

§

type Iter<'a> = Box<dyn Iterator<Item = Coord<T>> + 'a> where T: 'a

§

type ExteriorIter<'a> = Box<dyn Iterator<Item = Coord<T>> + 'a> where T: 'a

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for Line<T>

§

type Iter<'a> = Chain<Once<Coord<T>>, Once<Coord<T>>> where T: 'a

§

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

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for LineString<T>

§

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

§

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

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for MultiLineString<T>

§

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

§

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

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for MultiPoint<T>

§

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

§

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

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for MultiPolygon<T>

§

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

§

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

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for Point<T>

§

type Iter<'a> = Once<Coord<T>> where T: 'a

§

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

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for Polygon<T>

§

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

§

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

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for Rect<T>

§

type Iter<'a> = Chain<Chain<Chain<Once<Coord<T>>, Once<Coord<T>>>, Once<Coord<T>>>, Once<Coord<T>>> where T: 'a

§

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

§

type Scalar = T

source§

impl<T: CoordNum> CoordsIter for Triangle<T>

§

type Iter<'a> = Chain<Chain<Once<Coord<T>>, Once<Coord<T>>>, Once<Coord<T>>> where T: 'a

§

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

§

type Scalar = T