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
+4 -2
View File
@@ -5,8 +5,8 @@ goog.require('ol.Size');
/** /**
* @typedef {function(this:ol.source.Source, ol.Extent, ol.Size, ol.Projection): * @typedef {function(this:ol.source.ImageSource, ol.Extent, ol.Size,
* (string|undefined)} * ol.Projection): (string|undefined)}
*/ */
ol.ImageUrlFunctionType; ol.ImageUrlFunctionType;
@@ -22,6 +22,7 @@ ol.ImageUrlFunction.createFromParamsFunction =
function(baseUrl, params, paramsFunction) { function(baseUrl, params, paramsFunction) {
return ( return (
/** /**
* @this {ol.source.ImageSource}
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {ol.Size} size Size. * @param {ol.Size} size Size.
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
@@ -34,6 +35,7 @@ ol.ImageUrlFunction.createFromParamsFunction =
/** /**
* @this {ol.source.ImageSource}
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {ol.Size} size Size. * @param {ol.Size} size Size.
* @return {string|undefined} Image URL. * @return {string|undefined} Image URL.
+1
View File
@@ -88,6 +88,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
.replace('{culture}', culture); .replace('{culture}', culture);
return ( return (
/** /**
* @this {ol.source.BingMaps}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
+10 -3
View File
@@ -75,10 +75,12 @@ ol.source.WMTS = function(options) {
function createFromWMTSTemplate(template) { function createFromWMTSTemplate(template) {
return ( return (
/** /**
* @this {ol.source.WMTS}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
function(tileCoord) { function(tileCoord, projection) {
if (goog.isNull(tileCoord)) { if (goog.isNull(tileCoord)) {
return undefined; return undefined;
} else { } else {
@@ -92,7 +94,6 @@ ol.source.WMTS = function(options) {
} }
var url = template; var url = template;
for (var key in localContext) { for (var key in localContext) {
// FIXME: should we filter properties with hasOwnProperty?
url = url.replace('{' + key + '}', localContext[key]) url = url.replace('{' + key + '}', localContext[key])
.replace('%7B' + key + '%7D', localContext[key]); .replace('%7B' + key + '%7D', localContext[key]);
} }
@@ -122,7 +123,13 @@ ol.source.WMTS = function(options) {
var tmpExtent = ol.extent.createEmpty(); var tmpExtent = ol.extent.createEmpty();
var tmpTileCoord = new ol.TileCoord(0, 0, 0); var tmpTileCoord = new ol.TileCoord(0, 0, 0);
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform( 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(); var tileGrid = this.getTileGrid();
goog.asserts.assert(!goog.isNull(tileGrid)); goog.asserts.assert(!goog.isNull(tileGrid));
if (tileGrid.getResolutions().length <= tileCoord.z) { if (tileGrid.getResolutions().length <= tileCoord.z) {
+7 -1
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; ol.TileUrlFunctionType;
@@ -20,6 +21,7 @@ ol.TileUrlFunctionType;
ol.TileUrlFunction.createFromTemplate = function(template) { ol.TileUrlFunction.createFromTemplate = function(template) {
return ( return (
/** /**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
@@ -56,6 +58,7 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
} }
return ( return (
/** /**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
@@ -84,6 +87,7 @@ ol.TileUrlFunction.createFromParamsFunction =
var tmpExtent = ol.extent.createEmpty(); var tmpExtent = ol.extent.createEmpty();
return ( return (
/** /**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
@@ -106,6 +110,7 @@ ol.TileUrlFunction.createFromParamsFunction =
/** /**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
@@ -126,6 +131,7 @@ ol.TileUrlFunction.withTileCoordTransform =
var tmpTileCoord = new ol.TileCoord(0, 0, 0); var tmpTileCoord = new ol.TileCoord(0, 0, 0);
return ( return (
/** /**
* @this {ol.source.ImageTileSource}
* @param {ol.TileCoord} tileCoord Tile Coordinate. * @param {ol.TileCoord} tileCoord Tile Coordinate.
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.