Trait geoarrow2::algorithm::geo::simplify_vw::SimplifyVw
source · pub trait SimplifyVw {
// Required method
fn simplify_vw(&self, epsilon: &f64) -> Self;
}
Expand description
Simplifies a geometry.
Polygons are simplified by running the 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§
sourcefn simplify_vw(&self, epsilon: &f64) -> Self
fn simplify_vw(&self, epsilon: &f64) -> Self
Returns the simplified representation of a geometry, using the Visvalingam-Whyatt algorithm
See here for a graphical explanation
Examples
use geoarrow2::algorithm::geo::SimplifyVw;
use geoarrow2::array::LineStringArray;
use geoarrow2::trait_::GeoArrayAccessor;
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 line_string_array: LineStringArray<i32> = vec![line_string].into();
let simplified_array = line_string_array.simplify_vw(&30.0);
let expected = line_string![
(x: 5.0, y: 2.0),
(x: 7.0, y: 25.0),
(x: 10.0, y: 10.0),
];
assert_eq!(expected, simplified_array.value_as_geo(0))
Object Safety§
This trait is not object safe.