Skip to content

Commit

Permalink
Fix vertex-vertex intersection in OverlayArea
Browse files Browse the repository at this point in the history
Signed-off-by: tanelk <[email protected]>
  • Loading branch information
tanelk committed Mar 14, 2024
1 parent 81639c5 commit 9a3b606
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))");
Expand Down

0 comments on commit 9a3b606

Please sign in to comment.