Apache Lucene open-source search software
LUCENE-10673: Improve check of equality for latitudes for spatial3d GeoBoundingBox (#1056)
Ignacio Verabd0718f0716a
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 58ecfd63933..1ae356fcc34 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -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---------------------diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.javaindex 6aa9a80da03..19142b64c19 100755--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java@@ -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 planereturn 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) {diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoBBox.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoBBox.javaindex 529b1a3231b..016d41a0aed 100755--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoBBox.java+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoBBox.java@@ -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));+ }+@Testpublic void testBBoxRandomLatDegenerate() {for (int i = 0; i < 100; i++) {