mirror of https://github.com/apache/lucene.git
LUCENE-7660: LatLonPointDistanceQuery could skip distance computations more often.
This commit is contained in:
parent
74240be0f5
commit
076662d1b2
|
@ -131,6 +131,10 @@ Optimizations
|
|||
* LUCENE-7661: Speed up for LatLonPointInPolygonQuery by pre-computing the
|
||||
relation of the polygon with a grid. (Adrien Grand)
|
||||
|
||||
* LUCENE-7660: Speed up LatLonPointDistanceQuery by improving the detection of
|
||||
whether BKD cells are entirely within the distance close to the dateline.
|
||||
(Adrien Grand)
|
||||
|
||||
Build
|
||||
|
||||
* LUCENE-7651: Fix Javadocs build for Java 8u121 by injecting "Google Code
|
||||
|
|
|
@ -152,7 +152,7 @@ public final class GeoUtils {
|
|||
}
|
||||
}
|
||||
|
||||
if (maxLon - lon < 90 && lon - minLon < 90 &&
|
||||
if (within90LonDegrees(lon, minLon, maxLon) &&
|
||||
SloppyMath.haversinSortKey(lat, lon, minLat, minLon) <= distanceSortKey &&
|
||||
SloppyMath.haversinSortKey(lat, lon, minLat, maxLon) <= distanceSortKey &&
|
||||
SloppyMath.haversinSortKey(lat, lon, maxLat, minLon) <= distanceSortKey &&
|
||||
|
@ -163,4 +163,15 @@ public final class GeoUtils {
|
|||
|
||||
return Relation.CELL_CROSSES_QUERY;
|
||||
}
|
||||
|
||||
/** Return whether all points of {@code [minLon,maxLon]} are within 90 degrees of {@code lon}. */
|
||||
static boolean within90LonDegrees(double lon, double minLon, double maxLon) {
|
||||
if (maxLon <= lon - 180) {
|
||||
lon -= 360;
|
||||
} else if (minLon >= lon + 180) {
|
||||
lon += 360;
|
||||
}
|
||||
return maxLon - lon < 90 && lon - minLon < 90;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -293,4 +293,16 @@ public class TestGeoUtils extends LuceneTestCase {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void testWithin90LonDegrees() {
|
||||
assertTrue(GeoUtils.within90LonDegrees(0, -80, 80));
|
||||
assertFalse(GeoUtils.within90LonDegrees(0, -100, 80));
|
||||
assertFalse(GeoUtils.within90LonDegrees(0, -80, 100));
|
||||
|
||||
assertTrue(GeoUtils.within90LonDegrees(-150, 140, 170));
|
||||
assertFalse(GeoUtils.within90LonDegrees(-150, 120, 150));
|
||||
|
||||
assertTrue(GeoUtils.within90LonDegrees(150, -170, -140));
|
||||
assertFalse(GeoUtils.within90LonDegrees(150, -150, -120));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue