Merge pull request #992 from elemoine/urlfunction

Stricter with types
This commit is contained in:
Éric Lemoine
2013-09-07 22:44:49 -07:00
4 changed files with 22 additions and 6 deletions

View File

@@ -5,8 +5,8 @@ goog.require('ol.Size');
/**
* @typedef {function(this:ol.source.Source, ol.Extent, ol.Size, ol.Projection):
* (string|undefined)}
* @typedef {function(this:ol.source.ImageSource, ol.Extent, ol.Size,
* ol.Projection): (string|undefined)}
*/
ol.ImageUrlFunctionType;
@@ -22,6 +22,7 @@ ol.ImageUrlFunction.createFromParamsFunction =
function(baseUrl, params, paramsFunction) {
return (
/**
* @this {ol.source.ImageSource}
* @param {ol.Extent} extent Extent.
* @param {ol.Size} size Size.
* @param {ol.Projection} projection Projection.
@@ -34,6 +35,7 @@ ol.ImageUrlFunction.createFromParamsFunction =
/**
* @this {ol.source.ImageSource}
* @param {ol.Extent} extent Extent.
* @param {ol.Size} size Size.
* @return {string|undefined} Image URL.

View File

@@ -88,6 +88,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
.replace('{culture}', culture);
return (
/**
* @this {ol.source.BingMaps}
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL.

View File

@@ -75,10 +75,12 @@ ol.source.WMTS = function(options) {
function createFromWMTSTemplate(template) {
return (
/**
* @this {ol.source.WMTS}
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL.
*/
function(tileCoord) {
function(tileCoord, projection) {
if (goog.isNull(tileCoord)) {
return undefined;
} else {
@@ -92,7 +94,6 @@ ol.source.WMTS = function(options) {
}
var url = template;
for (var key in localContext) {
// FIXME: should we filter properties with hasOwnProperty?
url = url.replace('{' + key + '}', localContext[key])
.replace('%7B' + key + '%7D', localContext[key]);
}
@@ -122,7 +123,13 @@ ol.source.WMTS = function(options) {
var tmpExtent = ol.extent.createEmpty();
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
function(tileCoord, projection) {
/**
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Projection} projection Projection.
* @param {ol.TileCoord=} opt_tileCoord Tile coordinate.
* @return {ol.TileCoord} Tile coordinate.
*/
function(tileCoord, projection, opt_tileCoord) {
var tileGrid = this.getTileGrid();
goog.asserts.assert(!goog.isNull(tileGrid));
if (tileGrid.getResolutions().length <= tileCoord.z) {

View File

@@ -8,7 +8,8 @@ goog.require('ol.extent');
/**
* @typedef {function(ol.TileCoord, ol.Projection): (string|undefined)}
* @typedef {function(this: ol.source.ImageTileSource, ol.TileCoord,
* ol.Projection): (string|undefined)}
*/
ol.TileUrlFunctionType;
@@ -20,6 +21,7 @@ ol.TileUrlFunctionType;
ol.TileUrlFunction.createFromTemplate = function(template) {
return (
/**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL.
@@ -56,6 +58,7 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
}
return (
/**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL.
@@ -84,6 +87,7 @@ ol.TileUrlFunction.createFromParamsFunction =
var tmpExtent = ol.extent.createEmpty();
return (
/**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL.
@@ -106,6 +110,7 @@ ol.TileUrlFunction.createFromParamsFunction =
/**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL.
@@ -126,6 +131,7 @@ ol.TileUrlFunction.withTileCoordTransform =
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
return (
/**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL.