Normalized

Trait Normalized 

Source
pub trait Normalized<T: Float> {
    // Required method
    fn normalized(&self) -> Self;
}

Required Methods§

Source

fn normalized(&self) -> Self

This trait returns a new geo-types Polygon/Multipolygon that follows the OGC winding rules

The rust geo and geo-types crates are not as strict as the OGC guidelines, and allow for polygons with inner and outer rings in any winding order. This trait returns a Polygon/Multipolygon where all outer rings are clockwise, and all inner rings are anti-clockwise.

§Examples
// Anti-clockwise winding order for outer ring
use geo::polygon;
use geo_normalized::Normalized;
let bad = polygon![
        (x: 1.0, y: 1.0),
        (x: 4.0, y: 1.0),
        (x: 4.0, y: 4.0),
        (x: 1.0, y: 4.0),
        (x: 1.0, y: 1.0),
        ];

// Clockwise winding order for outer ring
let good = polygon![
        (x: 1.0, y: 1.0),
        (x: 1.0, y: 4.0),
        (x: 4.0, y: 4.0),
        (x: 4.0, y: 1.0),
        (x: 1.0, y: 1.0),
        ];

let norm = bad.normalized();
// norm should have the same points and shape as `bad` but in the valid winding order
assert_eq!(norm, good);

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<T: Float + CoordNum + GeoNum> Normalized<T> for GeometryCollection<T>

Geometry Collections

Source§

fn normalized(&self) -> Self

Source§

impl<T: Float + CoordNum + GeoNum> Normalized<T> for MultiPolygon<T>

Polygons

Source§

fn normalized(&self) -> Self

Source§

impl<T: Float + CoordNum + GeoNum> Normalized<T> for Polygon<T>

Source§

fn normalized(&self) -> Self

Implementors§