Thoughts on WebMapServiceImageryProvider.

Hello,

For my first steps with cesium i tried the
WebMapServiceImageryProvider, Bing and OSM.

when you want to use a WMS as an overlay you cannot
tell cesium to get the layer with transparency (i.e. as png
or gif), the tiles are always fetched as jpeg which makes
it unusable for overlays.

You cannot define the style of the wms layer. It is quite
common that a wms layer has more than 1 style, if i want
something else than the default style currently I cannot
do it

The Cesium.DefaultProxy always appends ?url-to-fetch to
the request which makes it harder for other
proxy implementations which perhaps expect a
/proxy?get_url=url-to-fetch parameter

So my wish is to have something like:

var provider = new WebMapServiceImageryProvider({
    url: ‘http://sampleserver1/WMSServer’,
    layers : ‘0’,
    transparent: true, /* fetch transparent png or gif tiles */
    styles: ‘mystyle’, /* use this styles for my layers */
    proxy: new Cesium.DefaultProxy(’/proxy/?url=’) /* dont just append
     ?url to that proxyurl */
});

https://github.com/AnalyticalGraphicsInc/cesium/issues/517
https://github.com/AnalyticalGraphicsInc/cesium/issues/518
https://github.com/AnalyticalGraphicsInc/cesium/issues/519

Hi Christian,

You’re in luck - everything you want to do is already possible (even if it’s not as intuitive as it could be). Take a look at the code that creates the WMS layer in the “Imagery Layers Manipulation” Sandcastle example:

new Cesium.WebMapServiceImageryProvider({

url : 'http://mesonet.agron.iastate.edu/cgi-bin/wms/goes/conus_ir.cgi?',

layers : 'goes_conus_ir',

credit : 'Infrared data courtesy Iowa Environmental Mesonet',

parameters : {

transparent : 'true',

format : 'image/png'

},

proxy : new Cesium.DefaultProxy('/proxy/')

}));

The "parameters" property lets you pass any optional parameters you want to the WMS service.  You can use the same technique to specify a "style".

As for the proxy, the DefaultProxy could certainly use some improvement.  A Proxy is just a simple object with one method, though: getURL.  So you can implement a proxy to do what you want like this:

new Cesium.WebMapServiceImageryProvider({

url : 'http://mesonet.agron.iastate.edu/cgi-bin/wms/goes/conus_ir.cgi?’,

layers : ‘goes_conus_ir’,

credit : ‘Infrared data courtesy Iowa Environmental Mesonet’,

parameters : {

transparent : ‘true’,

format : ‘image/png’

},

proxy : {

getURL : function(url) {

return ‘/my/proxy/url?whatever=hi&url=’ + encodeURIComponent(url);

}

}

}));

I hope this helps. Let me know if you have any questions.

Kevin

this works fine, thanks a lot :slight_smile: