You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2013/01/22 22:26:14 UTC

svn commit: r1437185 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/CHANGES.txt lucene/spatial/ lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java lucene/spatial/src/test/org/apache/lucene/spatial/SpatialArgsTest.java

Author: dsmiley
Date: Tue Jan 22 21:26:14 2013
New Revision: 1437185

URL: http://svn.apache.org/viewvc?rev=1437185&view=rev
Log:
LUCENE-4550: fix SpatialArgs.calcDistanceFromErrPct

Added:
    lucene/dev/branches/branch_4x/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialArgsTest.java
      - copied unchanged from r1437182, lucene/dev/trunk/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialArgsTest.java
Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/spatial/   (props changed)
    lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1437185&r1=1437184&r2=1437185&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Tue Jan 22 21:26:14 2013
@@ -55,6 +55,11 @@ Bug Fixes
 * LUCENE-4705: Pass on FilterStrategy in FilteredQuery if the filtered query is 
   rewritten. (Simon Willnauer)
 
+* LUCENE-4550: Shapes wider than 180 degrees would use too much accuracy for the
+  PrefixTree based SpatialStrategy. For a pathological case of nearly 360
+  degrees and barely any height, it would generate so many indexed terms
+  (> 500k) that it could even cause an OutOfMemoryError. Fixed. (David Smiley)
+
 ======================= Lucene 4.1.0 =======================
 
 Changes in backwards compatibility policy

Modified: lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java?rev=1437185&r1=1437184&r2=1437185&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java (original)
+++ lucene/dev/branches/branch_4x/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgs.java Tue Jan 22 21:26:14 2013
@@ -47,7 +47,7 @@ public class SpatialArgs {
   /**
    * Computes the distance given a shape and the {@code distErrPct}.  The
    * algorithm is the fraction of the distance from the center of the query
-   * shape to its furthest bounding box corner.
+   * shape to its closest bounding box corner.
    *
    * @param shape Mandatory.
    * @param distErrPct 0 to 0.5
@@ -62,11 +62,13 @@ public class SpatialArgs {
       return 0;
     }
     Rectangle bbox = shape.getBoundingBox();
-    //The diagonal distance should be the same computed from any opposite corner,
-    // and this is the longest distance that might be occurring within the shape.
-    double diagonalDist = ctx.getDistCalc().distance(
-        ctx.makePoint(bbox.getMinX(), bbox.getMinY()), bbox.getMaxX(), bbox.getMaxY());
-    return diagonalDist * 0.5 * distErrPct;
+    //Compute the distance from the center to a corner.  Because the distance
+    // to a bottom corner vs a top corner can vary in a geospatial scenario,
+    // take the closest one (greater precision).
+    Point ctr = bbox.getCenter();
+    double y = (ctr.getY() >= 0 ? bbox.getMaxY() : bbox.getMinY());
+    double diagonalDist = ctx.getDistCalc().distance(ctr, bbox.getMaxX(), y);
+    return diagonalDist * distErrPct;
   }
 
   /**