From d9699e02f4e28c75cc5ffdd125b11d99325766c4 Mon Sep 17 00:00:00 2001 From: markharwood Date: Mon, 27 Jan 2014 17:05:19 +0000 Subject: [PATCH] Changed GeoEncodingTests to ensure accuracy always >1mm due to rounding errors with very small numbers --- .../org/elasticsearch/index/mapper/geo/GeoEncodingTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/index/mapper/geo/GeoEncodingTests.java b/src/test/java/org/elasticsearch/index/mapper/geo/GeoEncodingTests.java index f02e15d8337..f52363e89ae 100644 --- a/src/test/java/org/elasticsearch/index/mapper/geo/GeoEncodingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/geo/GeoEncodingTests.java @@ -36,7 +36,7 @@ public class GeoEncodingTests extends ElasticsearchTestCase { for (int i = 0; i < 10000; ++i) { final double lat = randomDouble() * 180 - 90; final double lon = randomDouble() * 360 - 180; - final Distance precision = new Distance(randomDouble() * 10, randomFrom(Arrays.asList(DistanceUnit.MILLIMETERS, DistanceUnit.METERS, DistanceUnit.KILOMETERS))); + final Distance precision = new Distance(1+(randomDouble() * 9), randomFrom(Arrays.asList(DistanceUnit.MILLIMETERS, DistanceUnit.METERS, DistanceUnit.KILOMETERS))); final GeoPointFieldMapper.Encoding encoding = GeoPointFieldMapper.Encoding.of(precision); assertThat(encoding.precision().convert(DistanceUnit.METERS).value, lessThanOrEqualTo(precision.convert(DistanceUnit.METERS).value)); final GeoPoint geoPoint = encoding.decode(encoding.encodeCoordinate(lat), encoding.encodeCoordinate(lon), new GeoPoint());