Apache Lucene open-source search software
LUCENE-8234: Fixed bug in how spatial relationship is computed for GeoStandardCircle when it covers the whole world
Ignacio Verad33276461735
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 1a6c1ef93f5..6111554207b 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -111,6 +111,11 @@ New Features* LUCENE-8125: ICUTokenizer support for emoji/emoji sequence tokens. (Robert Muir)+Bug Fixes++* LUCENE-8234: Fixed bug in how spatial relationship is computed for+ GeoStandardCircle when it covers the whole world. (Ignacio Vera)+Other* LUCENE-8228: removed obsolete IndexDeletionPolicy clone() requirements fromdiff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.javaindex 7ac45932c0d..a3c0d8954f7 100755--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoStandardCircle.java@@ -172,6 +172,18 @@ class GeoStandardCircle extends GeoBaseCircle {return geoShape.intersects(circlePlane, circlePoints);}+ @Override+ public int getRelationship(GeoShape geoShape) {+ if (circlePlane == null) {+ //same as GeoWorld+ if (geoShape.getEdgePoints().length > 0) {+ return WITHIN;+ }+ return OVERLAPS;+ }+ return super.getRelationship(geoShape);+ }+@Overridepublic void getBounds(Bounds bounds) {super.getBounds(bounds);diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.javaindex 95d2a4c4dc8..2e49022aab2 100755--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoCircleTest.java@@ -418,4 +418,12 @@ public class GeoCircleTest extends LuceneTestCase {assert gc.isWithin(gp)?solid.isWithin(gp):true;}++ @Test+ public void testWholeWorld() {+ final GeoCircle circle1 = GeoCircleFactory.makeGeoCircle(PlanetModel.SPHERE, 0.0, 0.0, 3.1415926535897913);+ final GeoCircle circle2 = GeoCircleFactory.makeGeoCircle(PlanetModel.SPHERE, Math.PI * 0.5, Math.PI, 3.141592653589792);++ assertTrue(circle1.getRelationship(circle2) == GeoArea.OVERLAPS);+ }}