Skip to content

Commit

Permalink
Add OverlayNGRobust unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Dec 20, 2024
1 parent 9ac6c2d commit 7665d6f
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.List;

import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.PrecisionModel;
import org.locationtech.jts.noding.SegmentNode;

import junit.textui.TestRunner;
Expand Down Expand Up @@ -62,6 +63,23 @@ public void testSegmentNodeOrderingIntersection() {
checkOverlaySuccess(a, b, OverlayNG.INTERSECTION);
}

/**
* See https://github.com/locationtech/jts/issues/288
*/
public void testUnionFixed() {
final String wkt1 =
"POLYGON ((-25 700, -25 327.5217935613, -24.9999982443 71.51813717395, 2000 70, -25 700))";
final String wkt2 =
"POLYGON ((-24.9999998349 674.30377216845, -25 674.30377216845, -24.99999893265 171.8884408023, -24.99999871375 139.9692190221, -25 139.9692190221, -25 20, 900 800, -25 700, -24.9999998349 674.30377216845))";

final Geometry geom1 = read(wkt1);
final Geometry geom2 = read(wkt2);

PrecisionModel pm = new PrecisionModel(2E10);
//-- no TopologyException thrown with fixed precision
OverlayNG.overlay(geom1, geom2, OverlayNG.UNION, pm);
}

// MD 2020-09-14 There is no known test case that requires Snap-Rounding to succeed.

public static void checkUnionSuccess(Geometry a, Geometry b) {
Expand Down Expand Up @@ -126,4 +144,5 @@ private void checkUnaryUnion(String[] wkt,String wktExpected) {
}
checkEqual(expected, result);
}

}

0 comments on commit 7665d6f

Please sign in to comment.