You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2016/08/04 12:14:47 UTC
lucene-solr:branch_6x: LUCENE-7402: If intersection computation falls
off the world, bounds includes whole world.
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 74653e9db -> 6b4938891
LUCENE-7402: If intersection computation falls off the world, bounds includes whole world.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6b493889
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6b493889
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6b493889
Branch: refs/heads/branch_6x
Commit: 6b4938891b0139fd0792bc7ee6bf9d23cb451c0b
Parents: 74653e9
Author: Karl Wright <Da...@gmail.com>
Authored: Thu Aug 4 08:12:08 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Thu Aug 4 08:13:37 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/spatial3d/geom/Bounds.java | 7 +++++++
.../apache/lucene/spatial3d/geom/LatLonBounds.java | 5 +++++
.../org/apache/lucene/spatial3d/geom/Plane.java | 16 ++++++++++++----
.../org/apache/lucene/spatial3d/geom/XYZBounds.java | 11 +++++++++++
.../apache/lucene/spatial3d/geom/GeoBBoxTest.java | 15 +++++++++++++++
5 files changed, 50 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6b493889/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Bounds.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Bounds.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Bounds.java
index 866068a..97a5d13 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Bounds.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Bounds.java
@@ -121,4 +121,11 @@ public interface Bounds {
*/
public Bounds noBottomLatitudeBound();
+ /** Signal that there is no bound whatsoever.
+ * The bound is limited only by the constraints of the
+ * planet.
+ *@return the updated Bounds object.,
+ */
+ public Bounds noBound(final PlanetModel planetModel);
+
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6b493889/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/LatLonBounds.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/LatLonBounds.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/LatLonBounds.java
index a607243..ef43dcc 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/LatLonBounds.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/LatLonBounds.java
@@ -253,6 +253,11 @@ public class LatLonBounds implements Bounds {
return this;
}
+ @Override
+ public Bounds noBound(final PlanetModel planetModel) {
+ return noLongitudeBound().noTopLatitudeBound().noBottomLatitudeBound();
+ }
+
// Protected methods
/** Update latitude bound.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6b493889/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
index 47c1b30..6cef2d8 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
@@ -1003,13 +1003,14 @@ public class Plane extends Vector {
* D - MINIMUM_RESOLUTION. Both are examined and intersection points determined.
*/
protected void findIntersectionBounds(final PlanetModel planetModel, final Bounds boundsInfo, final Plane q, final Membership... bounds) {
+ //System.out.println("Finding intersection bounds");
// Unnormalized, unchecked...
final double lineVectorX = y * q.z - z * q.y;
final double lineVectorY = z * q.x - x * q.z;
final double lineVectorZ = x * q.y - y * q.x;
if (Math.abs(lineVectorX) < MINIMUM_RESOLUTION && Math.abs(lineVectorY) < MINIMUM_RESOLUTION && Math.abs(lineVectorZ) < MINIMUM_RESOLUTION) {
// Degenerate case: parallel planes
- //System.err.println(" planes are parallel - no intersection");
+ //System.out.println(" planes are parallel - no intersection");
return;
}
@@ -1037,9 +1038,10 @@ public class Plane extends Vector {
final double denomXZ = this.x * q.z - this.z * q.x;
final double denomXY = this.x * q.y - this.y * q.x;
if (Math.abs(denomYZ) >= Math.abs(denomXZ) && Math.abs(denomYZ) >= Math.abs(denomXY)) {
+ //System.out.println("X biggest");
// X is the biggest, so our point will have x0 = 0.0
if (Math.abs(denomYZ) < MINIMUM_RESOLUTION_SQUARED) {
- //System.err.println(" Denominator is zero: no intersection");
+ //System.out.println(" Denominator is zero: no intersection");
return;
}
final double denom = 1.0 / denomYZ;
@@ -1061,9 +1063,10 @@ public class Plane extends Vector {
0.0, (-(this.D-MINIMUM_RESOLUTION) * q.z - this.z * -(q.D-MINIMUM_RESOLUTION)) * denom, (this.y * -(q.D-MINIMUM_RESOLUTION) + (this.D-MINIMUM_RESOLUTION) * q.y) * denom,
bounds);
} else if (Math.abs(denomXZ) >= Math.abs(denomXY) && Math.abs(denomXZ) >= Math.abs(denomYZ)) {
+ //System.out.println("Y biggest");
// Y is the biggest, so y0 = 0.0
if (Math.abs(denomXZ) < MINIMUM_RESOLUTION_SQUARED) {
- //System.err.println(" Denominator is zero: no intersection");
+ //System.out.println(" Denominator is zero: no intersection");
return;
}
final double denom = 1.0 / denomXZ;
@@ -1084,9 +1087,10 @@ public class Plane extends Vector {
(-(this.D-MINIMUM_RESOLUTION) * q.z - this.z * -(q.D-MINIMUM_RESOLUTION)) * denom, 0.0, (this.x * -(q.D-MINIMUM_RESOLUTION) + (this.D-MINIMUM_RESOLUTION) * q.x) * denom,
bounds);
} else {
+ //System.out.println("Z biggest");
// Z is the biggest, so Z0 = 0.0
if (Math.abs(denomXY) < MINIMUM_RESOLUTION_SQUARED) {
- //System.err.println(" Denominator is zero: no intersection");
+ //System.out.println(" Denominator is zero: no intersection");
return;
}
final double denom = 1.0 / denomXY;
@@ -1178,6 +1182,10 @@ public class Plane extends Vector {
if (point2Valid) {
boundsInfo.addPoint(new GeoPoint(point2X, point2Y, point2Z));
}
+ } else {
+ // If we can't intersect line with world, then it's outside the world, so
+ // we have to assume everything is included.
+ boundsInfo.noBound(planetModel);
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6b493889/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZBounds.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZBounds.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZBounds.java
index 85659ab..919b72e 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZBounds.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZBounds.java
@@ -293,6 +293,17 @@ public class XYZBounds implements Bounds {
}
@Override
+ public Bounds noBound(final PlanetModel planetModel) {
+ minX = planetModel.getMinimumXValue();
+ maxX = planetModel.getMaximumXValue();
+ minY = planetModel.getMinimumYValue();
+ maxY = planetModel.getMaximumYValue();
+ minZ = planetModel.getMinimumZValue();
+ maxZ = planetModel.getMaximumZValue();
+ return this;
+ }
+
+ @Override
public String toString() {
return "XYZBounds: [xmin="+minX+" xmax="+maxX+" ymin="+minY+" ymax="+maxY+" zmin="+minZ+" zmax="+maxZ+"]";
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6b493889/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java
index 993c79f..7530c74 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoBBoxTest.java
@@ -372,4 +372,19 @@ public class GeoBBoxTest {
assertTrue(box.isWithin(point)?solid.isWithin(point):true);
}
+ @Test
+ public void testFailureCase2() {
+ //final GeoPoint point = new GeoPoint(-0.7375647084975573, -2.3309121299774915E-10, 0.6746626163258577);
+ final GeoPoint point = new GeoPoint(-0.737564708579924, -9.032562595264542E-17, 0.6746626165197899);
+ final GeoBBox box = new GeoRectangle(PlanetModel.WGS84, 0.7988584710911523, 0.25383311815493353, -1.2236144735575564E-12, 7.356011300929654E-49);
+ final XYZBounds bounds = new XYZBounds();
+ box.getBounds(bounds);
+ final XYZSolid solid = XYZSolidFactory.makeXYZSolid(PlanetModel.WGS84, bounds.getMinimumX(), bounds.getMaximumX(), bounds.getMinimumY(), bounds.getMaximumY(), bounds.getMinimumZ(), bounds.getMaximumZ());
+
+ //System.out.println("Is within Y value? "+(point.y >= bounds.getMinimumY() && point.y <= bounds.getMaximumY()));
+ //System.out.println("Shape = "+box+" is within? "+box.isWithin(point));
+ //System.out.println("XYZBounds = "+bounds+" is within? "+solid.isWithin(point)+" solid="+solid);
+ assertTrue(box.isWithin(point) == solid.isWithin(point));
+ }
+
}