diff --git a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/UnionIoxPlugin.java b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/UnionIoxPlugin.java index d63c783..e3f955e 100644 --- a/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/UnionIoxPlugin.java +++ b/src/main/java/ch/geowerkstatt/ilivalidator/extensions/functions/UnionIoxPlugin.java @@ -65,7 +65,10 @@ private IomObject union(UnionSurfaceKey key) { .toArray(MultiPolygon[]::new); Geometry geometryCollection = new GeometryFactory().createGeometryCollection(polygons); - Geometry unionGeometry = geometryCollection.union(); + + // Calculating unionGeometry with Geometry.union() in JTS 1.14.0 may cause unexpected Exception + // See: https://github.com/GeoWerkstatt/geow-interlis-functions/issues/49 + Geometry unionGeometry = geometryCollection.buffer(0); try { if (unionGeometry instanceof Polygon) { diff --git a/src/test/data/Union/UnionTest.ili b/src/test/data/Union/UnionTest.ili new file mode 100644 index 0000000..d6dddba --- /dev/null +++ b/src/test/data/Union/UnionTest.ili @@ -0,0 +1,22 @@ +INTERLIS 2.4; + +MODEL TestSuite + AT "mailto:info@geowerkstatt.ch" VERSION "2020_01_15" = + IMPORTS GeoW_FunctionsExt; + + DOMAIN + !!@CRS=EPSG:2056 + Coord2 = COORD + 2460000.000 .. 2870000.000, + 1045000.000 .. 1310000.000, + ROTATION 2 -> 1; + + TOPIC FunctionTestTopic = + CLASS UnionTest = + geometry : MANDATORY AREA WITH (ARCS,STRAIGHTS) VERTEX Coord2 WITHOUT OVERLAPS > 0.05; + + SET CONSTRAINT GeoW_FunctionsExt.GetInnerRingsCount(GeoW_FunctionsExt.Union(ALL,"geometry"), UNDEFINED) == 0; + END UnionTest; + END FunctionTestTopic; + +END TestSuite. diff --git a/src/test/data/Union/UnionTest.xtf b/src/test/data/Union/UnionTest.xtf new file mode 100644 index 0000000..5a2760f --- /dev/null +++ b/src/test/data/Union/UnionTest.xtf @@ -0,0 +1,179 @@ + + + + + GeoW_FunctionsExt + TestSuite + + + + + + + + + + + 2682807 + 1216895 + + + 2682795 + 1216885 + + + 2682795 + 1216919 + + + 2682807 + 1216895 + + + + + + + + + + + + + 2682323.1119999997 + 1216563.0929999985 + + + 2682532.8150000013 + 1216383.9310000017 + + + 2682355.9409999996 + 1216436.9279999994 + + + 2682323.1119999997 + 1216563.0929999985 + + + + + + + + + + + + + 2682541.671 + 1216376.2459999993 + + + 2682532.8150000013 + 1216383.9310000017 + + + 2682549.9239999987 + 1216395.3790000007 + + + 2682541.671 + 1216376.2459999993 + + + + + + + + + + + + + 2684079.278000001 + 1219403.2149999999 + + + 2683622.9990000017 + 1219514.1849999987 + + + 2683781.8209999986 + 1219698.3060000017 + + + 2684079.278000001 + 1219403.2149999999 + + + + + + + + + + + + + 2682897.403999999 + 1218167.2280000001 + + + 2683428.9990000017 + 1217208.4189999998 + + + 2683200 + 1217201 + + + 2682360 + 1218110 + + + 2682897.403999999 + 1218167.2280000001 + + + + + + + + + + + + + 2683548.8319999985 + 1217497.7049999982 + + + 2683402.909000002 + 1216556.5390000008 + + + 2683200 + 1217201 + + + 2683428.9990000017 + 1217208.4189999998 + + + 2683548.8319999985 + 1217497.7049999982 + + + + + + + + + diff --git a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/UnionIoxPluginTest.java b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/UnionIoxPluginTest.java index 1d5bec7..ef155e6 100644 --- a/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/UnionIoxPluginTest.java +++ b/src/test/java/ch/geowerkstatt/ilivalidator/extensions/functions/UnionIoxPluginTest.java @@ -34,4 +34,10 @@ void mandatoryConstraintMergedInnerRings() throws Ili2cFailure, IoxException { AssertionHelper.assertNoConstraintError(vh, "innerRings"); AssertionHelper.assertNoConstraintError(vh, "innerRingsUnion"); } + + @Test + void test() throws Exception { + vh.runValidation(new String[]{"Union/UnionTest.xtf"}, new String[]{"Union/UnionTest.ili"}); + Assert.equals(0, vh.getErrs().size()); + } }