mirror of https://github.com/apache/lucene.git
don't quantize ALL generated points in this test, just the ones we index (except for some leniency: see the TODO).
This may cause more test failures!
This commit is contained in:
parent
f28f1096ce
commit
1ebb10c649
|
@ -485,12 +485,12 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||
|
||||
for (int id=0;id<numPoints;id++) {
|
||||
Document doc = new Document();
|
||||
lats[2*id] = randomLat(small);
|
||||
lons[2*id] = randomLon(small);
|
||||
lats[2*id] = quantizeLat(randomLat(small));
|
||||
lons[2*id] = quantizeLon(randomLon(small));
|
||||
doc.add(newStringField("id", ""+id, Field.Store.YES));
|
||||
addPointToDoc(FIELD_NAME, doc, lats[2*id], lons[2*id]);
|
||||
lats[2*id+1] = randomLat(small);
|
||||
lons[2*id+1] = randomLon(small);
|
||||
lats[2*id+1] = quantizeLat(randomLat(small));
|
||||
lons[2*id+1] = quantizeLon(randomLon(small));
|
||||
addPointToDoc(FIELD_NAME, doc, lats[2*id+1], lons[2*id+1]);
|
||||
|
||||
if (VERBOSE) {
|
||||
|
@ -513,6 +513,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||
int iters = atLeast(25);
|
||||
for (int iter=0;iter<iters;iter++) {
|
||||
GeoRect rect = randomRect(small);
|
||||
// TODO: why does this test need this quantization leniency? something is not right
|
||||
rect = new GeoRect(quantizeLat(rect.minLat), quantizeLat(rect.maxLat), quantizeLon(rect.minLon), quantizeLon(rect.maxLon));
|
||||
|
||||
if (VERBOSE) {
|
||||
System.out.println("\nTEST: iter=" + iter + " rect=" + rect);
|
||||
|
@ -664,26 +666,20 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public double randomLat(boolean small) {
|
||||
double result;
|
||||
if (small) {
|
||||
result = GeoTestUtil.nextLatitudeNear(originLat);
|
||||
return GeoTestUtil.nextLatitudeNear(originLat);
|
||||
} else {
|
||||
result = GeoTestUtil.nextLatitude();
|
||||
return GeoTestUtil.nextLatitude();
|
||||
}
|
||||
return quantizeLat(result);
|
||||
}
|
||||
|
||||
public double randomLon(boolean small) {
|
||||
double result;
|
||||
if (small) {
|
||||
result = GeoTestUtil.nextLongitudeNear(originLon);
|
||||
return GeoTestUtil.nextLongitudeNear(originLon);
|
||||
} else {
|
||||
result = GeoTestUtil.nextLongitude();
|
||||
return GeoTestUtil.nextLongitude();
|
||||
}
|
||||
return quantizeLon(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Override this to quantize randomly generated lat, so the test won't fail due to quantization errors, which are 1) annoying to debug,
|
||||
* and 2) should never affect "real" usage terribly. */
|
||||
|
@ -729,6 +725,13 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
|
||||
private void verify(boolean small, double[] lats, double[] lons) throws Exception {
|
||||
// quantize each value the same way the index does
|
||||
for (int i = 0; i < lats.length; i++) {
|
||||
lats[i] = quantizeLat(lats[i]);
|
||||
}
|
||||
for (int i = 0; i < lons.length; i++) {
|
||||
lons[i] = quantizeLon(lons[i]);
|
||||
}
|
||||
verifyRandomRectangles(small, lats, lons);
|
||||
verifyRandomDistances(small, lats, lons);
|
||||
verifyRandomPolygons(small, lats, lons);
|
||||
|
|
Loading…
Reference in New Issue