lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1700102 - in /lucene/dev/branches/lucene6699/lucene/spatial3d/src: java/org/apache/lucene/geo3d/ test/org/apache/lucene/geo3d/
Date Sun, 30 Aug 2015 09:45:19 GMT
Author: mikemccand
Date: Sun Aug 30 09:45:18 2015
New Revision: 1700102

URL: http://svn.apache.org/r1700102
Log:
LUCENE-6699: iterate

Modified:
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/BaseXYZSolid.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYZSolid.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYdZSolid.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XdYZSolid.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java
    lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/BaseXYZSolid.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/BaseXYZSolid.java?rev=1700102&r1=1700101&r2=1700102&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/BaseXYZSolid.java
(original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/BaseXYZSolid.java
Sun Aug 30 09:45:18 2015
@@ -36,6 +36,9 @@ public abstract class BaseXYZSolid exten
   /** Vertical plane normal to y unit vector passing through origin */
   protected static final Plane yVerticalPlane = new Plane(1.0, 0.0, 0.0, 0.0);
 
+  /** Empty point vector */
+  protected static final GeoPoint[] EMPTY_POINTS = new GeoPoint[0];
+  
   /**
    * Base solid constructor.
    *@param planetModel is the planet model.
@@ -61,20 +64,6 @@ public abstract class BaseXYZSolid exten
       }
     }
     return rval;
-  }
-  
-  /** Find the longest set of point solutions.
-   * @param pointArrays is the array of point arrays.
-   * @return one of the longest sets.
-   */
-  protected static GeoPoint[] findLargestSolution(final GeoPoint[]... pointArrays) {
-    GeoPoint[] rval = null;
-    for (final GeoPoint[] pointArray : pointArrays) {
-      if (rval == null || rval.length < pointArray.length) {
-        rval = pointArray;
-      }
-    }
-    return rval;
   }
   
   @Override

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYZSolid.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYZSolid.java?rev=1700102&r1=1700101&r2=1700102&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYZSolid.java
(original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYZSolid.java
Sun Aug 30 09:45:18 2015
@@ -153,80 +153,113 @@ public class XYZSolid extends BaseXYZSol
 
       // Now, compute the edge points.
       // This is the trickiest part of setting up an XYZSolid.  We've computed intersections
already, so
-      // we'll start there.  We know that at most there will be two disconnected shapes on
the planet surface.
-      // But there's also a case where exactly one plane slices through the world, and none
of the bounding plane
-      // intersections do.  Thus, if we don't find any of the edge intersection cases, we
have to look for that last case.
-      GeoPoint[] edgePoints = findLargestSolution(minXminY,minXmaxY,minXminZ,minXmaxZ,
-        maxXminY,maxXmaxY,maxXminZ,maxXmaxZ,
-        minYminZ,minYmaxZ,maxYminZ,maxYmaxZ);
-      if (edgePoints.length == 0) {
-        // The cases we are looking for are when the four corner points for any given
-        // plane are all outside of the world, AND that plane intersects the world.
-        // There are eight corner points all told; we must evaluate these WRT the planet
surface.
-        final boolean minXminYminZ = planetModel.pointOutside(minX, minY, minZ);
-        final boolean minXminYmaxZ = planetModel.pointOutside(minX, minY, maxZ);
-        final boolean minXmaxYminZ = planetModel.pointOutside(minX, maxY, minZ);
-        final boolean minXmaxYmaxZ = planetModel.pointOutside(minX, maxY, maxZ);
-        final boolean maxXminYminZ = planetModel.pointOutside(maxX, minY, minZ);
-        final boolean maxXminYmaxZ = planetModel.pointOutside(maxX, minY, maxZ);
-        final boolean maxXmaxYminZ = planetModel.pointOutside(maxX, maxY, minZ);
-        final boolean maxXmaxYmaxZ = planetModel.pointOutside(maxX, maxY, maxZ);
+      // we'll start there.
+      // There can be a number of shapes, each of which needs an edgepoint.  Each side by
itself might contribute
+      // an edgepoint, for instance, if the plane describing that side intercepts the planet
in such a way that the ellipse
+      // of interception does not meet any other planes.  Plane intersections can each contribute
0, 1, or 2 edgepoints.
+      //
+      // All of this makes for a lot of potential edgepoints, but I believe these can be
pruned back with careful analysis.
+      // I haven't yet done that analysis, however, so I will treat them all as individual
edgepoints.
+      
+      // The cases we are looking for are when the four corner points for any given
+      // plane are all outside of the world, AND that plane intersects the world.
+      // There are eight corner points all told; we must evaluate these WRT the planet surface.
+      final boolean minXminYminZ = planetModel.pointOutside(minX, minY, minZ);
+      final boolean minXminYmaxZ = planetModel.pointOutside(minX, minY, maxZ);
+      final boolean minXmaxYminZ = planetModel.pointOutside(minX, maxY, minZ);
+      final boolean minXmaxYmaxZ = planetModel.pointOutside(minX, maxY, maxZ);
+      final boolean maxXminYminZ = planetModel.pointOutside(maxX, minY, minZ);
+      final boolean maxXminYmaxZ = planetModel.pointOutside(maxX, minY, maxZ);
+      final boolean maxXmaxYminZ = planetModel.pointOutside(maxX, maxY, minZ);
+      final boolean maxXmaxYmaxZ = planetModel.pointOutside(maxX, maxY, maxZ);
         
-        // If we still haven't encountered anything, we need to look at single-plane/world
intersections.
-        // We detect these by looking at the world model and noting its x, y, and z bounds.
+      // Look at single-plane/world intersections.
+      // We detect these by looking at the world model and noting its x, y, and z bounds.
 
-        if (minX - worldMinX >= -Vector.MINIMUM_RESOLUTION && minX - worldMaxX
<= Vector.MINIMUM_RESOLUTION &&
-          minY < 0.0 && maxY > 0.0 && minZ < 0.0 && maxZ
> 0.0 &&
-          minXminYminZ && minXminYmaxZ && minXmaxYminZ && minXmaxYmaxZ)
{
-          // Find any point on the minX plane that intersects the world
-          // First construct a perpendicular plane that will allow us to find a sample point.
-          // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
-          // Then use it to compute a sample point.
-          edgePoints = new GeoPoint[]{minXPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
-        } else if (maxX - worldMinX >= -Vector.MINIMUM_RESOLUTION && maxX - worldMaxX
<= Vector.MINIMUM_RESOLUTION &&
-          minY < 0.0 && maxY > 0.0 && minZ < 0.0 && maxZ
> 0.0 &&
-          maxXminYminZ && maxXminYmaxZ && maxXmaxYminZ && maxXmaxYmaxZ)
{
-          // Find any point on the maxX plane that intersects the world
-          // First construct a perpendicular plane that will allow us to find a sample point.
-          // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
-          // Then use it to compute a sample point.
-          edgePoints = new GeoPoint[]{maxXPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
-        } else if (minY - worldMinY >= -Vector.MINIMUM_RESOLUTION && minY - worldMaxY
<= Vector.MINIMUM_RESOLUTION &&
-          minX < 0.0 && maxX > 0.0 && minZ < 0.0 && maxZ
> 0.0 &&
-          minXminYminZ && minXminYmaxZ && maxXminYminZ && maxXminYmaxZ)
{
-          // Find any point on the minY plane that intersects the world
-          // First construct a perpendicular plane that will allow us to find a sample point.
-          // This plane is vertical and goes through the points (0,0,0) and (0,1,0)
-          // Then use it to compute a sample point.
-          edgePoints = new GeoPoint[]{minYPlane.getSampleIntersectionPoint(planetModel, yVerticalPlane)};
-        } else if (maxY - worldMinY >= -Vector.MINIMUM_RESOLUTION && maxY - worldMaxY
<= Vector.MINIMUM_RESOLUTION &&
-          minX < 0.0 && maxX > 0.0 && minZ < 0.0 && maxZ
> 0.0 &&
-          minXmaxYminZ && minXmaxYmaxZ && maxXmaxYminZ && maxXmaxYmaxZ)
{
-          // Find any point on the maxY plane that intersects the world
-          // First construct a perpendicular plane that will allow us to find a sample point.
-          // This plane is vertical and goes through the points (0,0,0) and (0,1,0)
-          // Then use it to compute a sample point.
-          edgePoints = new GeoPoint[]{maxYPlane.getSampleIntersectionPoint(planetModel, yVerticalPlane)};
-        } else if (minZ - worldMinZ >= -Vector.MINIMUM_RESOLUTION && minZ - worldMaxZ
<= Vector.MINIMUM_RESOLUTION &&
-          minX < 0.0 && maxX > 0.0 && minY < 0.0 && maxY
> 0.0 &&
-          minXminYminZ && minXmaxYminZ && maxXminYminZ && maxXmaxYminZ)
{
-          // Find any point on the minZ plane that intersects the world
-          // First construct a perpendicular plane that will allow us to find a sample point.
-          // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
-          // Then use it to compute a sample point.
-          edgePoints = new GeoPoint[]{minZPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
-        } else if (maxZ - worldMinZ >= -Vector.MINIMUM_RESOLUTION && maxZ - worldMaxZ
<= Vector.MINIMUM_RESOLUTION &&
-          minX < 0.0 && maxX > 0.0 && minY < 0.0 && maxY
> 0.0 &&
-          minXminYmaxZ && minXmaxYmaxZ && maxXminYmaxZ && maxXmaxYmaxZ)
{
-          // Find any point on the maxZ plane that intersects the world
-          // First construct a perpendicular plane that will allow us to find a sample point.
-          // This plane is vertical and goes through the points (0,0,0) and (1,0,0) (that
is, its orientation doesn't matter)
-          // Then use it to compute a sample point.
-          edgePoints = new GeoPoint[]{maxZPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
-        }
+      final GeoPoint[] minXEdges;
+      if (minX - worldMinX >= -Vector.MINIMUM_RESOLUTION && minX - worldMaxX <=
Vector.MINIMUM_RESOLUTION &&
+        minY < 0.0 && maxY > 0.0 && minZ < 0.0 && maxZ >
0.0 &&
+        minXminYminZ && minXminYmaxZ && minXmaxYminZ && minXmaxYmaxZ)
{
+        // Find any point on the minX plane that intersects the world
+        // First construct a perpendicular plane that will allow us to find a sample point.
+        // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
+        // Then use it to compute a sample point.
+        minXEdges = new GeoPoint[]{minXPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
+      } else {
+        minXEdges = EMPTY_POINTS;
       }
-        
-      this.edgePoints = edgePoints;
+      
+      final GeoPoint[] maxXEdges;
+      if (maxX - worldMinX >= -Vector.MINIMUM_RESOLUTION && maxX - worldMaxX <=
Vector.MINIMUM_RESOLUTION &&
+        minY < 0.0 && maxY > 0.0 && minZ < 0.0 && maxZ >
0.0 &&
+        maxXminYminZ && maxXminYmaxZ && maxXmaxYminZ && maxXmaxYmaxZ)
{
+        // Find any point on the maxX plane that intersects the world
+        // First construct a perpendicular plane that will allow us to find a sample point.
+        // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
+        // Then use it to compute a sample point.
+        maxXEdges = new GeoPoint[]{maxXPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
+      } else {
+        maxXEdges = EMPTY_POINTS;
+      }
+      
+      final GeoPoint[] minYEdges;
+      if (minY - worldMinY >= -Vector.MINIMUM_RESOLUTION && minY - worldMaxY <=
Vector.MINIMUM_RESOLUTION &&
+        minX < 0.0 && maxX > 0.0 && minZ < 0.0 && maxZ >
0.0 &&
+        minXminYminZ && minXminYmaxZ && maxXminYminZ && maxXminYmaxZ)
{
+        // Find any point on the minY plane that intersects the world
+        // First construct a perpendicular plane that will allow us to find a sample point.
+        // This plane is vertical and goes through the points (0,0,0) and (0,1,0)
+        // Then use it to compute a sample point.
+        minYEdges = new GeoPoint[]{minYPlane.getSampleIntersectionPoint(planetModel, yVerticalPlane)};
+      } else {
+        minYEdges = EMPTY_POINTS;
+      }
+      
+      final GeoPoint[] maxYEdges;
+      if (maxY - worldMinY >= -Vector.MINIMUM_RESOLUTION && maxY - worldMaxY <=
Vector.MINIMUM_RESOLUTION &&
+        minX < 0.0 && maxX > 0.0 && minZ < 0.0 && maxZ >
0.0 &&
+        minXmaxYminZ && minXmaxYmaxZ && maxXmaxYminZ && maxXmaxYmaxZ)
{
+        // Find any point on the maxY plane that intersects the world
+        // First construct a perpendicular plane that will allow us to find a sample point.
+        // This plane is vertical and goes through the points (0,0,0) and (0,1,0)
+        // Then use it to compute a sample point.
+        maxYEdges = new GeoPoint[]{maxYPlane.getSampleIntersectionPoint(planetModel, yVerticalPlane)};
+      } else {
+        maxYEdges = EMPTY_POINTS;
+      }
+      
+      final GeoPoint[] minZEdges;
+      if (minZ - worldMinZ >= -Vector.MINIMUM_RESOLUTION && minZ - worldMaxZ <=
Vector.MINIMUM_RESOLUTION &&
+        minX < 0.0 && maxX > 0.0 && minY < 0.0 && maxY >
0.0 &&
+        minXminYminZ && minXmaxYminZ && maxXminYminZ && maxXmaxYminZ)
{
+        // Find any point on the minZ plane that intersects the world
+        // First construct a perpendicular plane that will allow us to find a sample point.
+        // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
+        // Then use it to compute a sample point.
+        minZEdges = new GeoPoint[]{minZPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
+      } else {
+        minZEdges = EMPTY_POINTS;
+      }
+      
+      final GeoPoint[] maxZEdges;
+      if (maxZ - worldMinZ >= -Vector.MINIMUM_RESOLUTION && maxZ - worldMaxZ <=
Vector.MINIMUM_RESOLUTION &&
+        minX < 0.0 && maxX > 0.0 && minY < 0.0 && maxY >
0.0 &&
+        minXminYmaxZ && minXmaxYmaxZ && maxXminYmaxZ && maxXmaxYmaxZ)
{
+        // Find any point on the maxZ plane that intersects the world
+        // First construct a perpendicular plane that will allow us to find a sample point.
+        // This plane is vertical and goes through the points (0,0,0) and (1,0,0) (that is,
its orientation doesn't matter)
+        // Then use it to compute a sample point.
+        maxZEdges = new GeoPoint[]{maxZPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
+      } else {
+        maxZEdges = EMPTY_POINTS;
+      }
+      
+      // Glue everything together.  This is not a minimal set of edgepoints, as of now, but
it does completely describe all shapes on the
+      // planet.
+      this.edgePoints = glueTogether(minXminY, minXmaxY, minXminZ, minXmaxZ,
+        maxXminY, maxXmaxY, maxXminZ, maxXmaxZ,
+        minYminZ, minYmaxZ, maxYminZ, maxYmaxZ,
+        minXEdges, maxXEdges, minYEdges, maxYEdges, minZEdges, maxZEdges);
     }
   }
 

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYdZSolid.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYdZSolid.java?rev=1700102&r1=1700101&r2=1700102&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYdZSolid.java
(original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XYdZSolid.java
Sun Aug 30 09:45:18 2015
@@ -96,31 +96,31 @@ public class XYdZSolid extends BaseXYZSo
     // we'll start there.  We know that at most there will be two disconnected shapes on
the planet surface.
     // But there's also a case where exactly one plane slices through the world, and none
of the bounding plane
     // intersections do.  Thus, if we don't find any of the edge intersection cases, we have
to look for that last case.
-    GeoPoint[] edgePoints = findLargestSolution(minXZ, maxXZ, minYZ, maxYZ);
       
-    if (edgePoints.length == 0) {
-      // If we still haven't encountered anything, we need to look at single-plane/world
intersections.
-      // We detect these by looking at the world model and noting its x, y, and z bounds.
-      // The cases we are looking for are when the four corner points for any given
-      // plane are all outside of the world, AND that plane intersects the world.
-      // There are four corner points all told; we must evaluate these WRT the planet surface.
-      final boolean minXminYZ = planetModel.pointOutside(minX, minY, Z);
-      final boolean minXmaxYZ = planetModel.pointOutside(minX, maxY, Z);
-      final boolean maxXminYZ = planetModel.pointOutside(maxX, minY, Z);
-      final boolean maxXmaxYZ = planetModel.pointOutside(maxX, maxY, Z);
+    // If we still haven't encountered anything, we need to look at single-plane/world intersections.
+    // We detect these by looking at the world model and noting its x, y, and z bounds.
+    // The cases we are looking for are when the four corner points for any given
+    // plane are all outside of the world, AND that plane intersects the world.
+    // There are four corner points all told; we must evaluate these WRT the planet surface.
+    final boolean minXminYZ = planetModel.pointOutside(minX, minY, Z);
+    final boolean minXmaxYZ = planetModel.pointOutside(minX, maxY, Z);
+    final boolean maxXminYZ = planetModel.pointOutside(maxX, minY, Z);
+    final boolean maxXmaxYZ = planetModel.pointOutside(maxX, maxY, Z);
 
-      if (Z - worldMinZ >= -Vector.MINIMUM_RESOLUTION && Z - worldMaxZ <= Vector.MINIMUM_RESOLUTION
&&
-        minX < 0.0 && maxX > 0.0 && minY < 0.0 && maxY >
0.0 &&
-        minXminYZ && minXmaxYZ && maxXminYZ && maxXmaxYZ) {
-        // Find any point on the minZ plane that intersects the world
-        // First construct a perpendicular plane that will allow us to find a sample point.
-        // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
-        // Then use it to compute a sample point.
-        edgePoints = new GeoPoint[]{zPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
-      }
+    final GeoPoint[] zEdges;
+    if (Z - worldMinZ >= -Vector.MINIMUM_RESOLUTION && Z - worldMaxZ <= Vector.MINIMUM_RESOLUTION
&&
+      minX < 0.0 && maxX > 0.0 && minY < 0.0 && maxY >
0.0 &&
+      minXminYZ && minXmaxYZ && maxXminYZ && maxXmaxYZ) {
+      // Find any point on the minZ plane that intersects the world
+      // First construct a perpendicular plane that will allow us to find a sample point.
+      // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
+      // Then use it to compute a sample point.
+      zEdges = new GeoPoint[]{zPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
+    } else {
+      zEdges= EMPTY_POINTS;
     }
 
-    this.edgePoints = edgePoints;
+    this.edgePoints = glueTogether(minXZ, maxXZ, minYZ, maxYZ, zEdges);
   }
 
   @Override

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XdYZSolid.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XdYZSolid.java?rev=1700102&r1=1700101&r2=1700102&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XdYZSolid.java
(original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/XdYZSolid.java
Sun Aug 30 09:45:18 2015
@@ -96,31 +96,31 @@ public class XdYZSolid extends BaseXYZSo
     // we'll start there.  We know that at most there will be two disconnected shapes on
the planet surface.
     // But there's also a case where exactly one plane slices through the world, and none
of the bounding plane
     // intersections do.  Thus, if we don't find any of the edge intersection cases, we have
to look for that last case.
-    GeoPoint[] edgePoints = findLargestSolution(minXY, maxXY, YminZ, YmaxZ);
       
-    if (edgePoints.length == 0) {
-      // If we still haven't encountered anything, we need to look at single-plane/world
intersections.
-      // We detect these by looking at the world model and noting its x, y, and z bounds.
-      // The cases we are looking for are when the four corner points for any given
-      // plane are all outside of the world, AND that plane intersects the world.
-      // There are four corner points all told; we must evaluate these WRT the planet surface.
-      final boolean minXYminZ = planetModel.pointOutside(minX, Y, minZ);
-      final boolean minXYmaxZ = planetModel.pointOutside(minX, Y, maxZ);
-      final boolean maxXYminZ = planetModel.pointOutside(maxX, Y, minZ);
-      final boolean maxXYmaxZ = planetModel.pointOutside(maxX, Y, maxZ);
+    // We need to look at single-plane/world intersections.
+    // We detect these by looking at the world model and noting its x, y, and z bounds.
+    // The cases we are looking for are when the four corner points for any given
+    // plane are all outside of the world, AND that plane intersects the world.
+    // There are four corner points all told; we must evaluate these WRT the planet surface.
+    final boolean minXYminZ = planetModel.pointOutside(minX, Y, minZ);
+    final boolean minXYmaxZ = planetModel.pointOutside(minX, Y, maxZ);
+    final boolean maxXYminZ = planetModel.pointOutside(maxX, Y, minZ);
+    final boolean maxXYmaxZ = planetModel.pointOutside(maxX, Y, maxZ);
 
-      if (Y - worldMinY >= -Vector.MINIMUM_RESOLUTION && Y - worldMaxY <= Vector.MINIMUM_RESOLUTION
&&
-        minX < 0.0 && maxX > 0.0 && minZ < 0.0 && maxZ >
0.0 &&
-        minXYminZ && minXYmaxZ && maxXYminZ && maxXYmaxZ) {
-        // Find any point on the minY plane that intersects the world
-        // First construct a perpendicular plane that will allow us to find a sample point.
-        // This plane is vertical and goes through the points (0,0,0) and (0,1,0)
-        // Then use it to compute a sample point.
-        edgePoints = new GeoPoint[]{yPlane.getSampleIntersectionPoint(planetModel, yVerticalPlane)};
-      }
+    final GeoPoint[] yEdges;
+    if (Y - worldMinY >= -Vector.MINIMUM_RESOLUTION && Y - worldMaxY <= Vector.MINIMUM_RESOLUTION
&&
+      minX < 0.0 && maxX > 0.0 && minZ < 0.0 && maxZ >
0.0 &&
+      minXYminZ && minXYmaxZ && maxXYminZ && maxXYmaxZ) {
+      // Find any point on the minY plane that intersects the world
+      // First construct a perpendicular plane that will allow us to find a sample point.
+      // This plane is vertical and goes through the points (0,0,0) and (0,1,0)
+      // Then use it to compute a sample point.
+      yEdges = new GeoPoint[]{yPlane.getSampleIntersectionPoint(planetModel, yVerticalPlane)};
+    } else {
+      yEdges = EMPTY_POINTS;
     }
 
-    this.edgePoints = edgePoints;
+    this.edgePoints = glueTogether(minXY, maxXY, YminZ, YmaxZ, yEdges);
   }
 
   @Override

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java?rev=1700102&r1=1700101&r2=1700102&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java
(original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/java/org/apache/lucene/geo3d/dXYZSolid.java
Sun Aug 30 09:45:18 2015
@@ -96,32 +96,32 @@ public class dXYZSolid extends BaseXYZSo
     // we'll start there.  We know that at most there will be two disconnected shapes on
the planet surface.
     // But there's also a case where exactly one plane slices through the world, and none
of the bounding plane
     // intersections do.  Thus, if we don't find any of the edge intersection cases, we have
to look for that last case.
-    GeoPoint[] edgePoints = findLargestSolution(XminY,XmaxY,XminZ,XmaxZ);
       
-    if (edgePoints.length == 0) {
-      // If we still haven't encountered anything, we need to look at single-plane/world
intersections.
-      // We detect these by looking at the world model and noting its x, y, and z bounds.
-      // For the single-dimension degenerate case, there's really only one plane that can
possibly intersect the world.
-      // The cases we are looking for are when the four corner points for any given
-      // plane are all outside of the world, AND that plane intersects the world.
-      // There are four corner points all told; we must evaluate these WRT the planet surface.
-      final boolean XminYminZ = planetModel.pointOutside(X, minY, minZ);
-      final boolean XminYmaxZ = planetModel.pointOutside(X, minY, maxZ);
-      final boolean XmaxYminZ = planetModel.pointOutside(X, maxY, minZ);
-      final boolean XmaxYmaxZ = planetModel.pointOutside(X, maxY, maxZ);
+    // We need to look at single-plane/world intersections.
+    // We detect these by looking at the world model and noting its x, y, and z bounds.
+    // For the single-dimension degenerate case, there's really only one plane that can possibly
intersect the world.
+    // The cases we are looking for are when the four corner points for any given
+    // plane are all outside of the world, AND that plane intersects the world.
+    // There are four corner points all told; we must evaluate these WRT the planet surface.
+    final boolean XminYminZ = planetModel.pointOutside(X, minY, minZ);
+    final boolean XminYmaxZ = planetModel.pointOutside(X, minY, maxZ);
+    final boolean XmaxYminZ = planetModel.pointOutside(X, maxY, minZ);
+    final boolean XmaxYmaxZ = planetModel.pointOutside(X, maxY, maxZ);
 
-      if (X - worldMinX >= -Vector.MINIMUM_RESOLUTION && X - worldMaxX <= Vector.MINIMUM_RESOLUTION
&&
-        minY < 0.0 && maxY > 0.0 && minZ < 0.0 && maxZ >
0.0 &&
-        XminYminZ && XminYmaxZ && XmaxYminZ && XmaxYmaxZ) {
-        // Find any point on the X plane that intersects the world
-        // First construct a perpendicular plane that will allow us to find a sample point.
-        // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
-        // Then use it to compute a sample point.
-        edgePoints = new GeoPoint[]{xPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
-      }
+    final GeoPoint[] xEdges;
+    if (X - worldMinX >= -Vector.MINIMUM_RESOLUTION && X - worldMaxX <= Vector.MINIMUM_RESOLUTION
&&
+      minY < 0.0 && maxY > 0.0 && minZ < 0.0 && maxZ >
0.0 &&
+      XminYminZ && XminYmaxZ && XmaxYminZ && XmaxYmaxZ) {
+      // Find any point on the X plane that intersects the world
+      // First construct a perpendicular plane that will allow us to find a sample point.
+      // This plane is vertical and goes through the points (0,0,0) and (1,0,0)
+      // Then use it to compute a sample point.
+      xEdges = new GeoPoint[]{xPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane)};
+    } else {
+      xEdges = EMPTY_POINTS;
     }
 
-    this.edgePoints = edgePoints;
+    this.edgePoints = glueTogether(XminY,XmaxY,XminZ,XmaxZ,xEdges);
   }
 
   @Override

Modified: lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java?rev=1700102&r1=1700101&r2=1700102&view=diff
==============================================================================
--- lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java
(original)
+++ lucene/dev/branches/lucene6699/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java
Sun Aug 30 09:45:18 2015
@@ -145,6 +145,14 @@ public class GeoBBoxTest {
     GeoPoint point;
     int relationship;
     
+    c= GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, 0.7570958596622309, -0.7458670829264561,
-0.9566079379002148, 1.4802570961901191);
+    solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,0.10922258701604912,0.1248184603754517,-0.8172414690802067,0.9959041483215542,-0.6136586624726926,0.6821740363641521);
+    point = new GeoPoint(PlanetModel.SPHERE, 0.3719987557178081, 1.4529582778845198);
+    assertTrue(c.isWithin(point));
+    assertTrue(solid.isWithin(point));
+    relationship = solid.getRelationship(c);
+    assertTrue(relationship == GeoArea.OVERLAPS || relationship == GeoArea.CONTAINS || relationship
== GeoArea.WITHIN);
+
     c= GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, 0.006607096847842122, -0.002828135860810422,
-0.0012934461873348349, 0.006727418645092394);
     solid = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,0.9999995988328008,1.0000000002328306,-0.0012934708508166816,0.006727393021214471,-0.002828157275369464,0.006607074060760007);
     point = new GeoPoint(PlanetModel.SPHERE, -5.236470872437899E-4, 3.992578692654256E-4);



Mime
View raw message