From fe7582e9d725b0fbeeac03a901203dfd45813266 Mon Sep 17 00:00:00 2001 From: Karl Wright Date: Sat, 9 Sep 2017 01:01:33 -0400 Subject: [PATCH] LUCENE-7965: GeoBBoxFactory was constructing the wrong shape at the poles, if the longitude range provided was greater than 180 degrees. --- .../org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java index d0427bc91df..12d479bee24 100755 --- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java +++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java @@ -82,6 +82,11 @@ public class GeoBBoxFactory { //System.err.println(" not vertical line"); if (extent >= Math.PI) { if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_ANGULAR_RESOLUTION) { + if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) { + return new GeoDegeneratePoint(planetModel, topLat, 0.0); + } else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) { + return new GeoDegeneratePoint(planetModel, bottomLat, 0.0); + } //System.err.println(" wide degenerate line"); return new GeoWideDegenerateHorizontalLine(planetModel, topLat, leftLon, rightLon); } @@ -94,8 +99,10 @@ public class GeoBBoxFactory { return new GeoWideRectangle(planetModel, topLat, bottomLat, leftLon, rightLon); } if (Math.abs(topLat - bottomLat) < Vector.MINIMUM_ANGULAR_RESOLUTION) { - if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION || Math.abs(topLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) { + if (Math.abs(topLat - Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) { return new GeoDegeneratePoint(planetModel, topLat, 0.0); + } else if (Math.abs(bottomLat + Math.PI * 0.5) < Vector.MINIMUM_ANGULAR_RESOLUTION) { + return new GeoDegeneratePoint(planetModel, bottomLat, 0.0); } //System.err.println(" horizontal line"); return new GeoDegenerateHorizontalLine(planetModel, topLat, leftLon, rightLon);