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.
A larger epsilon
means being more aggressive about removing points with less concern for
maintaining the existing shape.
Specifically, points closer than epsilon
distance from the simplified output may be
discarded.
An epsilon
less than or equal to zero will return an unaltered version of the geometry.
Required Methods§
sourcefn simplify(&self, epsilon: &T) -> Selfwhere
T: GeoFloat,
fn simplify(&self, epsilon: &T) -> Selfwhere
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)
Object Safety§
This trait is not object safe.