Removing pole restriction on GeoDistanceRangeQueryTests
This commit corrects the maxRadialDistance computation for points at the poles to half the distance of the meridian.
This commit is contained in:
parent
12bb1b79f6
commit
9b3920b52c
|
@ -68,6 +68,9 @@ public class GeoUtils {
|
||||||
|
|
||||||
/** Returns the maximum distance/radius from the point 'center' before overlapping */
|
/** Returns the maximum distance/radius from the point 'center' before overlapping */
|
||||||
public static double maxRadialDistance(GeoPoint center) {
|
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;
|
return SloppyMath.haversin(center.lat(), center.lon(), center.lat(), (180.0 + center.lon()) % 360)*1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class GeoDistanceRangeQueryTests extends AbstractQueryTestCase<GeoDistanc
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, randomGeohash(3, 12));
|
builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, randomGeohash(3, 12));
|
||||||
} else {
|
} else {
|
||||||
GeoPoint point = RandomGeoGenerator.randomPointIn(random(), -179, -89, 89, 179);
|
GeoPoint point = RandomGeoGenerator.randomPoint(random());
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, point);
|
builder = new GeoDistanceRangeQueryBuilder(GEO_POINT_FIELD_NAME, point);
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,10 +55,7 @@ public class GeoDistanceRangeQueryTests extends AbstractQueryTestCase<GeoDistanc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GeoPoint point = builder.point();
|
GeoPoint point = builder.point();
|
||||||
// todo remove the following pole hack when LUCENE-6846 lands
|
final double maxRadius = GeoUtils.maxRadialDistance(point);
|
||||||
final double distToPole = SloppyMath.haversin(point.lat(), point.lon(), (point.lat()<0) ? -90.0 : 90.0, point.lon());
|
|
||||||
final double maxRadius = GeoUtils.maxRadialDistance(point, distToPole);
|
|
||||||
|
|
||||||
final int fromValueMeters = randomInt((int)(maxRadius*0.5));
|
final int fromValueMeters = randomInt((int)(maxRadius*0.5));
|
||||||
final int toValueMeters = randomIntBetween(fromValueMeters + 1, (int)maxRadius);
|
final int toValueMeters = randomIntBetween(fromValueMeters + 1, (int)maxRadius);
|
||||||
DistanceUnit fromToUnits = randomFrom(DistanceUnit.values());
|
DistanceUnit fromToUnits = randomFrom(DistanceUnit.values());
|
||||||
|
|
Loading…
Reference in New Issue