LUCENE-10673: Improve check of equality for latitudes for spatial3d GeoBoundingBox (#1056)

This commit is contained in:
Ignacio Vera 2022-08-04 06:47:27 +02:00 committed by GitHub
parent 34154736c6
commit bd0718f071
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -112,6 +112,8 @@ Bug Fixes
---------------------
* LUCENE-10663: Fix KnnVectorQuery explain with multiple segments. (Shiming Li)
* LUCENE-10673: Improve check of equality for latitudes for spatial3d GeoBoundingBox (ignacio Vera)
Build
---------------------

View File

@ -146,7 +146,7 @@ public class GeoBBoxFactory {
// it is not enough with using the MINIMUM_ANGULAR_RESOLUTION, check as well the sin values
// just in case they describe the same plane
return Math.abs(lat1 - lat2) < Vector.MINIMUM_ANGULAR_RESOLUTION
|| Math.sin(lat1) == Math.sin(lat2);
|| Math.abs(Math.sin(lat1) - Math.sin(lat2)) < Vector.MINIMUM_RESOLUTION;
}
private static boolean longitudesEquals(double lon1, double lon2) {

View File

@ -502,6 +502,15 @@ public class TestGeoBBox extends LuceneTestCase {
}
}
@Test
public void testBBoxLatDegenerate() {
double minX = Geo3DUtil.fromDegrees(-180.0);
double maxX = Geo3DUtil.fromDegrees(-174.37500008381903);
double minY = Geo3DUtil.fromDegrees(89.99999765306711);
double maxY = Geo3DUtil.fromDegrees(89.99999794643372);
assertNotNull(GeoAreaFactory.makeGeoArea(PlanetModel.SPHERE, maxY, minY, minX, maxX));
}
@Test
public void testBBoxRandomLatDegenerate() {
for (int i = 0; i < 100; i++) {