Split a bounding box into small bounding boxes

991 views
Skip to first unread message

Corey Wallis

unread,
Jul 21, 2012, 11:24:40 PM7/21/12
to mapsfo...@googlegroups.com
Hi,

This strictly isn't a mapsforge problem but I'm hoping someone will be
able to help.

I have a series of bounding boxes defined using coordinates like this,
minlon, minlat, maxlon, maxlat.

I need to be able to divide these bounding boxes into four equal
smaller bounding boxes.

Does anyone know of an algorithm for achieving this? For added
complexity the larger bounding box may cross the equator or the prime
meridian.

As an example, one of the bounding boxes I have is this one:

http://www.openstreetmap.org/?minlon=104.871700&minlat=-45.956650&maxlon=156.037700&maxlat=-9.462760&box=yes

I need to split this bounding box into four equal smaller bounding boxes.

Any thoughts are gratefully received.

-Corey

Karsten Groll

unread,
Jul 31, 2012, 8:43:32 AM7/31/12
to mapsfo...@googlegroups.com
Hello Corey,

you could use our MercatorProjection class to calculate Latitude /
Longitude values to Meters, calculate the span in meters, divide it by
two and compute it back to Latitude / Longitude coordinates.

A simpler way is ignoring projections:

lat_i = |lat_1 - lat_2| * 0.5
lon_i = |lon_1 - lon_2| * 0.5
bbox1 = (lon_1, lat_1, lon_i, lat_i) // minLon, MinLat, maxLon, maxLat
etc...

I hope this is what you are looking for or is the problem more complicated?

Regards,

Karsten


2012/7/22 Corey Wallis <co...@servalproject.org>:

Corey Wallis

unread,
Aug 10, 2012, 2:56:53 AM8/10/12
to mapsfo...@googlegroups.com
Hi Karsten,

Apologies for the delay in my reply.

The algorithm I've settled on at the moment is to jus take the average
point between the min and max coordinates.

More information is on my blog here.

http://techxplorer.com/2012/08/02/splitting-a-bounding-box-into-four-quadrants-2/

With thanks.

-Corey
Reply all
Reply to author
Forward
0 new messages