lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r929956 - in /lucene/dev/trunk/lucene/contrib: CHANGES.txt spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
Date Thu, 01 Apr 2010 13:04:48 GMT
Author: gsingers
Date: Thu Apr  1 13:04:47 2010
New Revision: 929956

URL: http://svn.apache.org/viewvc?rev=929956&view=rev
Log:
LUCENE-2359: fixed edge case around 180th meridian

Modified:
    lucene/dev/trunk/lucene/contrib/CHANGES.txt
    lucene/dev/trunk/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java
    lucene/dev/trunk/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java

Modified: lucene/dev/trunk/lucene/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/CHANGES.txt?rev=929956&r1=929955&r2=929956&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/contrib/CHANGES.txt Thu Apr  1 13:04:47 2010
@@ -60,6 +60,9 @@ Bug fixes
 
  * LUCENE-2184: Fixed bug with handling best fit value when the proper best fit value is
 		not an indexed field.  Note, this change affects the APIs. (Grant Ingersoll)
+		
+ * LUCENE-2359: Fix bug in CartesianPolyFilterBuilder related to handling of behavior around
+		the 180th meridian (Grant Ingersoll)
    
 API Changes
 

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=929956&r1=929955&r2=929956&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
Thu Apr  1 13:04:47 2010
@@ -103,24 +103,26 @@ public class CartesianPolyFilterBuilder 
     // iterate from startX->endX
     //     iterate from startY -> endY
     //      shape.add(currentLat.currentLong);
-
+	//for the edge cases (prime meridian and the 180th meridian), this call handles all tiles
East of the meridian
+    //for all other cases, it handles the whole set of tiles
     shape = getShapeLoop(shape,ctp,latX,longX,latY,longY);
-
 	if (longX2 != 0.0) {
-		//We are around the prime meridian
-		if (longX == 0.0) {
-			longX = longX2;
-			longY = 0.0;
-        	shape = getShapeLoop(shape,ctp,latX,longX,latY,longY);
-		} else {//we are around the 180th longitude
-			longX = longX2;
-			longY = -180.0;
-			shape = getShapeLoop(shape,ctp,latY,longY,latX,longX);
-	}
+	      if (longX == 0.0) {
+	        longX = longX2;
+	        longY = 0.0;
+	        //handles the lower left longitude to the prime meridian
+	        //shape = getShapeLoop(shape, ctp, latX, longX, latY, longY);
+	      } else {
+	        //this clause handles the lower left longitude up to the 180 meridian
+	        longX = longX2;
+	        longY = 180.0;
+	      }
+	      shape = getShapeLoop(shape, ctp, latX, longX, latY, longY);
 
-        //System.err.println("getBoxShape2:"+latY+"," + longY);
-        //System.err.println("getBoxShape2:"+latX+"," + longX);
-    }
+	      //System.err.println("getBoxShape2:"+latY+"," + longY);
+	        //System.err.println("getBoxShape2:"+latX+"," + longX);
+	    }
+	
  
     return shape; 
   } 
@@ -132,7 +134,11 @@ public class CartesianPolyFilterBuilder 
     //System.err.println("getShapeLoop:"+latX+"," + longX);
     double beginAt = ctp.getTierBoxId(latX, longX);
     double endAt = ctp.getTierBoxId(latY, longY);
-    
+    if (beginAt > endAt){
+	      double tmp = beginAt;
+	      beginAt = endAt;
+	      endAt = tmp;
+	}
     double tierVert = ctp.getTierVerticalPosDivider();
     //System.err.println(" | "+ beginAt+" | "+ endAt);
     

Modified: lucene/dev/trunk/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java?rev=929956&r1=929955&r2=929956&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
(original)
+++ lucene/dev/trunk/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java
Thu Apr  1 13:04:47 2010
@@ -139,6 +139,7 @@ public class TestCartesian extends Lucen
     addPoint(writer,"Hilton Washington Embassy Row",38.9103000,-77.0451000);
     addPoint(writer,"HorseFeathers, Bar & Grill", 39.01220000000001, -77.3942);
     addPoint(writer,"Marshall Island Airfield",7.06, 171.2);
+    addPoint(writer, "Wonga Wongue Reserve, Gabon", -0.546562,9.459229);
     addPoint(writer,"Midway Island",25.7, -171.7);
     addPoint(writer,"North Pole Way",55.0, 4.0);
    
@@ -163,6 +164,34 @@ public class TestCartesian extends Lucen
     assertEquals(3474.331719997617, miles); 
   }
 
+  /*public void testCartesianPolyFilterBuilder() throws Exception {
+    CartesianPolyFilterBuilder cpfb = new CartesianPolyFilterBuilder(CartesianTierPlotter.DEFALT_FIELD_PREFIX,
2, 15);
+    //try out some shapes
+    final double miles = 20.0;
+        // Hawaii
+        // 2300 miles to Marshall Island Airfield
+    //Hawaii to Midway is 911 miles
+    lat = 0;
+    lng = -179.9;
+    Shape shape;
+    shape = cpfb.getBoxShape(lat, lng, miles);
+    System.out.println("Tier: " + shape.getTierLevel());
+    System.out.println("area: " + shape.getArea().size());
+    lat = 30;
+    lng = -100;
+    shape = cpfb.getBoxShape(lat, lng, miles);
+    System.out.println("Tier: " + shape.getTierLevel());
+    System.out.println("area: " + shape.getArea().size());
+
+    lat = 30;
+    lng = 100;
+    shape = cpfb.getBoxShape(lat, lng, miles);
+    System.out.println("Tier: " + shape.getTierLevel());
+    System.out.println("area: " + shape.getArea().size());
+  }
+*/
+
+
   public void testAntiM() throws IOException, InvalidGeoException {
     searcher = new IndexSearcher(directory, true);
 



Mime
View raw message