diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPolygon.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPolygon.java index 8e0dd8101f6..6377bfd1f61 100755 --- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPolygon.java +++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/TestGeoPolygon.java @@ -25,6 +25,38 @@ import org.junit.Test; public class TestGeoPolygon extends LuceneTestCase { + @Test + public void testH3CellsWrongIntersection() { + final List points1 = new ArrayList<>(); + addToList(points1, PlanetModel.SPHERE, -64.2102198418716, -39.14233318389477); + addToList(points1, PlanetModel.SPHERE, -64.21016450005413, -39.142267144439614); + addToList(points1, PlanetModel.SPHERE, -64.21021077465937, -39.1421844504783); + addToList(points1, PlanetModel.SPHERE, -64.21031239098929, -39.142167795785085); + addToList(points1, PlanetModel.SPHERE, -64.2103677330169, -39.14223383513698); + addToList(points1, PlanetModel.SPHERE, -64.21032145850448, -39.14231652928534); + final List points2 = new ArrayList<>(); + addToList(points2, PlanetModel.SPHERE, -64.20991499254879, -39.14238314705201); + addToList(points2, PlanetModel.SPHERE, -64.20985965132967, -39.14231710755475); + addToList(points2, PlanetModel.SPHERE, -64.20990592624541, -39.142234413886875); + addToList(points2, PlanetModel.SPHERE, -64.21000754228744, -39.142217759529174); + addToList(points2, PlanetModel.SPHERE, -64.21006288371667, -39.14228379892317); + addToList(points2, PlanetModel.SPHERE, -64.21001660889377, -39.14236649277811); + + final GeoPolygon polygon1 = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points1); + final GeoPolygon polygon2 = GeoPolygonFactory.makeGeoPolygon(PlanetModel.SPHERE, points2); + // System.out.println("Polygon1 = "+polygon1); + // System.out.println("Polygon2 = "+polygon2); + assertFalse(polygon1.intersects(polygon2)); + } + + private static void addToList(List points, PlanetModel planetModel, double lon, double lat) { + points.add( + new GeoPoint( + planetModel, + Geo3DUtil.fromDegrees(lat), + Geo3DUtil.fromDegrees(lon))); + } + @Test public void testPolygonPointFiltering() { final GeoPoint point1 = new GeoPoint(PlanetModel.WGS84, 1.0, 2.0);