iTowns / itowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data
http://www.itowns-project.org
Other
1.1k stars 298 forks source link

Enable vendor-specific parameter(s) for WMS source #959

Closed SesticM closed 5 years ago

SesticM commented 5 years ago

Many map servers provide their own, vendor-specific URL parameters when handling WMS calls. Such parameters are out of standard Web Map Service specification, but contribute large amount during actual implementation. It would be of much help if WMSSource supported such capability via vendorSpecific property containing an array of name/value pairs (if any) being added to resulting GetMap URL call. Default value for vendorSpecific property would be, naturally, empty array. So, instead of writing a custom, JavaScript-based vendor-specific WMS source, an additional property to existing class would do the job.

Good example for this is GeoServer's WMS service and related vendor-specific parameters. GeoServer comes bundled with GeoWebCache, providing WMTS capability and caching out of the box. To be able to utilize GWC's GridSet functionality via "classic" WMS GetMap call, additional parameters (TILED, TILESORIGIN) are required. There are many other vendor-specific parameters available for GeoServer's WMS service.

zarov commented 5 years ago

Good remark ! This seems simple to patch in the current WMSSource, if you want to do a PR about it. Meanwhile you can also write your own WMSVendorSource inheriting from WMSSource if you want to add only specific parameters.

I quickly read the geoserver documentation, I didn't see any dynamic parameter, can you confirm that ?

SesticM commented 5 years ago

Please find below possible use-cases of utilizing GeoServer-specific WMS vendor parameters:

1) Single vendor-specific parameter:

var layer1 = new itowns.ColorLayer('dof_2012_02500_rs', {
    source: {
            protocol: 'wms',
                url: 'http://igeo.geoinova.com/geoserver/inova/wms',
                name: 'inova:dof_2012_02500_rs',
                projection: 'EPSG:4326',
        transparent: true,
        format: 'image/png,
        vendorSpecific: [{'buffer':2}]
        }
});
view.addLayer(layer1);

Produces:

http://igeo.geoinova.com/geoserver/inova/wms?SERVICE=WMS&REQUEST=GetMap&LAYERS=inova:dof_2012_02500_rs&VERSION=1.3.0&STYLES=&FORMAT=image/png&TRANSPARENT=true&BBOX=45.000000000,-135.000000000,90.000000000,-
90.000000000&CRS=EPSG:4326&WIDTH=256&HEIGHT=256&buffer=2

2) Multiple vendor-specific parameters:

var layer2 = new itowns.ColorLayer('dof_2012_02500_rs', {
    source: {
            protocol: 'wms',
                url: 'http://igeo.geoinova.com/geoserver/inova/wms',
                name: 'inova:dof_2012_02500_rs',
                projection: 'EPSG:4326',
        transparent: true,
        format: 'image/png,
        vendorSpecific: [{'tiled':true},{'tilesorigin'='0,0'}]
        }
});
view.addLayer(layer2);

Produces:

http://igeo.geoinova.com/geoserver/inova/wms?SERVICE=WMS&REQUEST=GetMap&LAYERS=inova:dof_2012_02500_rs&VERSION=1.3.0&STYLES=&FORMAT=image/png&TRANSPARENT=true&BBOX=45.000000000,-135.000000000,90.000000000,-
90.000000000&CRS=EPSG:4326&WIDTH=256&HEIGHT=256&tiled=true&tilesorigin=0,0
SesticM commented 5 years ago

Yes, I fully agree, in first I also intended to code down WMSGeoServerSource as WMSSource descendant, but then figured out that such implementation (and other related, potential implementations) might bloat Sources code-base. Frankly, it seems like a purely architectural descision...

SesticM commented 5 years ago

Besides WMS, WFS source may also benefit from vendor-specific parameters: GeoServer WFS documentation

zarov commented 5 years ago

Ok, extending it to WFS. You know even if you can't validate a PR, you can still comment on it, no problem !

zarov commented 5 years ago

Solved in #973