lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject svn commit: r1674732 [2/2] - in /lucene/dev/branches/lucene6196/lucene/spatial/src: java/org/apache/lucene/spatial/spatial4j/geo3d/ test/org/apache/lucene/spatial/spatial4j/ test/org/apache/lucene/spatial/spatial4j/geo3d/
Date Mon, 20 Apr 2015 04:31:30 GMT
Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoPoint.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoPoint.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoPoint.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoPoint.java Mon Apr 20 04:31:29 2015
@@ -21,24 +21,62 @@ package org.apache.lucene.spatial.spatia
 */
 public class GeoPoint extends Vector
 {
-    public GeoPoint(double sinLat, double sinLon, double cosLat, double cosLon)
+    public GeoPoint(final double sinLat, final double sinLon, final double cosLat, final double cosLon)
     {
         super(cosLat*cosLon,cosLat*sinLon,sinLat);
     }
       
-    public GeoPoint(double lat, double lon)
+    public GeoPoint(final double lat, final double lon)
     {
         this(Math.sin(lat),Math.sin(lon),Math.cos(lat),Math.cos(lon));
     }
           
-    public GeoPoint(double x, double y, double z)
+    public GeoPoint(final double x, final double y, final double z)
     {
         super(x,y,z);
     }
           
-    public double arcDistance(GeoPoint v)
+    public double arcDistance(final GeoPoint v)
     {
         return Tools.safeAcos(evaluate(v));
     }
 
+    /** Find a single point that is a specified arc distance away from this point.
+    */
+    public GeoPoint getSamplePoint(final double sinRotationAngle, final double cosRotationAngle) {
+        // Rotate in the best of three possible directions: x-y, x-z, y-z.
+        final double absX = Math.abs(x);
+        final double absY = Math.abs(y);
+        final double absZ = Math.abs(z);
+        if (absX > absY) {
+            // x > y
+            if (absY > absZ) {
+                // x > y > z
+                // rotate in x-y
+                return new GeoPoint(x*cosRotationAngle-y*sinRotationAngle,x*sinRotationAngle+y*cosRotationAngle,z);
+            } else {
+                // x > z > y OR z > x > y
+                // rotate in x-z
+                return new GeoPoint(x*cosRotationAngle-z*sinRotationAngle,y,x*sinRotationAngle+z*cosRotationAngle);
+            }
+        } else {
+            // y > x
+            if (absX > absZ) {
+                // y > x > z
+                // rotate in x-y
+                return new GeoPoint(x*cosRotationAngle-y*sinRotationAngle,x*sinRotationAngle+y*cosRotationAngle,z);
+            } else {
+                // y > z > x OR z > y > x
+                // rotate in y-z
+                return new GeoPoint(x,y*cosRotationAngle-z*sinRotationAngle,y*sinRotationAngle+z*cosRotationAngle);
+            }
+        }
+    }
+    
+    /** Find a single point that is a specified arc distance away from this point.
+    */
+    public GeoPoint getSamplePoint(final double rotationAngle) {
+        return getSamplePoint(Math.sin(rotationAngle), Math.cos(rotationAngle));
+    }
+
 }

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoPolygonFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoPolygonFactory.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoPolygonFactory.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoPolygonFactory.java Mon Apr 20 04:31:29 2015
@@ -17,8 +17,9 @@ package org.apache.lucene.spatial.spatia
  * limitations under the License.
  */
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.List;
 
 /** Class which constructs a GeoMembershipShape representing an arbitrary polygon.
 */
@@ -38,25 +39,28 @@ public class GeoPolygonFactory
         // describing membership.
         return buildPolygonShape(pointList, convexPointIndex, getLegalIndex(convexPointIndex+1,pointList.size()),
             new SidedPlane(pointList.get(getLegalIndex(convexPointIndex-1,pointList.size())),
-                pointList.get(convexPointIndex), pointList.get(getLegalIndex(convexPointIndex+1,pointList.size()))));
+                pointList.get(convexPointIndex), pointList.get(getLegalIndex(convexPointIndex+1,pointList.size()))),
+            false);
     }
 
-    public static GeoMembershipShape buildPolygonShape(List<GeoPoint> pointsList, int startPointIndex, int endPointIndex, SidedPlane startingEdge) {
+    public static GeoMembershipShape buildPolygonShape(List<GeoPoint> pointsList, int startPointIndex, int endPointIndex, SidedPlane startingEdge, boolean isInternalEdge) {
         // Algorithm as follows:
         // Start with sided edge.  Go through all points in some order.  For each new point, determine if the point is within all edges considered so far.
         // If not, put it into a list of points for recursion.  If it is within, add new edge and keep going.
         // Once we detect a point that is within, if there are points put aside for recursion, then call recursively.
         
         // Current composite.  This is what we'll actually be returning.
-        GeoCompositeMembershipShape rval = new GeoCompositeMembershipShape();
+        final GeoCompositeMembershipShape rval = new GeoCompositeMembershipShape();
         
-        List<GeoPoint> recursionList = new ArrayList<GeoPoint>();
-        List<GeoPoint> currentList = new ArrayList<GeoPoint>();
-        List<SidedPlane> currentPlanes = new ArrayList<SidedPlane>();
+        final List<GeoPoint> recursionList = new ArrayList<GeoPoint>();
+        final List<GeoPoint> currentList = new ArrayList<GeoPoint>();
+        final BitSet internalEdgeList = new BitSet();
+        final List<SidedPlane> currentPlanes = new ArrayList<SidedPlane>();
         
         // Initialize the current list and current planes
         currentList.add(pointsList.get(startPointIndex));
         currentList.add(pointsList.get(endPointIndex));
+        internalEdgeList.set(currentPlanes.size(),isInternalEdge);
         currentPlanes.add(startingEdge);
         
         // Now, scan all remaining points, in order.  We'll use an index and just add to it.
@@ -92,7 +96,8 @@ public class GeoPolygonFactory
                 }
                 if (!pointInside) {
                     // Any excluded points?
-                    if (recursionList.size() > 0) {
+                    boolean isInternalBoundary = recursionList.size() > 0;
+                    if (isInternalBoundary) {
                         // Handle exclusion
                         recursionList.add(newPoint);
                         recursionList.add(currentList.get(currentList.size()-1));
@@ -103,10 +108,11 @@ public class GeoPolygonFactory
                         }
                         // We want the other side for the recursion
                         SidedPlane otherSideNewBoundary = new SidedPlane(newBoundary);
-                        rval.addShape(buildPolygonShape(recursionList,recursionList.size()-2,recursionList.size()-1,otherSideNewBoundary));
+                        rval.addShape(buildPolygonShape(recursionList,recursionList.size()-2,recursionList.size()-1,otherSideNewBoundary,true));
                         recursionList.clear();
                     }
                     currentList.add(newPoint);
+                    internalEdgeList.set(currentPlanes.size(),isInternalBoundary);
                     currentPlanes.add(newBoundary);
                 } else {
                     recursionList.add(newPoint);
@@ -116,7 +122,8 @@ public class GeoPolygonFactory
             }
         }
         
-        if (recursionList.size() > 0) {
+        boolean returnEdgeInternalBoundary = recursionList.size() > 0;
+        if (returnEdgeInternalBoundary) {
             // The last step back to the start point had a recursion, so take care of that before we complete our work
             recursionList.add(currentList.get(0));
             recursionList.add(currentList.get(currentList.size()-1));
@@ -129,18 +136,11 @@ public class GeoPolygonFactory
             SidedPlane newBoundary = new SidedPlane(currentList.get(currentList.size()-2),currentList.get(0),currentList.get(currentList.size()-1));
             // We want the other side for the recursion
             SidedPlane otherSideNewBoundary = new SidedPlane(newBoundary);
-            rval.addShape(buildPolygonShape(recursionList,recursionList.size()-2,recursionList.size()-1,otherSideNewBoundary));
+            rval.addShape(buildPolygonShape(recursionList,recursionList.size()-2,recursionList.size()-1,otherSideNewBoundary,true));
             recursionList.clear();
         }
-        
         // Now, add in the current shape.
-        /*
-        System.out.println("Creating polygon:");
-        for (GeoPoint p : currentList) {
-            System.out.println(" "+p);
-        }
-        */
-        rval.addShape(new GeoConvexPolygon(currentList));
+        rval.addShape(new GeoConvexPolygon(currentList,internalEdgeList,returnEdgeInternalBoundary));
         //System.out.println("Done creating polygon");
         return rval;
     }

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoRectangle.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoRectangle.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoRectangle.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoRectangle.java Mon Apr 20 04:31:29 2015
@@ -21,7 +21,7 @@ package org.apache.lucene.spatial.spatia
 * The left-right maximum extent for this shape is PI; for anything larger, use
 * GeoWideRectangle.
 */
-public class GeoRectangle implements GeoBBox
+public class GeoRectangle extends GeoBBoxBase
 {
     public final double topLat;
     public final double bottomLat;
@@ -42,8 +42,10 @@ public class GeoRectangle implements Geo
       
     public final GeoPoint centerPoint;
 
+    public final GeoPoint[] edgePoints;
+    
     /** Accepts only values in the following ranges: lat: {@code -PI/2 -> PI/2}, lon: {@code -PI -> PI} */
-    public GeoRectangle(double topLat, double bottomLat, double leftLon, double rightLon)
+    public GeoRectangle(final double topLat, final double bottomLat, final double leftLon, double rightLon)
     {
         // Argument checking
         if (topLat > Math.PI * 0.5 || topLat < -Math.PI * 0.5)
@@ -68,14 +70,14 @@ public class GeoRectangle implements Geo
         this.leftLon = leftLon;
         this.rightLon = rightLon;
           
-        double sinTopLat = Math.sin(topLat);
-        double cosTopLat = Math.cos(topLat);
-        double sinBottomLat = Math.sin(bottomLat);
-        double cosBottomLat = Math.cos(bottomLat);
-        double sinLeftLon = Math.sin(leftLon);
-        double cosLeftLon = Math.cos(leftLon);
-        double sinRightLon = Math.sin(rightLon);
-        double cosRightLon = Math.cos(rightLon);
+        final double sinTopLat = Math.sin(topLat);
+        final double cosTopLat = Math.cos(topLat);
+        final double sinBottomLat = Math.sin(bottomLat);
+        final double cosBottomLat = Math.cos(bottomLat);
+        final double sinLeftLon = Math.sin(leftLon);
+        final double cosLeftLon = Math.cos(leftLon);
+        final double sinRightLon = Math.sin(rightLon);
+        final double cosRightLon = Math.cos(rightLon);
         
         // Now build the four points
         this.ULHC = new GeoPoint(sinTopLat,sinLeftLon,cosTopLat,cosLeftLon);
@@ -83,31 +85,32 @@ public class GeoRectangle implements Geo
         this.LRHC = new GeoPoint(sinBottomLat,sinRightLon,cosBottomLat,cosRightLon);
         this.LLHC = new GeoPoint(sinBottomLat,sinLeftLon,cosBottomLat,cosLeftLon);
         
-        double middleLat = (topLat + bottomLat) * 0.5;
-        double sinMiddleLat = Math.sin(middleLat);
-        cosMiddleLat = Math.cos(middleLat);
+        final double middleLat = (topLat + bottomLat) * 0.5;
+        final double sinMiddleLat = Math.sin(middleLat);
+        this.cosMiddleLat = Math.cos(middleLat);
         // Normalize
         while (leftLon > rightLon) {
             rightLon += Math.PI * 2.0;
         }
-        double middleLon = (leftLon + rightLon) * 0.5;
-        double sinMiddleLon = Math.sin(middleLon);
-        double cosMiddleLon = Math.cos(middleLon);
+        final double middleLon = (leftLon + rightLon) * 0.5;
+        final double sinMiddleLon = Math.sin(middleLon);
+        final double cosMiddleLon = Math.cos(middleLon);
           
-        centerPoint = new GeoPoint(sinMiddleLat,sinMiddleLon,cosMiddleLat,cosMiddleLon);
+        this.centerPoint = new GeoPoint(sinMiddleLat,sinMiddleLon,cosMiddleLat,cosMiddleLon);
 
         this.topPlane = new SidedPlane(centerPoint,sinTopLat);
         this.bottomPlane = new SidedPlane(centerPoint,sinBottomLat);
         this.leftPlane = new SidedPlane(centerPoint,cosLeftLon,sinLeftLon);
         this.rightPlane = new SidedPlane(centerPoint,cosRightLon,sinRightLon);
 
+        this.edgePoints = new GeoPoint[]{ULHC};
     }
 
     @Override
-    public GeoBBox expand(double angle)
+    public GeoBBox expand(final double angle)
     {
-        double newTopLat = topLat + angle;
-        double newBottomLat = bottomLat - angle;
+        final double newTopLat = topLat + angle;
+        final double newBottomLat = bottomLat - angle;
         // Figuring out when we escalate to a special case requires some prefiguring
         double currentLonSpan = rightLon - leftLon;
         if (currentLonSpan < 0.0)
@@ -122,7 +125,7 @@ public class GeoRectangle implements Geo
     }
 
     @Override
-    public boolean isWithin(Vector point)
+    public boolean isWithin(final Vector point)
     {
         return topPlane.isWithin(point) &&
           bottomPlane.isWithin(point) &&
@@ -131,7 +134,7 @@ public class GeoRectangle implements Geo
     }
 
     @Override
-    public boolean isWithin(double x, double y, double z)
+    public boolean isWithin(final double x, final double y, final double z)
     {
         return topPlane.isWithin(x,y,z) &&
           bottomPlane.isWithin(x,y,z) &&
@@ -145,20 +148,20 @@ public class GeoRectangle implements Geo
         // Here we compute the distance from the middle point to one of the corners.  However, we need to be careful
         // to use the longest of three distances: the distance to a corner on the top; the distnace to a corner on the bottom, and
         // the distance to the right or left edge from the center.
-        double centerAngle = (rightLon - (rightLon + leftLon) * 0.5) * cosMiddleLat;
-        double topAngle = centerPoint.arcDistance(URHC);
-        double bottomAngle = centerPoint.arcDistance(LLHC);
+        final double centerAngle = (rightLon - (rightLon + leftLon) * 0.5) * cosMiddleLat;
+        final double topAngle = centerPoint.arcDistance(URHC);
+        final double bottomAngle = centerPoint.arcDistance(LLHC);
         return Math.max(centerAngle,Math.max(topAngle,bottomAngle));
     }
       
     @Override
-    public GeoPoint getInteriorPoint()
+    public GeoPoint[] getEdgePoints()
     {
-        return centerPoint;
+        return edgePoints;
     }
       
     @Override
-    public boolean intersects(Plane p, Membership... bounds)
+    public boolean intersects(final Plane p, final Membership... bounds)
     {
         return p.intersects(topPlane,bounds,bottomPlane,leftPlane,rightPlane) ||
           p.intersects(bottomPlane,bounds,topPlane,leftPlane,rightPlane) ||
@@ -184,17 +187,26 @@ public class GeoRectangle implements Geo
     }
 
     @Override
-    public int getRelationship(GeoShape path) {
+    public int getRelationship(final GeoShape path) {
+        final int insideRectangle = isShapeInsideBBox(path);
+        if (insideRectangle == SOME_INSIDE)
+            return OVERLAPS;
+
+        final boolean insideShape = path.isWithin(ULHC);
+        
+        if (insideRectangle == ALL_INSIDE && insideShape)
+            return OVERLAPS;
+
         if (path.intersects(topPlane,bottomPlane,leftPlane,rightPlane) ||
             path.intersects(bottomPlane,topPlane,leftPlane,rightPlane) ||
             path.intersects(leftPlane,topPlane,bottomPlane,rightPlane) ||
             path.intersects(rightPlane,leftPlane,topPlane,bottomPlane))
             return OVERLAPS;
 
-        if (isWithin(path.getInteriorPoint()))
+        if (insideRectangle == ALL_INSIDE)
             return WITHIN;
     
-        if (path.isWithin(centerPoint))
+        if (insideShape)
             return CONTAINS;
         
         return DISJOINT;
@@ -215,5 +227,10 @@ public class GeoRectangle implements Geo
         result = 31 * result + LRHC.hashCode();
         return result;
     }
+    
+    @Override
+    public String toString() {
+        return "GeoRectangle: {toplat="+topLat+"("+topLat*180.0/Math.PI+"), bottomlat="+bottomLat+"("+bottomLat*180.0/Math.PI+"), leftlon="+leftLon+"("+leftLon*180.0/Math.PI+"), rightlon="+rightLon+"("+rightLon*180.0/Math.PI+")}";
+    }
 }
   

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoShape.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoShape.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoShape.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoShape.java Mon Apr 20 04:31:29 2015
@@ -23,20 +23,25 @@ package org.apache.lucene.spatial.spatia
 */
 public interface GeoShape extends Membership {
 
-    /** Return a sample point that is inside the shape.
-     *@return an interior point.
+    /** Return a sample point that is on the outside edge/boundary of the shape.
+     *@return samples of all edge points from distinct edge sections.  Typically one point
+     * is returned, but zero or two are also possible.
      */
-    public GeoPoint getInteriorPoint();
+    public GeoPoint[] getEdgePoints();
     
     /** Assess whether a plane, within the provided bounds, intersects
-     * with the shape.
+     * with the shape.  Note well that this method is allowed to return "true"
+     * if there are internal edges of a composite shape which intersect the plane.  
+     * Doing this can cause getRelationship() for most GeoBBox shapes to return
+     * OVERLAPS rather than the more correct CONTAINS, but that cannot be
+     * helped for some complex shapes that are built out of overlapping parts.
      *@param plane is the plane to assess for intersection with the shape's edges or
      *  bounding curves.
      *@param bounds are a set of bounds that define an area that an
      *  intersection must be within in order to qualify (provided by a GeoArea).
      *@return true if there's such an intersection, false if not.
      */
-    public boolean intersects(Plane plane, Membership... bounds);
+    public boolean intersects(final Plane plane, final Membership... bounds);
 
     /** Compute longitude/latitude bounds for the shape.
     *@param bounds is the optional input bounds object.  If this is null,
@@ -45,7 +50,7 @@ public interface GeoShape extends Member
     * be computed, then return a Bounds object with noLongitudeBound,
     * noTopLatitudeBound, and noBottomLatitudeBound.
     */
-    public Bounds getBounds(Bounds bounds);
+    public Bounds getBounds(final Bounds bounds);
 
     /** Equals */
     public boolean equals(Object o);

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideDegenerateHorizontalLine.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideDegenerateHorizontalLine.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideDegenerateHorizontalLine.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideDegenerateHorizontalLine.java Mon Apr 20 04:31:29 2015
@@ -19,7 +19,7 @@ package org.apache.lucene.spatial.spatia
 
 /** Degenerate bounding box wider than PI and limited on two sides (left lon, right lon).
 */
-public class GeoWideDegenerateHorizontalLine implements GeoBBox
+public class GeoWideDegenerateHorizontalLine extends GeoBBoxBase
 {
     public final double latitude;
     public final double leftLon;
@@ -36,10 +36,12 @@ public class GeoWideDegenerateHorizontal
 
     public final EitherBound eitherBound;
     
+    public final GeoPoint[] edgePoints;
+    
     /** Accepts only values in the following ranges: lat: {@code -PI/2 -> PI/2}, lon: {@code -PI -> PI}.
      * Horizontal angle must be greater than or equal to PI.
      */
-    public GeoWideDegenerateHorizontalLine(double latitude, double leftLon, double rightLon)
+    public GeoWideDegenerateHorizontalLine(final double latitude, final double leftLon, double rightLon)
     {
         // Argument checking
         if (latitude > Math.PI * 0.5 || latitude < -Math.PI * 0.5)
@@ -59,12 +61,12 @@ public class GeoWideDegenerateHorizontal
         this.leftLon = leftLon;
         this.rightLon = rightLon;
           
-        double sinLatitude = Math.sin(latitude);
-        double cosLatitude = Math.cos(latitude);
-        double sinLeftLon = Math.sin(leftLon);
-        double cosLeftLon = Math.cos(leftLon);
-        double sinRightLon = Math.sin(rightLon);
-        double cosRightLon = Math.cos(rightLon);
+        final double sinLatitude = Math.sin(latitude);
+        final double cosLatitude = Math.cos(latitude);
+        final double sinLeftLon = Math.sin(leftLon);
+        final double cosLeftLon = Math.cos(leftLon);
+        final double sinRightLon = Math.sin(rightLon);
+        final double cosRightLon = Math.cos(rightLon);
         
         // Now build the two points
         this.LHC = new GeoPoint(sinLatitude,sinLeftLon,cosLatitude,cosLeftLon);
@@ -80,19 +82,21 @@ public class GeoWideDegenerateHorizontal
         double sinMiddleLon = Math.sin(middleLon);
         double cosMiddleLon = Math.cos(middleLon);
           
-        centerPoint = new GeoPoint(sinLatitude,sinMiddleLon,cosLatitude,cosMiddleLon);
+        this.centerPoint = new GeoPoint(sinLatitude,sinMiddleLon,cosLatitude,cosMiddleLon);
 
         this.leftPlane = new SidedPlane(centerPoint,cosLeftLon,sinLeftLon);
         this.rightPlane = new SidedPlane(centerPoint,cosRightLon,sinRightLon);
 
         this.eitherBound = new EitherBound();
+        
+        this.edgePoints = new GeoPoint[]{centerPoint};
     }
 
     @Override
-    public GeoBBox expand(double angle)
+    public GeoBBox expand(final double angle)
     {
-        double newTopLat = latitude + angle;
-        double newBottomLat = latitude - angle;
+        final double newTopLat = latitude + angle;
+        final double newBottomLat = latitude - angle;
         // Figuring out when we escalate to a special case requires some prefiguring
         double currentLonSpan = rightLon - leftLon;
         if (currentLonSpan < 0.0)
@@ -107,15 +111,17 @@ public class GeoWideDegenerateHorizontal
     }
 
     @Override
-    public boolean isWithin(Vector point)
+    public boolean isWithin(final Vector point)
     {
+        if (point == null)
+            return false;
         return plane.evaluate(point) == 0.0 &&
           (leftPlane.isWithin(point) ||
           rightPlane.isWithin(point));
     }
 
     @Override
-    public boolean isWithin(double x, double y, double z)
+    public boolean isWithin(final double x, final double y, final double z)
     {
         return plane.evaluate(x,y,z) == 0.0 &&
           (leftPlane.isWithin(x,y,z) ||
@@ -128,19 +134,19 @@ public class GeoWideDegenerateHorizontal
         // Here we compute the distance from the middle point to one of the corners.  However, we need to be careful
         // to use the longest of three distances: the distance to a corner on the top; the distnace to a corner on the bottom, and
         // the distance to the right or left edge from the center.
-        double topAngle = centerPoint.arcDistance(RHC);
-        double bottomAngle = centerPoint.arcDistance(LHC);
+        final double topAngle = centerPoint.arcDistance(RHC);
+        final double bottomAngle = centerPoint.arcDistance(LHC);
         return Math.max(topAngle,bottomAngle);
     }
       
     @Override
-    public GeoPoint getInteriorPoint()
+    public GeoPoint[] getEdgePoints()
     {
-        return centerPoint;
+        return edgePoints;
     }
       
     @Override
-    public boolean intersects(Plane p, Membership... bounds)
+    public boolean intersects(final Plane p, final Membership... bounds)
     {
         // Right and left bounds are essentially independent hemispheres; crossing into the wrong part of one
         // requires crossing into the right part of the other.  So intersection can ignore the left/right bounds.
@@ -165,8 +171,7 @@ public class GeoWideDegenerateHorizontal
     }
 
     @Override
-    public int getRelationship(GeoShape path) {
-
+    public int getRelationship(final GeoShape path) {
         if (path.intersects(plane,eitherBound)) {
             return OVERLAPS;
         }
@@ -194,17 +199,22 @@ public class GeoWideDegenerateHorizontal
         return result;
     }
 
+    @Override
+    public String toString() {
+        return "GeoWideDegenerateHorizontalLine: {latitude="+latitude+"("+latitude*180.0/Math.PI+"), leftlon="+leftLon+"("+leftLon*180.0/Math.PI+"), rightLon="+rightLon+"("+rightLon*180.0/Math.PI+")}";
+    }
+
     protected class EitherBound implements Membership {
         public EitherBound() {
         }
         
         @Override
-        public boolean isWithin(Vector v) {
+        public boolean isWithin(final Vector v) {
             return leftPlane.isWithin(v) || rightPlane.isWithin(v);
         }
         
         @Override
-        public boolean isWithin(double x, double y, double z) {
+        public boolean isWithin(final double x, final double y, final double z) {
             return leftPlane.isWithin(x,y,z) || rightPlane.isWithin(x,y,z);
         }
     }

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideLongitudeSlice.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideLongitudeSlice.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideLongitudeSlice.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideLongitudeSlice.java Mon Apr 20 04:31:29 2015
@@ -20,7 +20,7 @@ package org.apache.lucene.spatial.spatia
 /** Bounding box wider than PI but limited on left and right sides (
 * left lon, right lon).
 */
-public class GeoWideLongitudeSlice implements GeoBBox
+public class GeoWideLongitudeSlice extends GeoBBoxBase
 {
     public final double leftLon;
     public final double rightLon;
@@ -29,11 +29,13 @@ public class GeoWideLongitudeSlice imple
     public final SidedPlane rightPlane;
       
     public final GeoPoint centerPoint;
-
+    public final GeoPoint northPole = new GeoPoint(0.0,0.0,1.0);
+    public final GeoPoint[] edgePoints = new GeoPoint[]{northPole};
+    
     /** Accepts only values in the following ranges: lon: {@code -PI -> PI}.
     * Horizantal angle must be greater than or equal to PI.
     */
-    public GeoWideLongitudeSlice(double leftLon, double rightLon)
+    public GeoWideLongitudeSlice(final double leftLon, double rightLon)
     {
         // Argument checking
         if (leftLon < -Math.PI || leftLon > Math.PI)
@@ -50,24 +52,24 @@ public class GeoWideLongitudeSlice imple
         this.leftLon = leftLon;
         this.rightLon = rightLon;
           
-        double sinLeftLon = Math.sin(leftLon);
-        double cosLeftLon = Math.cos(leftLon);
-        double sinRightLon = Math.sin(rightLon);
-        double cosRightLon = Math.cos(rightLon);
+        final double sinLeftLon = Math.sin(leftLon);
+        final double cosLeftLon = Math.cos(leftLon);
+        final double sinRightLon = Math.sin(rightLon);
+        final double cosRightLon = Math.cos(rightLon);
 
         // Normalize
         while (leftLon > rightLon) {
             rightLon += Math.PI * 2.0;
         }
-        double middleLon = (leftLon + rightLon) * 0.5;
-        centerPoint = new GeoPoint(0.0,middleLon);              
+        final double middleLon = (leftLon + rightLon) * 0.5;
+        this.centerPoint = new GeoPoint(0.0,middleLon);              
         
         this.leftPlane = new SidedPlane(centerPoint,cosLeftLon,sinLeftLon);
         this.rightPlane = new SidedPlane(centerPoint,cosRightLon,sinRightLon);
     }
 
     @Override
-    public GeoBBox expand(double angle)
+    public GeoBBox expand(final double angle)
     {
         // Figuring out when we escalate to a special case requires some prefiguring
         double currentLonSpan = rightLon - leftLon;
@@ -83,14 +85,14 @@ public class GeoWideLongitudeSlice imple
     }
 
     @Override
-    public boolean isWithin(Vector point)
+    public boolean isWithin(final Vector point)
     {
         return leftPlane.isWithin(point) ||
           rightPlane.isWithin(point);
     }
 
     @Override
-    public boolean isWithin(double x, double y, double z)
+    public boolean isWithin(final double x, final double y, final double z)
     {
         return leftPlane.isWithin(x,y,z) ||
           rightPlane.isWithin(x,y,z);
@@ -107,13 +109,13 @@ public class GeoWideLongitudeSlice imple
     }
       
     @Override
-    public GeoPoint getInteriorPoint()
+    public GeoPoint[] getEdgePoints()
     {
-        return centerPoint;
+        return edgePoints;
     }
       
     @Override
-    public boolean intersects(Plane p, Membership... bounds)
+    public boolean intersects(final Plane p, final Membership... bounds)
     {
         // Right and left bounds are essentially independent hemispheres; crossing into the wrong part of one
         // requires crossing into the right part of the other.  So intersection can ignore the left/right bounds.
@@ -139,15 +141,24 @@ public class GeoWideLongitudeSlice imple
     }
 
     @Override
-    public int getRelationship(GeoShape path) {
+    public int getRelationship(final GeoShape path) {
+        final int insideRectangle = isShapeInsideBBox(path);
+        if (insideRectangle == SOME_INSIDE)
+            return OVERLAPS;
+
+        final boolean insideShape = path.isWithin(northPole);
+        
+        if (insideRectangle == ALL_INSIDE && insideShape)
+            return OVERLAPS;
+
         if (path.intersects(leftPlane) ||
             path.intersects(rightPlane))
             return OVERLAPS;
 
-        if (isWithin(path.getInteriorPoint()))
+        if (insideRectangle == ALL_INSIDE)
             return WITHIN;
 
-        if (path.isWithin(centerPoint))
+        if (insideShape)
             return CONTAINS;
         
         return DISJOINT;
@@ -172,5 +183,10 @@ public class GeoWideLongitudeSlice imple
         result = 31 * result + (int) (temp ^ (temp >>> 32));
         return result;
     }
+    
+    @Override
+    public String toString() {
+        return "GeoWideLongitudeSlice: {leftlon="+leftLon+"("+leftLon*180.0/Math.PI+"), rightlon="+rightLon+"("+rightLon*180.0/Math.PI+")}";
+    }
 }
   

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideRectangle.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideRectangle.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideRectangle.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWideRectangle.java Mon Apr 20 04:31:29 2015
@@ -20,7 +20,7 @@ package org.apache.lucene.spatial.spatia
 /** Bounding box wider than PI but limited on four sides (top lat,
 * bottom lat, left lon, right lon).
 */
-public class GeoWideRectangle implements GeoBBox
+public class GeoWideRectangle extends GeoBBoxBase
 {
     public final double topLat;
     public final double bottomLat;
@@ -43,10 +43,12 @@ public class GeoWideRectangle implements
 
     public final EitherBound eitherBound;
     
+    public final GeoPoint[] edgePoints;
+    
     /** Accepts only values in the following ranges: lat: {@code -PI/2 -> PI/2}, lon: {@code -PI -> PI}.
      * Horizontal angle must be greater than or equal to PI.
      */
-    public GeoWideRectangle(double topLat, double bottomLat, double leftLon, double rightLon)
+    public GeoWideRectangle(final double topLat, final double bottomLat, final double leftLon, double rightLon)
     {
         // Argument checking
         if (topLat > Math.PI * 0.5 || topLat < -Math.PI * 0.5)
@@ -71,14 +73,14 @@ public class GeoWideRectangle implements
         this.leftLon = leftLon;
         this.rightLon = rightLon;
           
-        double sinTopLat = Math.sin(topLat);
-        double cosTopLat = Math.cos(topLat);
-        double sinBottomLat = Math.sin(bottomLat);
-        double cosBottomLat = Math.cos(bottomLat);
-        double sinLeftLon = Math.sin(leftLon);
-        double cosLeftLon = Math.cos(leftLon);
-        double sinRightLon = Math.sin(rightLon);
-        double cosRightLon = Math.cos(rightLon);
+        final double sinTopLat = Math.sin(topLat);
+        final double cosTopLat = Math.cos(topLat);
+        final double sinBottomLat = Math.sin(bottomLat);
+        final double cosBottomLat = Math.cos(bottomLat);
+        final double sinLeftLon = Math.sin(leftLon);
+        final double cosLeftLon = Math.cos(leftLon);
+        final double sinRightLon = Math.sin(rightLon);
+        final double cosRightLon = Math.cos(rightLon);
         
         // Now build the four points
         this.ULHC = new GeoPoint(sinTopLat,sinLeftLon,cosTopLat,cosLeftLon);
@@ -86,18 +88,18 @@ public class GeoWideRectangle implements
         this.LRHC = new GeoPoint(sinBottomLat,sinRightLon,cosBottomLat,cosRightLon);
         this.LLHC = new GeoPoint(sinBottomLat,sinLeftLon,cosBottomLat,cosLeftLon);
         
-        double middleLat = (topLat + bottomLat) * 0.5;
-        double sinMiddleLat = Math.sin(middleLat);
-        cosMiddleLat = Math.cos(middleLat);
+        final double middleLat = (topLat + bottomLat) * 0.5;
+        final double sinMiddleLat = Math.sin(middleLat);
+        this.cosMiddleLat = Math.cos(middleLat);
         // Normalize
         while (leftLon > rightLon) {
             rightLon += Math.PI * 2.0;
         }
-        double middleLon = (leftLon + rightLon) * 0.5;
-        double sinMiddleLon = Math.sin(middleLon);
-        double cosMiddleLon = Math.cos(middleLon);
+        final double middleLon = (leftLon + rightLon) * 0.5;
+        final double sinMiddleLon = Math.sin(middleLon);
+        final double cosMiddleLon = Math.cos(middleLon);
           
-        centerPoint = new GeoPoint(sinMiddleLat,sinMiddleLon,cosMiddleLat,cosMiddleLon);
+        this.centerPoint = new GeoPoint(sinMiddleLat,sinMiddleLon,cosMiddleLat,cosMiddleLon);
 
         this.topPlane = new SidedPlane(centerPoint,sinTopLat);
         this.bottomPlane = new SidedPlane(centerPoint,sinBottomLat);
@@ -105,13 +107,15 @@ public class GeoWideRectangle implements
         this.rightPlane = new SidedPlane(centerPoint,cosRightLon,sinRightLon);
           
         this.eitherBound = new EitherBound();
+        
+        this.edgePoints = new GeoPoint[]{ULHC};
     }
 
     @Override
-    public GeoBBox expand(double angle)
+    public GeoBBox expand(final double angle)
     {
-        double newTopLat = topLat + angle;
-        double newBottomLat = bottomLat - angle;
+        final double newTopLat = topLat + angle;
+        final double newBottomLat = bottomLat - angle;
         // Figuring out when we escalate to a special case requires some prefiguring
         double currentLonSpan = rightLon - leftLon;
         if (currentLonSpan < 0.0)
@@ -126,7 +130,7 @@ public class GeoWideRectangle implements
     }
 
     @Override
-    public boolean isWithin(Vector point)
+    public boolean isWithin(final Vector point)
     {
         return topPlane.isWithin(point) &&
           bottomPlane.isWithin(point) &&
@@ -135,7 +139,7 @@ public class GeoWideRectangle implements
     }
 
     @Override
-    public boolean isWithin(double x, double y, double z)
+    public boolean isWithin(final double x, final double y, final double z)
     {
         return topPlane.isWithin(x,y,z) &&
           bottomPlane.isWithin(x,y,z) &&
@@ -149,20 +153,20 @@ public class GeoWideRectangle implements
         // Here we compute the distance from the middle point to one of the corners.  However, we need to be careful
         // to use the longest of three distances: the distance to a corner on the top; the distnace to a corner on the bottom, and
         // the distance to the right or left edge from the center.
-        double centerAngle = (rightLon - (rightLon + leftLon) * 0.5) * cosMiddleLat;
-        double topAngle = centerPoint.arcDistance(URHC);
-        double bottomAngle = centerPoint.arcDistance(LLHC);
+        final double centerAngle = (rightLon - (rightLon + leftLon) * 0.5) * cosMiddleLat;
+        final double topAngle = centerPoint.arcDistance(URHC);
+        final double bottomAngle = centerPoint.arcDistance(LLHC);
         return Math.max(centerAngle,Math.max(topAngle,bottomAngle));
     }
       
     @Override
-    public GeoPoint getInteriorPoint()
+    public GeoPoint[] getEdgePoints()
     {
-        return centerPoint;
+        return edgePoints;
     }
       
     @Override
-    public boolean intersects(Plane p, Membership... bounds)
+    public boolean intersects(final Plane p, final Membership... bounds)
     {
         // Right and left bounds are essentially independent hemispheres; crossing into the wrong part of one
         // requires crossing into the right part of the other.  So intersection can ignore the left/right bounds.
@@ -190,19 +194,31 @@ public class GeoWideRectangle implements
     }
 
     @Override
-    public int getRelationship(GeoShape path) {
+    public int getRelationship(final GeoShape path) {
+        final int insideRectangle = isShapeInsideBBox(path);
+        if (insideRectangle == SOME_INSIDE)
+            return OVERLAPS;
+        
+        final boolean insideShape = path.isWithin(ULHC);
+        
+        if (insideRectangle == ALL_INSIDE && insideShape)
+            return OVERLAPS;
+        
         if (path.intersects(topPlane,bottomPlane,eitherBound) ||
             path.intersects(bottomPlane,topPlane,eitherBound) ||
             path.intersects(leftPlane,topPlane,bottomPlane) ||
-            path.intersects(rightPlane,topPlane,bottomPlane))
+            path.intersects(rightPlane,topPlane,bottomPlane)) {
             return OVERLAPS;
+        }
 
-        if (isWithin(path.getInteriorPoint()))
+        if (insideRectangle == ALL_INSIDE) {
             return WITHIN;
+        }
     
-        if (path.isWithin(centerPoint))
+        if (insideShape) {
             return CONTAINS;
-        
+        }
+
         return DISJOINT;
     }
 
@@ -222,17 +238,22 @@ public class GeoWideRectangle implements
         return result;
     }
 
+    @Override
+    public String toString() {
+        return "GeoWideRectangle: {toplat="+topLat+"("+topLat*180.0/Math.PI+"), bottomlat="+bottomLat+"("+bottomLat*180.0/Math.PI+"), leftlon="+leftLon+"("+leftLon*180.0/Math.PI+"), rightlon="+rightLon+"("+rightLon*180.0/Math.PI+")}";
+    }
+
     protected class EitherBound implements Membership {
         public EitherBound() {
         }
         
         @Override
-        public boolean isWithin(Vector v) {
+        public boolean isWithin(final Vector v) {
             return leftPlane.isWithin(v) || rightPlane.isWithin(v);
         }
         
         @Override
-        public boolean isWithin(double x, double y, double z) {
+        public boolean isWithin(final double x, final double y, final double z) {
             return leftPlane.isWithin(x,y,z) || rightPlane.isWithin(x,y,z);
         }
     }

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWorld.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWorld.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWorld.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoWorld.java Mon Apr 20 04:31:29 2015
@@ -19,16 +19,17 @@ package org.apache.lucene.spatial.spatia
 
 /** Bounding box including the entire world.
 */
-public class GeoWorld implements GeoBBox
+public class GeoWorld extends GeoBBoxBase
 {
     protected final static GeoPoint originPoint = new GeoPoint(1.0,0.0,0.0);
-      
+    protected final static GeoPoint[] edgePoints = new GeoPoint[0];
+        
     public GeoWorld()
     {
     }
       
     @Override
-    public GeoBBox expand(double angle)
+    public GeoBBox expand(final double angle)
     {
         return this;
     }
@@ -40,25 +41,25 @@ public class GeoWorld implements GeoBBox
     }
 
     @Override
-    public boolean isWithin(Vector point)
+    public boolean isWithin(final Vector point)
     {
         return true;
     }
 
     @Override
-    public boolean isWithin(double x, double y, double z)
+    public boolean isWithin(final double x, final double y, final double z)
     {
         return true;
     }
     
     @Override
-    public GeoPoint getInteriorPoint()
+    public GeoPoint[] getEdgePoints()
     {
-        return originPoint;
+        return edgePoints;
     }
       
     @Override
-    public boolean intersects(Plane p, Membership... bounds)
+    public boolean intersects(final Plane p, final Membership... bounds)
     {
         return false;
     }
@@ -80,9 +81,12 @@ public class GeoWorld implements GeoBBox
     }
 
     @Override
-    public int getRelationship(GeoShape path) {
-        // Path is always within the world
-        return WITHIN;
+    public int getRelationship(final GeoShape path) {
+        if (path.getEdgePoints().length > 0)
+            // Path is always within the world
+            return WITHIN;
+        
+        return OVERLAPS;
     }
 
     @Override
@@ -97,4 +101,9 @@ public class GeoWorld implements GeoBBox
     public int hashCode() {
         return 0;
     }
+    
+    @Override
+    public String toString() {
+        return "GeoWorld";
+    }
 }

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Membership.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Membership.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Membership.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Membership.java Mon Apr 20 04:31:29 2015
@@ -25,7 +25,7 @@ public interface Membership {
      *@param point is the point to check.
      *@return true if the point is within this shape
      */
-    public boolean isWithin(Vector point);
+    public boolean isWithin(final Vector point);
 
     /** Check if a point is within this shape.
      *@param x is x coordinate of point to check.
@@ -33,6 +33,6 @@ public interface Membership {
      *@param z is z coordinate of point to check.
      *@return true if the point is within this shape
      */
-    public boolean isWithin(double x, double y, double z);
+    public boolean isWithin(final double x, final double y, final double z);
 
 }

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Plane.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Plane.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Plane.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Plane.java Mon Apr 20 04:31:29 2015
@@ -22,13 +22,16 @@ package org.apache.lucene.spatial.spatia
 */
 public class Plane extends Vector
 {
+    protected final static GeoPoint[] NO_POINTS = new GeoPoint[0];
+    protected final static Membership[] NO_BOUNDS = new Membership[0];
+    
     public final double D;
   
     /** Construct a plane through two points and origin.
      *@param A is the first point (origin based).
      *@param B is the second point (origin based).
      */
-    public Plane(Vector A, Vector B) {
+    public Plane(final Vector A, final Vector B) {
         super(A,B);
         D = 0.0;
     }
@@ -36,7 +39,7 @@ public class Plane extends Vector
     /** Construct a horizontal plane at a specified Z.
      *@param height is the specified Z coordinate.
      */
-    public Plane(double height) {
+    public Plane(final double height) {
         super(0.0,0.0,1.0);
         D = -height;
     }
@@ -46,7 +49,7 @@ public class Plane extends Vector
      *@param x is the specified x value.
      *@param y is the specified y value.
      */
-    public Plane(double x, double y) {
+    public Plane(final double x, final double y) {
         super(y,-x,0.0);
         D = 0.0;
     }
@@ -55,7 +58,7 @@ public class Plane extends Vector
      * from origin.
      *@param D is the D offset from the origin.
      */
-    public Plane(Vector v, double D) {
+    public Plane(final Vector v, final double D) {
         super(v.x,v.y,v.z);
         this.D = D;
     }
@@ -65,7 +68,7 @@ public class Plane extends Vector
      *@param v is the vector.
      *@return the result of the evaluation.
      */
-    public double evaluate(Vector v) {
+    public double evaluate(final Vector v) {
         return super.evaluate(v) + D;
     }
   
@@ -85,11 +88,11 @@ public class Plane extends Vector
     *@param moreBounds is another set of bounds.
     *@return the intersection point(s) on the unit sphere, if there are any.
     */
-    protected GeoPoint[] findIntersections(Plane q, Membership[] bounds, Membership[] moreBounds) {
-        Vector lineVector = new Vector(this,q);
+    protected GeoPoint[] findIntersections(final Plane q, final Membership[] bounds, final Membership[] moreBounds) {
+        final Vector lineVector = new Vector(this,q);
         if (lineVector.x == 0.0 && lineVector.y == 0.0 && lineVector.z == 0.0) {
             // Degenerate case: parallel planes
-            return new GeoPoint[0];
+            return NO_POINTS;
         }
 
         // The line will have the equation: A t + A0 = x, B t + B0 = y, C t + C0 = z.
@@ -115,30 +118,30 @@ public class Plane extends Vector
         double y0;
         double z0;
         // We try to maximize the determinant in the denominator
-        double denomYZ = this.y*q.z - this.z*q.y;
-        double denomXZ = this.x*q.z - this.z*q.x;
-        double denomXY = this.x*q.y - this.y*q.x;
+        final double denomYZ = this.y*q.z - this.z*q.y;
+        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)) {
             // X is the biggest, so our point will have x0 = 0.0
             if (Math.abs(denomYZ) < 1.0e-35)
-                return new GeoPoint[0];
-            double denom = 1.0 / denomYZ;
+                return NO_POINTS;
+            final double denom = 1.0 / denomYZ;
             x0 = 0.0;
             y0 = (-this.D * q.z - this.z * -q.D) * denom;
             z0 = (this.y * -q.D + this.D * q.y) * denom;
         } else if (Math.abs(denomXZ) >= Math.abs(denomXY) && Math.abs(denomXZ) >= Math.abs(denomYZ)) {
             // Y is the biggest, so y0 = 0.0
             if (Math.abs(denomXZ) < 1.0e-35)
-                return new GeoPoint[0];
-            double denom = 1.0 / denomXZ;
+                return NO_POINTS;
+            final double denom = 1.0 / denomXZ;
             x0 = (-this.D * q.z - this.z * -q.D) * denom;
             y0 = 0.0;
             z0 = (this.x * -q.D + this.D * q.x) * denom;
         } else {
             // Z is the biggest, so Z0 = 0.0
             if (Math.abs(denomXY) < 1.0e-35)
-                return new GeoPoint[0];
-            double denom = 1.0 / denomXY;
+                return NO_POINTS;
+            final double denom = 1.0 / denomXY;
             x0 = (-this.D * q.y - this.y * -q.D) * denom;
             y0 = (this.x * -q.D + this.D * q.x) * denom;
             z0 = 0.0;
@@ -151,26 +154,26 @@ public class Plane extends Vector
         // A^2 t^2 + 2AA0t + A0^2 + B^2 t^2 + 2BB0t + B0^2 + C^2 t^2 + 2CC0t + C0^2 - 1,0 = 0.0
         // [A^2 + B^2 + C^2] t^2 + [2AA0 + 2BB0 + 2CC0] t + [A0^2 + B0^2 + C0^2 - 1,0] = 0.0
         // Use the quadratic formula to determine t values and candidate point(s)
-        double A = lineVector.x * lineVector.x + lineVector.y * lineVector.y + lineVector.z * lineVector.z;
-        double B = 2.0*(lineVector.x * x0 + lineVector.y * y0 + lineVector.z * z0);
-        double C = x0*x0 + y0*y0 + z0*z0 - 1.0;
+        final double A = lineVector.x * lineVector.x + lineVector.y * lineVector.y + lineVector.z * lineVector.z;
+        final double B = 2.0*(lineVector.x * x0 + lineVector.y * y0 + lineVector.z * z0);
+        final double C = x0*x0 + y0*y0 + z0*z0 - 1.0;
 
-        double BsquaredMinus = B * B - 4.0 * A * C;
+        final double BsquaredMinus = B * B - 4.0 * A * C;
         if (BsquaredMinus < 0.0)
-            return new GeoPoint[0];
-        double inverse2A = 1.0 / (2.0 * A);
+            return NO_POINTS;
+        final double inverse2A = 1.0 / (2.0 * A);
         if (BsquaredMinus == 0.0) {
             // One solution only
-            double t = -B * inverse2A;
+            final double t = -B * inverse2A;
             GeoPoint point = new GeoPoint(lineVector.x * t + x0, lineVector.y * t + y0, lineVector.z * t + z0);
             if (point.isWithin(bounds,moreBounds))
                 return new GeoPoint[]{point};
-            return new GeoPoint[0];
+            return NO_POINTS;
         } else {
             // Two solutions
-            double sqrtTerm = Math.sqrt(BsquaredMinus);
-            double t1 = (-B + sqrtTerm) * inverse2A;
-            double t2 = (-B - sqrtTerm) * inverse2A;
+            final double sqrtTerm = Math.sqrt(BsquaredMinus);
+            final double t1 = (-B + sqrtTerm) * inverse2A;
+            final double t2 = (-B - sqrtTerm) * inverse2A;
             GeoPoint point1 = new GeoPoint(lineVector.x * t1 + x0, lineVector.y * t1 + y0, lineVector.z * t1 + z0);
             GeoPoint point2 = new GeoPoint(lineVector.x * t2 + x0, lineVector.y * t2 + y0, lineVector.z * t2 + z0);
             if (point1.isWithin(bounds,moreBounds)) {
@@ -180,7 +183,7 @@ public class Plane extends Vector
             }
             if (point2.isWithin(bounds,moreBounds))
                 return new GeoPoint[]{point2};
-            return new GeoPoint[0];
+            return NO_POINTS;
         }
     }
     
@@ -192,8 +195,8 @@ public class Plane extends Vector
     *@param boundsInfo is the info to update with additional bounding information.
     *@param bounds are the surfaces delineating what's inside the shape.
     */
-    public void recordBounds(Plane q, Bounds boundsInfo, Membership... bounds) {
-        GeoPoint[] intersectionPoints = findIntersections(q,bounds,new Membership[0]);
+    public void recordBounds(final Plane q, final Bounds boundsInfo, final Membership... bounds) {
+        final GeoPoint[] intersectionPoints = findIntersections(q,bounds,NO_BOUNDS);
         for (GeoPoint intersectionPoint : intersectionPoints) {
             boundsInfo.addPoint(intersectionPoint);
         }
@@ -205,7 +208,7 @@ public class Plane extends Vector
     *@param boundsInfo is the info to update with additional bounding information.
     *@param bounds are the surfaces delineating what's inside the shape.
     */
-    public void recordBounds(Bounds boundsInfo, Membership... bounds) {
+    public void recordBounds(final Bounds boundsInfo, final Membership... bounds) {
         // For clarity, load local variables with good names
         double A = this.x;
         double B = this.y;
@@ -617,7 +620,7 @@ public class Plane extends Vector
 
     }
     
-    protected static void addPoint(Bounds boundsInfo, Membership[] bounds, double x, double y, double z) {
+    protected static void addPoint(final Bounds boundsInfo, final Membership[] bounds, final double x, final double y, final double z) {
         // Make sure the discovered point is within the bounds
         for (Membership bound : bounds) {
             if (!bound.isWithin(x,y,z))
@@ -635,10 +638,19 @@ public class Plane extends Vector
      *@param moreBounds are more bounds.
      *@return true if there's an intersection.
      */
-    public boolean intersects(Plane q, Membership[] bounds, Membership... moreBounds) {
+    public boolean intersects(final Plane q, final Membership[] bounds, final Membership... moreBounds) {
         return findIntersections(q,bounds,moreBounds).length > 0;
     }
     
+    /** Find a sample point on the intersection between two planes and the unit sphere.
+    */
+    public GeoPoint getSampleIntersectionPoint(final Plane q) {
+        final GeoPoint[] intersections = findIntersections(q, NO_BOUNDS, NO_BOUNDS);
+        if (intersections.length == 0)
+            return null;
+        return intersections[0];
+    }
+    
     @Override
     public String toString() {
         return "[A="+x+", B="+y+"; C="+z+"; D="+D+"]";

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Vector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Vector.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Vector.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/Vector.java Mon Apr 20 04:31:29 2015
@@ -40,7 +40,7 @@ public class Vector
      *@param A is the first vector
      *@param B is the second
      */
-    public Vector(Vector A, Vector B) {
+    public Vector(final Vector A, final Vector B) {
         // x = u2v3 - u3v2
         // y = u3v1 - u1v3
         // z = u1v2 - u2v1
@@ -67,7 +67,7 @@ public class Vector
      *@param v is the vector to evaluate.
      *@return the result.
      */
-    public double evaluate(Vector v) {
+    public double evaluate(final Vector v) {
         return this.x * v.x + this.y * v.y + this.z * v.z;
     }
 
@@ -77,7 +77,7 @@ public class Vector
      *@param z is the x value of the vector to evaluate.
      *@return the result.
      */
-    public double evaluate(double x, double y, double z) {
+    public double evaluate(final double x, final double y, final double z) {
         return this.x * x + this.y * y + this.z * z;
     }
 
@@ -87,14 +87,14 @@ public class Vector
      *@param moreBounds is the second part of the set of planes.
      *@return true if the point is within the bounds.
      */
-    public boolean isWithin(Membership[] bounds, Membership[] moreBounds) {
+    public boolean isWithin(final Membership[] bounds, final Membership[] moreBounds) {
         // Return true if the point described is within all provided bounds
         for (Membership bound : bounds) {
-            if (!bound.isWithin(this))
+            if (bound != null && !bound.isWithin(this))
                 return false;
         }
         for (Membership bound : moreBounds) {
-            if (!bound.isWithin(this))
+            if (bound != null && !bound.isWithin(this))
                 return false;
         }
         return true;
@@ -106,7 +106,7 @@ public class Vector
      *@param v is the vector to compute a distance to.
      *@return the square of the linear distance.
      */
-    public double linearDistanceSquared(Vector v) {
+    public double linearDistanceSquared(final Vector v) {
         double deltaX = this.x - v.x;
         double deltaY = this.y - v.y;
         double deltaZ = this.z - v.z;
@@ -121,7 +121,7 @@ public class Vector
      *@param z is the z part of the vector to compute a distance to.
      *@return the square of the linear distance.
      */
-    public double linearDistanceSquared(double x, double y, double z) {
+    public double linearDistanceSquared(final double x, final double y, final double z) {
         double deltaX = this.x - x;
         double deltaY = this.y - y;
         double deltaZ = this.z - z;
@@ -134,7 +134,7 @@ public class Vector
      *@param v is the vector to compute a distance to.
      *@return the linear distance.
      */
-    public double linearDistance(Vector v) {
+    public double linearDistance(final Vector v) {
         return Math.sqrt(linearDistanceSquared(v));
     }
     
@@ -146,7 +146,7 @@ public class Vector
      *@param z is the z part of the vector to compute a distance to.
      *@return the linear distance.
      */
-    public double linearDistance(double x, double y, double z) {
+    public double linearDistance(final double x, final double y, final double z) {
         return Math.sqrt(linearDistanceSquared(x,y,z));
     }
     
@@ -156,7 +156,7 @@ public class Vector
      *@param v is the vector to compute a distance to.
      *@return the square of the normal distance.
      */
-    public double normalDistanceSquared(Vector v) {
+    public double normalDistanceSquared(final Vector v) {
         double t = this.evaluate(v);
         double deltaX = this.x * t - v.x;
         double deltaY = this.y * t - v.y;
@@ -172,7 +172,7 @@ public class Vector
      *@param z is the z part of the vector to compute a distance to.
      *@return the square of the normal distance.
      */
-    public double normalDistanceSquared(double x, double y, double z) {
+    public double normalDistanceSquared(final double x, final double y, final double z) {
         double t = this.evaluate(x,y,z);
         double deltaX = this.x * t - x;
         double deltaY = this.y * t - y;
@@ -186,7 +186,7 @@ public class Vector
      *@param v is the vector to compute a distance to.
      *@return the normal distance.
      */
-    public double normalDistance(Vector v) {
+    public double normalDistance(final Vector v) {
         return Math.sqrt(normalDistanceSquared(v));
     }
 
@@ -198,7 +198,7 @@ public class Vector
      *@param z is the z part of the vector to compute a distance to.
      *@return the normal distance.
      */
-    public double normalDistance(double x, double y, double z) {
+    public double normalDistance(final double x, final double y, final double z) {
         return Math.sqrt(normalDistanceSquared(x,y,z));
     }
     
@@ -208,7 +208,7 @@ public class Vector
     public double magnitude() {
         return Math.sqrt(x * x + y * y + z * z);
     }
-                
+    
     @Override
     public boolean equals(Object o) {
         if (!(o instanceof Vector))

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/Geo3dRptTest.java Mon Apr 20 04:31:29 2015
@@ -21,10 +21,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import com.carrotsearch.randomizedtesting.annotations.Repeat;
 import com.carrotsearch.randomizedtesting.annotations.Seed;
 import com.spatial4j.core.context.SpatialContext;
-import com.spatial4j.core.distance.DistanceUtils;
 import com.spatial4j.core.shape.Point;
 import com.spatial4j.core.shape.Rectangle;
 import com.spatial4j.core.shape.Shape;
@@ -34,17 +32,15 @@ import org.apache.lucene.spatial.prefix.
 import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
 import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
 import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
-import org.apache.lucene.spatial.prefix.tree.Cell;
-import org.apache.lucene.spatial.prefix.tree.CellIterator;
 import org.apache.lucene.spatial.query.SpatialOperation;
 import org.apache.lucene.spatial.serialized.SerializedDVStrategy;
-import org.apache.lucene.spatial.spatial4j.Geo3dShape;
+import org.apache.lucene.spatial.spatial4j.geo3d.GeoBBox;
+import org.apache.lucene.spatial.spatial4j.geo3d.GeoBBoxFactory;
+import org.apache.lucene.spatial.spatial4j.geo3d.GeoCircle;
+import org.apache.lucene.spatial.spatial4j.geo3d.GeoPath;
 import org.apache.lucene.spatial.spatial4j.geo3d.GeoPoint;
 import org.apache.lucene.spatial.spatial4j.geo3d.GeoPolygonFactory;
 import org.apache.lucene.spatial.spatial4j.geo3d.GeoShape;
-import org.apache.lucene.spatial.spatial4j.geo3d.GeoCircle;
-import org.apache.lucene.spatial.spatial4j.geo3d.GeoPath;
-import org.apache.lucene.spatial.spatial4j.geo3d.GeoBBoxFactory;
 import org.junit.Test;
 
 import static com.spatial4j.core.distance.DistanceUtils.DEGREES_TO_RADIANS;
@@ -84,8 +80,8 @@ public class Geo3dRptTest extends Random
   }
 
   @Test
-  @Repeat(iterations = 20)
-  //Seed("A9C215F48F200BB0")
+  //@Repeat(iterations = 2000)
+  @Seed("B808B88D6F8E285C")
   public void testOperations() throws IOException {
     setupStrategy();
 
@@ -93,15 +89,31 @@ public class Geo3dRptTest extends Random
   }
 
   @Test
-  public void testTriangleDisjointRect() throws IOException {
-    setupStrategy();
-    Rectangle rect = ctx.makeRectangle(-180, 180, 77, 84);
-    Shape triangle = makeTriangle(-149, 35, 88, -11, -27, -18);
-    assertTrue(rect.relate(triangle).intersects());     //unsure if this is correct or not but passes
-    //if they intersect, then the following rect cell can be "within" the triangle
-    final Rectangle cellRect = ctx.makeRectangle(-180, -168.75, 73.125, 78.75);
+  public void testBigCircleFailure() throws IOException {
+    Rectangle rect = ctx.makeRectangle(-162, 89, -46, 38);
+    GeoCircle rawShape = new GeoCircle(-9 * DEGREES_TO_RADIANS, 134 * DEGREES_TO_RADIANS, 159 * DEGREES_TO_RADIANS);
+    Shape shape = new Geo3dShape(rawShape, ctx);
+    assertTrue(rect.relate(shape).intersects() == false);     //DWS: unsure if this is correct or not but passes
+    //since they don't intersect, then the following cell rect can't be WITHIN the circle
+    final Rectangle cellRect = ctx.makeRectangle(-11.25, 0, 0, 5.625);
+    assert cellRect.relate(rect).intersects();
+    assertTrue(cellRect.relate(shape) != SpatialRelation.WITHIN);
+  }
+
+  @Test
+  public void testWideRectFailure() throws IOException {
+    Rectangle rect = ctx.makeRectangle(-29, 9, 16, 25);
+    final GeoBBox geoBBox = GeoBBoxFactory.makeGeoBBox(
+        74 * DEGREES_TO_RADIANS, -31 * DEGREES_TO_RADIANS, -29 * DEGREES_TO_RADIANS, -45 * DEGREES_TO_RADIANS);
+    Shape shape = new Geo3dShape(geoBBox, ctx);
+    //Rect(minX=-22.5,maxX=-11.25,minY=11.25,maxY=16.875)
+    //since they don't intersect, then the following cell rect can't be WITHIN the geo3d shape
+    final Rectangle cellRect = ctx.makeRectangle(-22.5, -11.25, 11.25, 16.875);
     assert cellRect.relate(rect).intersects();
-    //assertTrue(cellRect.relate(triangle) != SpatialRelation.WITHIN);
+    assertTrue(rect.relate(shape).intersects() == false);
+    assertTrue(cellRect.relate(shape) != SpatialRelation.WITHIN);
+//    setupStrategy();
+//    testOperation(rect, SpatialOperation.Intersects, shape, false);
   }
 
   private Shape makeTriangle(double x1, double y1, double x2, double y2, double x3, double y3) {
@@ -163,8 +175,14 @@ public class Geo3dRptTest extends Random
     case 2: {
         // Rectangles
         while (true) {
-          final Point ulhcPoint = randomPoint();
-          final Point lrhcPoint = randomPoint();
+          Point ulhcPoint = randomPoint();
+          Point lrhcPoint = randomPoint();
+          if (ulhcPoint.getY() < lrhcPoint.getY()) {
+            //swap
+            Point temp = ulhcPoint;
+            ulhcPoint = lrhcPoint;
+            lrhcPoint = temp;
+          }
           try {
             final GeoShape shape = GeoBBoxFactory.makeGeoBBox(ulhcPoint.getY() * DEGREES_TO_RADIANS,
               lrhcPoint.getY() * DEGREES_TO_RADIANS,
@@ -181,7 +199,7 @@ public class Geo3dRptTest extends Random
     case 3: {
         // Paths
         final int pointCount = random().nextInt(5) + 1;
-        final double width = random().nextInt(90) * DEGREES_TO_RADIANS;
+        final double width = (random().nextInt(89)+1) * DEGREES_TO_RADIANS;
         while (true) {
           try {
             final GeoPath path = new GeoPath(width);

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoConvexPolygonTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoConvexPolygonTest.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoConvexPolygonTest.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoConvexPolygonTest.java Mon Apr 20 04:31:29 2015
@@ -17,10 +17,12 @@ package org.apache.lucene.spatial.spatia
  * limitations under the License.
  */
 
-import static org.junit.Assert.*;
-
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 public class GeoConvexPolygonTest {
 
 
@@ -29,10 +31,10 @@ public class GeoConvexPolygonTest {
         GeoConvexPolygon c;
         GeoPoint gp;
         c = new GeoConvexPolygon(-0.1,-0.5);
-        c.addPoint(0.0,-0.6);
-        c.addPoint(0.1,-0.5);
-        c.addPoint(0.0,-0.4);
-        c.donePoints();
+        c.addPoint(0.0,-0.6,false);
+        c.addPoint(0.1,-0.5,false);
+        c.addPoint(0.0,-0.4,false);
+        c.donePoints(false);
         // Sample some points within
         gp = new GeoPoint(0.0,-0.5);
         assertTrue(c.isWithin(gp));
@@ -68,10 +70,10 @@ public class GeoConvexPolygonTest {
         Bounds b;
         
         c = new GeoConvexPolygon(-0.1,-0.5);
-        c.addPoint(0.0,-0.6);
-        c.addPoint(0.1,-0.5);
-        c.addPoint(0.0,-0.4);
-        c.donePoints();
+        c.addPoint(0.0,-0.6,false);
+        c.addPoint(0.1,-0.5,false);
+        c.addPoint(0.0,-0.4,false);
+        c.donePoints(false);
 
         b = c.getBounds(null);
         assertFalse(b.checkNoLongitudeBound());

Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPathTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPathTest.java?rev=1674732&r1=1674731&r2=1674732&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPathTest.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/geo3d/GeoPathTest.java Mon Apr 20 04:31:29 2015
@@ -17,10 +17,12 @@ package org.apache.lucene.spatial.spatia
  * limitations under the License.
  */
 
-import static org.junit.Assert.*;
-
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 public class GeoPathTest {
 
     @Test
@@ -32,6 +34,7 @@ public class GeoPathTest {
         p.addPoint(0.0,0.0);
         p.addPoint(0.0,0.1);
         p.addPoint(0.0,0.2);
+        p.done();
         gp = new GeoPoint(Math.PI * 0.5,0.15);
         assertEquals(Double.MAX_VALUE, p.computeArcDistance(gp), 0.0);
         gp = new GeoPoint(0.05,0.15);
@@ -50,6 +53,7 @@ public class GeoPathTest {
         p.addPoint(0.0,0.0);
         p.addPoint(0.0,0.1);
         p.addPoint(0.0,0.2);
+        p.done();
         gp = new GeoPoint(0.05,0.15);
         assertEquals(0.15 + 0.05, p.computeArcDistance(gp), 0.000001);
         gp = new GeoPoint(0.0,0.12);
@@ -59,6 +63,7 @@ public class GeoPathTest {
         p = new GeoPath(0.1);
         p.addPoint(-Math.PI * 0.25,-0.5);
         p.addPoint(Math.PI * 0.25,-0.5);
+        p.done();
         gp = new GeoPoint(0.0,0.0);
         assertEquals(Double.MAX_VALUE, p.computeArcDistance(gp), 0.0);
         gp = new GeoPoint(-0.1,-1.0);
@@ -78,6 +83,7 @@ public class GeoPathTest {
         // Build a diagonal path crossing the equator
         p.addPoint(-0.2,-0.2);
         p.addPoint(0.2,0.2);
+        p.done();
         // Test points on the path
         gp = new GeoPoint(-0.2,-0.2);
         assertTrue(p.isWithin(gp));
@@ -128,6 +134,7 @@ public class GeoPathTest {
         p = new GeoPath(0.1);
         p.addPoint(-0.3,-0.3);
         p.addPoint(0.3,0.3);
+        p.done();
         // Easiest: The path is wholly contains the georect
         rect = new GeoRectangle(0.05,-0.05,-0.05,0.05);
         assertEquals(GeoArea.CONTAINS, rect.getRelationship(p));
@@ -161,7 +168,8 @@ public class GeoPathTest {
         c = new GeoPath(0.1);
         c.addPoint(-0.3,-0.3);
         c.addPoint(0.3,0.3);
-
+        c.done();
+        
         b = c.getBounds(null);
         assertFalse(b.checkNoLongitudeBound());
         assertFalse(b.checkNoTopLatitudeBound());



Mime
View raw message