lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r933908 - in /lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier: CartesianPolyFilterBuilder.java projections/CartesianTierPlotter.java
Date Wed, 14 Apr 2010 10:41:36 GMT
Author: gsingers
Date: Wed Apr 14 10:41:36 2010
New Revision: 933908

URL: http://svn.apache.org/viewvc?rev=933908&view=rev
Log:
LUCENE-2184: previous commit broke this

Modified:
    lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
    lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.java

Modified: lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java?rev=933908&r1=933907&r2=933908&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
(original)
+++ lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
Wed Apr 14 10:41:36 2010
@@ -69,7 +69,7 @@ public class CartesianPolyFilterBuilder 
     double longUpperRight = upperRight.getLng();
     double longLowerLeft = lowerLeft.getLng();
 
-    CartesianTierPlotter ctp = new CartesianTierPlotter( miles, projector, tierPrefix );
+    CartesianTierPlotter ctp = new CartesianTierPlotter( miles, projector, tierPrefix, minTier,
maxTier );
     Shape shape = new Shape(ctp.getTierLevelId());
 
     if (longUpperRight < longLowerLeft) { // Box cross the 180 meridian

Modified: lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.java?rev=933908&r1=933907&r2=933908&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.java
(original)
+++ lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.java
Wed Apr 14 10:41:36 2010
@@ -26,6 +26,8 @@ import org.apache.lucene.spatial.geometr
  */
 public class CartesianTierPlotter {
   public static final String DEFALT_FIELD_PREFIX = "_tier_";
+  public static final int DEFALT_MIN_TIER = 0;
+  public static final int DEFALT_MAX_TIER = 15;
   
   final int tierLevel;
   int tierLength;
@@ -49,8 +51,8 @@ public class CartesianTierPlotter {
   }
 
   public CartesianTierPlotter(double radius, IProjector projector,
-      String fieldPrefix) {
-    this(CartesianTierPlotter.bestFit(radius), projector, fieldPrefix);
+      String fieldPrefix, int minTier, int maxTier) {
+    this(CartesianTierPlotter.bestFit(radius, minTier, maxTier), projector, fieldPrefix);
   }
   
   private void setTierLength (){
@@ -143,18 +145,22 @@ public class CartesianTierPlotter {
    *  in accurate
    */
   static public int bestFit(double range) {
-    return bestFit(range, DistanceUnits.MILES);
+    return bestFit(range, DEFALT_MIN_TIER, DEFALT_MAX_TIER, DistanceUnits.MILES);
+  }
+  
+  static public int bestFit(double range, int minTier, int maxTier) {
+    return bestFit(range, minTier, maxTier, DistanceUnits.MILES);
   }
 
-  static public int bestFit(double range, DistanceUnits distanceUnit) {
+  static public int bestFit(double range, int minTier, int maxTier, DistanceUnits distanceUnit)
{
     double times = distanceUnit.earthCircumference() / (2.0d * range);
 
     int bestFit = (int) Math.ceil(log2(times));
 
-    if (bestFit > 15) {
-      // 15 is the granularity of about 1 mile
-      // finer granularity isn't accurate with standard java math
-      return 15;
+    if (bestFit > maxTier) {
+      return maxTier;
+    } else if (bestFit < minTier) {
+    	return minTier;
     }
     return bestFit;
   }



Mime
View raw message