Trait Simplify

Source
pub trait Simplify<T, Epsilon = T> {
    // Required method
    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§

Source

fn simplify(&self, epsilon: &T) -> Self
where T: GeoFloat,

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

§Examples
use geo::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)

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.

Implementors§

Source§

impl<T> Simplify<T> for LineString<T>
where T: GeoFloat,

Source§

impl<T> Simplify<T> for MultiLineString<T>
where T: GeoFloat,

Source§

impl<T> Simplify<T> for MultiPolygon<T>
where T: GeoFloat,

Source§

impl<T> Simplify<T> for Polygon<T>
where T: GeoFloat,