You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/08/21 01:31:05 UTC
[38/50] [abbrv] lucene-solr:jira/http2: LUCENE-8457: Use backing
planes for all potentially narrow GeoBBox shapes.
LUCENE-8457: Use backing planes for all potentially narrow GeoBBox shapes.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/30f64d77
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/30f64d77
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/30f64d77
Branch: refs/heads/jira/http2
Commit: 30f64d778ab218c276e5014f9c00437a128f64a7
Parents: 9f615fb
Author: Karl Wright <Da...@gmail.com>
Authored: Sat Aug 18 10:44:59 2018 -0400
Committer: Karl Wright <Da...@gmail.com>
Committed: Sat Aug 18 10:44:59 2018 -0400
----------------------------------------------------------------------
.../lucene/spatial3d/geom/GeoLongitudeSlice.java | 17 ++++++++++++++---
.../lucene/spatial3d/geom/GeoNorthRectangle.java | 18 ++++++++++++++++--
.../lucene/spatial3d/geom/GeoRectangle.java | 12 ++++++++++--
.../lucene/spatial3d/geom/GeoSouthRectangle.java | 16 ++++++++++++++--
.../apache/lucene/spatial3d/geom/SidedPlane.java | 16 ++++++++++++++++
.../lucene/spatial3d/geom/XYZSolidTest.java | 5 ++++-
6 files changed, 74 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/30f64d77/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
index 404bf8c..4a8a604 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoLongitudeSlice.java
@@ -36,6 +36,8 @@ class GeoLongitudeSlice extends GeoBaseBBox {
protected final SidedPlane leftPlane;
/** The right plane of the slice */
protected final SidedPlane rightPlane;
+ /** Backing plane (for narrow angles) */
+ protected final SidedPlane backingPlane;
/** The notable points for the slice (north and south poles) */
protected final GeoPoint[] planePoints;
/** The center point of the slice */
@@ -76,10 +78,18 @@ class GeoLongitudeSlice extends GeoBaseBBox {
rightLon += Math.PI * 2.0;
}
final double middleLon = (leftLon + rightLon) * 0.5;
- this.centerPoint = new GeoPoint(planetModel, 0.0, middleLon);
+ final double sinMiddleLon = Math.sin(middleLon);
+ final double cosMiddleLon = Math.cos(middleLon);
+
+ this.centerPoint = new GeoPoint(planetModel, 0.0, sinMiddleLon, 1.0, cosMiddleLon);
this.leftPlane = new SidedPlane(centerPoint, cosLeftLon, sinLeftLon);
this.rightPlane = new SidedPlane(centerPoint, cosRightLon, sinRightLon);
+
+ // Compute the backing plane
+ // The normal for this plane is a unit vector through the origin that goes through the middle lon. The plane's D is 0,
+ // because it goes through the origin.
+ this.backingPlane = new SidedPlane(this.centerPoint, cosMiddleLon, sinMiddleLon, 0.0, 0.0);
this.planePoints = new GeoPoint[]{planetModel.NORTH_POLE, planetModel.SOUTH_POLE};
this.edgePoints = new GeoPoint[]{planetModel.NORTH_POLE};
@@ -117,7 +127,8 @@ class GeoLongitudeSlice extends GeoBaseBBox {
@Override
public boolean isWithin(final double x, final double y, final double z) {
- return leftPlane.isWithin(x, y, z) &&
+ return backingPlane.isWithin(x, y, z) &&
+ leftPlane.isWithin(x, y, z) &&
rightPlane.isWithin(x, y, z);
}
@@ -158,7 +169,7 @@ class GeoLongitudeSlice extends GeoBaseBBox {
bounds
.addVerticalPlane(planetModel, leftLon, leftPlane, rightPlane)
.addVerticalPlane(planetModel, rightLon, rightPlane, leftPlane)
- .addIntersection(planetModel, rightPlane, leftPlane)
+ //.addIntersection(planetModel, rightPlane, leftPlane)
.addPoint(planetModel.NORTH_POLE)
.addPoint(planetModel.SOUTH_POLE);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/30f64d77/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
index 1dac929..a736455 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoNorthRectangle.java
@@ -47,6 +47,8 @@ class GeoNorthRectangle extends GeoBaseBBox {
protected final SidedPlane leftPlane;
/** Right-side plane */
protected final SidedPlane rightPlane;
+ /** Backing plane (for narrow angles) */
+ protected final SidedPlane backingPlane;
/** Bottom plane notable points */
protected final GeoPoint[] bottomPlanePoints;
/** Left plane notable points */
@@ -113,11 +115,22 @@ class GeoNorthRectangle extends GeoBaseBBox {
this.leftPlane = new SidedPlane(centerPoint, cosLeftLon, sinLeftLon);
this.rightPlane = new SidedPlane(centerPoint, cosRightLon, sinRightLon);
+ assert(bottomPlane.isWithin(centerPoint));
+ assert(leftPlane.isWithin(centerPoint));
+ assert(rightPlane.isWithin(centerPoint));
+
+ // Compute the backing plane
+ // The normal for this plane is a unit vector through the origin that goes through the middle lon. The plane's D is 0,
+ // because it goes through the origin.
+ this.backingPlane = new SidedPlane(this.centerPoint, cosMiddleLon, sinMiddleLon, 0.0, 0.0);
+
this.bottomPlanePoints = new GeoPoint[]{LLHC, LRHC};
this.leftPlanePoints = new GeoPoint[]{planetModel.NORTH_POLE, LLHC};
this.rightPlanePoints = new GeoPoint[]{planetModel.NORTH_POLE, LRHC};
this.edgePoints = new GeoPoint[]{planetModel.NORTH_POLE};
+
+ System.out.println("LLHC = "+LLHC+" LRHC = "+LRHC);
}
/**
@@ -156,7 +169,8 @@ class GeoNorthRectangle extends GeoBaseBBox {
@Override
public boolean isWithin(final double x, final double y, final double z) {
return
- bottomPlane.isWithin(x, y, z) &&
+ backingPlane.isWithin(x, y, z) &&
+ bottomPlane.isWithin(x, y, z) &&
leftPlane.isWithin(x, y, z) &&
rightPlane.isWithin(x, y, z);
}
@@ -209,7 +223,7 @@ class GeoNorthRectangle extends GeoBaseBBox {
.addHorizontalPlane(planetModel, bottomLat, bottomPlane, leftPlane, rightPlane)
.addVerticalPlane(planetModel, leftLon, leftPlane, bottomPlane, rightPlane)
.addVerticalPlane(planetModel, rightLon, rightPlane, bottomPlane, leftPlane)
- .addIntersection(planetModel, rightPlane, leftPlane, bottomPlane)
+ //.addIntersection(planetModel, rightPlane, leftPlane, bottomPlane)
.addPoint(LLHC).addPoint(LRHC).addPoint(planetModel.NORTH_POLE);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/30f64d77/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
index 7e98214..16073cd 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoRectangle.java
@@ -56,6 +56,8 @@ class GeoRectangle extends GeoBaseBBox {
protected final SidedPlane leftPlane;
/** The right plane */
protected final SidedPlane rightPlane;
+ /** Backing plane (for narrow angles) */
+ protected final SidedPlane backingPlane;
/** Notable points for the top plane */
protected final GeoPoint[] topPlanePoints;
@@ -138,6 +140,11 @@ class GeoRectangle extends GeoBaseBBox {
this.leftPlane = new SidedPlane(centerPoint, cosLeftLon, sinLeftLon);
this.rightPlane = new SidedPlane(centerPoint, cosRightLon, sinRightLon);
+ // Compute the backing plane
+ // The normal for this plane is a unit vector through the origin that goes through the middle lon. The plane's D is 0,
+ // because it goes through the origin.
+ this.backingPlane = new SidedPlane(this.centerPoint, cosMiddleLon, sinMiddleLon, 0.0, 0.0);
+
this.topPlanePoints = new GeoPoint[]{ULHC, URHC};
this.bottomPlanePoints = new GeoPoint[]{LLHC, LRHC};
this.leftPlanePoints = new GeoPoint[]{ULHC, LLHC};
@@ -182,7 +189,8 @@ class GeoRectangle extends GeoBaseBBox {
@Override
public boolean isWithin(final double x, final double y, final double z) {
- return topPlane.isWithin(x, y, z) &&
+ return backingPlane.isWithin(x,y,z) &&
+ topPlane.isWithin(x, y, z) &&
bottomPlane.isWithin(x, y, z) &&
leftPlane.isWithin(x, y, z) &&
rightPlane.isWithin(x, y, z);
@@ -232,7 +240,7 @@ class GeoRectangle extends GeoBaseBBox {
.addVerticalPlane(planetModel, rightLon, rightPlane, topPlane, bottomPlane, leftPlane)
.addHorizontalPlane(planetModel, bottomLat, bottomPlane, topPlane, leftPlane, rightPlane)
.addVerticalPlane(planetModel, leftLon, leftPlane, topPlane, bottomPlane, rightPlane)
- .addIntersection(planetModel, leftPlane, rightPlane, topPlane, bottomPlane)
+ //.addIntersection(planetModel, leftPlane, rightPlane, topPlane, bottomPlane)
.addPoint(ULHC).addPoint(URHC).addPoint(LLHC).addPoint(LRHC);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/30f64d77/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
index a23b927..fc05fc4 100644
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoSouthRectangle.java
@@ -48,6 +48,8 @@ class GeoSouthRectangle extends GeoBaseBBox {
protected final SidedPlane leftPlane;
/** The right plane */
protected final SidedPlane rightPlane;
+ /** Backing plane (for narrow angles) */
+ protected final SidedPlane backingPlane;
/** Notable points for the top plane */
protected final GeoPoint[] topPlanePoints;
@@ -117,6 +119,15 @@ class GeoSouthRectangle extends GeoBaseBBox {
this.leftPlane = new SidedPlane(centerPoint, cosLeftLon, sinLeftLon);
this.rightPlane = new SidedPlane(centerPoint, cosRightLon, sinRightLon);
+ assert(topPlane.isWithin(centerPoint));
+ assert(leftPlane.isWithin(centerPoint));
+ assert(rightPlane.isWithin(centerPoint));
+
+ // Compute the backing plane
+ // The normal for this plane is a unit vector through the origin that goes through the middle lon. The plane's D is 0,
+ // because it goes through the origin.
+ this.backingPlane = new SidedPlane(this.centerPoint, cosMiddleLon, sinMiddleLon, 0.0, 0.0);
+
this.topPlanePoints = new GeoPoint[]{ULHC, URHC};
this.leftPlanePoints = new GeoPoint[]{ULHC, planetModel.SOUTH_POLE};
this.rightPlanePoints = new GeoPoint[]{URHC, planetModel.SOUTH_POLE};
@@ -160,7 +171,8 @@ class GeoSouthRectangle extends GeoBaseBBox {
@Override
public boolean isWithin(final double x, final double y, final double z) {
- return topPlane.isWithin(x, y, z) &&
+ return backingPlane.isWithin(x, y, z) &&
+ topPlane.isWithin(x, y, z) &&
leftPlane.isWithin(x, y, z) &&
rightPlane.isWithin(x, y, z);
}
@@ -206,7 +218,7 @@ class GeoSouthRectangle extends GeoBaseBBox {
.addHorizontalPlane(planetModel, topLat, topPlane, leftPlane, rightPlane)
.addVerticalPlane(planetModel, leftLon, leftPlane, topPlane, rightPlane)
.addVerticalPlane(planetModel, rightLon, rightPlane, topPlane, leftPlane)
- .addIntersection(planetModel, rightPlane, leftPlane, topPlane)
+ //.addIntersection(planetModel, rightPlane, leftPlane, topPlane)
.addPoint(URHC).addPoint(ULHC).addPoint(planetModel.SOUTH_POLE);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/30f64d77/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
index 61d561d..5b22fc4 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/SidedPlane.java
@@ -145,6 +145,22 @@ public class SidedPlane extends Plane implements Membership {
* Construct a sided plane with a normal vector and offset.
*
* @param p point to evaluate.
+ * @param vX is the normal vector X.
+ * @param vY is the normal vector Y.
+ * @param vZ is the normal vector Z.
+ * @param D is the origin offset for the plan.
+ */
+ public SidedPlane(Vector p, double vX, double vY, double vZ, double D) {
+ super(vX, vY, vZ, D);
+ sigNum = Math.signum(evaluate(p));
+ if (sigNum == 0.0)
+ throw new IllegalArgumentException("Cannot determine sidedness because check point is on plane.");
+ }
+
+ /**
+ * Construct a sided plane with a normal vector and offset.
+ *
+ * @param p point to evaluate.
* @param v is the normal vector.
* @param D is the origin offset for the plan.
*/
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/30f64d77/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/XYZSolidTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/XYZSolidTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/XYZSolidTest.java
index 0325533..957e166 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/XYZSolidTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/XYZSolidTest.java
@@ -218,14 +218,17 @@ public class XYZSolidTest extends LuceneTestCase {
}
@Test
- @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8457")
+ //@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8457")
public void testLUCENE8457() {
GeoShape shape = GeoBBoxFactory.makeGeoBBox(PlanetModel.WGS84, Math.PI, 1.2487354264870392, 0.0, 3.5181789305199657E-12);
+ System.out.println("shape = "+shape);
XYZBounds bounds = new XYZBounds();
shape.getBounds(bounds);
XYZSolid solid = XYZSolidFactory.makeXYZSolid(PlanetModel.WGS84, bounds);
+ System.out.println("solid = "+solid);
GeoPoint point = new GeoPoint(PlanetModel.WGS84, 1.4812439919751819, -3.141592653589793);
+ System.out.println("point="+point);
//if the point is within the shape, it must be within the solid
if (shape.isWithin(point)) {
assertTrue(solid.isWithin(point));