Apache Lucene open-source search software
LUCENE-8251: Add an explicit test case to cover the discovered failure. But it appears to be already fixed.
Karl Wrightf41e7c4da7e5
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/Geo3DUtil.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/Geo3DUtil.javaindex add46e43e57..9a22abd7a53 100644--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/Geo3DUtil.java+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/Geo3DUtil.java@@ -40,6 +40,8 @@ class Geo3DUtil {final static double RADIANS_PER_METER = 1.0 / PlanetModel.WGS84_MEAN;/** How many radians are in one degree */final static double RADIANS_PER_DEGREE = Math.PI / 180.0;+ /** How many degrees in a radian */+ final static double DEGREES_PER_RADIAN = 180.0 / Math.PI;private static final double MAX_VALUE = PlanetModel.WGS84.getMaximumMagnitude();private static final int BITS = 32;@@ -113,6 +115,11 @@ class Geo3DUtil {static double fromDegrees(final double degrees) {return degrees * RADIANS_PER_DEGREE;}++ /** Converts radians to degrees */+ static double toDegrees(final double radians) {+ return radians * DEGREES_PER_RADIAN;+ }/** Converts earth-surface meters to radians */static double fromMeters(final double meters) {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 adff16c140c..e720cb21a52 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@@ -1569,4 +1569,22 @@ shape:assertTrue(polygon.isWithin(point) == largePolygon.isWithin(point));}+ @Test+ 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)));+ 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));++ //POINT(0.005183505059185348 1.98E-321)+ final GeoPoint point = new GeoPoint(PlanetModel.SPHERE, 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 b6364e02ea8..6c5e890dc9a 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();