Trait CoordsIter

Source
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());

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

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

Source§

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

Source§

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]

Source§

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

Source§

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

Source§

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>

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T

Source§

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

Source§

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

Source§

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

Source§

type Scalar = T