Apache Lucene open-source search software
LUCENE-8251: Add AwaitsFix for the tests that this issue covers.
Karl Wright79350bd4dd31
diff --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 c4e2c93e3a4..b6b657742ce 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@@ -1146,12 +1146,17 @@ class GeoComplexPolygon extends GeoBasePolygon {this.intersectionPoint = intersectionPoint;//System.out.println("Intersection point = "+intersectionPoint);-+ //System.out.println("TestPoint plane: "+testPoint+" -> "+intersectionPoint);+ //System.out.println("Travel plane: ["+thePointX+","+thePointY+","+thePointZ+"] -> "+intersectionPoint);+assert travelPlane.evaluateIsZero(intersectionPoint) : "intersection point must be on travel plane";assert testPointPlane.evaluateIsZero(intersectionPoint) : "intersection point must be on test point plane";-++ //System.out.println("Test point distance to intersection point: "+intersectionPoint.linearDistance(testPoint));+ //System.out.println("Check point distance to intersection point: "+intersectionPoint.linearDistance(thePointX, thePointY, thePointZ));+assert !testPoint.isNumericallyIdentical(intersectionPoint) : "test point is the same as intersection point";- assert !intersectionPoint.isNumericallyIdentical(thePointX, thePointY, thePointZ) : "check point is same is intersection point";+ assert !intersectionPoint.isNumericallyIdentical(thePointX, thePointY, thePointZ) : "check point is same as intersection point";this.testPointCutoffPlane = new SidedPlane(intersectionPoint, testPointPlane, testPoint);this.checkPointCutoffPlane = new SidedPlane(intersectionPoint, travelPlane, thePointX, thePointY, thePointZ);@@ -1324,7 +1329,7 @@ class GeoComplexPolygon extends GeoBasePolygon {System.out.println("");System.out.println("Considering edge "+(edge.startPoint)+" -> "+(edge.endPoint));*/-+// Some edges are going to be given to us even when there's no real intersection, so do that as a sanity check, first.final GeoPoint[] travelCrossings = travelPlane.findIntersections(planetModel, edge.plane, checkPointCutoffPlane, checkPointOtherCutoffPlane, edge.startPlane, edge.endPlane);if (travelCrossings != null && travelCrossings.length == 0) {@@ -1442,7 +1447,10 @@ class GeoComplexPolygon extends GeoBasePolygon {}-+ /** This is the amount we go, roughly, in both directions, to find adjoining points to test. If we go too far,+ * we might miss a transition, but if we go too little, we might not see it either due to numerical issues.+ */+ private final static double DELTA_DISTANCE = Vector.MINIMUM_RESOLUTION;// * 0.5;/** Given a point on the plane and the ellipsoid, this method looks for a pair of adjoining points on either side of the plane, which are* about MINIMUM_RESOLUTION away from the given point. This only works for planes which go through the center of the world.@@ -1451,12 +1459,12 @@ class GeoComplexPolygon extends GeoBasePolygon {// Compute a normalized perpendicular vectorfinal Vector perpendicular = new Vector(plane, pointOnPlane);// Compute two new points along this vector from the original- final GeoPoint pointA = planetModel.createSurfacePoint(pointOnPlane.x + perpendicular.x * Vector.MINIMUM_RESOLUTION,- pointOnPlane.y + perpendicular.y * Vector.MINIMUM_RESOLUTION,- pointOnPlane.z + perpendicular.z * Vector.MINIMUM_RESOLUTION);- final GeoPoint pointB = planetModel.createSurfacePoint(pointOnPlane.x - perpendicular.x * Vector.MINIMUM_RESOLUTION,- pointOnPlane.y - perpendicular.y * Vector.MINIMUM_RESOLUTION,- pointOnPlane.z - perpendicular.z * Vector.MINIMUM_RESOLUTION);+ final GeoPoint pointA = planetModel.createSurfacePoint(pointOnPlane.x + perpendicular.x * DELTA_DISTANCE,+ pointOnPlane.y + perpendicular.y * DELTA_DISTANCE,+ pointOnPlane.z + perpendicular.z * DELTA_DISTANCE);+ final GeoPoint pointB = planetModel.createSurfacePoint(pointOnPlane.x - perpendicular.x * DELTA_DISTANCE,+ pointOnPlane.y - perpendicular.y * DELTA_DISTANCE,+ pointOnPlane.z - perpendicular.z * DELTA_DISTANCE);//System.out.println("Distance: "+computeSquaredDistance(rval[0], pointOnPlane)+" and "+computeSquaredDistance(rval[1], pointOnPlane));return new GeoPoint[]{pointA, pointB};}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 e720cb21a52..86f5694de7f 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@@ -1570,20 +1570,21 @@ shape:}@Test+ @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8251")public void testLUCENE8251() {//POLYGON((135.63207358036593 -51.43541696593334,113.00782694696038 -58.984559858566556,0.0 -3.68E-321,-66.33598777585381 -7.382056816201731,135.63207358036593 -51.43541696593334))final List<GeoPoint> points = new ArrayList<>();- points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-51.43541696593334), Geo3DUtil.fromDegrees(135.63207358036593)));- points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-58.984559858566556), Geo3DUtil.fromDegrees(113.00782694696038)));- points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-3.68E-321), Geo3DUtil.fromDegrees(0.0)));- points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-7.382056816201731), Geo3DUtil.fromDegrees(-66.33598777585381)));- points.add(new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(-51.43541696593334), Geo3DUtil.fromDegrees(135.63207358036593)));+ points.add(new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(-51.43541696593334), Geo3DUtil.fromDegrees(135.63207358036593)));+ points.add(new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(-58.984559858566556), Geo3DUtil.fromDegrees(113.00782694696038)));+ points.add(new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(-3.68E-321), Geo3DUtil.fromDegrees(0.0)));+ points.add(new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(-7.382056816201731), Geo3DUtil.fromDegrees(-66.33598777585381)));+ points.add(new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(-51.43541696593334), Geo3DUtil.fromDegrees(135.63207358036593)));final GeoPolygonFactory.PolygonDescription description = new GeoPolygonFactory.PolygonDescription(points);- final GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, description);- final GeoPolygon largePolygon = GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.SPHERE, Collections.singletonList(description));+ final GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, description);+ final GeoPolygon largePolygon = GeoPolygonFactory.makeLargeGeoPolygon(PlanetModel.WGS84, Collections.singletonList(description));//POINT(0.005183505059185348 1.98E-321)- final GeoPoint point = new GeoPoint(PlanetModel.SPHERE, Geo3DUtil.fromDegrees(1.98E-321), Geo3DUtil.fromDegrees(0.005183505059185348));+ final GeoPoint point = new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(1.98E-321), Geo3DUtil.fromDegrees(0.005183505059185348));assertTrue(polygon.isWithin(point) == largePolygon.isWithin(point));}diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeoPolygonTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeoPolygonTest.javaindex 6c5e890dc9a..b6364e02ea8 100644--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeoPolygonTest.java+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomGeoPolygonTest.java@@ -92,7 +92,7 @@ public class RandomGeoPolygonTest extends RandomGeo3dShapeGenerator {* biased doubles.*/@Test- //@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8251")+ @AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/LUCENE-8251")@Repeat(iterations = 10)public void testComparePolygons() {final PlanetModel planetModel = randomPlanetModel();