[OpenLayers-Dev] WMS-Performance
Slawomir Messner
slawomir.messner at staff.uni-marburg.de
Fri Jun 10 01:59:20 EDT 2011
Hi,
I thought about optimizing the WMS Layers and the simplest thing would
be if the extents are known(which is the most of the cases) just to get
the tiles which are needed and for the others only one static file so
the browser has to cache only one file with no opacity. It should reduce
memory usage and number of request in cost of some calculations. So I
made the Extents WMS Layer(I know not a good name, I'm looking for a
good one) which I paste at the bottom. Than I thought I could save some
calculations by saving a tile's "empty"-state in it, by a class derived
from Image-class (just override the renderTile-funciton and add an
isEmpty-attribute in the class), but tiles are reused so this leads to
some ugly empty tiles in some cases(especially panning, zoom is no
problem). So I want to share the class with interested and hope for some
feedback and optimization suggestions. This solution is better then the
normal WMS especially in cases where a small WMS picture lies on an
bigger one and even better if someone has some small WMS layers in
"space", it could be interesting for mobiles too and it is interesting
if your caching your tiles like us so there are no empty tiles in cache
any more there is only one image for all. It should be inferior to the
normal one if your view is filled with the not empty WMS tiles because
intersection is calculated every time, but I don't know if the
calculations impact that much.
Regards
Slawomir
OpenLayers.Layer.WMS.Extents = OpenLayers.Class(OpenLayers.Layer.WMS, {
*extents:null,*
*emptyTileImageUrl:null,*
getURL: function (bounds) {
bounds = this.adjustBounds(bounds);
*if(this.extents == null || this.emptyTileImageUrl == null ||
this.extents.intersectsBounds(bounds)) {*
var imageSize = this.getImageSize();
var newParams = {};
// WMS 1.3 introduced axis order
var reverseAxisOrder = this.reverseAxisOrder();
newParams.BBOX = this.encodeBBOX ?
bounds.toBBOX(null, reverseAxisOrder) :
bounds.toArray(reverseAxisOrder);
newParams.WIDTH = imageSize.w;
newParams.HEIGHT = imageSize.h;
var requestString = this.getFullRequestString(newParams);
return requestString;
*} else {
return this.emptyTileImageUrl;
}*
},
CLASS_NAME: "OpenLayers.Layer.WMS.Extents"
});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20110610/f849bb0b/attachment.html
More information about the Dev
mailing list