You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by nk...@apache.org on 2016/04/08 17:55:50 UTC
lucene-solr:master: minor trimming from spatial module's
GeoEncodingUtils
Repository: lucene-solr
Updated Branches:
refs/heads/master 771680cfd -> d896eab98
minor trimming from spatial module's GeoEncodingUtils
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d896eab9
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d896eab9
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d896eab9
Branch: refs/heads/master
Commit: d896eab989e157353da3559feba4f4c4cb988746
Parents: 771680c
Author: nknize <nk...@apache.org>
Authored: Fri Apr 8 10:55:40 2016 -0500
Committer: nknize <nk...@apache.org>
Committed: Fri Apr 8 10:55:40 2016 -0500
----------------------------------------------------------------------
.../geopoint/search/GeoPointDistanceQuery.java | 5 ++---
.../geopoint/search/GeoPointInBBoxQuery.java | 2 --
.../geopoint/search/GeoPointInPolygonQuery.java | 3 +--
.../lucene/spatial/util/GeoEncodingUtils.java | 20 +++++++-------------
.../spatial/util/TestGeoEncodingUtils.java | 5 +++--
5 files changed, 13 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d896eab9/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointDistanceQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointDistanceQuery.java b/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointDistanceQuery.java
index 9e90a11..a6cf35c 100644
--- a/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointDistanceQuery.java
+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointDistanceQuery.java
@@ -31,9 +31,8 @@ import org.apache.lucene.geo.GeoUtils;
* circle. Terms
* 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)}.
- * All morton value comparisons are subject to the same precision tolerance defined in
- * {@value org.apache.lucene.spatial.util.GeoEncodingUtils#TOLERANCE} and distance comparisons are subject to the accuracy of the
- * haversine formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)
+ * Distance comparisons are subject to the accuracy of the 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
* queries one can expect upwards of 400m error. Vincenty shrinks this to ~40m error but pays a penalty for computing
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d896eab9/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInBBoxQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInBBoxQuery.java b/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInBBoxQuery.java
index f30950e..1634d45 100644
--- a/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInBBoxQuery.java
+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInBBoxQuery.java
@@ -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
* 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 value comparisons are subject to a precision tolerance defined in
- * {@value org.apache.lucene.spatial.util.GeoEncodingUtils#TOLERANCE}
*
* NOTES:
* 1. All latitude/longitude values must be in decimal degrees.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d896eab9/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInPolygonQuery.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInPolygonQuery.java b/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInPolygonQuery.java
index a06bdc0..26af78e 100644
--- a/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInPolygonQuery.java
+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/geopoint/search/GeoPointInPolygonQuery.java
@@ -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
* 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
- * term is passed to the final point in polygon check. All value comparisons are subject
- * to the same precision tolerance defined in {@value GeoEncodingUtils#TOLERANCE}
+ * term is passed to the final point in polygon check.
*
* @see Polygon
* @lucene.experimental
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d896eab9/lucene/spatial/src/java/org/apache/lucene/spatial/util/GeoEncodingUtils.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/util/GeoEncodingUtils.java b/lucene/spatial/src/java/org/apache/lucene/spatial/util/GeoEncodingUtils.java
index d2141d9..95aea2a 100644
--- a/lucene/spatial/src/java/org/apache/lucene/spatial/util/GeoEncodingUtils.java
+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/util/GeoEncodingUtils.java
@@ -41,10 +41,7 @@ public final class GeoEncodingUtils {
* for encoding <code>geoEncoded</code> values.
* @see #geoCodedToPrefixCodedBytes(long, int, BytesRefBuilder)
*/
- public static final int BUF_SIZE_LONG = 28/8 + 1;
-
- /** rounding error for quantized latitude and longitude values */
- public static final double TOLERANCE = 1E-6;
+ private static final int BUF_SIZE_LONG = 28/8 + 1;
// No instance:
private GeoEncodingUtils() {
@@ -91,8 +88,12 @@ public final class GeoEncodingUtils {
/** Convert a prefix coded geo term back into the geocoded morton long */
public static long prefixCodedToGeoCoded(final BytesRef val) {
- final long result = fromBytes((byte)0, (byte)0, (byte)0, (byte)0,
- val.bytes[val.offset+0], val.bytes[val.offset+1], val.bytes[val.offset+2], val.bytes[val.offset+3]);
+ final long result = 0L
+ | (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;
}
@@ -130,13 +131,6 @@ public final class GeoEncodingUtils {
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) */
public static String geoTermToString(long term) {
StringBuilder s = new StringBuilder(64);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d896eab9/lucene/spatial/src/test/org/apache/lucene/spatial/util/TestGeoEncodingUtils.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/util/TestGeoEncodingUtils.java b/lucene/spatial/src/test/org/apache/lucene/spatial/util/TestGeoEncodingUtils.java
index 1a1b2cc..aab0de0 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/util/TestGeoEncodingUtils.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/util/TestGeoEncodingUtils.java
@@ -61,8 +61,9 @@ public class TestGeoEncodingUtils extends LuceneTestCase {
double latEnc = GeoEncodingUtils.mortonUnhashLat(enc);
double lonEnc = GeoEncodingUtils.mortonUnhashLon(enc);
- assertEquals("lat=" + lat + " latEnc=" + latEnc + " diff=" + (lat - latEnc), lat, latEnc, GeoEncodingUtils.TOLERANCE);
- assertEquals("lon=" + lon + " lonEnc=" + lonEnc + " diff=" + (lon - lonEnc), lon, lonEnc, GeoEncodingUtils.TOLERANCE);
+ // todo remove 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);
}
}