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:
Ignacio Vera 2022-04-27 07:33:49 +02:00 committed by GitHub
parent f11468186a
commit 2b20b3f2ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -98,7 +98,7 @@ public class GeoBBoxFactory {
return new GeoDegenerateVerticalLine(planetModel, topLat, bottomLat, leftLon);
}
// System.err.println(" not vertical line");
if (extent >= Math.PI) {
if (extent >= GeoWideRectangle.MIN_WIDE_EXTENT) {
if (latitudesEquals(topLat, bottomLat)) {
if (isNorthPole(topLat)) {
return new GeoDegeneratePoint(planetModel, topLat, 0.0);

View File

@ -26,6 +26,10 @@ import java.io.OutputStream;
* @lucene.internal
*/
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 */
protected final double topLat;
/** The bottom latitude */
@ -111,7 +115,7 @@ class GeoWideRectangle extends GeoBaseBBox {
if (extent < 0.0) {
extent += 2.0 * Math.PI;
}
if (extent < Math.PI) {
if (extent < MIN_WIDE_EXTENT) {
throw new IllegalArgumentException("Width of rectangle too small");
}