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/04/15 09:01:45 UTC
[1/2] lucene-solr:master: LUCENE-7221: Fix broken bounds for
GeoCircles.
Repository: lucene-solr
Updated Branches:
refs/heads/master b7c5482d3 -> a0bc1e642
LUCENE-7221: Fix broken bounds for GeoCircles.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/5f0245fe
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/5f0245fe
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/5f0245fe
Branch: refs/heads/master
Commit: 5f0245febebdab866908f40d998bb3ee277aedd4
Parents: 7c09891
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 15 03:01:11 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 15 03:01:11 2016 -0400
----------------------------------------------------------------------
.../org/apache/lucene/spatial3d/geom/Plane.java | 56 ++++++++++++--------
.../apache/lucene/spatial3d/geom/XYZBounds.java | 32 +++++++++--
.../lucene/spatial3d/geom/GeoCircleTest.java | 17 ++++++
3 files changed, 80 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f0245fe/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 29c400a..ace7aa4 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
@@ -926,17 +926,23 @@ public class Plane extends Vector {
if (Math.abs(sqrtTerm) < MINIMUM_RESOLUTION_SQUARED) {
// One solution
final double m = -b / (2.0 * a);
- final double l = r * m + q;
- // x = ((1 - l*A) * ab^2 ) / (2 * m)
- // y = (-l*B * ab^2) / ( 2 * m)
- // z = (-l*C * c^2)/ (2 * m)
- final double denom0 = 0.5 / m;
- final GeoPoint thePoint = new GeoPoint((1.0-l*A) * abSquared * denom0, -l*B * abSquared * denom0, -l*C * cSquared * denom0);
- //Math is not quite accurate enough for this
- //assert planetModel.pointOnSurface(thePoint): "Point: "+thePoint+"; Planetmodel="+planetModel+"; A="+A+" B="+B+" C="+C+" D="+D+" planetfcn="+
- // (thePoint.x*thePoint.x*planetModel.inverseAb*planetModel.inverseAb + thePoint.y*thePoint.y*planetModel.inverseAb*planetModel.inverseAb + thePoint.z*thePoint.z*planetModel.inverseC*planetModel.inverseC);
- //assert evaluateIsZero(thePoint): "Evaluation of point: "+evaluate(thePoint);
- addPoint(boundsInfo, bounds, thePoint);
+ // Valid?
+ if (Math.abs(m) >= MINIMUM_RESOLUTION) {
+ final double l = r * m + q;
+ // x = ((1 - l*A) * ab^2 ) / (2 * m)
+ // y = (-l*B * ab^2) / ( 2 * m)
+ // z = (-l*C * c^2)/ (2 * m)
+ final double denom0 = 0.5 / m;
+ final GeoPoint thePoint = new GeoPoint((1.0-l*A) * abSquared * denom0, -l*B * abSquared * denom0, -l*C * cSquared * denom0);
+ //Math is not quite accurate enough for this
+ //assert planetModel.pointOnSurface(thePoint): "Point: "+thePoint+"; Planetmodel="+planetModel+"; A="+A+" B="+B+" C="+C+" D="+D+" planetfcn="+
+ // (thePoint.x*thePoint.x*planetModel.inverseAb*planetModel.inverseAb + thePoint.y*thePoint.y*planetModel.inverseAb*planetModel.inverseAb + thePoint.z*thePoint.z*planetModel.inverseC*planetModel.inverseC);
+ //assert evaluateIsZero(thePoint): "Evaluation of point: "+evaluate(thePoint);
+ addPoint(boundsInfo, bounds, thePoint);
+ } else {
+ // This is a plane of the form A=n B=0 C=0. We can set a bound only by noting the D value.
+ boundsInfo.addXValue(-D/A);
+ }
} else if (sqrtTerm > 0.0) {
// Two solutions
final double sqrtResult = Math.sqrt(sqrtTerm);
@@ -1089,17 +1095,23 @@ public class Plane extends Vector {
if (Math.abs(sqrtTerm) < MINIMUM_RESOLUTION_SQUARED) {
// One solution
final double m = -b / (2.0 * a);
- final double l = r * m + q;
- // x = (-l*A * ab^2 ) / (2 * m)
- // y = ((1.0-l*B) * ab^2) / ( 2 * m)
- // z = (-l*C * c^2)/ (2 * m)
- final double denom0 = 0.5 / m;
- final GeoPoint thePoint = new GeoPoint(-l*A * abSquared * denom0, (1.0-l*B) * abSquared * denom0, -l*C * cSquared * denom0);
- //Math is not quite accurate enough for this
- //assert planetModel.pointOnSurface(thePoint): "Point: "+thePoint+"; Planetmodel="+planetModel+"; A="+A+" B="+B+" C="+C+" D="+D+" planetfcn="+
- // (thePoint1.x*thePoint.x*planetModel.inverseAb*planetModel.inverseAb + thePoint.y*thePoint.y*planetModel.inverseAb*planetModel.inverseAb + thePoint.z*thePoint.z*planetModel.inverseC*planetModel.inverseC);
- //assert evaluateIsZero(thePoint): "Evaluation of point: "+evaluate(thePoint);
- addPoint(boundsInfo, bounds, thePoint);
+ // Valid?
+ if (Math.abs(m) >= MINIMUM_RESOLUTION) {
+ final double l = r * m + q;
+ // x = (-l*A * ab^2 ) / (2 * m)
+ // y = ((1.0-l*B) * ab^2) / ( 2 * m)
+ // z = (-l*C * c^2)/ (2 * m)
+ final double denom0 = 0.5 / m;
+ final GeoPoint thePoint = new GeoPoint(-l*A * abSquared * denom0, (1.0-l*B) * abSquared * denom0, -l*C * cSquared * denom0);
+ //Math is not quite accurate enough for this
+ //assert planetModel.pointOnSurface(thePoint): "Point: "+thePoint+"; Planetmodel="+planetModel+"; A="+A+" B="+B+" C="+C+" D="+D+" planetfcn="+
+ // (thePoint1.x*thePoint.x*planetModel.inverseAb*planetModel.inverseAb + thePoint.y*thePoint.y*planetModel.inverseAb*planetModel.inverseAb + thePoint.z*thePoint.z*planetModel.inverseC*planetModel.inverseC);
+ //assert evaluateIsZero(thePoint): "Evaluation of point: "+evaluate(thePoint);
+ addPoint(boundsInfo, bounds, thePoint);
+ } else {
+ // This is a plane of the form A=0 B=n C=0. We can set a bound only by noting the D value.
+ boundsInfo.addYValue(-D/B);
+ }
} else if (sqrtTerm > 0.0) {
// Two solutions
final double sqrtResult = Math.sqrt(sqrtTerm);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/5f0245fe/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 3ab2701..4b15014 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
@@ -195,7 +195,14 @@ public class XYZBounds implements Bounds {
@Override
public Bounds addXValue(final GeoPoint point) {
- final double x = point.x;
+ return addXValue(point.x);
+ }
+
+ /** Add a specific X value.
+ * @param x is the value to add.
+ * @return the bounds object.
+ */
+ public Bounds addXValue(final double x) {
final double small = x - FUDGE_FACTOR;
if (minX == null || minX > small) {
minX = new Double(small);
@@ -209,7 +216,14 @@ public class XYZBounds implements Bounds {
@Override
public Bounds addYValue(final GeoPoint point) {
- final double y = point.y;
+ return addYValue(point.y);
+ }
+
+ /** Add a specific Y value.
+ * @param y is the value to add.
+ * @return the bounds object.
+ */
+ public Bounds addYValue(final double y) {
final double small = y - FUDGE_FACTOR;
if (minY == null || minY > small) {
minY = new Double(small);
@@ -223,7 +237,14 @@ public class XYZBounds implements Bounds {
@Override
public Bounds addZValue(final GeoPoint point) {
- final double z = point.z;
+ return addZValue(point.z);
+ }
+
+ /** Add a specific Z value.
+ * @param z is the value to add.
+ * @return the bounds object.
+ */
+ public Bounds addZValue(final double z) {
final double small = z - FUDGE_FACTOR;
if (minZ == null || minZ > small) {
minZ = new Double(small);
@@ -264,4 +285,9 @@ public class XYZBounds implements Bounds {
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/5f0245fe/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
index ca8b669..ff2252c 100755
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java
@@ -392,4 +392,21 @@ public class GeoCircleTest extends LuceneTestCase {
}
+ @Test
+ public void testBoundsFailureCase1() {
+ // lat=2.7399499693409367E-13, lon=-3.141592653589793([X=-1.0011188539924791, Y=-1.226017000107956E-16, Z=2.743015573303327E-13])], radius=2.1814042682464985
+ final GeoCircle gc = GeoCircleFactory.makeGeoCircle(PlanetModel.WGS84, 2.7399499693409367E-13, -3.141592653589793, 2.1814042682464985);
+ // With a circle like this, zmin should equal zmax, and xmin should be PlanetModel.minimumX.
+ final GeoPoint gp = new GeoPoint(0.0054866241253590815, -0.004009749293376541, 0.997739304376186);
+ final GeoPoint gpOnSurface = PlanetModel.WGS84.createSurfacePoint(gp);
+ final XYZBounds bounds = new XYZBounds();
+ gc.getBounds(bounds);
+ //System.out.println("Bounds: "+bounds);
+ final XYZSolid solid = XYZSolidFactory.makeXYZSolid(PlanetModel.WGS84, bounds.getMinimumX(), bounds.getMaximumX(), bounds.getMinimumY(), bounds.getMaximumY(), bounds.getMinimumZ(), bounds.getMaximumZ());
+ assertTrue(gc.isWithin(gpOnSurface));
+ assertTrue(gc.isWithin(gp));
+ assertTrue(solid.isWithin(gpOnSurface)); // This fails
+ assertTrue(solid.isWithin(gp));
+ }
+
}
[2/2] lucene-solr:master: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/lucene-solr
Posted by kw...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/lucene-solr
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a0bc1e64
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a0bc1e64
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a0bc1e64
Branch: refs/heads/master
Commit: a0bc1e64270af39e7966c920da5353ccae0588ba
Parents: 5f0245f b7c5482
Author: Karl Wright <Da...@gmail.com>
Authored: Fri Apr 15 03:01:34 2016 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Fri Apr 15 03:01:34 2016 -0400
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +
.../org/apache/solr/handler/StreamHandler.java | 22 ++-
.../solr/client/solrj/io/stream/SortStream.java | 173 +++++++++++++++++++
.../solrj/io/stream/StreamExpressionTest.java | 42 +++++
4 files changed, 231 insertions(+), 9 deletions(-)
----------------------------------------------------------------------