diff --git a/modules/lab/src/main/java/org/locationtech/jts/operation/overlayarea/OverlayArea.java b/modules/lab/src/main/java/org/locationtech/jts/operation/overlayarea/OverlayArea.java index 8e475ebd52..7781e69c53 100644 --- a/modules/lab/src/main/java/org/locationtech/jts/operation/overlayarea/OverlayArea.java +++ b/modules/lab/src/main/java/org/locationtech/jts/operation/overlayarea/OverlayArea.java @@ -268,17 +268,17 @@ private static double areaForIntersection(Coordinate a0, Coordinate a1, Coordina * For accuracy the full edge is used to provide the direction vector. */ Coordinate intPt = li.getIntersection(0); - - boolean isAenteringB = Orientation.COUNTERCLOCKWISE == Orientation.index(a0, a1, b1); - - if ( isAenteringB ) { + + if ( Orientation.CLOCKWISE == Orientation.index(a0, a1, b0) ) { return EdgeVector.area2Term(intPt, a0, a1, true) + EdgeVector.area2Term(intPt, b1, b0, false); } - else { + else if ( Orientation.CLOCKWISE == Orientation.index(a0, a1, b1) ) { return EdgeVector.area2Term(intPt, a1, a0, false) + EdgeVector.area2Term(intPt, b0, b1, true); } + + return 0.0; } private double areaForInteriorVertices(LinearRing ring) { diff --git a/modules/lab/src/main/java/org/locationtech/jts/operation/overlayarea/SimpleOverlayArea.java b/modules/lab/src/main/java/org/locationtech/jts/operation/overlayarea/SimpleOverlayArea.java index 6d386c8af5..c6f204cf70 100644 --- a/modules/lab/src/main/java/org/locationtech/jts/operation/overlayarea/SimpleOverlayArea.java +++ b/modules/lab/src/main/java/org/locationtech/jts/operation/overlayarea/SimpleOverlayArea.java @@ -116,14 +116,12 @@ private double areaForIntersections(CoordinateSequence ringA, boolean isCCWA, Co * Use full edge to compute direction, for accuracy. */ Coordinate intPt = li.getIntersection(0); - - boolean isAenteringB = Orientation.COUNTERCLOCKWISE == Orientation.index(a0, a1, b1); - - if ( isAenteringB ) { + + if ( Orientation.CLOCKWISE == Orientation.index(a0, a1, b0) ) { area += EdgeVector.area2Term(intPt, a0, a1, true); area += EdgeVector.area2Term(intPt, b1, b0, false); } - else { + else if ( Orientation.CLOCKWISE == Orientation.index(a0, a1, b1) ) { area += EdgeVector.area2Term(intPt, a1, a0, false); area += EdgeVector.area2Term(intPt, b0, b1, true); } diff --git a/modules/lab/src/test/java/org/locationtech/jts/operation/overlayarea/OverlayAreaTest.java b/modules/lab/src/test/java/org/locationtech/jts/operation/overlayarea/OverlayAreaTest.java index 369ee013aa..0d9754bcb3 100644 --- a/modules/lab/src/test/java/org/locationtech/jts/operation/overlayarea/OverlayAreaTest.java +++ b/modules/lab/src/test/java/org/locationtech/jts/operation/overlayarea/OverlayAreaTest.java @@ -32,8 +32,7 @@ public void testDisjoint() { "POLYGON ((90 10, 50 10, 50 50, 90 50, 90 10))"); } - //TODO: fix this bug - public void xtestTouching() { + public void testTouching() { checkIntersectionArea( "POLYGON ((10 90, 50 90, 50 50, 10 50, 10 90))", "POLYGON ((90 10, 50 10, 50 50, 90 50, 90 10))"); diff --git a/modules/lab/src/test/java/org/locationtech/jts/operation/overlayarea/SimpleOverlayAreaTest.java b/modules/lab/src/test/java/org/locationtech/jts/operation/overlayarea/SimpleOverlayAreaTest.java index c2ab1813d7..a0ea15c0fe 100644 --- a/modules/lab/src/test/java/org/locationtech/jts/operation/overlayarea/SimpleOverlayAreaTest.java +++ b/modules/lab/src/test/java/org/locationtech/jts/operation/overlayarea/SimpleOverlayAreaTest.java @@ -32,8 +32,7 @@ public void testDisjoint() { "POLYGON ((90 10, 50 10, 50 50, 90 50, 90 10))"); } - //TODO: fix this bug - public void xtestTouching() { + public void testTouching() { checkIntersectionArea( "POLYGON ((10 90, 50 90, 50 50, 10 50, 10 90))", "POLYGON ((90 10, 50 10, 50 50, 90 50, 90 10))");