minor test cleanups

This commit is contained in:
Robert Muir 2016-03-28 12:00:53 -04:00
parent f3c743550f
commit c3ff34e54b
2 changed files with 5 additions and 23 deletions

View File

@ -27,6 +27,7 @@ import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.spatial.util.GeoTestUtil;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.SloppyMath;
@ -182,8 +183,8 @@ public class TestLatLonPointDistanceSort extends LuceneTestCase {
doc.add(new StoredField("id", i));
doc.add(new NumericDocValuesField("id", i));
if (random().nextInt(10) > 7) {
double latRaw = -90 + 180.0 * random().nextDouble();
double lonRaw = -180 + 360.0 * random().nextDouble();
double latRaw = GeoTestUtil.nextLatitude();
double lonRaw = GeoTestUtil.nextLongitude();
// pre-normalize up front, so we can just use quantized value for testing and do simple exact comparisons
double lat = LatLonPoint.decodeLatitude(LatLonPoint.encodeLatitude(latRaw));
double lon = LatLonPoint.decodeLongitude(LatLonPoint.encodeLongitude(lonRaw));
@ -198,8 +199,8 @@ public class TestLatLonPointDistanceSort extends LuceneTestCase {
IndexSearcher searcher = newSearcher(reader);
for (int i = 0; i < numQueries; i++) {
double lat = -90 + 180.0 * random().nextDouble();
double lon = -180 + 360.0 * random().nextDouble();
double lat = GeoTestUtil.nextLatitude();
double lon = GeoTestUtil.nextLongitude();
double missingValue = Double.POSITIVE_INFINITY;
Result expected[] = new Result[reader.maxDoc()];

View File

@ -28,9 +28,6 @@ import org.junit.BeforeClass;
*/
public class TestGeoUtils extends LuceneTestCase {
private static final double LON_SCALE = (0x1L<<GeoEncodingUtils.BITS)/360.0D;
private static final double LAT_SCALE = (0x1L<<GeoEncodingUtils.BITS)/180.0D;
// Global bounding box we will "cover" in the random test; we have to make this "smallish" else the queries take very long:
private static double originLat;
private static double originLon;
@ -41,22 +38,6 @@ public class TestGeoUtils extends LuceneTestCase {
originLat = GeoTestUtil.nextLatitude();
}
public long scaleLon(final double val) {
return (long) ((val-GeoUtils.MIN_LON_INCL) * LON_SCALE);
}
public long scaleLat(final double val) {
return (long) ((val-GeoUtils.MIN_LAT_INCL) * LAT_SCALE);
}
public double unscaleLon(final long val) {
return (val / LON_SCALE) + GeoUtils.MIN_LON_INCL;
}
public double unscaleLat(final long val) {
return (val / LAT_SCALE) + GeoUtils.MIN_LAT_INCL;
}
public double randomLat(boolean small) {
double result;
if (small) {