You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/08/02 11:27:15 UTC
svn commit: r1693796 - in /lucene/dev/trunk/lucene: CHANGES.txt
sandbox/src/java/org/apache/lucene/search/GeoPointTermsEnum.java
sandbox/src/java/org/apache/lucene/util/GeoUtils.java
sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
Author: mikemccand
Date: Sun Aug 2 09:27:15 2015
New Revision: 1693796
URL: http://svn.apache.org/r1693796
Log:
LUCENE-6710: use full 64 bits precision for GeoPointField
Modified:
lucene/dev/trunk/lucene/CHANGES.txt
lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermsEnum.java
lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java
lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1693796&r1=1693795&r2=1693796&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Sun Aug 2 09:27:15 2015
@@ -147,9 +147,12 @@ New Features
filtering. Range trees can also handle values larger than 64 bits.
(Adrien Grand, Mike McCandless)
-* LUCENE-6647: Add GeoHash string utility APIs (Nick Knize, Mike
+* LUCENE-6647: Add GeoHash string utility APIs (Nick Knize via Mike
McCandless).
+* LUCENE-6710: GeoPointField now uses full 64 bits (up from 62) to encode
+ lat/lon (Nick Knize via Mike McCandless).
+
API Changes
* LUCENE-6508: Simplify Lock api, there is now just
Modified: lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermsEnum.java?rev=1693796&r1=1693795&r2=1693796&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermsEnum.java (original)
+++ lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermsEnum.java Sun Aug 2 09:27:15 2015
@@ -17,6 +17,7 @@ package org.apache.lucene.search;
* limitations under the License.
*/
+import java.math.BigInteger;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -67,7 +68,13 @@ class GeoPointTermsEnum extends Filtered
*/
private final void computeRange(long term, final short shift) {
final long split = term | (0x1L<<shift);
- final long upperMax = term | ((0x1L<<(shift+1))-1);
+ assert shift < 64;
+ final long upperMax;
+ if (shift < 63) {
+ upperMax = term | ((1L << (shift+1))-1);
+ } else {
+ upperMax = 0xffffffffffffffffL;
+ }
final long lowerMax = split-1;
relateAndRecurse(term, lowerMax, shift);
@@ -88,7 +95,7 @@ class GeoPointTermsEnum extends Filtered
final double maxLon = GeoUtils.mortonUnhashLon(end);
final double maxLat = GeoUtils.mortonUnhashLat(end);
- final short level = (short)(62-res>>>1);
+ final short level = (short)((GeoUtils.BITS<<1)-res>>>1);
// if cell is within and a factor of the precision step, or it crosses the edge of the shape add the range
final boolean within = res % GeoPointField.PRECISION_STEP == 0 && cellWithin(minLon, minLat, maxLon, maxLat);
Modified: lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java?rev=1693796&r1=1693795&r2=1693796&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java (original)
+++ lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java Sun Aug 2 09:27:15 2015
@@ -27,9 +27,9 @@ import java.util.ArrayList;
public final class GeoUtils {
private static final short MIN_LON = -180;
private static final short MIN_LAT = -90;
- public static final short BITS = 31;
- private static final double LON_SCALE = (0x1L<<BITS)/360.0D;
- private static final double LAT_SCALE = (0x1L<<BITS)/180.0D;
+ public static final short BITS = 32;
+ private static final double LON_SCALE = ((0x1L<<BITS)-1)/360.0D;
+ private static final double LAT_SCALE = ((0x1L<<BITS)-1)/180.0D;
public static final double TOLERANCE = 1E-6;
/** Minimum longitude value. */
Modified: lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java?rev=1693796&r1=1693795&r2=1693796&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java (original)
+++ lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java Sun Aug 2 09:27:15 2015
@@ -239,6 +239,13 @@ public class TestGeoPointQuery extends L
doTestRandom(10000);
}
+ @Test
+ public void testMortonEncoding() throws Exception {
+ long hash = GeoUtils.mortonHash(180, 90);
+ assertEquals(180.0, GeoUtils.mortonUnhashLon(hash), 0);
+ assertEquals(90.0, GeoUtils.mortonUnhashLat(hash), 0);
+ }
+
@Nightly
public void testRandomBig() throws Exception {
doTestRandom(200000);