Skip to content

Commit

Permalink
Shortcut through simplification step if distanceTolerance is negative (
Browse files Browse the repository at this point in the history
  • Loading branch information
davecraig authored Nov 9, 2024
1 parent 9dccfb4 commit 1981abc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class DouglasPeuckerSimplifier {
* @return the simplified geometry
*/
public static Geometry simplify(Geometry geom, double distanceTolerance) {
if (geom.isEmpty()) {
if (geom.isEmpty() || (distanceTolerance < 0.0)) {
return geom.copy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@ void simplifyLineStringIfToleranceIsSet() {
true
)
);
// but doesn't resimplify if the tolerance is negative even when resimplify=true
assertEquals(
List.of(
feature(1, newLineString(10, 10, 20, 20, 30, 30), Map.of("a", 1))
),
FeatureMerge.mergeLineStrings(
List.of(
feature(1, newLineString(10, 10, 20, 20, 30, 30), Map.of("a", 1))
),
0,
-1,
0,
true
)
);
}

@Test
Expand Down

0 comments on commit 1981abc

Please sign in to comment.