[][src]Trait geo::algorithm::orient::Orient

pub trait Orient<T> {
    fn orient(&self, orientation: Direction) -> Self;
}

Required methods

fn orient(&self, orientation: Direction) -> Self

Orients a Polygon's exterior and interior rings according to convention

By default, the exterior ring of a Polygon is oriented counter-clockwise, and any interior rings are oriented clockwise.

Examples

use geo::{Point, LineString, Polygon};
use geo::orient::{Orient, Direction};
// a diamond shape, oriented clockwise outside
let points_ext = vec![(1.0, 0.0), (0.0, 1.0), (1.0, 2.0), (2.0, 1.0), (1.0, 0.0)];
// counter-clockwise interior
let points_int = vec![(1.0, 0.5), (1.5, 1.0), (1.0, 1.5), (0.5, 1.0), (1.0, 0.5)];
let poly = Polygon::new(LineString::from(points_ext), vec![LineString::from(points_int)]);
// a diamond shape, oriented counter-clockwise outside,
let oriented_ext = vec![(1.0, 0.0), (2.0, 1.0), (1.0, 2.0), (0.0, 1.0), (1.0, 0.0)];
let oriented_ext_ls = LineString::from(oriented_ext);
// clockwise interior
let oriented_int = vec![(1.0, 0.5), (0.5, 1.0), (1.0, 1.5), (1.5, 1.0), (1.0, 0.5)];
let oriented_int_ls = LineString::from(oriented_int);
// build corrected Polygon
let oriented = poly.orient(Direction::Default);
assert_eq!(oriented.exterior().0, oriented_ext_ls.0);
assert_eq!(oriented.interiors()[0].0, oriented_int_ls.0);
Loading content...

Implementors

impl<T> Orient<T> for MultiPolygon<T> where
    T: CoordinateType
[src]

impl<T> Orient<T> for Polygon<T> where
    T: CoordinateType
[src]

Loading content...