lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pj...@apache.org
Subject svn commit: r756849 - /lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java
Date Sat, 21 Mar 2009 00:46:28 GMT
Author: pjaol
Date: Sat Mar 21 00:46:27 2009
New Revision: 756849

URL: http://svn.apache.org/viewvc?rev=756849&view=rev
Log:
Fixed NPE for minimal bounding box search
LUCENE-1568

Modified:
    lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java

Modified: lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java?rev=756849&r1=756848&r2=756849&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java
(original)
+++ lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java
Sat Mar 21 00:46:27 2009
@@ -37,7 +37,7 @@
   private final double lng;
   private final double miles;
   private Filter cartesianFilter;
-  
+  private boolean needPrecision = true;
   /**
    * Create a distance query using
    * a boundary box wrapper around a more precise
@@ -54,6 +54,7 @@
     this.lat = lat;
     this.lng = lng;
     this.miles = miles;
+    this.needPrecision = needPrecise;
     
     
     CartesianPolyFilterBuilder cpf = new CartesianPolyFilterBuilder(tierFieldPrefix);
@@ -81,7 +82,7 @@
     this.lat = lat;
     this.lng = lng;
     this.miles = miles;
-    
+    this.needPrecision = needPrecise;
     
     CartesianPolyFilterBuilder cpf = new CartesianPolyFilterBuilder(tierFieldPrefix);
     cartesianFilter = cpf.getBoundingArea(lat, lng, (int)miles);
@@ -104,20 +105,37 @@
   * @param miles
   */
   public Filter getFilter() {
-    return new SerialChainFilter(new Filter[] {cartesianFilter, distanceFilter},
-                    new int[] {SerialChainFilter.AND,
-                           SerialChainFilter.SERIALAND});
+	Filter [] f;
+	int [] chain;
+	
+	if (needPrecision){
+		f = new Filter[]{cartesianFilter, distanceFilter};
+		chain = new int[] {SerialChainFilter.AND, 
+				SerialChainFilter.SERIALAND};
+	}else{
+		f= new Filter[]{cartesianFilter};
+		chain = new int[] {SerialChainFilter.AND};
+	}
+    return new SerialChainFilter( f, chain );
   }
   
   public Filter getFilter(Query query) {
     QueryWrapperFilter qf = new QueryWrapperFilter(query);
     
+    Filter [] f;
+    int [] chain;
     
-    return new SerialChainFilter(new Filter[] {cartesianFilter, qf, distanceFilter},
-          new int[] {SerialChainFilter.AND, 
-              SerialChainFilter.AND,
-              SerialChainFilter.SERIALAND});
-  
+	if (needPrecision){
+		f = new Filter[]{cartesianFilter, qf, distanceFilter};
+		chain = new int[] {SerialChainFilter.AND, 
+	              SerialChainFilter.AND,
+	              SerialChainFilter.SERIALAND};
+	}else{
+		f= new Filter[]{cartesianFilter, qf};
+		chain = new int[] {SerialChainFilter.AND, 
+	              SerialChainFilter.AND};
+	}
+    return new SerialChainFilter(f,chain); 
   }
     
   public Query getQuery() {



Mime
View raw message