WMS GetMap request parameters shall be params

To avoid surprises, we configure everything that is a WMS GetMap
request parameter in the params object, and not as direct
configuration option. This affects the VERSION and TRANSPARENT
params.
This commit is contained in:
ahocevar
2013-03-05 10:54:33 +01:00
committed by Tim Schaub
parent a912d48b59
commit c1f3a6cc54
7 changed files with 31 additions and 36 deletions

View File

@@ -15,8 +15,7 @@ goog.require('ol.source.ImageSource');
*/
ol.source.SingleImageWMS = function(options) {
var imageUrlFunction = goog.isDef(options.url) ?
ol.ImageUrlFunction.createWMSParams(
options.url, options.params, options.version) :
ol.ImageUrlFunction.createWMSParams(options.url, options.params) :
ol.ImageUrlFunction.nullImageUrlFunction;
goog.base(this, {

View File

@@ -21,25 +21,24 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
if (goog.isDef(tiledWMSOptions.tileGrid)) {
tileGrid = tiledWMSOptions.tileGrid;
}
var version = tiledWMSOptions.version;
var tileUrlFunction;
if (tiledWMSOptions.urls) {
var tileUrlFunctions = goog.array.map(
tiledWMSOptions.urls, function(url) {
return ol.TileUrlFunction.createWMSParams(
url, tiledWMSOptions.params, version);
url, tiledWMSOptions.params);
});
tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(
tileUrlFunctions);
} else if (tiledWMSOptions.url) {
tileUrlFunction = ol.TileUrlFunction.createWMSParams(
tiledWMSOptions.url, tiledWMSOptions.params, version);
tiledWMSOptions.url, tiledWMSOptions.params);
} else {
tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;
}
var transparent = goog.isDef(tiledWMSOptions.transparent) ?
tiledWMSOptions.transparent : true;
var transparent = goog.isDef(tiledWMSOptions.params['TRANSPARENT']) ?
tiledWMSOptions.params['TRANSPARENT'] : true;
var extent = tiledWMSOptions.extent;
var tileCoordTransform = function(tileCoord, tileGrid, projection) {

View File

@@ -7,31 +7,33 @@ goog.provide('ol.source.wms');
* @param {ol.Extent} extent Extent.
* @param {ol.Size} size Size.
* @param {ol.Projection} projection Projection.
* @param {string=} opt_version WMS version. Default is '1.3.0'.
* @return {string} WMS GetMap request URL.
*/
ol.source.wms.getUrl =
function(baseUrl, params, extent, size, projection, opt_version) {
var version = goog.isDef(opt_version) ? opt_version : '1.3.0';
var wms13 = version >= '1.3';
var axisOrientation = projection.getAxisOrientation();
var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ?
[extent.minY, extent.minX, extent.maxY, extent.maxX] :
[extent.minX, extent.minY, extent.maxX, extent.maxY];
function(baseUrl, params, extent, size, projection) {
var baseParams = {
'SERVICE': 'WMS',
'VERSION': version,
'VERSION': '1.3.0',
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true,
'WIDTH': size.width,
'HEIGHT': size.height,
'BBOX': bboxValues.join(',')
'HEIGHT': size.height
};
goog.object.extend(baseParams, params);
baseParams[wms13 ? 'CRS' : 'SRS'] = projection.getCode();
//TODO: Provide our own appendParams function to avoid this empty string hack
var stylesParam = 'STYLES';
baseParams[stylesParam] = params[stylesParam] || new String('');
var wms13 = baseParams['VERSION'] > '1.3';
baseParams[wms13 ? 'CRS' : 'SRS'] = projection.getCode();
var axisOrientation = projection.getAxisOrientation();
var bboxValues = (wms13 && axisOrientation.substr(0, 2) == 'ne') ?
[extent.minY, extent.minX, extent.maxY, extent.maxX] :
[extent.minX, extent.minY, extent.maxX, extent.maxY];
baseParams['BBOX'] = bboxValues.join(',');
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams);
};