Apache Lucene open-source search software
don't quantize ALL generated points in this test, just the ones we index (except for some leniency: see the TODO).
Robert Muir9189bdc1c27d
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.javaindex 595891046b8..021d638e759 100644--- a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java@@ -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);