From fed7343d2ea8136126084517ade408faaff279f2 Mon Sep 17 00:00:00 2001 From: Karl Wright Date: Wed, 24 May 2017 09:46:15 -0400 Subject: [PATCH] LUCENE-7849: GeoWideLongitudeSlice can fail to construct --- .../lucene/spatial3d/geom/GeoWideLongitudeSlice.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java index f208266bd01..705d961eaee 100755 --- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java +++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoWideLongitudeSlice.java @@ -75,7 +75,13 @@ class GeoWideLongitudeSlice extends GeoBaseBBox { while (leftLon > rightLon) { rightLon += Math.PI * 2.0; } - final double middleLon = (leftLon + rightLon) * 0.5; + double middleLon = (leftLon + rightLon) * 0.5; + while (middleLon > Math.PI) { + middleLon -= Math.PI * 2.0; + } + while (middleLon < -Math.PI) { + middleLon += Math.PI * 2.0; + } this.centerPoint = new GeoPoint(planetModel, 0.0, middleLon); this.leftPlane = new SidedPlane(centerPoint, cosLeftLon, sinLeftLon);