Odd boundingbox problem

42 views
Skip to first unread message

Jeff Schnitzer

unread,
Dec 30, 2011, 2:32:42 PM12/30/11
to javageomod...@googlegroups.com
I'm trying to do a simple bounding box search but getting some weird
results. Here are the three points I'm working with:

http://maps.googleapis.com/maps/api/staticmap?size=1024x1024&sensor=false&markers=|39.21384361610083,-120.59898251959079|36.33601447716089,-124.23985415033108|33.89083710,-118.39878420

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

Jeff Schnitzer

unread,
Jan 6, 2012, 3:14:52 AM1/6/12
to javageomod...@googlegroups.com
Does anyone have any thoughts on this?  Is this a bug or am I doing something wrong?

Thanks,
Jeff

Alexandre Gellibert

unread,
Jan 8, 2012, 5:02:27 PM1/8/12
to javageomod...@googlegroups.com
Hi Jeff,

Your code looks right.
You might want to tune the cost function depending to your needs.

Basically, if you want to search on finer bouding box, you could make a function like this (but this one will be very slow if you enter a big bounding box in entry because you'll get many tiny boxes to search on) :

GeocellManager.bestBboxSearchCells(bb, new CostFunction() {

            public double defaultCostFunction(int numCells, int resolution) {

                if(resolution < 5) {

                    return Double.MAX_VALUE;

                } else {

                    return 0;

                }

            }

        });

Thanks,
Alex
--
Alexandre Gellibert
alexandre...@gmail.com
Reply all
Reply to author
Forward
0 new messages