Apache Lucene open-source search software
LUCENE-8444: Prevent building functionally identical plane bounds when constructing DualCrossingEdgeIterator
Ignacio Veraea2e564dad69
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 14e2b023ca6..865f5e26625 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -179,6 +179,9 @@ Bug Fixes:* LUCENE-8445: Tighten condition when two planes are identical to prevent constructingbogus tiles when building GeoPolygons. (Ignacio Vera)+* LUCENE-8444: Prevent building functionally identical plane bounds when constructing+ DualCrossingEdgeIterator . (Ignacio Vera)+* LUCENE-8380: UTF8TaxonomyWriterCache inconsistency. (Ruslan Torobaev, Dawid Weiss)* LUCENE-8164: IndexWriter silently accepts broken payload. This has been fixeddiff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.javaindex 580338dd178..a7c55dd3ad2 100644--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoComplexPolygon.java@@ -1504,16 +1504,16 @@ class GeoComplexPolygon extends GeoBasePolygon {final SidedPlane testPointBound1 = new SidedPlane(intersectionPoint, testPointPlane, testPoint);final SidedPlane testPointBound2 = new SidedPlane(testPoint, testPointPlane, intersectionPoint);- if (testPointBound1.isNumericallyIdentical(testPointBound2)) {- throw new IllegalArgumentException("Dual iterator unreliable when bounds planes are numerically identical");+ if (testPointBound1.isFunctionallyIdentical(testPointBound2)) {+ throw new IllegalArgumentException("Dual iterator unreliable when bounds planes are functionally identical");}this.testPointCutoffPlane = testPointBound1;this.testPointOtherCutoffPlane = testPointBound2;final SidedPlane checkPointBound1 = new SidedPlane(intersectionPoint, travelPlane, thePointX, thePointY, thePointZ);final SidedPlane checkPointBound2 = new SidedPlane(thePointX, thePointY, thePointZ, travelPlane, intersectionPoint);- if (checkPointBound1.isNumericallyIdentical(checkPointBound2)) {- throw new IllegalArgumentException("Dual iterator unreliable when bounds planes are numerically identical");+ if (checkPointBound1.isFunctionallyIdentical(checkPointBound2)) {+ throw new IllegalArgumentException("Dual iterator unreliable when bounds planes are functionally identical");}this.checkPointCutoffPlane = checkPointBound1;this.checkPointOtherCutoffPlane = checkPointBound2;diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.javaindex c8cbc1bbad4..1aae82064e9 100755--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/GeoPolygonTest.java@@ -1850,6 +1850,24 @@ shape:}+ @Test+ public void testLUCENE8444() {+ //POLYGON((0.0 -67.68132244526963,-1.2477695347678826E-95 -88.11137674490907, 1.7059188343238906E-9 7.009654350320916,0.0 -67.68132244526963))+ final List<GeoPoint> points = new ArrayList<>();+ points.add(new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(-67.68132244526963), Geo3DUtil.fromDegrees(0.0)));+ points.add(new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(-88.11137674490907), Geo3DUtil.fromDegrees(-1.2477695347678826E-95)));+ points.add(new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(7.009654350320916), Geo3DUtil.fromDegrees(1.7059188343238906E-9)));++ final GeoPolygonFactory.PolygonDescription description = new GeoPolygonFactory.PolygonDescription(points);+ final GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, description);+ final GeoPolygon largePolygon = GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.WGS84, Collections.singletonList(description));++ //POINT(180.0 -61.73229670194638)+ final GeoPoint point = new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(-61.73229670194638), Geo3DUtil.fromDegrees(180.0));+ //assertTrue(polygon.isWithin(point) == largePolygon.isWithin(point));+ assertTrue(false == largePolygon.isWithin(point));+ }+@Testpublic void testLUCENE8445() {//POLYGON((32.18017946378854 -17.397683785381247,49.51018758330871 -9.870219317504647,58.77903721991479 33.90553510354402,2.640604559432277 9.363173880050821,3.1673235739886286E-10 8.853669066894417E-11,0.0 -5.7E-322,4.820339742500488E-5 5.99784517213369E-7,32.18017946378854 -17.397683785381247))