From 9b3920b52cf15ed7a1b604af15157be8543a01f9 Mon Sep 17 00:00:00 2001 From: Nicholas Knize Date: Fri, 13 Nov 2015 09:32:31 -0600 Subject: [PATCH] Removing pole restriction on GeoDistanceRangeQueryTests This commit corrects the maxRadialDistance computation for points at the poles to half the distance of the meridian. --- .../main/java/org/elasticsearch/common/geo/GeoUtils.java | 3 +++ .../index/query/GeoDistanceRangeQueryTests.java | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java b/core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java index 0d8fdfa2be7..83a8adab1e0 100644 --- a/core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java +++ b/core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java @@ -68,6 +68,9 @@ public class GeoUtils { /** Returns the maximum distance/radius from the point 'center' before overlapping */ public static double maxRadialDistance(GeoPoint center) { + if (Math.abs(center.lat()) == 90.0) { + return SloppyMath.haversin(center.lat(), center.lon(), 0, center.lon())*1000.0; + } return SloppyMath.haversin(center.lat(), center.lon(), center.lat(), (180.0 + center.lon()) % 360)*1000.0; } diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java index fb84bb669a0..00a68010358 100644 --- a/core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/GeoDistanceRangeQueryTests.java @@ -47,7 +47,7 @@ public class GeoDistanceRangeQueryTests extends AbstractQueryTestCase