pub trait SimplifyVwIdx<T, Epsilon = T> {
    // Required method
    fn simplify_vw_idx(&self, epsilon: &T) -> Vec<usize>
       where T: CoordFloat;
}
Expand description

Simplifies a geometry, returning the retained indices of the output

This operation uses the Visvalingam-Whyatt algorithm, and does not guarantee that the returned geometry is valid.

A larger epsilon means being more aggressive about removing points with less concern for maintaining the existing shape. Specifically, when you consider whether to remove a point, you can draw a triangle consisting of the candidate point and the points before and after it. If the area of this triangle is less than epsilon, we will remove the point.

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

Required Methods§

source

fn simplify_vw_idx(&self, epsilon: &T) -> Vec<usize>
where T: CoordFloat,

Returns the simplified representation of a geometry, using the Visvalingam-Whyatt algorithm

See here for a graphical explanation

§Examples
use geo::SimplifyVwIdx;
use geo::line_string;

let line_string = line_string![
    (x: 5.0, y: 2.0),
    (x: 3.0, y: 8.0),
    (x: 6.0, y: 20.0),
    (x: 7.0, y: 25.0),
    (x: 10.0, y: 10.0),
];

let simplified = line_string.simplify_vw_idx(&30.0);

let expected = vec![
    0_usize,
    3_usize,
    4_usize,
];

assert_eq!(expected, simplified);

Implementors§

source§

impl<T> SimplifyVwIdx<T> for LineString<T>
where T: CoordFloat,