I'm using a WMS server, which can take any sized bounding box (bbox), and render the proper image for it. I'm currently adding a layer using WebMapServiceImageryProvider, and this is working.
The owners of the WMS server have asked if I can reduce the calls to the server. For example, with other map engines, I get the extent, and request that as the WMS bbox, and make new requests as the user scrolls around and zooms in, etc. That is, Cesium, because of the tiling, is making one request per visible tile on the screen, resulting in many WMS requests to the server (per view change).
I can't seem to find a way to do this with Cesium. I did consider using a SingleTileImageryProvider, but I believe if I do so, I'll be stuck with JUST one image, and the user won't see better resolution as they zoom in closer.
I've also tried the following (modifying the Cesium source code):
1) Added a (_efficientWms) member to WebMapServiceImageryProvider, indicating I want this new behavior.
2) Added code to ImageryLayer.prototype._createTileImagerySkeletons(), where if the ImageProvider has this member set, will create a single TileImagery, with the following code, rather than produce one per tile:
// "Magic" to determine visibleRectangle in radians
var imagery = new Imagery(this, 0, 0, tileLevel, visibleRectangle);
tile.imagery.splice(insertionPoint, 0, new TileImagery(imagery, new Cartesian4(visibleRectangle.west, visibleRectangle.south, visibleRectangle.east, visibleRectangle.north)));
return true;
3) Changed ImageryLayer.prototype._requestImagery().doRequest() to pass the imagery.rectangle as an additional parameter to imageryProvider.requestImage().
4) Added the parameter to WebMapServiceImageryProvider.prototype.requestImage(), and code to use this rectangle as the "nativeRectangle" if _efficientWms is set:
var nativeRectangle = (this._efficientWms && rectangle && this._tilingScheme.rectangleToNativeRectangle(rectangle)) || this._tilingScheme.tileXYToNativeRectangle(x, y, level);
5) Some additional changes to get the magic in step 2 to determine the visible area.
With the above changes, I see the expected WMS requests to the server, which look like they have the correct bbox (and which show data when viewed directly in a browser as an image) - but I don't see the WMS images appear on the map.
Any help (including better ways to do this, or what I've done wrong) would be appreciated. Thank you.