Skip to content

Commit 2c85e14

Browse files
authored
Change CoverageUnion failure exception message (#1141)
1 parent 0e5ac9a commit 2c85e14

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

modules/core/src/main/java/org/locationtech/jts/operation/overlayng/CoverageUnion.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ public static Geometry union(Geometry coverage) {
7777
}
7878

7979
// a precision model is not needed since no noding is done
80-
return OverlayNG.union(coverage, null, noder );
80+
try {
81+
return OverlayNG.union(coverage, null, noder );
82+
}
83+
catch (TopologyException ex) {
84+
throw new TopologyException("Input coverage is invalid due to incorrect noding");
85+
}
8186
}
8287

8388
private CoverageUnion() {

modules/core/src/test/java/org/locationtech/jts/coverage/CoverageUnionTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
package org.locationtech.jts.coverage;
1313

1414
import org.locationtech.jts.geom.Geometry;
15+
import org.locationtech.jts.geom.TopologyException;
1516

1617
import junit.textui.TestRunner;
1718
import test.jts.GeometryTestCase;
@@ -61,6 +62,24 @@ public void testHolesTouching() {
6162
);
6263
}
6364

65+
public void testInvalidNodingError() {
66+
checkError(
67+
"GEOMETRYCOLLECTION (POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)), POLYGON ((1 0, 0.9 1, 2 1, 2 0, 1 0)))" );
68+
}
69+
70+
private void checkError(String wktCoverage) {
71+
Geometry covGeom = read(wktCoverage);
72+
Geometry[] coverage = toArray(covGeom);
73+
try {
74+
Geometry actual = CoverageUnion.union(coverage);
75+
}
76+
catch (TopologyException ex) {
77+
// executes with no error
78+
return;
79+
}
80+
fail("No error thrown for invalid input coverage");
81+
}
82+
6483
private void checkUnion(String wktCoverage, String wktExpected) {
6584
Geometry covGeom = read(wktCoverage);
6685
Geometry[] coverage = toArray(covGeom);

0 commit comments

Comments
 (0)