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/09/18 17:09:53 UTC
svn commit: r1703879 - in /lucene/dev/branches/lucene6780/lucene/sandbox/src:
java/org/apache/lucene/bkdtree/ java/org/apache/lucene/search/
java/org/apache/lucene/util/ test/org/apache/lucene/search/
test/org/apache/lucene/util/
Author: mikemccand
Date: Fri Sep 18 15:09:53 2015
New Revision: 1703879
URL: http://svn.apache.org/viewvc?rev=1703879&view=rev
Log:
LUCENE-6780: move GeoBBox -> GeoRect; turn off BKD verbosity
Added:
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoRect.java
- copied, changed from r1703282, lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoBoundingBox.java
Removed:
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoBoundingBox.java
Modified:
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDDistanceQuery.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQueryImpl.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/TestGeoUtils.java
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDDistanceQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDDistanceQuery.java?rev=1703879&r1=1703878&r2=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDDistanceQuery.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDDistanceQuery.java Fri Sep 18 15:09:53 2015
@@ -18,32 +18,25 @@ package org.apache.lucene.bkdtree;
*/
import java.io.IOException;
-import java.util.Set;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SortedNumericDocValues;
-import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreScorer;
import org.apache.lucene.search.ConstantScoreWeight;
import org.apache.lucene.search.DocIdSet;
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.Explanation;
-import org.apache.lucene.search.GeoBoundingBox;
-import org.apache.lucene.search.GeoPointDistanceQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.GeoProjectionUtils;
+import org.apache.lucene.util.GeoRect;
import org.apache.lucene.util.GeoUtils;
import org.apache.lucene.util.SloppyMath;
-import org.apache.lucene.util.ToStringUtils;
/** Finds all previously indexed points that fall within the specified distance from a center point.
*
@@ -74,13 +67,13 @@ public class BKDDistanceQuery extends Qu
this.centerLon = centerLon;
this.radiusMeters = radiusMeters;
- GeoBoundingBox bbox = GeoPointDistanceQuery.computeBBox(centerLon, centerLat, radiusMeters);
+ GeoRect bbox = GeoUtils.circleToBBox(centerLon, centerLat, radiusMeters);
minLon = bbox.minLon;
minLat = bbox.minLat;
maxLon = bbox.maxLon;
maxLat = bbox.maxLat;
- System.out.println("distance query bbox: lon=" + minLon + " TO " + maxLon + "; lat=" + minLat + " TO " + maxLat);
+ //System.out.println("distance query bbox: lon=" + minLon + " TO " + maxLon + "; lat=" + minLat + " TO " + maxLat);
assert minLat <= maxLat: "minLat=" + minLat + " maxLat=" + maxLat;
}
@@ -132,32 +125,32 @@ public class BKDDistanceQuery extends Qu
public boolean accept(double lat, double lon) {
double distanceMeters = SloppyMath.haversin(centerLat, centerLon, lat, lon) * 1000.0;
boolean result = distanceMeters <= radiusMeters;
- System.out.println("accept? centerLat=" + centerLat + " centerLon=" + centerLon + " lat=" + lat + " lon=" + lon + " distanceMeters=" + distanceMeters + " vs " + radiusMeters + " result=" + result);
+ //System.out.println("accept? centerLat=" + centerLat + " centerLon=" + centerLon + " lat=" + lat + " lon=" + lon + " distanceMeters=" + distanceMeters + " vs " + radiusMeters + " result=" + result);
return result;
}
@Override
public BKDTreeReader.Relation compare(double cellLatMin, double cellLatMax, double cellLonMin, double cellLonMax) {
- System.out.println("compare lat=" + cellLatMin + " TO " + cellLatMax + "; lon=" + cellLonMin + " TO " + cellLonMax);
+ //System.out.println("compare lat=" + cellLatMin + " TO " + cellLatMax + "; lon=" + cellLonMin + " TO " + cellLonMax);
if (GeoUtils.rectWithinCircle(cellLonMin, cellLatMin, cellLonMax, cellLatMax, centerLon, centerLat, radiusMeters)) {
// nocommit hacky workaround:
if (cellLonMax - cellLonMin < 100 && cellLatMax - cellLatMin < 50) {
- System.out.println(" CELL_INSIDE_SHAPE");
+ //System.out.println(" CELL_INSIDE_SHAPE");
return BKDTreeReader.Relation.CELL_INSIDE_SHAPE;
} else {
- System.out.println(" HACK: SHAPE_CROSSES_CELL");
+ //System.out.println(" HACK: SHAPE_CROSSES_CELL");
return BKDTreeReader.Relation.SHAPE_CROSSES_CELL;
}
} else if (GeoUtils.rectCrossesCircle(cellLonMin, cellLatMin, cellLonMax, cellLatMax, centerLon, centerLat, radiusMeters)) {
- System.out.println(" SHAPE_CROSSES_CELL");
+ //System.out.println(" SHAPE_CROSSES_CELL");
return BKDTreeReader.Relation.SHAPE_CROSSES_CELL;
} else {
// nocommit hacky workaround:
if (cellLonMax - cellLonMin < 100 && cellLatMax - cellLatMin < 50) {
- System.out.println(" SHAPE_OUTSIDE_CELL");
+ //System.out.println(" SHAPE_OUTSIDE_CELL");
return BKDTreeReader.Relation.SHAPE_OUTSIDE_CELL;
} else {
- System.out.println(" HACK: SHAPE_CROSSES_CELL");
+ //System.out.println(" HACK: SHAPE_CROSSES_CELL");
return BKDTreeReader.Relation.SHAPE_CROSSES_CELL;
}
}
@@ -177,7 +170,7 @@ public class BKDDistanceQuery extends Qu
}
if (maxLon < minLon) {
- System.out.println("BKD crosses dateline");
+ //System.out.println("BKD crosses dateline");
// Crosses date line: we just rewrite into OR of two bboxes:
// Disable coord here because a multi-valued doc could match both circles and get unfairly boosted:
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java?rev=1703879&r1=1703878&r2=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java Fri Sep 18 15:09:53 2015
@@ -132,7 +132,7 @@ final class BKDTreeReader implements Acc
}
private boolean accept(QueryState state, int docID) throws IOException {
- System.out.println(" check accept docID=" + docID);
+ //System.out.println(" check accept docID=" + docID);
state.sndv.setDocument(docID);
// How many values this doc has:
int count = state.sndv.count();
@@ -141,7 +141,7 @@ final class BKDTreeReader implements Acc
int latEnc = (int) ((enc>>32) & 0xffffffffL);
int lonEnc = (int) (enc & 0xffffffffL);
- System.out.println(" lat=" + BKDTreeWriter.decodeLat(latEnc) + " lon=" + BKDTreeWriter.decodeLon(lonEnc));
+ //System.out.println(" lat=" + BKDTreeWriter.decodeLat(latEnc) + " lon=" + BKDTreeWriter.decodeLon(lonEnc));
if (latEnc >= state.latMinEnc &&
latEnc < state.latMaxEnc &&
@@ -217,8 +217,8 @@ final class BKDTreeReader implements Acc
int cellLatMinEnc, int cellLatMaxEnc, int cellLonMinEnc, int cellLonMaxEnc)
throws IOException {
- System.out.println("\nBKD: intersect nodeID=" + nodeID + " lat=" + BKDTreeWriter.decodeLat(state.latMinEnc) + " TO " + BKDTreeWriter.decodeLat(state.latMaxEnc) +
- " lon=" + BKDTreeWriter.decodeLon(state.lonMinEnc) + " TO " + BKDTreeWriter.decodeLon(state.lonMaxEnc));
+ //System.out.println("\nBKD: intersect nodeID=" + nodeID + " lat=" + BKDTreeWriter.decodeLat(state.latMinEnc) + " TO " + BKDTreeWriter.decodeLat(state.latMaxEnc) +
+ //" lon=" + BKDTreeWriter.decodeLon(state.lonMinEnc) + " TO " + BKDTreeWriter.decodeLon(state.lonMaxEnc));
// 2.06 sec -> 1.52 sec for 225 OSM London queries:
if (state.latLonFilter != null) {
@@ -242,7 +242,7 @@ final class BKDTreeReader implements Acc
// The cell crosses the shape boundary, so we fall through and do full filtering
}
} else {
- System.out.println(" straight recurse");
+ //System.out.println(" straight recurse");
}
// TODO: clean this up: the bbox case should also just be a filter, and we should assert filter != null at the start
} else if (state.latMinEnc <= cellLatMinEnc && state.latMaxEnc >= cellLatMaxEnc && state.lonMinEnc <= cellLonMinEnc && state.lonMaxEnc >= cellLonMaxEnc) {
@@ -270,7 +270,7 @@ final class BKDTreeReader implements Acc
int hitCount = 0;
long fp = leafBlockFPs[nodeID-leafNodeOffset];
- System.out.println(" intersect leaf fp=" + fp);
+ //System.out.println(" intersect leaf fp=" + fp);
if (fp == 0) {
// Dead end node (adversary case):
//System.out.println(" dead-end leaf");
@@ -316,57 +316,57 @@ final class BKDTreeReader implements Acc
if (dim == 0) {
- System.out.println(" split on lat=" + BKDTreeWriter.decodeLat(splitValue));
+ //System.out.println(" split on lat=" + BKDTreeWriter.decodeLat(splitValue));
// Inner node split on lat:
// Left node:
if (state.latMinEnc < splitValue) {
- System.out.println(" recurse left");
+ //System.out.println(" recurse left");
count += intersect(state,
2*nodeID,
cellLatMinEnc, splitValue, cellLonMinEnc, cellLonMaxEnc);
} else {
- System.out.println(" no recurse left");
+ //System.out.println(" no recurse left");
}
// Right node:
if (state.latMaxEnc >= splitValue) {
- System.out.println(" recurse right");
+ //System.out.println(" recurse right");
count += intersect(state,
2*nodeID+1,
splitValue, cellLatMaxEnc, cellLonMinEnc, cellLonMaxEnc);
} else {
- System.out.println(" no recurse right");
+ //System.out.println(" no recurse right");
}
} else {
// Inner node split on lon:
assert dim == 1;
- System.out.println(" split on lon=" + BKDTreeWriter.decodeLon(splitValue));
+ //System.out.println(" split on lon=" + BKDTreeWriter.decodeLon(splitValue));
// Left node:
if (state.lonMinEnc < splitValue) {
- System.out.println(" recurse left");
+ //System.out.println(" recurse left");
count += intersect(state,
2*nodeID,
cellLatMinEnc, cellLatMaxEnc, cellLonMinEnc, splitValue);
} else {
- System.out.println(" no recurse left");
+ //System.out.println(" no recurse left");
}
// Right node:
if (state.lonMaxEnc >= splitValue) {
- System.out.println(" recurse right");
+ //System.out.println(" recurse right");
count += intersect(state,
2*nodeID+1,
cellLatMinEnc, cellLatMaxEnc, splitValue, cellLonMaxEnc);
} else {
- System.out.println(" no recurse right");
+ //System.out.println(" no recurse right");
}
}
- System.out.println(" return nodeID=" + nodeID);
+ //System.out.println(" return nodeID=" + nodeID);
return count;
}
}
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java?rev=1703879&r1=1703878&r2=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQuery.java Fri Sep 18 15:09:53 2015
@@ -18,15 +18,16 @@ package org.apache.lucene.search;
*/
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.util.GeoDistanceUtils;
-import org.apache.lucene.util.GeoProjectionUtils;
+import org.apache.lucene.util.GeoRect;
import org.apache.lucene.util.GeoUtils;
+// nocommit fix javadocs below: lineCrossesSphere is not used anymore?
+
/** Implements a simple point distance query on a GeoPoint field. This is based on
* {@link org.apache.lucene.search.GeoPointInBBoxQuery} and is implemented using a two phase approach. First,
* like {@code GeoPointInBBoxQueryImpl} candidate terms are queried using the numeric ranges based on
* the morton codes of the min and max lat/lon pairs that intersect the boundary of the point-radius
- * circle (see {@link org.apache.lucene.util.GeoUtils#lineCrossesSphere}. Terms
+ * circle (see org.apache.lucene.util.GeoUtils#lineCrossesSphere). 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#haversin}.
* All morton value comparisons are subject to the same precision tolerance defined in
@@ -50,7 +51,7 @@ public final class GeoPointDistanceQuery
this(field, GeoUtils.circleToBBox(centerLon, centerLat, radiusMeters), centerLon, centerLat, radiusMeters);
}
- private GeoPointDistanceQuery(final String field, GeoBoundingBox bbox, final double centerLon,
+ private GeoPointDistanceQuery(final String field, GeoRect bbox, final double centerLon,
final double centerLat, final double radiusMeters) {
super(field, bbox.minLon, bbox.minLat, bbox.maxLon, bbox.maxLat);
@@ -76,15 +77,15 @@ public final class GeoPointDistanceQuery
if (maxLon < minLon) {
BooleanQuery.Builder bqb = new BooleanQuery.Builder();
- GeoPointDistanceQueryImpl left = new GeoPointDistanceQueryImpl(field, this, new GeoBoundingBox(-180.0D, maxLon,
+ GeoPointDistanceQueryImpl left = new GeoPointDistanceQueryImpl(field, this, new GeoRect(GeoUtils.MIN_LON_INCL, maxLon,
minLat, maxLat));
bqb.add(new BooleanClause(left, BooleanClause.Occur.SHOULD));
- GeoPointDistanceQueryImpl right = new GeoPointDistanceQueryImpl(field, this, new GeoBoundingBox(minLon, 180.0D,
+ GeoPointDistanceQueryImpl right = new GeoPointDistanceQueryImpl(field, this, new GeoRect(minLon, GeoUtils.MAX_LON_INCL,
minLat, maxLat));
bqb.add(new BooleanClause(right, BooleanClause.Occur.SHOULD));
return bqb.build();
}
- return new GeoPointDistanceQueryImpl(field, this, new GeoBoundingBox(this.minLon, this.maxLon, this.minLat, this.maxLat));
+ return new GeoPointDistanceQueryImpl(field, this, new GeoRect(this.minLon, this.maxLon, this.minLat, this.maxLat));
}
@Override
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQueryImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQueryImpl.java?rev=1703879&r1=1703878&r2=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQueryImpl.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointDistanceQueryImpl.java Fri Sep 18 15:09:53 2015
@@ -23,6 +23,7 @@ import org.apache.lucene.document.GeoPoi
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.AttributeSource;
+import org.apache.lucene.util.GeoRect;
import org.apache.lucene.util.GeoUtils;
import org.apache.lucene.util.SloppyMath;
@@ -33,7 +34,7 @@ import org.apache.lucene.util.SloppyMath
final class GeoPointDistanceQueryImpl extends GeoPointInBBoxQueryImpl {
private final GeoPointDistanceQuery query;
- GeoPointDistanceQueryImpl(final String field, final GeoPointDistanceQuery q, final GeoBoundingBox bbox) {
+ GeoPointDistanceQueryImpl(final String field, final GeoPointDistanceQuery q, final GeoRect bbox) {
super(field, bbox.minLon, bbox.minLat, bbox.maxLon, bbox.maxLat);
query = q;
}
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java?rev=1703879&r1=1703878&r2=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointInPolygonQuery.java Fri Sep 18 15:09:53 2015
@@ -17,14 +17,16 @@ package org.apache.lucene.search;
* limitations under the License.
*/
+import java.io.IOException;
+import java.util.Arrays;
+
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.AttributeSource;
+import org.apache.lucene.util.GeoRect;
import org.apache.lucene.util.GeoUtils;
-import org.apache.lucene.util.ToStringUtils;
-import java.io.IOException;
-import java.util.Arrays;
+// nocommit javadoc wtf this query does about the dateline!
/** Implements a simple point in polygon query on a GeoPoint field. This is based on
* {@code GeoPointInBBoxQueryImpl} and is implemented using a
@@ -60,7 +62,7 @@ public final class GeoPointInPolygonQuer
}
/** Common constructor, used only internally. */
- private GeoPointInPolygonQuery(final String field, GeoBoundingBox bbox, final double[] polyLons, final double[] polyLats) {
+ private GeoPointInPolygonQuery(final String field, GeoRect bbox, final double[] polyLons, final double[] polyLats) {
super(field, bbox.minLon, bbox.minLat, bbox.maxLon, bbox.maxLat);
if (polyLats.length != polyLons.length) {
throw new IllegalArgumentException("polyLats and polyLons must be equal length");
@@ -183,7 +185,7 @@ public final class GeoPointInPolygonQuer
}
}
- private static GeoBoundingBox computeBBox(double[] polyLons, double[] polyLats) {
+ private static GeoRect computeBBox(double[] polyLons, double[] polyLats) {
if (polyLons.length != polyLats.length) {
throw new IllegalArgumentException("polyLons and polyLats must be equal length");
}
@@ -206,7 +208,7 @@ public final class GeoPointInPolygonQuer
maxLat = Math.max(polyLats[i], maxLat);
}
- return new GeoBoundingBox(minLon, maxLon, minLat, maxLat);
+ return new GeoRect(minLon, maxLon, minLat, maxLat);
}
/**
Copied: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoRect.java (from r1703282, lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoBoundingBox.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoRect.java?p2=lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoRect.java&p1=lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoBoundingBox.java&r1=1703282&r2=1703879&rev=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/search/GeoBoundingBox.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoRect.java Fri Sep 18 15:09:53 2015
@@ -1,4 +1,4 @@
-package org.apache.lucene.search;
+package org.apache.lucene.util;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,18 +17,14 @@ package org.apache.lucene.search;
* limitations under the License.
*/
-import org.apache.lucene.util.GeoUtils;
-
-// nocommit rename to GeoRect? It's not just a bounding box ... it's any rect ...
-
/** Represents a lat/lon rectangle. */
-public class GeoBoundingBox {
+public class GeoRect {
public final double minLon;
public final double maxLon;
public final double minLat;
public final double maxLat;
- public GeoBoundingBox(double minLon, double maxLon, double minLat, double maxLat) {
+ public GeoRect(double minLon, double maxLon, double minLat, double maxLat) {
if (GeoUtils.isValidLon(minLon) == false) {
throw new IllegalArgumentException("invalid minLon " + minLon);
}
@@ -45,10 +41,13 @@ public class GeoBoundingBox {
this.maxLon = maxLon;
this.minLat = minLat;
this.maxLat = maxLat;
+ assert maxLat >= minLat;
+
+ // NOTE: cannot assert maxLon >= minLon since this rect could cross the dateline
}
@Override
public String toString() {
- return "GeoBoundingBox(lon=" + minLon + " TO " + maxLon + ", lat=" + minLat + " TO " + maxLat + ")";
+ return "GeoRect(lon=" + minLon + " TO " + maxLon + ", lat=" + minLat + " TO " + maxLat + ")";
}
}
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java?rev=1703879&r1=1703878&r2=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java Fri Sep 18 15:09:53 2015
@@ -19,8 +19,6 @@ package org.apache.lucene.util;
import java.util.ArrayList;
-import org.apache.lucene.search.GeoBoundingBox;
-
/**
* Basic reusable geo-spatial utility methods
*
@@ -109,8 +107,8 @@ public final class GeoUtils {
return (off <= 180 ? off : 360-off) - 90;
}
- public static final boolean bboxContains(final double lon, final double lat, final double minLon,
- final double minLat, final double maxLon, final double maxLat) {
+ public static boolean bboxContains(final double lon, final double lat, final double minLon,
+ final double minLat, final double maxLon, final double maxLat) {
return (compare(lon, minLon) >= 0 && compare(lon, maxLon) <= 0
&& compare(lat, minLat) >= 0 && compare(lat, maxLat) <= 0);
}
@@ -331,7 +329,7 @@ public final class GeoUtils {
/**
* Compute Bounding Box for a circle using WGS-84 parameters
*/
- public static GeoBoundingBox circleToBBox(final double centerLon, final double centerLat, final double radiusMeters) {
+ public static GeoRect circleToBBox(final double centerLon, final double centerLat, final double radiusMeters) {
final double radLat = StrictMath.toRadians(centerLat);
final double radLon = StrictMath.toRadians(centerLon);
double radDistance = (radiusMeters + 12000) / GeoProjectionUtils.SEMIMAJOR_AXIS;
@@ -358,10 +356,11 @@ public final class GeoUtils {
maxLon = GeoProjectionUtils.MAX_LON_RADIANS;
}
- return new GeoBoundingBox(StrictMath.toDegrees(minLon), StrictMath.toDegrees(maxLon),
+ return new GeoRect(StrictMath.toDegrees(minLon), StrictMath.toDegrees(maxLon),
StrictMath.toDegrees(minLat), StrictMath.toDegrees(maxLat));
}
+ /*
/**
* Computes whether or a 3dimensional line segment intersects or crosses a sphere
*
@@ -376,9 +375,8 @@ public final class GeoUtils {
* @param centerAlt altitude of the center point (in meters)
* @param radiusMeters search sphere radius (in meters)
* @return whether the provided line segment is a secant of the
- */
- // nocommit can/should we remove this?
- // todo not used for 2d at the moment. used for 3d w/ altitude (we can keep or add back)
+ * /
+ // NOTE: not used for 2d at the moment. used for 3d w/ altitude (we can keep or add back)
private static boolean lineCrossesSphere(double lon1, double lat1, double alt1, double lon2,
double lat2, double alt2, double centerLon, double centerLat,
double centerAlt, double radiusMeters) {
@@ -414,6 +412,7 @@ public final class GeoUtils {
return true;
}
+ */
public static boolean isValidLat(double lat) {
return Double.isNaN(lat) == false && lat >= MIN_LAT_INCL && lat <= MAX_LAT_INCL;
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java?rev=1703879&r1=1703878&r2=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java Fri Sep 18 15:09:53 2015
@@ -41,17 +41,15 @@ import org.apache.lucene.index.RandomInd
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.FixedBitSet;
-import org.apache.lucene.util.GeoDistanceUtils;
import org.apache.lucene.util.GeoProjectionUtils;
+import org.apache.lucene.util.GeoRect;
import org.apache.lucene.util.GeoUtils;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.SloppyMath;
-import org.apache.lucene.util.TestGeoUtils;
import org.apache.lucene.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Test;
/**
* Unit testing for basic GeoPoint query logic
@@ -417,7 +415,7 @@ public class TestGeoPointQuery extends L
// nocommit
if (false && random().nextBoolean()) {
- GeoBoundingBox bbox = randomBBox();
+ GeoRect bbox = randomBBox();
query = new GeoPointInBBoxQuery(FIELD_NAME, bbox.minLon, bbox.minLat, bbox.maxLon, bbox.maxLat);
verifyHits = new VerifyHits() {
@@ -469,7 +467,7 @@ public class TestGeoPointQuery extends L
}
};
} else {
- GeoBoundingBox bbox = randomBBox();
+ GeoRect bbox = randomBBox();
double[] pLats = new double[5];
double[] pLons = new double[5];
@@ -586,7 +584,7 @@ public class TestGeoPointQuery extends L
return (SloppyMath.haversin(latA, lonA, latB, lonB)*1000.0 <= radius);
}
- private static boolean rectContainsPointEnc(GeoBoundingBox bbox, double pointLat, double pointLon) {
+ private static boolean rectContainsPointEnc(GeoRect bbox, double pointLat, double pointLon) {
// We should never see a deleted doc here?
assert Double.isNaN(pointLat) == false;
return GeoUtils.bboxContains(pointLon, pointLat, bbox.minLon, bbox.minLat, bbox.maxLon, bbox.maxLat);
@@ -608,7 +606,7 @@ public class TestGeoPointQuery extends L
return delta < DISTANCE_ERR;
}
- private static boolean bboxQueryCanBeWrong(GeoBoundingBox bbox, double lat, double lon) {
+ private static boolean bboxQueryCanBeWrong(GeoRect bbox, double lat, double lon) {
// we can tolerate variance at the GeoUtils.TOLERANCE decimal place
final int tLon = (int)(lon/(GeoUtils.TOLERANCE-1));
final int tLat = (int)(lat/(GeoUtils.TOLERANCE-1));
@@ -621,7 +619,7 @@ public class TestGeoPointQuery extends L
|| (tMaxLon - tLon) == 0 || (tMaxLat - tLat) == 0);
}
- public static GeoBoundingBox randomBBox() {
+ public static GeoRect randomBBox() {
double lat0 = randomLat();
double lat1 = randomLat();
double lon0 = randomLon();
@@ -640,7 +638,7 @@ public class TestGeoPointQuery extends L
lon1 = x;
}
- return new GeoBoundingBox(lon0, lon1, lat0, lat1);
+ return new GeoRect(lon0, lon1, lat0, lat1);
}
private static double randomLat() {
Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/TestGeoUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/TestGeoUtils.java?rev=1703879&r1=1703878&r2=1703879&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/TestGeoUtils.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/test/org/apache/lucene/util/TestGeoUtils.java Fri Sep 18 15:09:53 2015
@@ -25,8 +25,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.lucene.search.GeoBoundingBox;
-import org.apache.lucene.search.GeoPointDistanceQuery;
import org.junit.BeforeClass;
import com.carrotsearch.randomizedtesting.generators.RandomInts;
@@ -442,7 +440,7 @@ public class TestGeoUtils extends Lucene
log.println("\nTEST: iter=" + iter + " radiusMeters=" + radiusMeters + " centerLon=" + centerLon + " centerLat=" + centerLat);
}
- GeoBoundingBox bbox = GeoUtils.circleToBBox(centerLon, centerLat, radiusMeters);
+ GeoRect bbox = GeoUtils.circleToBBox(centerLon, centerLat, radiusMeters);
Set<Integer> hits = new HashSet<>();