logo
pub trait SimplifyVwIdx<T, Epsilon = T> {
    fn simplifyvw_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.

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 Visvalingam-Whyatt algorithm

See here for a graphical explanation

Examples
use geo::algorithm::simplifyvw::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.simplifyvw_idx(&30.0);

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

assert_eq!(expected, simplified);

Implementors