You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2015/05/04 22:13:26 UTC
svn commit: r1677670 - in
/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j:
Geo3dShape.java geo3d/GeoBBoxFactory.java geo3d/GeoDegeneratePoint.java
Author: dsmiley
Date: Mon May 4 20:13:25 2015
New Revision: 1677670
URL: http://svn.apache.org/r1677670
Log:
LUCENE-6196: committing Karl's latest patch
https://reviews.apache.org/r/33811/ (diff #3)
Modified:
lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java
lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoBBoxFactory.java
lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoDegeneratePoint.java
Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java?rev=1677670&r1=1677669&r2=1677670&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/Geo3dShape.java Mon May 4 20:13:25 2015
@@ -91,6 +91,8 @@ public class Geo3dShape implements Shape
return SpatialRelation.DISJOINT;
}
+ protected final double ROUNDOFF_ADJUSTMENT = 0.01;
+
@Override
public Rectangle getBoundingBox() {
if (boundingBox == null) {
@@ -116,7 +118,7 @@ public class Geo3dShape implements Shape
} else {
maxLat = bounds.getMaxLatitude().doubleValue() * DEGREES_PER_RADIAN;
}
- boundingBox = new RectangleImpl(leftLon, rightLon, minLat, maxLat, ctx);
+ boundingBox = new RectangleImpl(leftLon, rightLon, minLat, maxLat, ctx).getBuffered(ROUNDOFF_ADJUSTMENT, ctx);
}
return boundingBox;
}
Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoBBoxFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoBBoxFactory.java?rev=1677670&r1=1677669&r2=1677670&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoBBoxFactory.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoBBoxFactory.java Mon May 4 20:13:25 2015
@@ -45,17 +45,17 @@ public class GeoBBoxFactory {
leftLon = -Math.PI;
if (rightLon > Math.PI)
rightLon = Math.PI;
- if (leftLon == -Math.PI && rightLon == Math.PI) {
- if (topLat == Math.PI * 0.5 && bottomLat == -Math.PI * 0.5)
+ if (Math.abs(leftLon + Math.PI) < Vector.MINIMUM_RESOLUTION && Math.abs(rightLon - Math.PI) < Vector.MINIMUM_RESOLUTION) {
+ if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION && Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION)
return new GeoWorld();
- if (topLat == bottomLat) {
- if (topLat == Math.PI * 0.5 || topLat == -Math.PI * 0.5)
+ if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_RESOLUTION) {
+ if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION || Math.abs(topLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION)
return new GeoDegeneratePoint(topLat, 0.0);
return new GeoDegenerateLatitudeZone(topLat);
}
- if (topLat == Math.PI * 0.5)
+ if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION)
return new GeoNorthLatitudeZone(bottomLat);
- else if (bottomLat == -Math.PI * 0.5)
+ else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION)
return new GeoSouthLatitudeZone(topLat);
return new GeoLatitudeZone(topLat, bottomLat);
}
@@ -64,7 +64,7 @@ public class GeoBBoxFactory {
if (extent < 0.0)
extent += Math.PI * 2.0;
if (topLat == Math.PI * 0.5 && bottomLat == -Math.PI * 0.5) {
- if (leftLon == rightLon)
+ if (Math.abs(leftLon - rightLon) < Vector.MINIMUM_RESOLUTION)
return new GeoDegenerateLongitudeSlice(leftLon);
if (extent >= Math.PI)
@@ -73,32 +73,35 @@ public class GeoBBoxFactory {
return new GeoLongitudeSlice(leftLon, rightLon);
}
//System.err.println(" not longitude slice");
- if (leftLon == rightLon) {
- if (topLat == bottomLat)
+ if (Math.abs(leftLon - rightLon) < Vector.MINIMUM_RESOLUTION) {
+ if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_RESOLUTION)
return new GeoDegeneratePoint(topLat, leftLon);
return new GeoDegenerateVerticalLine(topLat, bottomLat, leftLon);
}
//System.err.println(" not vertical line");
if (extent >= Math.PI) {
- if (topLat == bottomLat) {
+ if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_RESOLUTION) {
//System.err.println(" wide degenerate line");
return new GeoWideDegenerateHorizontalLine(topLat, leftLon, rightLon);
}
- if (topLat == Math.PI * 0.5) {
+ if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
return new GeoWideNorthRectangle(bottomLat, leftLon, rightLon);
- } else if (bottomLat == -Math.PI * 0.5) {
+ } else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
return new GeoWideSouthRectangle(topLat, leftLon, rightLon);
}
//System.err.println(" wide rect");
return new GeoWideRectangle(topLat, bottomLat, leftLon, rightLon);
}
- if (topLat == bottomLat) {
+ if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_RESOLUTION) {
+ if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION || Math.abs(topLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
+ return new GeoDegeneratePoint(topLat, 0.0);
+ }
//System.err.println(" horizontal line");
return new GeoDegenerateHorizontalLine(topLat, leftLon, rightLon);
}
- if (topLat == Math.PI * 0.5) {
+ if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
return new GeoNorthRectangle(bottomLat, leftLon, rightLon);
- } else if (bottomLat == -Math.PI * 0.5) {
+ } else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
return new GeoSouthRectangle(topLat, leftLon, rightLon);
}
//System.err.println(" rectangle");
Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoDegeneratePoint.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoDegeneratePoint.java?rev=1677670&r1=1677669&r2=1677670&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoDegeneratePoint.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/java/org/apache/lucene/spatial/spatial4j/geo3d/GeoDegeneratePoint.java Mon May 4 20:13:25 2015
@@ -72,7 +72,8 @@ public class GeoDegeneratePoint extends
*/
@Override
public boolean intersects(final Plane plane, final GeoPoint[] notablePoints, final Membership... bounds) {
- if (plane.evaluate(this) == 0.0)
+ // If not on the plane, no intersection
+ if (!plane.evaluateIsZero(this))
return false;
for (Membership m : bounds) {
@@ -183,9 +184,12 @@ public class GeoDegeneratePoint extends
*/
@Override
public int getRelationship(final GeoShape shape) {
- if (shape.isWithin(this))
+ if (shape.isWithin(this)) {
+ //System.err.println("Degenerate point "+this+" is WITHIN shape "+shape);
return CONTAINS;
+ }
+ //System.err.println("Degenerate point "+this+" is NOT within shape "+shape);
return DISJOINT;
}