diff --git a/geo/src/algorithm/simplify.rs b/geo/src/algorithm/simplify.rs index a829134432..aa63cc0a1f 100644 --- a/geo/src/algorithm/simplify.rs +++ b/geo/src/algorithm/simplify.rs @@ -19,6 +19,10 @@ fn rdp(points: &[Point], epsilon: &T) -> Vec> where T: Float, { + // Epsilon must be greater than zero for any meaningful simplification to happen + if *epsilon <= T::zero() { + points.to_vec(); + } compute_rdp( &points .into_iter() diff --git a/geo/src/algorithm/simplifyvw.rs b/geo/src/algorithm/simplifyvw.rs index eaf3aa3908..23379ac9ea 100644 --- a/geo/src/algorithm/simplifyvw.rs +++ b/geo/src/algorithm/simplifyvw.rs @@ -191,6 +191,10 @@ fn visvalingam(orig: &LineString, epsilon: &T) -> Vec> where T: Float, { + // Epsilon must be greater than zero for any meaningful simplification to happen + if *epsilon <= T::zero() { + return orig.0.to_vec() + } let subset = visvalingam_indices(orig, epsilon); // filter orig using the indices // using get would be more robust here, but the input subset is guaranteed to be valid in this case @@ -251,7 +255,7 @@ fn visvalingam_preserve( where T: Float + RTreeNum, { - if orig.0.len() < 3 { + if orig.0.len() < 3 || *epsilon <= T::zero() { return orig.0.to_vec(); } let max = orig.0.len();