Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ public static Geometry union(Geometry coverage) {
}

// a precision model is not needed since no noding is done
return OverlayNG.union(coverage, null, noder );
try {
return OverlayNG.union(coverage, null, noder );
}
catch (TopologyException ex) {
throw new TopologyException("Input coverage is invalid due to incorrect noding");
}
}

private CoverageUnion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package org.locationtech.jts.coverage;

import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.TopologyException;

import junit.textui.TestRunner;
import test.jts.GeometryTestCase;
Expand Down Expand Up @@ -61,6 +62,24 @@ public void testHolesTouching() {
);
}

public void testInvalidNodingError() {
checkError(
"GEOMETRYCOLLECTION (POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)), POLYGON ((1 0, 0.9 1, 2 1, 2 0, 1 0)))" );
}

private void checkError(String wktCoverage) {
Geometry covGeom = read(wktCoverage);
Geometry[] coverage = toArray(covGeom);
try {
Geometry actual = CoverageUnion.union(coverage);
}
catch (TopologyException ex) {
// executes with no error
return;
}
fail("No error thrown for invalid input coverage");
}

private void checkUnion(String wktCoverage, String wktExpected) {
Geometry covGeom = read(wktCoverage);
Geometry[] coverage = toArray(covGeom);
Expand Down