mirror of https://github.com/apache/lucene.git
LUCENE-10508: Fix error for rectangles with an extent close to 180 degrees (#824)
This commit introduces a GeoWideRectangle.MIN_WIDE_EXTENT that takes into account the angular resolution in order to build a GeoWideRectangle.
This commit is contained in:
parent
f11468186a
commit
2b20b3f2ca
|
@ -98,7 +98,7 @@ public class GeoBBoxFactory {
|
||||||
return new GeoDegenerateVerticalLine(planetModel, topLat, bottomLat, leftLon);
|
return new GeoDegenerateVerticalLine(planetModel, topLat, bottomLat, leftLon);
|
||||||
}
|
}
|
||||||
// System.err.println(" not vertical line");
|
// System.err.println(" not vertical line");
|
||||||
if (extent >= Math.PI) {
|
if (extent >= GeoWideRectangle.MIN_WIDE_EXTENT) {
|
||||||
if (latitudesEquals(topLat, bottomLat)) {
|
if (latitudesEquals(topLat, bottomLat)) {
|
||||||
if (isNorthPole(topLat)) {
|
if (isNorthPole(topLat)) {
|
||||||
return new GeoDegeneratePoint(planetModel, topLat, 0.0);
|
return new GeoDegeneratePoint(planetModel, topLat, 0.0);
|
||||||
|
|
|
@ -26,6 +26,10 @@ import java.io.OutputStream;
|
||||||
* @lucene.internal
|
* @lucene.internal
|
||||||
*/
|
*/
|
||||||
class GeoWideRectangle extends GeoBaseBBox {
|
class GeoWideRectangle extends GeoBaseBBox {
|
||||||
|
|
||||||
|
/** Minimum extent for a rectangle of this type */
|
||||||
|
public static final double MIN_WIDE_EXTENT = Math.PI - Vector.MINIMUM_ANGULAR_RESOLUTION;
|
||||||
|
|
||||||
/** The top latitude */
|
/** The top latitude */
|
||||||
protected final double topLat;
|
protected final double topLat;
|
||||||
/** The bottom latitude */
|
/** The bottom latitude */
|
||||||
|
@ -111,7 +115,7 @@ class GeoWideRectangle extends GeoBaseBBox {
|
||||||
if (extent < 0.0) {
|
if (extent < 0.0) {
|
||||||
extent += 2.0 * Math.PI;
|
extent += 2.0 * Math.PI;
|
||||||
}
|
}
|
||||||
if (extent < Math.PI) {
|
if (extent < MIN_WIDE_EXTENT) {
|
||||||
throw new IllegalArgumentException("Width of rectangle too small");
|
throw new IllegalArgumentException("Width of rectangle too small");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue