Skip to content

Commit

Permalink
Add preventative debug assert
Browse files Browse the repository at this point in the history
  • Loading branch information
urschrei authored and michaelkirk committed Dec 6, 2022
1 parent 4886fc7 commit c61abfa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions geo/src/algorithm/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ where
}
},
);
debug_assert_ne!(farthest_index, 0);

if farthest_distance > *epsilon {
// The farthest index was larger than epsilon, so we will recursively simplify subsegments
Expand Down Expand Up @@ -248,6 +249,18 @@ mod test {
use crate::geo_types::coord;
use crate::{line_string, polygon};

#[test]
fn recursion_test() {
let vec = [
coord! { x: 8.0, y: 100.0 },
coord! { x: 9.0, y: 100.0 },
coord! { x: 12.0, y: 100.0 },
];
let compare = vec![coord! {x: 8.0, y: 100.0}, coord! {x: 12.0, y: 100.0}];
let simplified = rdp(vec.into_iter(), &1.0);
assert_eq!(simplified, compare);
}

#[test]
fn rdp_test() {
let vec = vec![
Expand Down

0 comments on commit c61abfa

Please sign in to comment.