You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/09/02 22:09:40 UTC
svn commit: r1700887 [2/2] - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/sandbox/ lucene/sandbox/src/java/org/apache/lucene/bkdtree/
lucene/sandbox/src/java/org/apache/lucene/rangetree/ lucene/spatial/
lucene/spatial/src/java/org/apache/lucene...
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoShape.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoShape.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoShape.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoShape.java Wed Sep 2 20:09:39 2015
@@ -54,14 +54,11 @@ public interface GeoShape extends Member
public boolean intersects(final Plane plane, final GeoPoint[] notablePoints, final Membership... bounds);
/**
- * Compute longitude/latitude bounds for the shape.
+ * Compute bounds for the shape.
*
- * @param bounds is the optional input bounds object. If this is null,
- * a bounds object will be created. Otherwise, the input object will be modified.
- * @return a Bounds object describing the shape's bounds. If the bounds cannot
- * be computed, then return a Bounds object with noLongitudeBound,
- * noTopLatitudeBound, and noBottomLatitudeBound.
+ * @param bounds is the input bounds object.
+ * The input object will be modified.
*/
- public Bounds getBounds(final Bounds bounds);
+ public void getBounds(final Bounds bounds);
}
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoSouthLatitudeZone.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoSouthLatitudeZone.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoSouthLatitudeZone.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoSouthLatitudeZone.java Wed Sep 2 20:09:39 2015
@@ -102,21 +102,11 @@ public class GeoSouthLatitudeZone extend
return p.intersects(planetModel, topPlane, notablePoints, planePoints, bounds);
}
- /**
- * Compute longitude/latitude bounds for the shape.
- *
- * @param bounds is the optional input bounds object. If this is null,
- * a bounds object will be created. Otherwise, the input object will be modified.
- * @return a Bounds object describing the shape's bounds. If the bounds cannot
- * be computed, then return a Bounds object with noLongitudeBound,
- * noTopLatitudeBound, and noBottomLatitudeBound.
- */
@Override
- public Bounds getBounds(Bounds bounds) {
- if (bounds == null)
- bounds = new Bounds();
- bounds.noLongitudeBound().addLatitudeZone(topLat).noBottomLatitudeBound();
- return bounds;
+ public void getBounds(Bounds bounds) {
+ super.getBounds(bounds);
+ bounds
+ .addHorizontalPlane(planetModel, topLat, topPlane);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoSouthRectangle.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoSouthRectangle.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoSouthRectangle.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoSouthRectangle.java Wed Sep 2 20:09:39 2015
@@ -94,8 +94,8 @@ public class GeoSouthRectangle extends G
final double cosRightLon = Math.cos(rightLon);
// Now build the four points
- this.ULHC = new GeoPoint(planetModel, sinTopLat, sinLeftLon, cosTopLat, cosLeftLon);
- this.URHC = new GeoPoint(planetModel, sinTopLat, sinRightLon, cosTopLat, cosRightLon);
+ this.ULHC = new GeoPoint(planetModel, sinTopLat, sinLeftLon, cosTopLat, cosLeftLon, topLat, leftLon);
+ this.URHC = new GeoPoint(planetModel, sinTopLat, sinRightLon, cosTopLat, cosRightLon, topLat, rightLon);
final double middleLat = (topLat - Math.PI * 0.5) * 0.5;
final double sinMiddleLat = Math.sin(middleLat);
@@ -174,12 +174,13 @@ public class GeoSouthRectangle extends G
}
@Override
- public Bounds getBounds(Bounds bounds) {
- if (bounds == null)
- bounds = new Bounds();
- bounds.addLatitudeZone(topLat).noBottomLatitudeBound()
- .addLongitudeSlice(leftLon, rightLon);
- return bounds;
+ public void getBounds(Bounds bounds) {
+ super.getBounds(bounds);
+ bounds
+ .addHorizontalPlane(planetModel, topLat, topPlane, leftPlane, rightPlane)
+ .addVerticalPlane(planetModel, leftLon, leftPlane, topPlane, rightPlane)
+ .addVerticalPlane(planetModel, rightLon, rightPlane, topPlane, leftPlane)
+ .addPoint(URHC).addPoint(ULHC).addPoint(planetModel.SOUTH_POLE);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideDegenerateHorizontalLine.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideDegenerateHorizontalLine.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideDegenerateHorizontalLine.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideDegenerateHorizontalLine.java Wed Sep 2 20:09:39 2015
@@ -90,8 +90,8 @@ public class GeoWideDegenerateHorizontal
final double cosRightLon = Math.cos(rightLon);
// Now build the two points
- this.LHC = new GeoPoint(planetModel, sinLatitude, sinLeftLon, cosLatitude, cosLeftLon);
- this.RHC = new GeoPoint(planetModel, sinLatitude, sinRightLon, cosLatitude, cosRightLon);
+ this.LHC = new GeoPoint(planetModel, sinLatitude, sinLeftLon, cosLatitude, cosLeftLon, latitude, leftLon);
+ this.RHC = new GeoPoint(planetModel, sinLatitude, sinRightLon, cosLatitude, cosRightLon, latitude, rightLon);
this.plane = new Plane(planetModel, sinLatitude);
@@ -167,12 +167,12 @@ public class GeoWideDegenerateHorizontal
}
@Override
- public Bounds getBounds(Bounds bounds) {
- if (bounds == null)
- bounds = new Bounds();
- bounds.addLatitudeZone(latitude)
- .addLongitudeSlice(leftLon, rightLon);
- return bounds;
+ public void getBounds(Bounds bounds) {
+ super.getBounds(bounds);
+ bounds.isWide()
+ .addHorizontalPlane(planetModel, latitude, plane, eitherBound)
+ .addPoint(LHC)
+ .addPoint(RHC);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideLongitudeSlice.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideLongitudeSlice.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideLongitudeSlice.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideLongitudeSlice.java Wed Sep 2 20:09:39 2015
@@ -135,12 +135,13 @@ public class GeoWideLongitudeSlice exten
}
@Override
- public Bounds getBounds(Bounds bounds) {
- if (bounds == null)
- bounds = new Bounds();
- bounds.noTopLatitudeBound().noBottomLatitudeBound();
- bounds.addLongitudeSlice(leftLon, rightLon);
- return bounds;
+ public void getBounds(Bounds bounds) {
+ super.getBounds(bounds);
+ bounds.isWide()
+ .addVerticalPlane(planetModel, leftLon, leftPlane)
+ .addVerticalPlane(planetModel, rightLon, rightPlane)
+ .addPoint(planetModel.NORTH_POLE)
+ .addPoint(planetModel.SOUTH_POLE);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideNorthRectangle.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideNorthRectangle.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideNorthRectangle.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideNorthRectangle.java Wed Sep 2 20:09:39 2015
@@ -94,8 +94,8 @@ public class GeoWideNorthRectangle exten
final double cosRightLon = Math.cos(rightLon);
// Now build the four points
- this.LRHC = new GeoPoint(planetModel, sinBottomLat, sinRightLon, cosBottomLat, cosRightLon);
- this.LLHC = new GeoPoint(planetModel, sinBottomLat, sinLeftLon, cosBottomLat, cosLeftLon);
+ this.LRHC = new GeoPoint(planetModel, sinBottomLat, sinRightLon, cosBottomLat, cosRightLon, bottomLat, rightLon);
+ this.LLHC = new GeoPoint(planetModel, sinBottomLat, sinLeftLon, cosBottomLat, cosLeftLon, bottomLat, leftLon);
final double middleLat = (Math.PI * 0.5 + bottomLat) * 0.5;
final double sinMiddleLat = Math.sin(middleLat);
@@ -178,12 +178,13 @@ public class GeoWideNorthRectangle exten
}
@Override
- public Bounds getBounds(Bounds bounds) {
- if (bounds == null)
- bounds = new Bounds();
- bounds.noTopLatitudeBound().addLatitudeZone(bottomLat)
- .addLongitudeSlice(leftLon, rightLon);
- return bounds;
+ public void getBounds(Bounds bounds) {
+ super.getBounds(bounds);
+ bounds.isWide()
+ .addHorizontalPlane(planetModel, bottomLat, bottomPlane, eitherBound)
+ .addVerticalPlane(planetModel, leftLon, leftPlane, bottomPlane)
+ .addVerticalPlane(planetModel, rightLon, rightPlane, bottomPlane)
+ .addPoint(LLHC).addPoint(LRHC).addPoint(planetModel.NORTH_POLE);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideRectangle.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideRectangle.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideRectangle.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideRectangle.java Wed Sep 2 20:09:39 2015
@@ -111,10 +111,10 @@ public class GeoWideRectangle extends Ge
final double cosRightLon = Math.cos(rightLon);
// Now build the four points
- this.ULHC = new GeoPoint(planetModel, sinTopLat, sinLeftLon, cosTopLat, cosLeftLon);
- this.URHC = new GeoPoint(planetModel, sinTopLat, sinRightLon, cosTopLat, cosRightLon);
- this.LRHC = new GeoPoint(planetModel, sinBottomLat, sinRightLon, cosBottomLat, cosRightLon);
- this.LLHC = new GeoPoint(planetModel, sinBottomLat, sinLeftLon, cosBottomLat, cosLeftLon);
+ this.ULHC = new GeoPoint(planetModel, sinTopLat, sinLeftLon, cosTopLat, cosLeftLon, topLat, leftLon);
+ this.URHC = new GeoPoint(planetModel, sinTopLat, sinRightLon, cosTopLat, cosRightLon, topLat, rightLon);
+ this.LRHC = new GeoPoint(planetModel, sinBottomLat, sinRightLon, cosBottomLat, cosRightLon, bottomLat, rightLon);
+ this.LLHC = new GeoPoint(planetModel, sinBottomLat, sinLeftLon, cosBottomLat, cosLeftLon, bottomLat, leftLon);
final double middleLat = (topLat + bottomLat) * 0.5;
final double sinMiddleLat = Math.sin(middleLat);
@@ -206,12 +206,14 @@ public class GeoWideRectangle extends Ge
}
@Override
- public Bounds getBounds(Bounds bounds) {
- if (bounds == null)
- bounds = new Bounds();
- bounds.addLatitudeZone(topLat).addLatitudeZone(bottomLat)
- .addLongitudeSlice(leftLon, rightLon);
- return bounds;
+ public void getBounds(Bounds bounds) {
+ super.getBounds(bounds);
+ bounds.isWide()
+ .addHorizontalPlane(planetModel, topLat, topPlane, bottomPlane, eitherBound)
+ .addVerticalPlane(planetModel, rightLon, rightPlane, topPlane, bottomPlane)
+ .addHorizontalPlane(planetModel, bottomLat, bottomPlane, topPlane, eitherBound)
+ .addVerticalPlane(planetModel, leftLon, leftPlane, topPlane, bottomPlane)
+ .addPoint(ULHC).addPoint(URHC).addPoint(LRHC).addPoint(LLHC);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideSouthRectangle.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideSouthRectangle.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideSouthRectangle.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWideSouthRectangle.java Wed Sep 2 20:09:39 2015
@@ -94,8 +94,8 @@ public class GeoWideSouthRectangle exten
final double cosRightLon = Math.cos(rightLon);
// Now build the four points
- this.ULHC = new GeoPoint(planetModel, sinTopLat, sinLeftLon, cosTopLat, cosLeftLon);
- this.URHC = new GeoPoint(planetModel, sinTopLat, sinRightLon, cosTopLat, cosRightLon);
+ this.ULHC = new GeoPoint(planetModel, sinTopLat, sinLeftLon, cosTopLat, cosLeftLon, topLat, leftLon);
+ this.URHC = new GeoPoint(planetModel, sinTopLat, sinRightLon, cosTopLat, cosRightLon, topLat, rightLon);
final double middleLat = (topLat - Math.PI * 0.5) * 0.5;
final double sinMiddleLat = Math.sin(middleLat);
@@ -177,12 +177,13 @@ public class GeoWideSouthRectangle exten
}
@Override
- public Bounds getBounds(Bounds bounds) {
- if (bounds == null)
- bounds = new Bounds();
- bounds.addLatitudeZone(topLat).noBottomLatitudeBound()
- .addLongitudeSlice(leftLon, rightLon);
- return bounds;
+ public void getBounds(Bounds bounds) {
+ super.getBounds(bounds);
+ bounds.isWide()
+ .addHorizontalPlane(planetModel, topLat, topPlane, eitherBound)
+ .addVerticalPlane(planetModel, rightLon, rightPlane, topPlane)
+ .addVerticalPlane(planetModel, leftLon, leftPlane, topPlane)
+ .addPoint(ULHC).addPoint(URHC).addPoint(planetModel.SOUTH_POLE);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWorld.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWorld.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWorld.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/GeoWorld.java Wed Sep 2 20:09:39 2015
@@ -68,11 +68,10 @@ public class GeoWorld extends GeoBaseBBo
}
@Override
- public Bounds getBounds(Bounds bounds) {
- if (bounds == null)
- bounds = new Bounds();
- bounds.noLongitudeBound().noTopLatitudeBound().noBottomLatitudeBound();
- return bounds;
+ public void getBounds(Bounds bounds) {
+ super.getBounds(bounds);
+ // Unnecessary
+ //bounds.noLongitudeBound().noTopLatitudeBound().noBottomLatitudeBound();
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Plane.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Plane.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Plane.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Plane.java Wed Sep 2 20:09:39 2015
@@ -28,6 +28,13 @@ public class Plane extends Vector {
protected final static GeoPoint[] NO_POINTS = new GeoPoint[0];
/** An array with no bounds in it */
protected final static Membership[] NO_BOUNDS = new Membership[0];
+ /** A vertical plane normal to the Y axis */
+ protected final static Plane normalYPlane = new Plane(0.0,1.0,0.0,0.0);
+ /** A vertical plane normal to the X axis */
+ protected final static Plane normalXPlane = new Plane(1.0,0.0,0.0,0.0);
+ /** A vertical plane normal to the Z axis */
+ protected final static Plane normalZPlane = new Plane(0.0,0.0,1.0,0.0);
+
/** Ax + By + Cz + D = 0 */
public final double D;
@@ -88,12 +95,12 @@ public class Plane extends Vector {
this.D = D;
}
- /** Construct the most accurate normalized, vertical plane given a set of points. If none of the points can determine
- * the plane, return null.
- * @param planePoints is a set of points to choose from. The best one for constructing the most precise normal plane is picked.
- * @return the normal plane
+ /** Construct the most accurate normalized plane through an x-y point and including the Z axis.
+ * If none of the points can determine the plane, return null.
+ * @param planePoints is a set of points to choose from. The best one for constructing the most precise plane is picked.
+ * @return the plane
*/
- public static Plane constructNormalizedVerticalPlane(final Vector... planePoints) {
+ public static Plane constructNormalizedZPlane(final Vector... planePoints) {
// Pick the best one (with the greatest x-y distance)
double bestDistance = 0.0;
Vector bestPoint = null;
@@ -104,19 +111,86 @@ public class Plane extends Vector {
bestPoint = point;
}
}
- return constructNormalizedVerticalPlane(bestPoint.x, bestPoint.y);
+ return constructNormalizedZPlane(bestPoint.x, bestPoint.y);
+ }
+
+ /** Construct the most accurate normalized plane through an x-z point and including the Y axis.
+ * If none of the points can determine the plane, return null.
+ * @param planePoints is a set of points to choose from. The best one for constructing the most precise plane is picked.
+ * @return the plane
+ */
+ public static Plane constructNormalizedYPlane(final Vector... planePoints) {
+ // Pick the best one (with the greatest x-z distance)
+ double bestDistance = 0.0;
+ Vector bestPoint = null;
+ for (final Vector point : planePoints) {
+ final double pointDist = point.x * point.x + point.z * point.z;
+ if (pointDist > bestDistance) {
+ bestDistance = pointDist;
+ bestPoint = point;
+ }
+ }
+ return constructNormalizedYPlane(bestPoint.x, bestPoint.z, 0.0);
}
- /** Construct a normalized, vertical plane through an x-y point. If the x-y point is at (0,0), return null.
+ /** Construct the most accurate normalized plane through an y-z point and including the X axis.
+ * If none of the points can determine the plane, return null.
+ * @param planePoints is a set of points to choose from. The best one for constructing the most precise plane is picked.
+ * @return the plane
+ */
+ public static Plane constructNormalizedXPlane(final Vector... planePoints) {
+ // Pick the best one (with the greatest y-z distance)
+ double bestDistance = 0.0;
+ Vector bestPoint = null;
+ for (final Vector point : planePoints) {
+ final double pointDist = point.y * point.y + point.z * point.z;
+ if (pointDist > bestDistance) {
+ bestDistance = pointDist;
+ bestPoint = point;
+ }
+ }
+ return constructNormalizedXPlane(bestPoint.y, bestPoint.z, 0.0);
+ }
+
+ /** Construct a normalized plane through an x-y point and including the Z axis.
+ * If the x-y point is at (0,0), return null.
* @param x is the x value.
* @param y is the y value.
- * @return a vertical plane passing through the center and (x,y,0).
+ * @return a plane passing through the Z axis and (x,y,0).
*/
- public static Plane constructNormalizedVerticalPlane(final double x, final double y) {
+ public static Plane constructNormalizedZPlane(final double x, final double y) {
if (Math.abs(x) < MINIMUM_RESOLUTION && Math.abs(y) < MINIMUM_RESOLUTION)
return null;
final double denom = 1.0 / Math.sqrt(x*x + y*y);
- return new Plane(x * denom, y * denom);
+ return new Plane(y * denom, -x * denom, 0.0, 0.0);
+ }
+
+ /** Construct a normalized plane through an x-z point and parallel to the Y axis.
+ * If the x-z point is at (0,0), return null.
+ * @param x is the x value.
+ * @param z is the z value.
+ * @param DValue is the offset from the origin for the plane.
+ * @return a plane parallel to the Y axis and perpendicular to the x and z values given.
+ */
+ public static Plane constructNormalizedYPlane(final double x, final double z, final double DValue) {
+ if (Math.abs(x) < MINIMUM_RESOLUTION && Math.abs(z) < MINIMUM_RESOLUTION)
+ return null;
+ final double denom = 1.0 / Math.sqrt(x*x + z*z);
+ return new Plane(z * denom, 0.0, -x * denom, DValue);
+ }
+
+ /** Construct a normalized plane through a y-z point and parallel to the X axis.
+ * If the y-z point is at (0,0), return null.
+ * @param y is the y value.
+ * @param z is the z value.
+ * @param DValue is the offset from the origin for the plane.
+ * @return a plane parallel to the X axis and perpendicular to the y and z values given.
+ */
+ public static Plane constructNormalizedXPlane(final double y, final double z, final double DValue) {
+ if (Math.abs(y) < MINIMUM_RESOLUTION && Math.abs(z) < MINIMUM_RESOLUTION)
+ return null;
+ final double denom = 1.0 / Math.sqrt(y*y + z*z);
+ return new Plane(0.0, z * denom, -y * denom, DValue);
}
/**
@@ -695,35 +769,149 @@ public class Plane extends Vector {
throw new RuntimeException("Intersection point not on ellipsoid; point="+point);
}
*/
-
+
/**
- * Accumulate bounds information for this plane, intersected with another plane
- * and with the unit sphere.
- * Updates both latitude and longitude information, using max/min points found
+ * Accumulate (x,y,z) bounds information for this plane, intersected with the unit sphere.
+ * Updates min/max information, using max/min points found
* within the specified bounds.
*
- * @param planetModel is the planet model to use to determine bounding points
- * @param q is the plane to intersect with.
- * @param boundsInfo is the info to update with additional bounding information.
+ * @param planetModel is the planet model to use in determining bounds.
+ * @param boundsInfo is the xyz info to update with additional bounding information.
* @param bounds are the surfaces delineating what's inside the shape.
*/
- public void recordBounds(final PlanetModel planetModel, final Plane q, final Bounds boundsInfo, final Membership... bounds) {
- final GeoPoint[] intersectionPoints = findIntersections(planetModel, q, bounds, NO_BOUNDS);
- for (GeoPoint intersectionPoint : intersectionPoints) {
- boundsInfo.addPoint(intersectionPoint);
+ public void recordBounds(final PlanetModel planetModel, final XYZBounds boundsInfo, final Membership... bounds) {
+ // Basic plan is to do three intersections of the plane and the planet.
+ // For min/max x, we intersect a vertical plane such that y = 0.
+ // For min/max y, we intersect a vertical plane such that x = 0.
+ // For min/max z, we intersect a vertical plane that is chosen to go through the high point of the arc.
+ // For clarity, load local variables with good names
+ final double A = this.x;
+ final double B = this.y;
+ final double C = this.z;
+
+ // For the X and Y values, we need a D value, which is the AVERAGE D value
+ // for two planes that pass through the two Z points determined here, for the axis in question.
+ final GeoPoint[] zPoints;
+ if (!boundsInfo.isSmallestMinX(planetModel) || !boundsInfo.isLargestMaxX(planetModel) ||
+ !boundsInfo.isSmallestMinY(planetModel) || !boundsInfo.isLargestMaxY(planetModel)) {
+ if ((Math.abs(A) >= MINIMUM_RESOLUTION || Math.abs(B) >= MINIMUM_RESOLUTION)) {
+ // We need unconstrained values in order to compute D
+ zPoints = findIntersections(planetModel, constructNormalizedZPlane(A,B), NO_BOUNDS, NO_BOUNDS);
+ if (zPoints.length == 0) {
+ // No intersections, so plane never intersects world.
+ //System.err.println(" plane never intersects world");
+ return;
+ }
+ //for (final GeoPoint p : zPoints) {
+ // System.err.println("zPoint: "+p);
+ //}
+ } else {
+ zPoints = null;
+ }
+ } else {
+ zPoints = null;
}
- }
+ // Do Z.
+ if (!boundsInfo.isSmallestMinZ(planetModel) || !boundsInfo.isLargestMaxZ(planetModel)) {
+ //System.err.println(" computing Z bound");
+ // Compute Z bounds for this arc
+ // With ellipsoids, we really have only one viable way to do this computation.
+ // Specifically, we compute an appropriate vertical plane, based on the current plane's x-y orientation, and
+ // then intersect it with this one and with the ellipsoid. This gives us zero, one, or two points to use
+ // as bounds.
+ // There is one special case: horizontal circles. These require TWO vertical planes: one for the x, and one for
+ // the y, and we use all four resulting points in the bounds computation.
+ if ((Math.abs(A) >= MINIMUM_RESOLUTION || Math.abs(B) >= MINIMUM_RESOLUTION)) {
+ // NOT a degenerate case
+ //System.err.println(" not degenerate");
+ final Plane normalizedZPlane = constructNormalizedZPlane(A,B);
+ final GeoPoint[] points = findIntersections(planetModel, normalizedZPlane, bounds, NO_BOUNDS);
+ for (final GeoPoint point : points) {
+ assert planetModel.pointOnSurface(point);
+ //System.err.println(" Point = "+point+"; this.evaluate(point)="+this.evaluate(point)+"; normalizedZPlane.evaluate(point)="+normalizedZPlane.evaluate(point));
+ addPoint(boundsInfo, bounds, point);
+ }
+ } else {
+ // Since a==b==0, any plane including the Z axis suffices.
+ //System.err.println(" Perpendicular to z");
+ final GeoPoint[] points = findIntersections(planetModel, normalYPlane, NO_BOUNDS, NO_BOUNDS);
+ boundsInfo.addZValue(points[0]);
+ }
+ }
+
+ if (!boundsInfo.isSmallestMinX(planetModel) || !boundsInfo.isLargestMaxX(planetModel)) {
+ //System.err.println(" computing X bound");
+ if ((Math.abs(B) >= MINIMUM_RESOLUTION || Math.abs(C) >= MINIMUM_RESOLUTION)) {
+ // NOT a degenerate case. Compute D.
+ //System.err.println(" not degenerate; B="+B+"; C="+C);
+ final Plane originPlane = constructNormalizedXPlane(B,C,0.0);
+ double DValue = 0.0;
+ if (zPoints != null) {
+ for (final GeoPoint p : zPoints) {
+ final double zValue = originPlane.evaluate(p);
+ //System.err.println(" originPlane.evaluate(zpoint)="+zValue);
+ DValue += zValue;
+ }
+ DValue /= (double)zPoints.length;
+ }
+ final Plane normalizedXPlane = constructNormalizedXPlane(B,C,-DValue);
+ final GeoPoint[] points = findIntersections(planetModel, normalizedXPlane, bounds, NO_BOUNDS);
+ for (final GeoPoint point : points) {
+ assert planetModel.pointOnSurface(point);
+ //System.err.println(" Point = "+point+"; this.evaluate(point)="+this.evaluate(point)+"; normalizedXPlane.evaluate(point)="+normalizedXPlane.evaluate(point));
+ addPoint(boundsInfo, bounds, point);
+ }
+ } else {
+ // Since b==c==0, any plane including the X axis suffices.
+ //System.err.println(" Perpendicular to x");
+ final GeoPoint[] points = findIntersections(planetModel, normalZPlane, NO_BOUNDS, NO_BOUNDS);
+ boundsInfo.addXValue(points[0]);
+ }
+ }
+
+ // Do Y
+ if (!boundsInfo.isSmallestMinY(planetModel) || !boundsInfo.isLargestMaxY(planetModel)) {
+ //System.err.println(" computing Y bound");
+ if ((Math.abs(A) >= MINIMUM_RESOLUTION || Math.abs(C) >= MINIMUM_RESOLUTION)) {
+ // NOT a degenerate case. Compute D.
+ //System.err.println(" not degenerate");
+ final Plane originPlane = constructNormalizedYPlane(A,C,0.0);
+ double DValue = 0.0;
+ if (zPoints != null) {
+ for (final GeoPoint p : zPoints) {
+ DValue += originPlane.evaluate(p);
+ }
+ DValue /= (double)zPoints.length;
+ }
+ final Plane normalizedYPlane = constructNormalizedYPlane(A,C,-DValue);
+ final GeoPoint[] points = findIntersections(planetModel, normalizedYPlane, bounds, NO_BOUNDS);
+ for (final GeoPoint point : points) {
+ assert planetModel.pointOnSurface(point);
+ //System.err.println(" Point = "+point+"; this.evaluate(point)="+this.evaluate(point)+"; normalizedYPlane.evaluate(point)="+normalizedYPlane.evaluate(point));
+ addPoint(boundsInfo, bounds, point);
+ }
+ } else {
+ // Since a==c==0, any plane including the Y axis suffices.
+ // It doesn't matter that we may discard the point due to bounds, because if there are bounds, we'll have endpoints
+ // that will be tallied separately.
+ //System.err.println(" Perpendicular to y");
+ final GeoPoint[] points = findIntersections(planetModel, normalXPlane, NO_BOUNDS, NO_BOUNDS);
+ boundsInfo.addYValue(points[0]);
+ }
+ }
+ }
+
/**
* Accumulate bounds information for this plane, intersected with the unit sphere.
* Updates both latitude and longitude information, using max/min points found
* within the specified bounds.
*
* @param planetModel is the planet model to use in determining bounds.
- * @param boundsInfo is the info to update with additional bounding information.
+ * @param boundsInfo is the lat/lon info to update with additional bounding information.
* @param bounds are the surfaces delineating what's inside the shape.
*/
- public void recordBounds(final PlanetModel planetModel, final Bounds boundsInfo, final Membership... bounds) {
+ public void recordBounds(final PlanetModel planetModel, final LatLonBounds boundsInfo, final Membership... bounds) {
// For clarity, load local variables with good names
final double A = this.x;
final double B = this.y;
@@ -741,18 +929,15 @@ public class Plane extends Vector {
if ((Math.abs(A) >= MINIMUM_RESOLUTION || Math.abs(B) >= MINIMUM_RESOLUTION)) {
// NOT a horizontal circle!
//System.err.println(" Not a horizontal circle");
- final Plane verticalPlane = constructNormalizedVerticalPlane(A,B);
- final GeoPoint[] points = findIntersections(planetModel, verticalPlane, NO_BOUNDS, NO_BOUNDS);
+ final Plane verticalPlane = constructNormalizedZPlane(A,B);
+ final GeoPoint[] points = findIntersections(planetModel, verticalPlane, bounds, NO_BOUNDS);
for (final GeoPoint point : points) {
- addPoint(boundsInfo, bounds, point.x, point.y, point.z);
+ addPoint(boundsInfo, bounds, point);
}
} else {
- // Horizontal circle. Since a==b, one vertical plane suffices.
- final Plane verticalPlane = new Plane(1.0,0.0);
- final GeoPoint[] points = findIntersections(planetModel, verticalPlane, NO_BOUNDS, NO_BOUNDS);
- // There will always be two points; we only need one.
- final GeoPoint point = points[0];
- boundsInfo.addHorizontalCircle(point.z/Math.sqrt(point.x * point.x + point.y * point.y + point.z * point.z));
+ // Horizontal circle. Since a==b, any vertical plane suffices.
+ final GeoPoint[] points = findIntersections(planetModel, normalXPlane, NO_BOUNDS, NO_BOUNDS);
+ boundsInfo.addZValue(points[0]);
}
//System.err.println("Done latitude bounds");
}
@@ -808,7 +993,7 @@ public class Plane extends Vector {
double y0 = -b / (2.0 * a);
double x0 = (-D - B * y0) / A;
double z0 = 0.0;
- addPoint(boundsInfo, bounds, x0, y0, z0);
+ addPoint(boundsInfo, bounds, new GeoPoint(x0, y0, z0));
} else if (sqrtClause > 0.0) {
double sqrtResult = Math.sqrt(sqrtClause);
double denom = 1.0 / (2.0 * a);
@@ -823,8 +1008,8 @@ public class Plane extends Vector {
double z0a = 0.0;
double z0b = 0.0;
- addPoint(boundsInfo, bounds, x0a, y0a, z0a);
- addPoint(boundsInfo, bounds, x0b, y0b, z0b);
+ addPoint(boundsInfo, bounds, new GeoPoint(x0a, y0a, z0a));
+ addPoint(boundsInfo, bounds, new GeoPoint(x0b, y0b, z0b));
}
} else {
@@ -841,7 +1026,7 @@ public class Plane extends Vector {
double x0 = -b / (2.0 * a);
double y0 = (-D - A * x0) / B;
double z0 = 0.0;
- addPoint(boundsInfo, bounds, x0, y0, z0);
+ addPoint(boundsInfo, bounds, new GeoPoint(x0, y0, z0));
} else if (sqrtClause > 0.0) {
double sqrtResult = Math.sqrt(sqrtClause);
double denom = 1.0 / (2.0 * a);
@@ -854,8 +1039,8 @@ public class Plane extends Vector {
double z0a = 0.0;
double z0b = 0.0;
- addPoint(boundsInfo, bounds, x0a, y0a, z0a);
- addPoint(boundsInfo, bounds, x0b, y0b, z0b);
+ addPoint(boundsInfo, bounds, new GeoPoint(x0a, y0a, z0a));
+ addPoint(boundsInfo, bounds, new GeoPoint(x0b, y0b, z0b));
}
}
}
@@ -949,7 +1134,7 @@ public class Plane extends Vector {
double x0 = (-2.0 * J - I * y0) / H;
double z0 = (-A * x0 - B * y0 - D) / C;
- addPoint(boundsInfo, bounds, x0, y0, z0);
+ addPoint(boundsInfo, bounds, new GeoPoint(x0, y0, z0));
} else if (sqrtClause > 0.0) {
//System.err.println(" Two solutions");
double sqrtResult = Math.sqrt(sqrtClause);
@@ -964,8 +1149,8 @@ public class Plane extends Vector {
double z0a = (-A * x0a - B * y0a - D) * Cdenom;
double z0b = (-A * x0b - B * y0b - D) * Cdenom;
- addPoint(boundsInfo, bounds, x0a, y0a, z0a);
- addPoint(boundsInfo, bounds, x0b, y0b, z0b);
+ addPoint(boundsInfo, bounds, new GeoPoint(x0a, y0a, z0a));
+ addPoint(boundsInfo, bounds, new GeoPoint(x0b, y0b, z0b));
}
} else {
@@ -1001,7 +1186,7 @@ public class Plane extends Vector {
double z0 = (-A * x0 - B * y0 - D) / C;
// Verify that x&y fulfill the equation
// 2Ex^2 + 2Fy^2 + 2Gxy + Hx + Iy = 0
- addPoint(boundsInfo, bounds, x0, y0, z0);
+ addPoint(boundsInfo, bounds, new GeoPoint(x0, y0, z0));
} else if (sqrtClause > 0.0) {
//System.err.println(" Two solutions");
double sqrtResult = Math.sqrt(sqrtClause);
@@ -1016,8 +1201,8 @@ public class Plane extends Vector {
double z0a = (-A * x0a - B * y0a - D) * Cdenom;
double z0b = (-A * x0b - B * y0b - D) * Cdenom;
- addPoint(boundsInfo, bounds, x0a, y0a, z0a);
- addPoint(boundsInfo, bounds, x0b, y0b, z0b);
+ addPoint(boundsInfo, bounds, new GeoPoint(x0a, y0a, z0a));
+ addPoint(boundsInfo, bounds, new GeoPoint(x0b, y0b, z0b));
}
}
}
@@ -1029,10 +1214,26 @@ public class Plane extends Vector {
/** Add a point to boundsInfo if within a specifically bounded area.
* @param boundsInfo is the object to be modified.
* @param bounds is the area that the point must be within.
+ * @param point is the point.
+ */
+ protected static void addPoint(final Bounds boundsInfo, final Membership[] bounds, final GeoPoint point) {
+ // Make sure the discovered point is within the bounds
+ for (Membership bound : bounds) {
+ if (!bound.isWithin(point))
+ return;
+ }
+ // Add the point
+ boundsInfo.addPoint(point);
+ }
+
+ /** Add a point to boundsInfo if within a specifically bounded area.
+ * @param boundsInfo is the object to be modified.
+ * @param bounds is the area that the point must be within.
* @param x is the x value.
* @param y is the y value.
* @param z is the z value.
*/
+ /*
protected static void addPoint(final Bounds boundsInfo, final Membership[] bounds, final double x, final double y, final double z) {
//System.err.println(" Want to add point x="+x+" y="+y+" z="+z);
// Make sure the discovered point is within the bounds
@@ -1045,6 +1246,7 @@ public class Plane extends Vector {
//System.out.println("Adding point x="+x+" y="+y+" z="+z);
boundsInfo.addPoint(x, y, z);
}
+ */
/**
* Determine whether the plane intersects another plane within the
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/PlanetModel.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/PlanetModel.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/PlanetModel.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/PlanetModel.java Wed Sep 2 20:09:39 2015
@@ -65,6 +65,14 @@ public class PlanetModel {
public final GeoPoint NORTH_POLE;
/** South pole */
public final GeoPoint SOUTH_POLE;
+ /** Min X pole */
+ public final GeoPoint MIN_X_POLE;
+ /** Max X pole */
+ public final GeoPoint MAX_X_POLE;
+ /** Min Y pole */
+ public final GeoPoint MIN_Y_POLE;
+ /** Max Y pole */
+ public final GeoPoint MAX_Y_POLE;
/** Constructor.
* @param ab is the x/y scaling factor.
@@ -81,6 +89,10 @@ public class PlanetModel {
this.inverseCSquared = inverseC * inverseC;
this.NORTH_POLE = new GeoPoint(c, 0.0, 0.0, 1.0, Math.PI * 0.5, 0.0);
this.SOUTH_POLE = new GeoPoint(c, 0.0, 0.0, -1.0, -Math.PI * 0.5, 0.0);
+ this.MIN_X_POLE = new GeoPoint(ab, -1.0, 0.0, 0.0, 0.0, -Math.PI);
+ this.MAX_X_POLE = new GeoPoint(ab, 1.0, 0.0, 0.0, 0.0, 0.0);
+ this.MIN_Y_POLE = new GeoPoint(ab, 0.0, -1.0, 0.0, 0.0, -Math.PI * 0.5);
+ this.MAX_Y_POLE = new GeoPoint(ab, 0.0, 1.0, 0.0, 0.0, Math.PI * 0.5);
}
/** Find the minimum magnitude of all points on the ellipsoid.
@@ -97,6 +109,86 @@ public class PlanetModel {
return Math.max(this.ab, this.c);
}
+ /** Find the minimum x value.
+ *@return the minimum X value.
+ */
+ public double getMinimumXValue() {
+ return -this.ab;
+ }
+
+ /** Find the maximum x value.
+ *@return the maximum X value.
+ */
+ public double getMaximumXValue() {
+ return this.ab;
+ }
+
+ /** Find the minimum y value.
+ *@return the minimum Y value.
+ */
+ public double getMinimumYValue() {
+ return -this.ab;
+ }
+
+ /** Find the maximum y value.
+ *@return the maximum Y value.
+ */
+ public double getMaximumYValue() {
+ return this.ab;
+ }
+
+ /** Find the minimum z value.
+ *@return the minimum Z value.
+ */
+ public double getMinimumZValue() {
+ return -this.c;
+ }
+
+ /** Find the maximum z value.
+ *@return the maximum Z value.
+ */
+ public double getMaximumZValue() {
+ return this.c;
+ }
+
+ /** Check if point is on surface.
+ * @param v is the point to check.
+ * @return true if the point is on the planet surface.
+ */
+ public boolean pointOnSurface(final Vector v) {
+ return pointOnSurface(v.x, v.y, v.z);
+ }
+
+ /** Check if point is on surface.
+ * @param x is the x coord.
+ * @param y is the y coord.
+ * @param z is the z coord.
+ */
+ public boolean pointOnSurface(final double x, final double y, final double z) {
+ // Equation of planet surface is:
+ // x^2 / a^2 + y^2 / b^2 + z^2 / c^2 - 1 = 0
+ return Math.abs((x * x + y * y) * inverseAb * inverseAb + z * z * inverseC * inverseC - 1.0) < Vector.MINIMUM_RESOLUTION;
+ }
+
+ /** Check if point is outside surface.
+ * @param v is the point to check.
+ * @return true if the point is outside the planet surface.
+ */
+ public boolean pointOutside(final Vector v) {
+ return pointOutside(v.x, v.y, v.z);
+ }
+
+ /** Check if point is outside surface.
+ * @param x is the x coord.
+ * @param y is the y coord.
+ * @param z is the z coord.
+ */
+ public boolean pointOutside(final double x, final double y, final double z) {
+ // Equation of planet surface is:
+ // x^2 / a^2 + y^2 / b^2 + z^2 / c^2 - 1 = 0
+ return (x * x + y * y) * inverseAb * inverseAb + z * z * inverseC * inverseC - 1.0 > Vector.MINIMUM_RESOLUTION;
+ }
+
/** Compute surface distance between two points.
* @param p1 is the first point.
* @param p2 is the second point.
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/SidedPlane.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/SidedPlane.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/SidedPlane.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/SidedPlane.java Wed Sep 2 20:09:39 2015
@@ -48,6 +48,8 @@ public class SidedPlane extends Plane im
public SidedPlane(Vector p, Vector A, Vector B) {
super(A, B);
sigNum = Math.signum(evaluate(p));
+ if (sigNum == 0.0)
+ throw new IllegalArgumentException("Cannot determine sidedness because check point is on plane.");
}
/**
@@ -60,6 +62,8 @@ public class SidedPlane extends Plane im
public SidedPlane(Vector p, final PlanetModel planetModel, double sinLat) {
super(planetModel, sinLat);
sigNum = Math.signum(evaluate(p));
+ if (sigNum == 0.0)
+ throw new IllegalArgumentException("Cannot determine sidedness because check point is on plane.");
}
/**
@@ -72,6 +76,8 @@ public class SidedPlane extends Plane im
public SidedPlane(Vector p, double x, double y) {
super(x, y);
sigNum = Math.signum(evaluate(p));
+ if (sigNum == 0.0)
+ throw new IllegalArgumentException("Cannot determine sidedness because check point is on plane.");
}
/**
@@ -84,6 +90,24 @@ public class SidedPlane extends Plane im
public SidedPlane(Vector p, Vector v, double D) {
super(v, D);
sigNum = Math.signum(evaluate(p));
+ if (sigNum == 0.0)
+ throw new IllegalArgumentException("Cannot determine sidedness because check point is on plane.");
+ }
+
+ /**
+ * Construct a sided plane with a normal vector and offset.
+ *
+ * @param pX X coord of point to evaluate.
+ * @param pY Y coord of point to evaluate.
+ * @param pZ Z coord of point to evaluate.
+ * @param v is the normal vector.
+ * @param D is the origin offset for the plan.
+ */
+ public SidedPlane(double pX, double pY, double pZ, Vector v, double D) {
+ super(v, D);
+ sigNum = Math.signum(evaluate(pX,pY,pZ));
+ if (sigNum == 0.0)
+ throw new IllegalArgumentException("Cannot determine sidedness because check point is on plane.");
}
/** Construct a sided plane from two points and a third normal vector.
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/java/org/apache/lucene/geo3d/Vector.java Wed Sep 2 20:09:39 2015
@@ -28,7 +28,7 @@ public class Vector {
* Values that are all considered to be essentially zero have a magnitude
* less than this.
*/
- public static final double MINIMUM_RESOLUTION = 1e-12;
+ public static final double MINIMUM_RESOLUTION = 5.0e-13;
/**
* For squared quantities, the bound is squared too.
*/
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java?rev=1700887&r1=1700883&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/bkdtree3d/TestGeo3DPointField.java Wed Sep 2 20:09:39 2015
@@ -228,7 +228,7 @@ public class TestGeo3DPointField extends
}
public void testBKDRandom() throws Exception {
- List<Point> points = new ArrayList<>();
+ final List<Point> points = new ArrayList<>();
int numPoints = atLeast(10000);
Directory dir = newDirectory();
IndexOutput out = dir.createOutput("bkd", IOContext.DEFAULT);
@@ -284,12 +284,12 @@ public class TestGeo3DPointField extends
Range y = randomRange(planetModel);
Range z = randomRange(planetModel);
- int xMinEnc = encodeValue(planetMax, x.min);
- int xMaxEnc = encodeValue(planetMax, x.max);
- int yMinEnc = encodeValue(planetMax, y.min);
- int yMaxEnc = encodeValue(planetMax, y.max);
- int zMinEnc = encodeValue(planetMax, z.min);
- int zMaxEnc = encodeValue(planetMax, z.max);
+ final int xMinEnc = encodeValue(planetMax, x.min);
+ final int xMaxEnc = encodeValue(planetMax, x.max);
+ final int yMinEnc = encodeValue(planetMax, y.min);
+ final int yMaxEnc = encodeValue(planetMax, y.max);
+ final int zMinEnc = encodeValue(planetMax, z.min);
+ final int zMaxEnc = encodeValue(planetMax, z.max);
if (VERBOSE) {
System.err.println("\nTEST: iter=" + iter + " bbox: x=" + x + " (" + xMinEnc + " TO " + xMaxEnc+ ")" + " y=" + y + " (" + yMinEnc + " TO " + yMaxEnc + ")" + " z=" + z + " (" + zMinEnc + " TO " + zMaxEnc + ")" );
@@ -893,12 +893,12 @@ public class TestGeo3DPointField extends
}
}
- private static void verify(double[] lats, double[] lons) throws Exception {
+ private static void verify(final double[] lats, final double[] lons) throws Exception {
int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);
int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);
IndexWriterConfig iwc = newIndexWriterConfig();
- PlanetModel planetModel;
+ final PlanetModel planetModel;
if (random().nextBoolean()) {
planetModel = PlanetModel.WGS84;
} else {
@@ -928,7 +928,7 @@ public class TestGeo3DPointField extends
} else {
dir = newDirectory();
}
- Set<Integer> deleted = new HashSet<>();
+ final Set<Integer> deleted = new HashSet<>();
// RandomIndexWriter is too slow here:
IndexWriter w = new IndexWriter(dir, iwc);
for(int id=0;id<lats.length;id++) {
@@ -955,7 +955,7 @@ public class TestGeo3DPointField extends
w.close();
// We can't wrap with "exotic" readers because the geo3d query must see the Geo3DDVFormat:
- IndexSearcher s = newSearcher(r, false);
+ final IndexSearcher s = newSearcher(r, false);
int numThreads = TestUtil.nextInt(random(), 2, 5);
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoBBoxTest.java Wed Sep 2 20:09:39 2015
@@ -44,7 +44,7 @@ public class GeoBBoxTest {
relationship = box.getRelationship(shape);
assertEquals(GeoArea.CONTAINS, relationship);
box = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, -61.85 * DEGREES_TO_RADIANS, -67.5 * DEGREES_TO_RADIANS, -180 * DEGREES_TO_RADIANS, -168.75 * DEGREES_TO_RADIANS);
- System.out.println("Shape = " + shape + " Rect = " + box);
+ //System.out.println("Shape = " + shape + " Rect = " + box);
relationship = box.getRelationship(shape);
assertEquals(GeoArea.CONTAINS, relationship);
}
@@ -139,11 +139,61 @@ public class GeoBBoxTest {
@Test
public void testBBoxBounds() {
GeoBBox c;
- Bounds b;
+ LatLonBounds b;
+ XYZBounds xyzb;
+ GeoArea solid;
+ 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);
+ 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, Math.PI * 0.25, -Math.PI * 0.25, -1.0, 1.0);
+ b = new LatLonBounds();
+ c.getBounds(b);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ assertFalse(b.checkNoLongitudeBound());
+ assertFalse(b.checkNoTopLatitudeBound());
+ assertFalse(b.checkNoBottomLatitudeBound());
+ assertEquals(-1.0, b.getLeftLongitude(), 0.000001);
+ assertEquals(1.0, b.getRightLongitude(), 0.000001);
+ assertEquals(-Math.PI * 0.25, b.getMinLatitude(), 0.000001);
+ assertEquals(Math.PI * 0.25, b.getMaxLatitude(), 0.000001);
+ assertEquals(0.382051, xyzb.getMinimumX(), 0.000001);
+ assertEquals(1.0, xyzb.getMaximumX(), 0.000001);
+ assertEquals(-0.841471, xyzb.getMinimumY(), 0.000001);
+ assertEquals(0.841471, xyzb.getMaximumY(), 0.000001);
+ assertEquals(-0.707107, xyzb.getMinimumZ(), 0.000001);
+ assertEquals(0.707107, xyzb.getMaximumZ(), 0.000001);
+
+ GeoArea area = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,
+ xyzb.getMinimumX() - 2.0 * Vector.MINIMUM_RESOLUTION,
+ xyzb.getMaximumX() + 2.0 * Vector.MINIMUM_RESOLUTION,
+ xyzb.getMinimumY() - 2.0 * Vector.MINIMUM_RESOLUTION,
+ xyzb.getMaximumY() + 2.0 * Vector.MINIMUM_RESOLUTION,
+ xyzb.getMinimumZ() - 2.0 * Vector.MINIMUM_RESOLUTION,
+ xyzb.getMaximumZ() + 2.0 * Vector.MINIMUM_RESOLUTION);
+ assertEquals(GeoArea.WITHIN, area.getRelationship(c));
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, 0.0, -Math.PI * 0.25, -1.0, 1.0);
-
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -151,10 +201,19 @@ public class GeoBBoxTest {
assertEquals(1.0, b.getRightLongitude(), 0.000001);
assertEquals(-Math.PI * 0.25, b.getMinLatitude(), 0.000001);
assertEquals(0.0, b.getMaxLatitude(), 0.000001);
+ assertEquals(0.382051, xyzb.getMinimumX(), 0.000001);
+ assertEquals(1.0, xyzb.getMaximumX(), 0.000001);
+ assertEquals(-0.841471, xyzb.getMinimumY(), 0.000001);
+ assertEquals(0.841471, xyzb.getMaximumY(), 0.000001);
+ assertEquals(-0.707107, xyzb.getMinimumZ(), 0.000001);
+ assertEquals(0.0, xyzb.getMaximumZ(), 0.000001);
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, 0.0, -Math.PI * 0.25, 1.0, -1.0);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
assertTrue(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -162,30 +221,56 @@ public class GeoBBoxTest {
//assertEquals(-1.0,b.getRightLongitude(),0.000001);
assertEquals(-Math.PI * 0.25, b.getMinLatitude(), 0.000001);
assertEquals(0.0, b.getMaxLatitude(), 0.000001);
+ assertEquals(-1.0, xyzb.getMinimumX(), 0.000001);
+ assertEquals(0.540303, xyzb.getMaximumX(), 0.000001);
+ assertEquals(-1.0, xyzb.getMinimumY(), 0.000001);
+ assertEquals(1.0, xyzb.getMaximumY(), 0.000001);
+ assertEquals(-0.707107, xyzb.getMinimumZ(), 0.000001);
+ assertEquals(0.0, xyzb.getMaximumZ(), 0.000001);
+
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, -1.0, 1.0);
- b = c.getBounds(null);
- assertFalse(b.checkNoLongitudeBound());
+ b = new LatLonBounds();
+ c.getBounds(b);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
- assertEquals(-1.0, b.getLeftLongitude(), 0.000001);
- assertEquals(1.0, b.getRightLongitude(), 0.000001);
+ //assertEquals(-1.0, b.getLeftLongitude(), 0.000001);
+ //assertEquals(1.0, b.getRightLongitude(), 0.000001);
+ assertEquals(0.0, xyzb.getMinimumX(), 0.000001);
+ assertEquals(1.0, xyzb.getMaximumX(), 0.000001);
+ assertEquals(-0.841471, xyzb.getMinimumY(), 0.000001);
+ assertEquals(0.841471, xyzb.getMaximumY(), 0.000001);
+ assertEquals(-1.0, xyzb.getMinimumZ(), 0.000001);
+ assertEquals(1.0, xyzb.getMaximumZ(), 0.000001);
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, 1.0, -1.0);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
//assertEquals(1.0,b.getLeftLongitude(),0.000001);
//assertEquals(-1.0,b.getRightLongitude(),0.000001);
+ assertEquals(-1.0, xyzb.getMinimumX(), 0.000001);
+ assertEquals(0.540303, xyzb.getMaximumX(), 0.000001);
+ assertEquals(-1.0, xyzb.getMinimumY(), 0.000001);
+ assertEquals(1.0, xyzb.getMaximumY(), 0.000001);
+ assertEquals(-1.0, xyzb.getMinimumZ(), 0.000001);
+ assertEquals(1.0, xyzb.getMaximumZ(), 0.000001);
// Check wide variants of rectangle and longitude slice
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, 0.0, -Math.PI * 0.25, -Math.PI + 0.1, Math.PI - 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -196,7 +281,8 @@ public class GeoBBoxTest {
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, 0.0, -Math.PI * 0.25, Math.PI - 0.1, -Math.PI + 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -207,7 +293,8 @@ public class GeoBBoxTest {
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, -Math.PI + 0.1, Math.PI - 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
@@ -216,17 +303,19 @@ public class GeoBBoxTest {
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, Math.PI - 0.1, -Math.PI + 0.1);
- b = c.getBounds(null);
- assertFalse(b.checkNoLongitudeBound());
+ b = new LatLonBounds();
+ c.getBounds(b);
+ assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
- assertEquals(Math.PI - 0.1, b.getLeftLongitude(), 0.000001);
- assertEquals(-Math.PI + 0.1, b.getRightLongitude(), 0.000001);
+ //assertEquals(Math.PI - 0.1, b.getLeftLongitude(), 0.000001);
+ //assertEquals(-Math.PI + 0.1, b.getRightLongitude(), 0.000001);
// Check latitude zone
c = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, 1.0, -1.0, -Math.PI, Math.PI);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -240,9 +329,9 @@ public class GeoBBoxTest {
c1 = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, -Math.PI, 0.0);
c2 = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, 0.0, Math.PI);
- b = new Bounds();
- b = c1.getBounds(b);
- b = c2.getBounds(b);
+ b = new LatLonBounds();
+ c1.getBounds(b);
+ c2.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
@@ -250,9 +339,9 @@ public class GeoBBoxTest {
c1 = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, -Math.PI, 0.0);
c2 = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, 0.0, Math.PI * 0.5);
- b = new Bounds();
- b = c1.getBounds(b);
- b = c2.getBounds(b);
+ b = new LatLonBounds();
+ c1.getBounds(b);
+ c2.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
@@ -262,9 +351,9 @@ public class GeoBBoxTest {
c1 = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, -Math.PI * 0.5, 0.0);
c2 = GeoBBoxFactory.makeGeoBBox(PlanetModel.SPHERE, Math.PI * 0.5, -Math.PI * 0.5, 0.0, Math.PI);
- b = new Bounds();
- b = c1.getBounds(b);
- b = c2.getBounds(b);
+ b = new LatLonBounds();
+ c1.getBounds(b);
+ c2.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoCircleTest.java Wed Sep 2 20:09:39 2015
@@ -23,8 +23,9 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-public class GeoCircleTest {
+import org.apache.lucene.util.LuceneTestCase;
+public class GeoCircleTest extends LuceneTestCase {
@Test
public void testCircleDistance() {
@@ -62,7 +63,8 @@ public class GeoCircleTest {
assertTrue(c.isWithin(gp));
gp = new GeoPoint(PlanetModel.SPHERE, 0.0, Math.PI);
assertTrue(c.isWithin(gp));
- Bounds b = c.getBounds(null);
+ LatLonBounds b = new LatLonBounds();
+ c.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
@@ -93,12 +95,157 @@ public class GeoCircleTest {
@Test
public void testCircleBounds() {
GeoCircle c;
- Bounds b;
-
-
+ LatLonBounds b;
+ XYZBounds xyzb;
+ GeoArea area;
+ GeoPoint p1;
+ GeoPoint p2;
+ int relationship;
+
+ // Twelfth BKD discovered failure
+ c = new GeoCircle(PlanetModel.WGS84,-0.00824379317765984,-0.0011677469001838581,0.0011530035396910402);
+ p1 = new GeoPoint(PlanetModel.WGS84,-0.006505092992723671,0.007654282718327381);
+ p2 = new GeoPoint(1.0010681673665647,0.007662608264336381,-0.006512324005914593);
+ assertTrue(!c.isWithin(p1));
+ assertTrue(!c.isWithin(p2));
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ relationship = area.getRelationship(c);
+ assertTrue(relationship == GeoArea.OVERLAPS || relationship == GeoArea.WITHIN);
+ // Point is actually outside the bounds, and outside the shape
+ assertTrue(!area.isWithin(p1));
+ // Approximate point the same
+ assertTrue(!area.isWithin(p2));
+
+ // Eleventh BKD discovered failure
+ c = new GeoCircle(PlanetModel.SPHERE,-0.004431288600558495,-0.003687846671278374,1.704543429364245E-8);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ //System.err.println(area);
+ relationship = area.getRelationship(c);
+ assertTrue(GeoArea.WITHIN == relationship || GeoArea.OVERLAPS == relationship);
+
+ // Tenth BKD discovered failure
+ c = new GeoCircle(PlanetModel.WGS84,-0.0018829770647349636,-0.001969499061382591,1.3045439293158305E-5);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ //System.err.println(area);
+ relationship = area.getRelationship(c);
+ assertTrue(GeoArea.WITHIN == relationship || GeoArea.OVERLAPS == relationship);
+
+ // Ninth BKD discovered failure
+ c = new GeoCircle(PlanetModel.SPHERE,-4.211990380885122E-5,-0.0022958453508173044,1.4318475623498535E-5);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ //System.err.println(area);
+ relationship = area.getRelationship(c);
+ assertTrue(GeoArea.WITHIN == relationship || GeoArea.OVERLAPS == relationship);
+
+ // Eighth BKD discovered failure
+ c = new GeoCircle(PlanetModel.SPHERE,0.005321278689117842,-0.00216937368755372,1.5306034422500785E-4);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ //System.err.println(area);
+ relationship = area.getRelationship(c);
+ assertTrue(GeoArea.WITHIN == relationship || GeoArea.OVERLAPS == relationship);
+
+ // Seventh BKD discovered failure
+ c = new GeoCircle(PlanetModel.SPHERE,-0.0021627146783861745, -0.0017298167021592304,2.0818312293195752E-4);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ //System.err.println(area);
+ relationship = area.getRelationship(c);
+ assertTrue(GeoArea.WITHIN == relationship || GeoArea.OVERLAPS == relationship);
+
+ // Sixth BKD discovered failure
+ c = new GeoCircle(PlanetModel.WGS84,-0.006450320645814321,0.004660694205115142,0.00489710732634323);
+ //xyzb = new XYZBounds();
+ //c.getBounds(xyzb);
+ //System.err.println("xmin="+xyzb.getMinimumX()+", xmax="+xyzb.getMaximumX()+",ymin="+xyzb.getMinimumY()+", ymax="+xyzb.getMaximumY()+",zmin="+xyzb.getMinimumZ()+", zmax="+xyzb.getMaximumZ());
+ //xmin=1.0010356621420726, xmax=1.0011141249179447,ymin=-2.5326643901354566E-4, ymax=0.009584741915757169,zmin=-0.011359874956269283, zmax=-0.0015549504447452225
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84,1.0010822580620098,1.0010945779732867,0.007079167343247293,0.007541006774427837,-0.0021855011220022575,-0.001896122718181518);
+ assertTrue(GeoArea.CONTAINS != area.getRelationship(c));
+ /*
+ p1 = new GeoPoint(1.0010893045436076,0.007380935180644008,-0.002140671370616495);
+ // This has a different bounding box, so we can't use it.
+ //p2 = new GeoPoint(PlanetModel.WGS84,-0.002164069780096702, 0.007505617500830066);
+ p2 = new GeoPoint(PlanetModel.WGS84,p1.getLatitude(),p1.getLongitude());
+ assertTrue(PlanetModel.WGS84.pointOnSurface(p2));
+ assertTrue(!c.isWithin(p2));
+ assertTrue(!area.isWithin(p2));
+ assertTrue(!c.isWithin(p1));
+ assertTrue(PlanetModel.WGS84.pointOnSurface(p1)); // This fails
+ assertTrue(!area.isWithin(p1)); // This fails
+ */
+
+ // Fifth BKD discovered failure
+ c = new GeoCircle(PlanetModel.SPHERE, -0.004282454525970269, -1.6739831367422277E-4, 1.959639723134033E-6);
+ assertTrue(c.isWithin(c.getEdgePoints()[0]));
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ assertTrue(GeoArea.WITHIN == area.getRelationship(c) || GeoArea.OVERLAPS == area.getRelationship(c));
+
+ // Fourth BKD discovered failure
+ c = new GeoCircle(PlanetModel.SPHERE, -0.0048795517261255, 0.004053904306995974, 5.93699764258874E-6);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ assertTrue(GeoArea.WITHIN == area.getRelationship(c) || GeoArea.OVERLAPS == area.getRelationship(c));
+
+ // Yet another test case from BKD
+ c = new GeoCircle(PlanetModel.WGS84, 0.006229478708446979, 0.005570196723795424, 3.840276763694387E-5);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ p1 = new GeoPoint(PlanetModel.WGS84, 0.006224927111830945, 0.005597367237251763);
+ p2 = new GeoPoint(1.0010836083810235, 0.005603490759433942, 0.006231850560862502);
+ assertTrue(PlanetModel.WGS84.pointOnSurface(p1));
+ //assertTrue(PlanetModel.WGS84.pointOnSurface(p2));
+ assertTrue(c.isWithin(p1));
+ assertTrue(c.isWithin(p2));
+ assertTrue(area.isWithin(p1));
+ assertTrue(area.isWithin(p2));
+
+ // Another test case from BKD
+ c = new GeoCircle(PlanetModel.SPHERE, -0.005955031040627789, -0.0029274772647399153, 1.601488279374338E-5);
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+
+ relationship = area.getRelationship(c);
+ assertTrue(relationship == GeoArea.WITHIN || relationship == GeoArea.OVERLAPS);
+
+ // Test case from BKD
+ c = new GeoCircle(PlanetModel.SPHERE, -0.765816119338, 0.991848766844, 0.8153163226330487);
+ p1 = new GeoPoint(0.7692262265236023, -0.055089298115534646, -0.6365973465711254);
+ assertTrue(c.isWithin(p1));
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ assertTrue(p1.x >= xyzb.getMinimumX() && p1.x <= xyzb.getMaximumX());
+ assertTrue(p1.y >= xyzb.getMinimumY() && p1.y <= xyzb.getMaximumY());
+ assertTrue(p1.z >= xyzb.getMinimumZ() && p1.z <= xyzb.getMaximumZ());
+
// Vertical circle cases
c = new GeoCircle(PlanetModel.SPHERE, 0.0, -0.5, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -107,7 +254,8 @@ public class GeoCircleTest {
assertEquals(-0.1, b.getMinLatitude(), 0.000001);
assertEquals(0.1, b.getMaxLatitude(), 0.000001);
c = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.5, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -116,7 +264,8 @@ public class GeoCircleTest {
assertEquals(-0.1, b.getMinLatitude(), 0.000001);
assertEquals(0.1, b.getMaxLatitude(), 0.000001);
c = new GeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -125,7 +274,8 @@ public class GeoCircleTest {
assertEquals(-0.1, b.getMinLatitude(), 0.000001);
assertEquals(0.1, b.getMaxLatitude(), 0.000001);
c = new GeoCircle(PlanetModel.SPHERE, 0.0, Math.PI, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -135,13 +285,15 @@ public class GeoCircleTest {
assertEquals(0.1, b.getMaxLatitude(), 0.000001);
// Horizontal circle cases
c = new GeoCircle(PlanetModel.SPHERE, Math.PI * 0.5, 0.0, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertTrue(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
assertEquals(Math.PI * 0.5 - 0.1, b.getMinLatitude(), 0.000001);
c = new GeoCircle(PlanetModel.SPHERE, -Math.PI * 0.5, 0.0, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertTrue(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertTrue(b.checkNoBottomLatitudeBound());
@@ -149,7 +301,8 @@ public class GeoCircleTest {
// Now do a somewhat tilted plane, facing different directions.
c = new GeoCircle(PlanetModel.SPHERE, 0.01, 0.0, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -159,7 +312,8 @@ public class GeoCircleTest {
assertEquals(0.1, b.getRightLongitude(), 0.00001);
c = new GeoCircle(PlanetModel.SPHERE, 0.01, Math.PI, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -169,7 +323,8 @@ public class GeoCircleTest {
assertEquals(-Math.PI + 0.1, b.getRightLongitude(), 0.00001);
c = new GeoCircle(PlanetModel.SPHERE, 0.01, Math.PI * 0.5, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -179,7 +334,8 @@ public class GeoCircleTest {
assertEquals(Math.PI * 0.5 + 0.1, b.getRightLongitude(), 0.00001);
c = new GeoCircle(PlanetModel.SPHERE, 0.01, -Math.PI * 0.5, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -190,7 +346,8 @@ public class GeoCircleTest {
// Slightly tilted, PI/4 direction.
c = new GeoCircle(PlanetModel.SPHERE, 0.01, Math.PI * 0.25, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -200,7 +357,8 @@ public class GeoCircleTest {
assertEquals(Math.PI * 0.25 + 0.1, b.getRightLongitude(), 0.00001);
c = new GeoCircle(PlanetModel.SPHERE, 0.01, -Math.PI * 0.25, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -210,7 +368,8 @@ public class GeoCircleTest {
assertEquals(-Math.PI * 0.25 + 0.1, b.getRightLongitude(), 0.00001);
c = new GeoCircle(PlanetModel.SPHERE, -0.01, Math.PI * 0.25, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -220,7 +379,8 @@ public class GeoCircleTest {
assertEquals(Math.PI * 0.25 + 0.1, b.getRightLongitude(), 0.00001);
c = new GeoCircle(PlanetModel.SPHERE, -0.01, -Math.PI * 0.25, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
@@ -231,7 +391,8 @@ public class GeoCircleTest {
// Now do a somewhat tilted plane.
c = new GeoCircle(PlanetModel.SPHERE, 0.01, -0.5, 0.1);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoConvexPolygonTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoConvexPolygonTest.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoConvexPolygonTest.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoConvexPolygonTest.java Wed Sep 2 20:09:39 2015
@@ -70,7 +70,7 @@ public class GeoConvexPolygonTest {
@Test
public void testPolygonBounds() {
GeoConvexPolygon c;
- Bounds b;
+ LatLonBounds b;
c = new GeoConvexPolygon(PlanetModel.SPHERE, -0.1, -0.5);
c.addPoint(0.0, -0.6, false);
@@ -78,7 +78,8 @@ public class GeoConvexPolygonTest {
c.addPoint(0.0, -0.4, false);
c.done(false);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoModelTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoModelTest.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoModelTest.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoModelTest.java Wed Sep 2 20:09:39 2015
@@ -43,7 +43,9 @@ public class GeoModelTest {
assertTrue(circle.isWithin(northPole));
assertFalse(circle.isWithin(southPole));
assertFalse(circle.isWithin(point1));
- Bounds bounds = circle.getBounds(null);
+ LatLonBounds bounds;
+ bounds = new LatLonBounds();
+ circle.getBounds(bounds);
assertTrue(bounds.checkNoLongitudeBound());
assertTrue(bounds.checkNoTopLatitudeBound());
assertFalse(bounds.checkNoBottomLatitudeBound());
@@ -53,7 +55,8 @@ public class GeoModelTest {
assertTrue(circle.isWithin(point1));
assertFalse(circle.isWithin(northPole));
assertFalse(circle.isWithin(southPole));
- bounds = circle.getBounds(null);
+ bounds = new LatLonBounds();
+ circle.getBounds(bounds);
assertFalse(bounds.checkNoTopLatitudeBound());
assertFalse(bounds.checkNoLongitudeBound());
assertFalse(bounds.checkNoBottomLatitudeBound());
@@ -66,7 +69,8 @@ public class GeoModelTest {
assertTrue(circle.isWithin(point2));
assertFalse(circle.isWithin(northPole));
assertFalse(circle.isWithin(southPole));
- bounds = circle.getBounds(null);
+ bounds = new LatLonBounds();
+ circle.getBounds(bounds);
assertFalse(bounds.checkNoLongitudeBound());
assertFalse(bounds.checkNoTopLatitudeBound());
assertFalse(bounds.checkNoBottomLatitudeBound());
@@ -91,7 +95,8 @@ public class GeoModelTest {
assertFalse(bbox.isWithin(leftOutsidePoint));
final GeoPoint rightOutsidePoint = new GeoPoint(scaledModel, 0.5, 1.01);
assertFalse(bbox.isWithin(rightOutsidePoint));
- final Bounds bounds = bbox.getBounds(null);
+ final LatLonBounds bounds = new LatLonBounds();
+ bbox.getBounds(bounds);
assertFalse(bounds.checkNoLongitudeBound());
assertFalse(bounds.checkNoTopLatitudeBound());
assertFalse(bounds.checkNoBottomLatitudeBound());
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoPathTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoPathTest.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoPathTest.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoPathTest.java Wed Sep 2 20:09:39 2015
@@ -165,14 +165,54 @@ public class GeoPathTest {
@Test
public void testPathBounds() {
GeoPath c;
- Bounds b;
+ LatLonBounds b;
+ XYZBounds xyzb;
+ GeoPoint point;
+ int relationship;
+ GeoArea area;
+
+ c = new GeoPath(PlanetModel.WGS84, 0.6894050545377601);
+ c.addPoint(-0.0788176065762948, 0.9431251741731624);
+ c.addPoint(0.510387871458147, 0.5327078872484678);
+ c.addPoint(-0.5624521609859962, 1.5398841746888388);
+ c.addPoint(-0.5025171434638661, -0.5895998642788894);
+ c.done();
+ point = new GeoPoint(PlanetModel.WGS84, 0.023652082107211682, 0.023131910152748437);
+ //System.err.println("Point.x = "+point.x+"; point.y="+point.y+"; point.z="+point.z);
+ assertTrue(c.isWithin(point));
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ //System.err.println("minx="+xyzb.getMinimumX()+" maxx="+xyzb.getMaximumX()+" miny="+xyzb.getMinimumY()+" maxy="+xyzb.getMaximumY()+" minz="+xyzb.getMinimumZ()+" maxz="+xyzb.getMaximumZ());
+ //System.err.println("point.x="+point.x+" point.y="+point.y+" point.z="+point.z);
+ relationship = area.getRelationship(c);
+ assertTrue(relationship == GeoArea.WITHIN || relationship == GeoArea.OVERLAPS);
+ assertTrue(area.isWithin(point));
+
+ c = new GeoPath(PlanetModel.WGS84, 0.7766715171374766);
+ c.addPoint(-0.2751718361148076, -0.7786721269011477);
+ c.addPoint(0.5728375851539309, -1.2700115736820465);
+ c.done();
+ point = new GeoPoint(PlanetModel.WGS84, -0.01580760332365284, -0.03956004622490505);
+ assertTrue(c.isWithin(point));
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ //System.err.println("minx="+xyzb.getMinimumX()+" maxx="+xyzb.getMaximumX()+" miny="+xyzb.getMinimumY()+" maxy="+xyzb.getMaximumY()+" minz="+xyzb.getMinimumZ()+" maxz="+xyzb.getMaximumZ());
+ //System.err.println("point.x="+point.x+" point.y="+point.y+" point.z="+point.z);
+ relationship = area.getRelationship(c);
+ assertTrue(relationship == GeoArea.WITHIN || relationship == GeoArea.OVERLAPS);
+ assertTrue(area.isWithin(point));
c = new GeoPath(PlanetModel.SPHERE, 0.1);
c.addPoint(-0.3, -0.3);
c.addPoint(0.3, 0.3);
c.done();
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());
Modified: lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoPolygonTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoPolygonTest.java?rev=1700887&r1=1700886&r2=1700887&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoPolygonTest.java (original)
+++ lucene/dev/branches/branch_5x/lucene/spatial3d/src/test/org/apache/lucene/geo3d/GeoPolygonTest.java Wed Sep 2 20:09:39 2015
@@ -121,9 +121,29 @@ public class GeoPolygonTest {
@Test
public void testPolygonBounds() {
GeoMembershipShape c;
- Bounds b;
+ LatLonBounds b;
List<GeoPoint> points;
-
+ XYZBounds xyzb;
+ GeoPoint point;
+ GeoArea area;
+
+ // BKD failure
+ points = new ArrayList<GeoPoint>();
+ points.add(new GeoPoint(PlanetModel.WGS84, -0.36716183577912814, 1.4836349969188696));
+ points.add(new GeoPoint(PlanetModel.WGS84, 0.7846038240742979, -0.02743348424931823));
+ points.add(new GeoPoint(PlanetModel.WGS84, -0.7376479402362607, -0.5072961758807019));
+ points.add(new GeoPoint(PlanetModel.WGS84, -0.3760415907667887, 1.4970455334565513));
+
+ c = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, points, 1);
+
+ point = new GeoPoint(PlanetModel.WGS84, -0.01580760332365284, -0.03956004622490505);
+ assertTrue(c.isWithin(point));
+ xyzb = new XYZBounds();
+ c.getBounds(xyzb);
+ area = GeoAreaFactory.makeGeoArea(PlanetModel.WGS84,
+ xyzb.getMinimumX(), xyzb.getMaximumX(), xyzb.getMinimumY(), xyzb.getMaximumY(), xyzb.getMinimumZ(), xyzb.getMaximumZ());
+ assertTrue(area.isWithin(point));
+
points = new ArrayList<GeoPoint>();
points.add(new GeoPoint(PlanetModel.SPHERE, -0.1, -0.5));
points.add(new GeoPoint(PlanetModel.SPHERE, 0.0, -0.6));
@@ -132,7 +152,8 @@ public class GeoPolygonTest {
c = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points, 0);
- b = c.getBounds(null);
+ b = new LatLonBounds();
+ c.getBounds(b);
assertFalse(b.checkNoLongitudeBound());
assertFalse(b.checkNoTopLatitudeBound());
assertFalse(b.checkNoBottomLatitudeBound());