How do you calculate a bounding box (that can be used where ever a asked 16 Feb '11, 03:59 panzi |
Convert the longitude and latitude of the map center to tile coordinates using the alogrithm described in the Slippy Map Tilenames article on the wiki, keeping the fractional part. Add / substract half of the width from tileX and half of the height from tileY to generate the coordinates of the four corners of the bbox. Convert them back to longitude and latitude using the description from the same wiki page. All you are now left to do is to create the string describing the bbox from the coordinates of the four corners. For mapnik this should be minlong,minlat,maxlong,maxlat. answered 16 Feb '11, 07:31 petschge Frederik Ramm ♦ http://pastebin.com/mMKrhA4D is what I did with what you wrote. But the calculated values are too large. Why is that?
(27 Jul '12, 22:19)
Richart
|
You probably need to take in account pixel size of each tile... I've needed this myself so this is what I've come up with and documented at OSM Wiki:
You can see code in action here answered 10 Jun '13, 18:08 Matija Nalis |