Changed GeoEncodingTests to ensure accuracy always >1mm due to rounding errors with very small numbers
This commit is contained in:
parent
95bf091dd6
commit
d9699e02f4
|
@ -36,7 +36,7 @@ public class GeoEncodingTests extends ElasticsearchTestCase {
|
||||||
for (int i = 0; i < 10000; ++i) {
|
for (int i = 0; i < 10000; ++i) {
|
||||||
final double lat = randomDouble() * 180 - 90;
|
final double lat = randomDouble() * 180 - 90;
|
||||||
final double lon = randomDouble() * 360 - 180;
|
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);
|
final GeoPointFieldMapper.Encoding encoding = GeoPointFieldMapper.Encoding.of(precision);
|
||||||
assertThat(encoding.precision().convert(DistanceUnit.METERS).value, lessThanOrEqualTo(precision.convert(DistanceUnit.METERS).value));
|
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());
|
final GeoPoint geoPoint = encoding.decode(encoding.encodeCoordinate(lat), encoding.encodeCoordinate(lon), new GeoPoint());
|
||||||
|
|
Loading…
Reference in New Issue