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/07 03:50:17 UTC
lucene-solr:branch_6x: LUCENE-7185: make an empty grid the simple way
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 6868a8cd7 -> e75db9476
LUCENE-7185: make an empty grid the simple way
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e75db947
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e75db947
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e75db947
Branch: refs/heads/branch_6x
Commit: e75db9476764b9a6a426686a58e18f38a26883a5
Parents: 6868a8c
Author: Robert Muir <rm...@apache.org>
Authored: Wed Apr 6 21:48:33 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Wed Apr 6 21:50:10 2016 -0400
----------------------------------------------------------------------
.../java/org/apache/lucene/document/LatLonGrid.java | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e75db947/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 5d594c6..9b4e981 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonGrid.java
@@ -74,11 +74,17 @@ final class LatLonGrid {
}
long latitudeRange = maxLat - (long) minLat;
long longitudeRange = maxLon - (long) minLon;
- // we spill over the edge of the bounding box in each direction a bit,
- // but it prevents edge case bugs.
- latPerCell = latitudeRange / (GRID_SIZE - 1);
- lonPerCell = longitudeRange / (GRID_SIZE - 1);
- fill(polygons, 0, GRID_SIZE, 0, GRID_SIZE);
+
+ if (latitudeRange < GRID_SIZE || longitudeRange < GRID_SIZE) {
+ // don't complicate fill right now if you pass e.g. emptyish stuff: make an "empty grid"
+ latPerCell = lonPerCell = Long.MAX_VALUE;
+ } else {
+ // we spill over the edge of the bounding box in each direction a bit,
+ // but it prevents edge case bugs.
+ latPerCell = latitudeRange / (GRID_SIZE - 1);
+ lonPerCell = longitudeRange / (GRID_SIZE - 1);
+ fill(polygons, 0, GRID_SIZE, 0, GRID_SIZE);
+ }
}
/** fills a 2D range of grid cells [minLatIndex .. maxLatIndex) X [minLonIndex .. maxLonIndex) */