logo
pub trait Simplify<T, Epsilon = T> {
    fn simplify(&self, epsilon: &T) -> Self
    where
        T: GeoFloat
; }
Expand description

Simplifies a geometry.

The Ramer–Douglas–Peucker algorithm simplifies a linestring. Polygons are simplified by running the RDP algorithm on all their constituent rings. This may result in invalid Polygons, and has no guarantee of preserving topology.

Multi* objects are simplified by simplifying all their constituent geometries individually.

An epsilon less than or equal to zero will return an unaltered version of the geometry.

Required Methods

Returns the simplified representation of a geometry, using the Ramer–Douglas–Peucker algorithm

Examples
use geo::algorithm::simplify::Simplify;
use geo::line_string;

let line_string = line_string![
    (x: 0.0, y: 0.0),
    (x: 5.0, y: 4.0),
    (x: 11.0, y: 5.5),
    (x: 17.3, y: 3.2),
    (x: 27.8, y: 0.1),
];

let simplified = line_string.simplify(&1.0);

let expected = line_string![
    (x: 0.0, y: 0.0),
    (x: 5.0, y: 4.0),
    (x: 11.0, y: 5.5),
    (x: 27.8, y: 0.1),
];

assert_eq!(expected, simplified)

Implementors