mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 19:15:06 +00:00
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++) {
|
for (int id=0;id<numPoints;id++) {
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
lats[2*id] = randomLat(small);
|
lats[2*id] = quantizeLat(randomLat(small));
|
||||||
lons[2*id] = randomLon(small);
|
lons[2*id] = quantizeLon(randomLon(small));
|
||||||
doc.add(newStringField("id", ""+id, Field.Store.YES));
|
doc.add(newStringField("id", ""+id, Field.Store.YES));
|
||||||
addPointToDoc(FIELD_NAME, doc, lats[2*id], lons[2*id]);
|
addPointToDoc(FIELD_NAME, doc, lats[2*id], lons[2*id]);
|
||||||
lats[2*id+1] = randomLat(small);
|
lats[2*id+1] = quantizeLat(randomLat(small));
|
||||||
lons[2*id+1] = randomLon(small);
|
lons[2*id+1] = quantizeLon(randomLon(small));
|
||||||
addPointToDoc(FIELD_NAME, doc, lats[2*id+1], lons[2*id+1]);
|
addPointToDoc(FIELD_NAME, doc, lats[2*id+1], lons[2*id+1]);
|
||||||
|
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
@ -513,6 +513,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||||||
int iters = atLeast(25);
|
int iters = atLeast(25);
|
||||||
for (int iter=0;iter<iters;iter++) {
|
for (int iter=0;iter<iters;iter++) {
|
||||||
GeoRect rect = randomRect(small);
|
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) {
|
if (VERBOSE) {
|
||||||
System.out.println("\nTEST: iter=" + iter + " rect=" + rect);
|
System.out.println("\nTEST: iter=" + iter + " rect=" + rect);
|
||||||
@ -664,27 +666,21 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double randomLat(boolean small) {
|
public double randomLat(boolean small) {
|
||||||
double result;
|
|
||||||
if (small) {
|
if (small) {
|
||||||
result = GeoTestUtil.nextLatitudeNear(originLat);
|
return GeoTestUtil.nextLatitudeNear(originLat);
|
||||||
} else {
|
} else {
|
||||||
result = GeoTestUtil.nextLatitude();
|
return GeoTestUtil.nextLatitude();
|
||||||
}
|
}
|
||||||
return quantizeLat(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double randomLon(boolean small) {
|
public double randomLon(boolean small) {
|
||||||
double result;
|
|
||||||
if (small) {
|
if (small) {
|
||||||
result = GeoTestUtil.nextLongitudeNear(originLon);
|
return GeoTestUtil.nextLongitudeNear(originLon);
|
||||||
} else {
|
} 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,
|
/** 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. */
|
* and 2) should never affect "real" usage terribly. */
|
||||||
protected double quantizeLat(double lat) {
|
protected double quantizeLat(double lat) {
|
||||||
@ -729,6 +725,13 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void verify(boolean small, double[] lats, double[] lons) throws Exception {
|
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);
|
verifyRandomRectangles(small, lats, lons);
|
||||||
verifyRandomDistances(small, lats, lons);
|
verifyRandomDistances(small, lats, lons);
|
||||||
verifyRandomPolygons(small, lats, lons);
|
verifyRandomPolygons(small, lats, lons);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user