mirror of https://github.com/apache/lucene.git
LUCENE-7511: Introduce Vector.MINIMUM_ANGULAR_RESOLUTION.
This commit is contained in:
parent
9bd152804d
commit
283b329bbb
|
@ -45,18 +45,18 @@ public class GeoBBoxFactory {
|
|||
leftLon = -Math.PI;
|
||||
if (rightLon > Math.PI)
|
||||
rightLon = Math.PI;
|
||||
if ((Math.abs(leftLon + Math.PI) < Vector.MINIMUM_RESOLUTION && Math.abs(rightLon - Math.PI) < Vector.MINIMUM_RESOLUTION) ||
|
||||
(Math.abs(rightLon + Math.PI) < Vector.MINIMUM_RESOLUTION && Math.abs(leftLon - 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)
|
||||
if ((Math.abs(leftLon + Math.PI) < Vector.MINIMUM_ANGULAR_RESOLUTION && Math.abs(rightLon - Math.PI) < Vector.MINIMUM_ANGULAR_RESOLUTION) ||
|
||||
(Math.abs(rightLon + Math.PI) < Vector.MINIMUM_ANGULAR_RESOLUTION && Math.abs(leftLon - Math.PI) < Vector.MINIMUM_ANGULAR_RESOLUTION)) {
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION && Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION)
|
||||
return new GeoWorld(planetModel);
|
||||
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)
|
||||
if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION || Math.abs(topLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION)
|
||||
return new GeoDegeneratePoint(planetModel, topLat, 0.0);
|
||||
return new GeoDegenerateLatitudeZone(planetModel, topLat);
|
||||
}
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION)
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION)
|
||||
return new GeoNorthLatitudeZone(planetModel, bottomLat);
|
||||
else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION)
|
||||
else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION)
|
||||
return new GeoSouthLatitudeZone(planetModel, topLat);
|
||||
return new GeoLatitudeZone(planetModel, topLat, bottomLat);
|
||||
}
|
||||
|
@ -65,7 +65,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 (Math.abs(leftLon - rightLon) < Vector.MINIMUM_RESOLUTION)
|
||||
if (Math.abs(leftLon - rightLon) < Vector.MINIMUM_ANGULAR_RESOLUTION)
|
||||
return new GeoDegenerateLongitudeSlice(planetModel, leftLon);
|
||||
|
||||
if (extent >= Math.PI)
|
||||
|
@ -74,35 +74,35 @@ public class GeoBBoxFactory {
|
|||
return new GeoLongitudeSlice(planetModel, leftLon, rightLon);
|
||||
}
|
||||
//System.err.println(" not longitude slice");
|
||||
if (Math.abs(leftLon - rightLon) < Vector.MINIMUM_RESOLUTION) {
|
||||
if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_RESOLUTION)
|
||||
if (Math.abs(leftLon - rightLon) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_ANGULAR_RESOLUTION)
|
||||
return new GeoDegeneratePoint(planetModel, topLat, leftLon);
|
||||
return new GeoDegenerateVerticalLine(planetModel, topLat, bottomLat, leftLon);
|
||||
}
|
||||
//System.err.println(" not vertical line");
|
||||
if (extent >= Math.PI) {
|
||||
if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_RESOLUTION) {
|
||||
if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
//System.err.println(" wide degenerate line");
|
||||
return new GeoWideDegenerateHorizontalLine(planetModel, topLat, leftLon, rightLon);
|
||||
}
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
return new GeoWideNorthRectangle(planetModel, bottomLat, leftLon, rightLon);
|
||||
} else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
|
||||
} else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
return new GeoWideSouthRectangle(planetModel, topLat, leftLon, rightLon);
|
||||
}
|
||||
//System.err.println(" wide rect");
|
||||
return new GeoWideRectangle(planetModel, topLat, bottomLat, leftLon, rightLon);
|
||||
}
|
||||
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) {
|
||||
if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION || Math.abs(topLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
return new GeoDegeneratePoint(planetModel, topLat, 0.0);
|
||||
}
|
||||
//System.err.println(" horizontal line");
|
||||
return new GeoDegenerateHorizontalLine(planetModel, topLat, leftLon, rightLon);
|
||||
}
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
|
||||
if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
return new GeoNorthRectangle(planetModel, bottomLat, leftLon, rightLon);
|
||||
} else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_RESOLUTION) {
|
||||
} else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
return new GeoSouthRectangle(planetModel, topLat, leftLon, rightLon);
|
||||
}
|
||||
//System.err.println(" rectangle");
|
||||
|
|
|
@ -34,7 +34,7 @@ public class GeoCircleFactory {
|
|||
* @return a GeoCircle corresponding to what was specified.
|
||||
*/
|
||||
public static GeoCircle makeGeoCircle(final PlanetModel planetModel, final double latitude, final double longitude, final double radius) {
|
||||
if (radius < Vector.MINIMUM_RESOLUTION) {
|
||||
if (radius < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
return new GeoDegeneratePoint(planetModel, latitude, longitude);
|
||||
}
|
||||
return new GeoStandardCircle(planetModel, latitude, longitude, radius);
|
||||
|
|
|
@ -601,7 +601,7 @@ public class GeoPolygonFactory {
|
|||
if (angleDelta > Math.PI) {
|
||||
angleDelta -= Math.PI * 2.0;
|
||||
}
|
||||
if (Math.abs(angleDelta - Math.PI) < Vector.MINIMUM_RESOLUTION) {
|
||||
if (Math.abs(angleDelta - Math.PI) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
return null;
|
||||
}
|
||||
//System.out.println(" angle delta = "+angleDelta);
|
||||
|
@ -624,7 +624,7 @@ public class GeoPolygonFactory {
|
|||
if (angleDelta > Math.PI) {
|
||||
angleDelta -= Math.PI * 2.0;
|
||||
}
|
||||
if (Math.abs(angleDelta - Math.PI) < Vector.MINIMUM_RESOLUTION) {
|
||||
if (Math.abs(angleDelta - Math.PI) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
return null;
|
||||
}
|
||||
//System.out.println(" angle delta = "+angleDelta);
|
||||
|
@ -634,7 +634,7 @@ public class GeoPolygonFactory {
|
|||
|
||||
// Clockwise == inside == negative
|
||||
//System.out.println("Arcdistance = "+arcDistance);
|
||||
if (Math.abs(arcDistance) < Vector.MINIMUM_RESOLUTION) {
|
||||
if (Math.abs(arcDistance) < Vector.MINIMUM_ANGULAR_RESOLUTION) {
|
||||
// No idea what direction, so try another pole.
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,10 @@ public class Vector {
|
|||
* less than this.
|
||||
*/
|
||||
public static final double MINIMUM_RESOLUTION = 1.0e-12;
|
||||
/**
|
||||
* Angular version of minimum resolution.
|
||||
*/
|
||||
public static final double MINIMUM_ANGULAR_RESOLUTION = Math.PI * MINIMUM_RESOLUTION;
|
||||
/**
|
||||
* For squared quantities, the bound is squared too.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue