The two to the north around San Francisco are the bounding box; the
one to the south near Manhattan Beach is the one I'm checking. The
one near MB is outside the bounding box by what seems like a fairly
large margin.
Here's my test case:
public class GeocellsTest {
private static final BoundingBox WEIRD_SF_BB = new
BoundingBox(39.21384361610083, -120.59898251959079, 36.33601447716089,
-124.23985415033108);
private static final Point MANHATTAN_BEACH = new
Point(33.89083710,-118.39878420);
@Test
public void testExactInputsBoundingBoxSearch() throws Exception {
Set<String> manhattanBeachCells =
Sets.newHashSet(GeocellManager.generateGeoCell(MANHATTAN_BEACH));
Set<String> sfCells =
Sets.newHashSet(GeocellManager.bestBboxSearchCells(WEIRD_SF_BB,
null));
assert Sets.intersection(manhattanBeachCells, sfCells).isEmpty();
}
}
This case is failing; that is, manhattanBeachCells has overlap with
the sfCells of the bounding box.
manhattanBeachCells: [8, 8e, 8e4, 8e45, 8e455, 8e455a, 8e455a5,
8e455a5e, 8e455a5e2, 8e455a5e24, 8e455a5e246, 8e455a5e246a,
8e455a5e246a5]
sfCells: [8e1, 8e3, 8e4, 8e6]
What am I doing wrong? Do I need to pass a better cost function into
bestBboxSearchCells? If so, how would I define such a cost function?
This code is being used to filter an indexed 'cells' collection in an
appengine query.
Thanks,
Jeff
GeocellManager.bestBboxSearchCells(bb, new CostFunction() {
public double defaultCostFunction(int numCells, int resolution) {
if(resolution < 5) {
return Double.MAX_VALUE;
} else {
return 0;
}
}
});