Trait geo::algorithm::orient::Orient   [−][src]
Required methods
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::orient::{Direction, Orient};
use geo::polygon;
// a diamond shape
let polygon = polygon![
    // exterior oriented clockwise
    exterior: [
        (x: 1.0, y: 0.0),
        (x: 0.0, y: 1.0),
        (x: 1.0, y: 2.0),
        (x: 2.0, y: 1.0),
        (x: 1.0, y: 0.0),
    ],
    // interior oriented counter-clockwise
    interiors: [
        [
            (x: 1.0, y: 0.5),
            (x: 1.5, y: 1.0),
            (x: 1.0, y: 1.5),
            (x: 0.5, y: 1.0),
            (x: 1.0, y: 0.5),
        ],
    ],
];
let oriented = polygon.orient(Direction::Default);
// a diamond shape
let expected = polygon![
    // exterior oriented counter-clockwise
    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),
    ],
    // interior oriented clockwise
    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),
        ],
    ],
];
assert_eq!(expected, oriented);