Handle urls and templates in ol.source.UrlTile

This makes url templates available for ol.source.VectorTile.
This commit is contained in:
Andreas Hocevar
2015-10-01 19:19:37 +02:00
parent af69933c64
commit 4784b7f2e2
8 changed files with 131 additions and 178 deletions
+5 -48
View File
@@ -11,7 +11,6 @@ goog.require('goog.string');
goog.require('goog.uri.utils');
goog.require('ol');
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.size');
@@ -49,20 +48,11 @@ ol.source.TileWMS = function(opt_options) {
tileGrid: options.tileGrid,
tileLoadFunction: options.tileLoadFunction,
tileUrlFunction: goog.bind(this.tileUrlFunction_, this),
url: options.url,
urls: options.urls,
wrapX: options.wrapX !== undefined ? options.wrapX : true
});
var urls = options.urls;
if (urls === undefined && options.url !== undefined) {
urls = ol.TileUrlFunction.expandUrl(options.url);
}
/**
* @private
* @type {!Array.<string>}
*/
this.urls_ = urls || [];
/**
* @private
* @type {number}
@@ -221,7 +211,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ =
function(tileCoord, tileSize, tileExtent,
pixelRatio, projection, params) {
var urls = this.urls_;
var urls = this.urls;
if (urls.length === 0) {
return undefined;
}
@@ -301,16 +291,6 @@ ol.source.TileWMS.prototype.getTilePixelSize =
};
/**
* Return the URLs used for this WMS source.
* @return {!Array.<string>} URLs.
* @api stable
*/
ol.source.TileWMS.prototype.getUrls = function() {
return this.urls_;
};
/**
* @private
*/
@@ -319,8 +299,8 @@ ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() {
var res = [];
var j, jj;
for (j = 0, jj = this.urls_.length; j < jj; ++j) {
res[i++] = this.urls_[j];
for (j = 0, jj = this.urls.length; j < jj; ++j) {
res[i++] = this.urls[j];
}
var key;
@@ -332,29 +312,6 @@ ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() {
};
/**
* Set the URL to use for requests.
* @param {string|undefined} url URL.
* @api stable
*/
ol.source.TileWMS.prototype.setUrl = function(url) {
var urls = url !== undefined ? ol.TileUrlFunction.expandUrl(url) : null;
this.setUrls(urls);
};
/**
* Set the URLs to use for requests.
* @param {Array.<string>|undefined} urls URLs.
* @api stable
*/
ol.source.TileWMS.prototype.setUrls = function(urls) {
this.urls_ = urls || [];
this.resetCoordKeyPrefix_();
this.changed();
};
/**
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {number} pixelRatio Pixel ratio.