<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
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. <br>
Regards<br>
Slawomir<br>
<br>
OpenLayers.Layer.WMS.Extents =
OpenLayers.Class(OpenLayers.Layer.WMS, {<br>
<br>
<b> extents:null,</b><br>
<b>emptyTileImageUrl:null,</b><br>
<br>
getURL: function (bounds) {<br>
bounds = this.adjustBounds(bounds);<br>
<b> if(this.extents == null || this.emptyTileImageUrl == null
|| this.extents.intersectsBounds(bounds)) {</b><br>
var imageSize = this.getImageSize();<br>
var newParams = {};<br>
// WMS 1.3 introduced axis order<br>
var reverseAxisOrder = this.reverseAxisOrder();<br>
newParams.BBOX = this.encodeBBOX ?<br>
bounds.toBBOX(null, reverseAxisOrder) :<br>
bounds.toArray(reverseAxisOrder);<br>
<br>
newParams.WIDTH = imageSize.w;<br>
newParams.HEIGHT = imageSize.h;<br>
var requestString =
this.getFullRequestString(newParams);<br>
return requestString;<br>
<b> } else {<br>
return this.emptyTileImageUrl;<br>
}</b><br>
},<br>
<br>
CLASS_NAME: "OpenLayers.Layer.WMS.Extents"<br>
});<br>
</body>
</html>