[OpenLayers-Users] how to calculate BBOX for tiles

joncoign jncoign at Knology.net
Sat Apr 11 14:34:18 EDT 2009


I don't think this will be a full solution to what you need, but it might get you started. We update the tile urls requested so that they are compatible with Google Tile index system. 

We do this by setting an option called getURL when creating either a WMS or TMS layer. 

getURL's signature is 

function YourGetTileURLMethodName (bounds)

I think this will get you from a tile's bounds to the URL you need however, I don't think it will handle splitting up a larger BBOX into the smaller BBOXs to handle all of the tiles. You can find the documentation on the WMS.getURL method at

http://dev.openlayers.org/releases/OpenLayers-2.7/doc/devdocs/files/OpenLayers/Layer/WMS-js.html#OpenLayers.Layer.WMS.getURL

and the TMS version at 

http://dev.openlayers.org/releases/OpenLayers-2.7/doc/devdocs/files/OpenLayers/Layer/TMS-js.html#OpenLayers.Layer.TMS.getURL

To get the function defintion for the Openlayers implmentation you can execute the following statement in a JavaScript debugger.

alert (LayerVariable.getURL);

The default implementation on the dev build we are using is:

function (bounds) {
    bounds = this.adjustBounds(bounds);
    var imageSize = this.getImageSize();
    var newParams = {BBOX: this.encodeBBOX ? bounds.toBBOX() : bounds.toArray(), WIDTH: imageSize.w, HEIGHT: imageSize.h};
    var requestString = this.getFullRequestString(newParams);
    return requestString;
}

Jon


Hi List!

I am trying to selectivly delete tiles from TileCache for specific
BBOXes in order to regenerate parts of the map. I am using this script
which Tim posted two years ago:
http://n2.nabble.com/locating-bad-tiles...-td1836476.html
Supplying the URL which OpenLayers generates for a specific tile
refreshes this tile in the TileCache.

So I need to know how OpenLayers calculates the BBOXes for the tiles to
be requested. Can someone point me to this piece of code?

Here is what should happen:

- I have the BBOX of the part of the map that should be regenerated
- calculate the corresponding tiles in all zoom levels
- pass these tiles' BBOX to Tim's script that regenerates the matching
tiles in the TileCache

or in short: how to get the URLs for tiles, that cover a specific area?

Thanks for any hints - or even better approaches.

Kevin



-- 
http://www.kevinkempfer.de
Tel.: (07071) 860303
ICQ:  2186573
Skype: kevin0815

Natürlich gibt es eine jenseitige Welt. Die Frage ist nur:
wie weit ist sie von der Innenstadt entfernt, und wie lange hat sie offen.
Woody Allen


 
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users



-- 
View this message in context: http://n2.nabble.com/how-to-calculate-BBOX-for-tiles-tp2604027p2621502.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list