You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by nk...@apache.org on 2016/01/21 15:59:00 UTC
svn commit: r1725971 -
/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/util/GeoRelationUtils.java
Author: nknize
Date: Thu Jan 21 14:59:00 2016
New Revision: 1725971
URL: http://svn.apache.org/viewvc?rev=1725971&view=rev
Log:
LUCENE-6974: Correct horizontal collinear logic bug in GeoRelationUtils.lineCrossesLine
Modified:
lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/util/GeoRelationUtils.java
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/util/GeoRelationUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/util/GeoRelationUtils.java?rev=1725971&r1=1725970&r2=1725971&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/util/GeoRelationUtils.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/util/GeoRelationUtils.java Thu Jan 21 14:59:00 2016
@@ -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));
}