Trait geo::algorithm::extremes::ExtremeIndices [] [src]

pub trait ExtremeIndices<T: Float + Signed> {
    fn extreme_indices(&self) -> Result<Extremes, ()>;
}

Required Methods

Find the extreme x and y indices of a convex Polygon

The polygon must be convex and properly (ccw) oriented.

use geo::{Point, LineString, Polygon};
use geo::extremes::ExtremeIndices;
// a diamond shape
let points_raw = vec![(1.0, 0.0), (2.0, 1.0), (1.0, 2.0), (0.0, 1.0), (1.0, 0.0)];
let points = points_raw.iter().map(|e| Point::new(e.0, e.1)).collect::<Vec<_>>();
let poly = Polygon::new(LineString(points), vec![]);
// Polygon is both convex and oriented counter-clockwise
let extremes = poly.extreme_indices().unwrap();
assert_eq!(extremes.ymin, 0);
assert_eq!(extremes.xmax, 1);
assert_eq!(extremes.ymax, 2);
assert_eq!(extremes.xmin, 3);

Implementors