Avoid unneeded parameter concatenations (thanks @twpayne, refs #85)

This commit is contained in:
Éric Lemoine
2012-11-04 19:31:20 +01:00
parent 529c3e8b6a
commit dd014a3b79
3 changed files with 18 additions and 36 deletions

View File

@@ -2,6 +2,7 @@ goog.provide('ol.TileUrlFunction');
goog.provide('ol.TileUrlFunctionType');
goog.require('goog.math');
goog.require('goog.uri.utils');
goog.require('ol.TileCoord');
goog.require('ol.tilegrid.TileGrid');
@@ -69,29 +70,21 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
/**
* @param {string} baseUrl WMS base URL.
* @param {Object} baseParams Query string parameters.
* @param {string} baseUrl Base URL (may have query data).
* @param {ol.tilegrid.TileGrid} tileGrid Tile grid.
* @return {ol.TileUrlFunctionType} Tile URL function.
*/
ol.TileUrlFunction.createBboxParam = function(baseUrl, baseParams, tileGrid) {
ol.TileUrlFunction.createBboxParam = function(baseUrl, tileGrid) {
return function(tileCoord) {
if (goog.isNull(tileCoord)) {
return undefined;
} else {
var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
var params = goog.object.clone(baseParams);
// FIXME Projection dependant axis order.
var bboxValue = [
tileExtent.minX, tileExtent.minY, tileExtent.maxX, tileExtent.maxY
].join(',');
goog.object.extend(params, {'BBOX': bboxValue});
var url = baseUrl;
for (var p in params) {
url += (~url.indexOf('?') ? '&' : '?') +
p + '=' + encodeURIComponent(params[p]);
}
return url;
return goog.uri.utils.appendParam(baseUrl, 'BBOX', bboxValue);
}
};
};