LUCENE-2359: fixed edge case around 180th meridian

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@929956 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Grant Ingersoll 2010-04-01 13:04:47 +00:00
parent 3860c16a66
commit eaca8cc2e8
3 changed files with 54 additions and 16 deletions

View File

@ -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

View File

@ -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);

View File

@ -139,6 +139,7 @@ public class TestCartesian extends LuceneTestCase {
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 LuceneTestCase {
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);