mirror of https://github.com/apache/lucene.git
LUCENE-6974: Correct horizontal collinear logic bug in GeoRelationUtils.lineCrossesLine
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1725966 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb47a8b965
commit
977980fcdc
|
@ -153,15 +153,15 @@ public class GeoRelationUtils {
|
|||
final double minBy = Math.min(bY1, bY2);
|
||||
final double maxBy = Math.max(bY1, bY2);
|
||||
|
||||
return !(minBy > maxAy || maxBy < minAy) || !(minAy > maxBy || maxAy < minBy);
|
||||
return !(minBy >= maxAy || maxBy <= minAy);
|
||||
}
|
||||
// horizontally collinear
|
||||
final double minAx = Math.min(aX1, aX2);
|
||||
final double maxAx = Math.max(aX1, aY2);
|
||||
final double maxAx = Math.max(aX1, aX2);
|
||||
final double minBx = Math.min(bX1, bX2);
|
||||
final double maxBx = Math.max(bX1, bX2);
|
||||
|
||||
return !(minBx >= maxAx || maxBx <= minAx) || !(minAx >= maxBx || maxAx <= minBx);
|
||||
return !(minBx >= maxAx || maxBx <= minAx);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -181,6 +181,11 @@ public class GeoRelationUtils {
|
|||
// approximation: check if rectangle crosses poly (to handle concave/pacman polys), then check one of the corners
|
||||
// are contained
|
||||
if (approx == true) {
|
||||
// short-cut: if bounding boxes cross, rect is not within
|
||||
if (rectCrosses(rMinX, rMinY, rMaxX, rMaxY, sMinX, sMinY, sMaxX, sMaxY) == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(rectCrossesPoly(rMinX, rMinY, rMaxX, rMaxY, shapeX, shapeY, sMinX, sMinY, sMaxX, sMaxY) ||
|
||||
!pointInPolygon(shapeX, shapeY, rMinY, rMinX));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue