Trait geo::algorithm::coords_iter::CoordsIter[][src]

pub trait CoordsIter<'a> {
    type Iter: Iterator<Item = Coordinate<Self::Scalar>>;
    type ExteriorIter: Iterator<Item = Coordinate<Self::Scalar>>;
    type Scalar: CoordNum;
    fn coords_iter(&'a self) -> Self::Iter;
fn coords_count(&'a self) -> usize;
fn exterior_coords_iter(&'a self) -> Self::ExteriorIter; }

Iterate over geometry coordinates.

Associated Types

Loading content...

Required methods

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

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

Examples

use geo::coords_iter::CoordsIter;

let multi_point = geo::MultiPoint(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::Coordinate { x: -10., y: 0. }), iter.next());
assert_eq!(Some(geo::Coordinate { x: 20., y: 20. }), iter.next());
assert_eq!(Some(geo::Coordinate { x: 30., y: 40. }), iter.next());
assert_eq!(None, iter.next());

fn coords_count(&'a self) -> usize[src]

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

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

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::Coordinate { x: 1., y: 0. }), iter.next());
assert_eq!(Some(geo::Coordinate { x: 2., y: 1. }), iter.next());
assert_eq!(Some(geo::Coordinate { x: 1., y: 2. }), iter.next());
assert_eq!(Some(geo::Coordinate { x: 0., y: 1. }), iter.next());
assert_eq!(Some(geo::Coordinate { x: 1., y: 0. }), iter.next());
assert_eq!(None, iter.next());
Loading content...

Implementors

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

type Iter = GeometryCoordsIter<'a, T>

type ExteriorIter = GeometryExteriorCoordsIter<'a, T>

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the Geometry.

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

type Iter = Box<dyn Iterator<Item = Coordinate<T>> + 'a>

type ExteriorIter = Box<dyn Iterator<Item = Coordinate<T>> + 'a>

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the GeometryCollection.

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

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

type ExteriorIter = Self::Iter

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the LineString.

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

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

type ExteriorIter = Self::Iter

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the MultiLineString.

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

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

type ExteriorIter = Self::Iter

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the MultiPoint.

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

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

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the MultiPolygon.

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

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

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

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the Polygon.

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

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

type ExteriorIter = Self::Iter

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the Rect.

Note: Although a Rect is represented by two coordinates, it is spatially represented by four, so this method returns 4.

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

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

type ExteriorIter = Self::Iter

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the Triangle.

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

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

type ExteriorIter = Self::Iter

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the Line.

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

type Iter = Once<Coordinate<T>>

type ExteriorIter = Self::Iter

type Scalar = T

fn coords_count(&'a self) -> usize[src]

Return the number of coordinates in the Point.

Loading content...