Trait geo::algorithm::simplify::Simplify [] [src]

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

Simplifies a geometry.

The Ramer–Douglas–Peucker algorithm simplifes 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 simplifing all their constituent geometries individually.

Required Methods

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

use geo::{Point, LineString};
use geo::algorithm::simplify::{Simplify};

let mut vec = Vec::new();
vec.push(Point::new(0.0, 0.0));
vec.push(Point::new(5.0, 4.0));
vec.push(Point::new(11.0, 5.5));
vec.push(Point::new(17.3, 3.2));
vec.push(Point::new(27.8, 0.1));
let linestring = LineString(vec);
let mut compare = Vec::new();
compare.push(Point::new(0.0, 0.0));
compare.push(Point::new(5.0, 4.0));
compare.push(Point::new(11.0, 5.5));
compare.push(Point::new(27.8, 0.1));
let ls_compare = LineString(compare);
let simplified = linestring.simplify(&1.0);
assert_eq!(simplified, ls_compare)

Implementors