This commit is contained in:
Karl Wright 2016-04-08 15:53:30 -04:00
commit eb8751256d
9 changed files with 18 additions and 25 deletions

View File

@ -1,10 +1,10 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="JUnit"> <library name="JUnit">
<CLASSES> <CLASSES>
<root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/junit-4.10.jar!/" /> <root url="file://$PROJECT_DIR$/lucene/test-framework/lib" />
<root url="jar://$PROJECT_DIR$/lucene/test-framework/lib/randomizedtesting-runner-2.3.2.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />
<jarDirectory url="file://$PROJECT_DIR$/lucene/test-framework/lib" recursive="false" />
</library> </library>
</component> </component>

View File

@ -341,7 +341,9 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
"5.4.1-cfs", "5.4.1-cfs",
"5.4.1-nocfs", "5.4.1-nocfs",
"5.5.0-cfs", "5.5.0-cfs",
"5.5.0-nocfs" "5.5.0-nocfs",
"6.0.0-cfs",
"6.0.0-nocfs"
}; };
// TODO: on 6.0.0 release, gen the single segment indices and add here: // TODO: on 6.0.0 release, gen the single segment indices and add here:

View File

@ -31,9 +31,8 @@ import org.apache.lucene.geo.GeoUtils;
* circle. Terms * circle. Terms
* passing this initial filter are then passed to a secondary {@code postFilter} method that verifies whether the * passing this initial filter are then passed to a secondary {@code postFilter} method that verifies whether the
* decoded lat/lon point fall within the specified query distance (see {@link org.apache.lucene.util.SloppyMath#haversinMeters(double, double, double, double)}. * decoded lat/lon point fall within the specified query distance (see {@link org.apache.lucene.util.SloppyMath#haversinMeters(double, double, double, double)}.
* All morton value comparisons are subject to the same precision tolerance defined in * Distance comparisons are subject to the accuracy of the haversine formula
* {@value org.apache.lucene.spatial.util.GeoEncodingUtils#TOLERANCE} and distance comparisons are subject to the accuracy of the * (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
* haversine formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
* *
* <p>Note: This query currently uses haversine which is a sloppy distance calculation (see above reference). For large * <p>Note: This query currently uses haversine which is a sloppy distance calculation (see above reference). For large
* queries one can expect upwards of 400m error. Vincenty shrinks this to ~40m error but pays a penalty for computing * queries one can expect upwards of 400m error. Vincenty shrinks this to ~40m error but pays a penalty for computing

View File

@ -31,8 +31,6 @@ import org.apache.lucene.geo.GeoUtils;
* range based on the morton codes of the min and max lat/lon pairs. Terms * range based on the morton codes of the min and max lat/lon pairs. Terms
* passing this initial filter are passed to a final check that verifies whether * passing this initial filter are passed to a final check that verifies whether
* the decoded lat/lon falls within (or on the boundary) of the query bounding box. * the decoded lat/lon falls within (or on the boundary) of the query bounding box.
* The value comparisons are subject to a precision tolerance defined in
* {@value org.apache.lucene.spatial.util.GeoEncodingUtils#TOLERANCE}
* *
* NOTES: * NOTES:
* 1. All latitude/longitude values must be in decimal degrees. * 1. All latitude/longitude values must be in decimal degrees.

View File

@ -33,8 +33,7 @@ import org.apache.lucene.geo.Polygon;
* of the min and max lat/lon pairs. Terms passing this initial filter are passed * of the min and max lat/lon pairs. Terms passing this initial filter are passed
* to a secondary filter that verifies whether the decoded lat/lon point falls within * to a secondary filter that verifies whether the decoded lat/lon point falls within
* (or on the boundary) of the bounding box query. Finally, the remaining candidate * (or on the boundary) of the bounding box query. Finally, the remaining candidate
* term is passed to the final point in polygon check. All value comparisons are subject * term is passed to the final point in polygon check.
* to the same precision tolerance defined in {@value GeoEncodingUtils#TOLERANCE}
* *
* @see Polygon * @see Polygon
* @lucene.experimental * @lucene.experimental

View File

@ -41,10 +41,7 @@ public final class GeoEncodingUtils {
* for encoding <code>geoEncoded</code> values. * for encoding <code>geoEncoded</code> values.
* @see #geoCodedToPrefixCodedBytes(long, int, BytesRefBuilder) * @see #geoCodedToPrefixCodedBytes(long, int, BytesRefBuilder)
*/ */
public static final int BUF_SIZE_LONG = 28/8 + 1; private static final int BUF_SIZE_LONG = 28/8 + 1;
/** rounding error for quantized latitude and longitude values */
public static final double TOLERANCE = 1E-6;
// No instance: // No instance:
private GeoEncodingUtils() { private GeoEncodingUtils() {
@ -91,8 +88,12 @@ public final class GeoEncodingUtils {
/** Convert a prefix coded geo term back into the geocoded morton long */ /** Convert a prefix coded geo term back into the geocoded morton long */
public static long prefixCodedToGeoCoded(final BytesRef val) { public static long prefixCodedToGeoCoded(final BytesRef val) {
final long result = fromBytes((byte)0, (byte)0, (byte)0, (byte)0, final long result = 0L
val.bytes[val.offset+0], val.bytes[val.offset+1], val.bytes[val.offset+2], val.bytes[val.offset+3]); | (val.bytes[val.offset+0] & 255L) << 24
| (val.bytes[val.offset+1] & 255L) << 16
| (val.bytes[val.offset+2] & 255L) << 8
| val.bytes[val.offset+3] & 255L;
return result << 32; return result << 32;
} }
@ -130,13 +131,6 @@ public final class GeoEncodingUtils {
return shift; return shift;
} }
/** Converts 8 bytes to a long value */
protected static long fromBytes(byte b1, byte b2, byte b3, byte b4, byte b5, byte b6, byte b7, byte b8) {
return ((long)b1 & 255L) << 56 | ((long)b2 & 255L) << 48 | ((long)b3 & 255L) << 40
| ((long)b4 & 255L) << 32 | ((long)b5 & 255L) << 24 | ((long)b6 & 255L) << 16
| ((long)b7 & 255L) << 8 | (long)b8 & 255L;
}
/** Converts a long value into a bit string (useful for debugging) */ /** Converts a long value into a bit string (useful for debugging) */
public static String geoTermToString(long term) { public static String geoTermToString(long term) {
StringBuilder s = new StringBuilder(64); StringBuilder s = new StringBuilder(64);

View File

@ -61,8 +61,9 @@ public class TestGeoEncodingUtils extends LuceneTestCase {
double latEnc = GeoEncodingUtils.mortonUnhashLat(enc); double latEnc = GeoEncodingUtils.mortonUnhashLat(enc);
double lonEnc = GeoEncodingUtils.mortonUnhashLon(enc); double lonEnc = GeoEncodingUtils.mortonUnhashLon(enc);
assertEquals("lat=" + lat + " latEnc=" + latEnc + " diff=" + (lat - latEnc), lat, latEnc, GeoEncodingUtils.TOLERANCE); // todo remove tolerance
assertEquals("lon=" + lon + " lonEnc=" + lonEnc + " diff=" + (lon - lonEnc), lon, lonEnc, GeoEncodingUtils.TOLERANCE); assertEquals("lat=" + lat + " latEnc=" + latEnc + " diff=" + (lat - latEnc), lat, latEnc, 1e-6);
assertEquals("lon=" + lon + " lonEnc=" + lonEnc + " diff=" + (lon - lonEnc), lon, lonEnc, 1e-6);
} }
} }