You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2016/04/22 21:11:12 UTC
lucene-solr:master: LUCENE-7249: LatLonPoint polygon should use tree
relate()
Repository: lucene-solr
Updated Branches:
refs/heads/master 666472b74 -> 88c9da6c8
LUCENE-7249: LatLonPoint polygon should use tree relate()
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/88c9da6c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/88c9da6c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/88c9da6c
Branch: refs/heads/master
Commit: 88c9da6c899c7015f6c9a818a4a4f91984022254
Parents: 666472b
Author: Robert Muir <rm...@apache.org>
Authored: Fri Apr 22 15:10:39 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Fri Apr 22 15:11:03 2016 -0400
----------------------------------------------------------------------
.../src/java/org/apache/lucene/document/LatLonGrid.java | 4 ++--
.../org/apache/lucene/document/LatLonPointInPolygonQuery.java | 5 +++--
.../src/test/org/apache/lucene/document/TestLatLonGrid.java | 6 +++---
3 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/88c9da6c/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
index 2083f03..4b3b2b2 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
@@ -62,12 +62,12 @@ final class LatLonGrid {
final LatLonTree[] tree;
- LatLonGrid(int minLat, int maxLat, int minLon, int maxLon, Polygon... polygons) {
+ LatLonGrid(int minLat, int maxLat, int minLon, int maxLon, LatLonTree[] tree) {
this.minLat = minLat;
this.maxLat = maxLat;
this.minLon = minLon;
this.maxLon = maxLon;
- this.tree = LatLonTree.build(polygons);
+ this.tree = tree;
if (minLon > maxLon) {
// maybe make 2 grids if you want this?
throw new IllegalArgumentException("Grid cannot cross the dateline");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/88c9da6c/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java
index 15361b5..23a98d2 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPointInPolygonQuery.java
@@ -92,10 +92,11 @@ final class LatLonPointInPolygonQuery extends Query {
NumericUtils.intToSortableBytes(encodeLongitude(box.minLon), minLon, 0);
NumericUtils.intToSortableBytes(encodeLongitude(box.maxLon), maxLon, 0);
+ final LatLonTree[] tree = LatLonTree.build(polygons);
final LatLonGrid grid = new LatLonGrid(encodeLatitude(box.minLat),
encodeLatitude(box.maxLat),
encodeLongitude(box.minLon),
- encodeLongitude(box.maxLon), polygons);
+ encodeLongitude(box.maxLon), tree);
return new ConstantScoreWeight(this) {
@@ -156,7 +157,7 @@ final class LatLonPointInPolygonQuery extends Query {
double cellMaxLat = decodeLatitude(maxPackedValue, 0);
double cellMaxLon = decodeLongitude(maxPackedValue, Integer.BYTES);
- return Polygon.relate(polygons, cellMinLat, cellMaxLat, cellMinLon, cellMaxLon);
+ return LatLonTree.relate(tree, cellMinLat, cellMaxLat, cellMinLon, cellMaxLon);
}
});
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/88c9da6c/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java b/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java
index 891e3d5..0c185ea 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/document/TestLatLonGrid.java
@@ -40,7 +40,7 @@ public class TestLatLonGrid extends LuceneTestCase {
int maxLat = encodeLatitude(box.maxLat);
int minLon = encodeLongitude(box.minLon);
int maxLon = encodeLongitude(box.maxLon);
- LatLonGrid grid = new LatLonGrid(minLat, maxLat, minLon, maxLon, polygon);
+ LatLonGrid grid = new LatLonGrid(minLat, maxLat, minLon, maxLon, LatLonTree.build(polygon));
// we are in integer space... but exhaustive testing is slow!
for (int j = 0; j < 10000; j++) {
int lat = TestUtil.nextInt(random(), minLat, maxLat);
@@ -79,7 +79,7 @@ public class TestLatLonGrid extends LuceneTestCase {
int maxLat = encodeLatitude(box.maxLat);
int minLon = encodeLongitude(box.minLon);
int maxLon = encodeLongitude(box.maxLon);
- LatLonGrid grid = new LatLonGrid(minLat, maxLat, minLon, maxLon, polygon);
+ LatLonGrid grid = new LatLonGrid(minLat, maxLat, minLon, maxLon, LatLonTree.build(polygon));
// we are in integer space... but exhaustive testing is slow!
for (int j = 0; j < 1000; j++) {
int lat = TestUtil.nextInt(random(), minLat, maxLat);
@@ -99,7 +99,7 @@ public class TestLatLonGrid extends LuceneTestCase {
double ONE = decodeLatitude(1);
Polygon tiny = new Polygon(new double[] { ZERO, ZERO, ONE, ONE, ZERO }, new double[] { ZERO, ONE, ONE, ZERO, ZERO });
for (int max = 1; max < 500000; max++) {
- LatLonGrid grid = new LatLonGrid(0, max, 0, max, tiny);
+ LatLonGrid grid = new LatLonGrid(0, max, 0, max, LatLonTree.build(tiny));
assertEquals(tiny.contains(decodeLatitude(max), decodeLongitude(max)), grid.contains(max, max));
}
}