Merge pull request #677 from twpayne/improve-type-checking
Improve type checking
This commit is contained in:
+28
-8
@@ -17,7 +17,12 @@ ol.animation.bounce = function(options) {
|
|||||||
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
||||||
var easing = goog.isDef(options.easing) ?
|
var easing = goog.isDef(options.easing) ?
|
||||||
options.easing : ol.easing.upAndDown;
|
options.easing : ol.easing.upAndDown;
|
||||||
return function(map, frameState) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.Map} map Map.
|
||||||
|
* @param {?ol.FrameState} frameState Frame state.
|
||||||
|
*/
|
||||||
|
function(map, frameState) {
|
||||||
if (frameState.time < start) {
|
if (frameState.time < start) {
|
||||||
frameState.animate = true;
|
frameState.animate = true;
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
@@ -32,7 +37,7 @@ ol.animation.bounce = function(options) {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +53,12 @@ ol.animation.pan = function(options) {
|
|||||||
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
||||||
var easing = goog.isDef(options.easing) ?
|
var easing = goog.isDef(options.easing) ?
|
||||||
options.easing : ol.easing.inAndOut;
|
options.easing : ol.easing.inAndOut;
|
||||||
return function(map, frameState) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.Map} map Map.
|
||||||
|
* @param {?ol.FrameState} frameState Frame state.
|
||||||
|
*/
|
||||||
|
function(map, frameState) {
|
||||||
if (frameState.time < start) {
|
if (frameState.time < start) {
|
||||||
frameState.animate = true;
|
frameState.animate = true;
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
@@ -65,7 +75,7 @@ ol.animation.pan = function(options) {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -80,7 +90,12 @@ ol.animation.rotate = function(options) {
|
|||||||
var easing = goog.isDef(options.easing) ?
|
var easing = goog.isDef(options.easing) ?
|
||||||
options.easing : ol.easing.inAndOut;
|
options.easing : ol.easing.inAndOut;
|
||||||
|
|
||||||
return function(map, frameState) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.Map} map Map.
|
||||||
|
* @param {?ol.FrameState} frameState Frame state.
|
||||||
|
*/
|
||||||
|
function(map, frameState) {
|
||||||
if (frameState.time < start) {
|
if (frameState.time < start) {
|
||||||
frameState.animate = true;
|
frameState.animate = true;
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
@@ -96,7 +111,7 @@ ol.animation.rotate = function(options) {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -110,7 +125,12 @@ ol.animation.zoom = function(options) {
|
|||||||
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
var duration = goog.isDef(options.duration) ? options.duration : 1000;
|
||||||
var easing = goog.isDef(options.easing) ?
|
var easing = goog.isDef(options.easing) ?
|
||||||
options.easing : ol.easing.inAndOut;
|
options.easing : ol.easing.inAndOut;
|
||||||
return function(map, frameState) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.Map} map Map.
|
||||||
|
* @param {?ol.FrameState} frameState Frame state.
|
||||||
|
*/
|
||||||
|
function(map, frameState) {
|
||||||
if (frameState.time < start) {
|
if (frameState.time < start) {
|
||||||
frameState.animate = true;
|
frameState.animate = true;
|
||||||
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
|
||||||
@@ -126,5 +146,5 @@ ol.animation.zoom = function(options) {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,9 +35,14 @@ ol.coordinate.add = function(coordinate, delta) {
|
|||||||
* @return {ol.CoordinateFormatType} Coordinate format.
|
* @return {ol.CoordinateFormatType} Coordinate format.
|
||||||
*/
|
*/
|
||||||
ol.coordinate.createStringXY = function(opt_precision) {
|
ol.coordinate.createStringXY = function(opt_precision) {
|
||||||
return function(coordinate) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.Coordinate|undefined} coordinate Coordinate.
|
||||||
|
* @return {string} String XY.
|
||||||
|
*/
|
||||||
|
function(coordinate) {
|
||||||
return ol.coordinate.toStringXY(coordinate, opt_precision);
|
return ol.coordinate.toStringXY(coordinate, opt_precision);
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,15 +15,21 @@ ol.ImageUrlFunctionType;
|
|||||||
* @param {string} baseUrl Base URL (may have query data).
|
* @param {string} baseUrl Base URL (may have query data).
|
||||||
* @param {Object.<string,*>} params to encode in the url.
|
* @param {Object.<string,*>} params to encode in the url.
|
||||||
* @param {function(string, Object.<string,*>, ol.Extent, ol.Size,
|
* @param {function(string, Object.<string,*>, ol.Extent, ol.Size,
|
||||||
* ol.Projection)} paramsFunction params function.
|
* ol.Projection): (string|undefined)} paramsFunction params function.
|
||||||
* @return {ol.ImageUrlFunctionType} Image URL function.
|
* @return {ol.ImageUrlFunctionType} Image URL function.
|
||||||
*/
|
*/
|
||||||
ol.ImageUrlFunction.createFromParamsFunction =
|
ol.ImageUrlFunction.createFromParamsFunction =
|
||||||
function(baseUrl, params, paramsFunction) {
|
function(baseUrl, params, paramsFunction) {
|
||||||
return function(extent, size, projection) {
|
return (
|
||||||
return paramsFunction(
|
/**
|
||||||
baseUrl, params, extent, size, projection);
|
* @param {ol.Extent} extent Extent.
|
||||||
};
|
* @param {ol.Size} size Size.
|
||||||
|
* @param {ol.Projection} projection Projection.
|
||||||
|
* @return {string|undefined} URL.
|
||||||
|
*/
|
||||||
|
function(extent, size, projection) {
|
||||||
|
return paramsFunction(baseUrl, params, extent, size, projection);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -266,10 +266,17 @@ ol.renderer.Layer.prototype.updateUsedTiles =
|
|||||||
*/
|
*/
|
||||||
ol.renderer.Layer.prototype.createGetTileIfLoadedFunction =
|
ol.renderer.Layer.prototype.createGetTileIfLoadedFunction =
|
||||||
function(isLoadedFunction, tileSource, projection) {
|
function(isLoadedFunction, tileSource, projection) {
|
||||||
return function(z, x, y) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {number} z Z.
|
||||||
|
* @param {number} x X.
|
||||||
|
* @param {number} y Y.
|
||||||
|
* @return {ol.Tile} Tile.
|
||||||
|
*/
|
||||||
|
function(z, x, y) {
|
||||||
var tile = tileSource.getTile(z, x, y, projection);
|
var tile = tileSource.getTile(z, x, y, projection);
|
||||||
return isLoadedFunction(tile) ? tile : null;
|
return isLoadedFunction(tile) ? tile : null;
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,21 @@ ol.ResolutionConstraintType;
|
|||||||
ol.ResolutionConstraint.createContinuous =
|
ol.ResolutionConstraint.createContinuous =
|
||||||
function(power, maxResolution, opt_minResolution) {
|
function(power, maxResolution, opt_minResolution) {
|
||||||
var minResolution = opt_minResolution || 0;
|
var minResolution = opt_minResolution || 0;
|
||||||
return function(resolution, delta, direction) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {number|undefined} resolution Resolution.
|
||||||
|
* @param {number} delta Delta.
|
||||||
|
* @param {number} direction Direction.
|
||||||
|
* @return {number|undefined} Resolution.
|
||||||
|
*/
|
||||||
|
function(resolution, delta, direction) {
|
||||||
if (goog.isDef(resolution)) {
|
if (goog.isDef(resolution)) {
|
||||||
resolution /= Math.pow(power, delta);
|
resolution /= Math.pow(power, delta);
|
||||||
return goog.math.clamp(resolution, minResolution, maxResolution);
|
return goog.math.clamp(resolution, minResolution, maxResolution);
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -37,15 +44,23 @@ ol.ResolutionConstraint.createContinuous =
|
|||||||
*/
|
*/
|
||||||
ol.ResolutionConstraint.createSnapToResolutions =
|
ol.ResolutionConstraint.createSnapToResolutions =
|
||||||
function(resolutions) {
|
function(resolutions) {
|
||||||
return function(resolution, delta, direction) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {number|undefined} resolution Resolution.
|
||||||
|
* @param {number} delta Delta.
|
||||||
|
* @param {number} direction Direction.
|
||||||
|
* @return {number|undefined} Resolution.
|
||||||
|
*/
|
||||||
|
function(resolution, delta, direction) {
|
||||||
if (goog.isDef(resolution)) {
|
if (goog.isDef(resolution)) {
|
||||||
var z = ol.array.linearFindNearest(resolutions, resolution, direction);
|
var z =
|
||||||
|
ol.array.linearFindNearest(resolutions, resolution, direction);
|
||||||
z = goog.math.clamp(z + delta, 0, resolutions.length - 1);
|
z = goog.math.clamp(z + delta, 0, resolutions.length - 1);
|
||||||
return resolutions[z];
|
return resolutions[z];
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -57,7 +72,14 @@ ol.ResolutionConstraint.createSnapToResolutions =
|
|||||||
*/
|
*/
|
||||||
ol.ResolutionConstraint.createSnapToPower =
|
ol.ResolutionConstraint.createSnapToPower =
|
||||||
function(power, maxResolution, opt_maxLevel) {
|
function(power, maxResolution, opt_maxLevel) {
|
||||||
return function(resolution, delta, direction) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {number|undefined} resolution Resolution.
|
||||||
|
* @param {number} delta Delta.
|
||||||
|
* @param {number} direction Direction.
|
||||||
|
* @return {number|undefined} Resolution.
|
||||||
|
*/
|
||||||
|
function(resolution, delta, direction) {
|
||||||
if (goog.isDef(resolution)) {
|
if (goog.isDef(resolution)) {
|
||||||
var offset;
|
var offset;
|
||||||
if (direction > 0) {
|
if (direction > 0) {
|
||||||
@@ -77,5 +99,5 @@ ol.ResolutionConstraint.createSnapToPower =
|
|||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,14 +28,20 @@ ol.RotationConstraint.none = function(rotation, delta) {
|
|||||||
*/
|
*/
|
||||||
ol.RotationConstraint.createSnapToN = function(n) {
|
ol.RotationConstraint.createSnapToN = function(n) {
|
||||||
var theta = 2 * Math.PI / n;
|
var theta = 2 * Math.PI / n;
|
||||||
return function(rotation, delta) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {number|undefined} rotation Rotation.
|
||||||
|
* @param {number} delta Delta.
|
||||||
|
* @return {number|undefined} Rotation.
|
||||||
|
*/
|
||||||
|
function(rotation, delta) {
|
||||||
if (goog.isDef(rotation)) {
|
if (goog.isDef(rotation)) {
|
||||||
rotation = Math.floor((rotation + delta) / theta + 0.5) * theta;
|
rotation = Math.floor((rotation + delta) / theta + 0.5) * theta;
|
||||||
return rotation;
|
return rotation;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +51,13 @@ ol.RotationConstraint.createSnapToN = function(n) {
|
|||||||
*/
|
*/
|
||||||
ol.RotationConstraint.createSnapToZero = function(opt_tolerance) {
|
ol.RotationConstraint.createSnapToZero = function(opt_tolerance) {
|
||||||
var tolerance = opt_tolerance || 0.1;
|
var tolerance = opt_tolerance || 0.1;
|
||||||
return function(rotation, delta) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {number|undefined} rotation Rotation.
|
||||||
|
* @param {number} delta Delta.
|
||||||
|
* @return {number|undefined} Rotation.
|
||||||
|
*/
|
||||||
|
function(rotation, delta) {
|
||||||
if (goog.isDef(rotation)) {
|
if (goog.isDef(rotation)) {
|
||||||
if (Math.abs(rotation + delta) <= tolerance) {
|
if (Math.abs(rotation + delta) <= tolerance) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -55,5 +67,5 @@ ol.RotationConstraint.createSnapToZero = function(opt_tolerance) {
|
|||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -88,7 +88,13 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
var imageUrl = resource.imageUrl
|
var imageUrl = resource.imageUrl
|
||||||
.replace('{subdomain}', subdomain)
|
.replace('{subdomain}', subdomain)
|
||||||
.replace('{culture}', culture);
|
.replace('{culture}', culture);
|
||||||
return function(tileCoord, projection) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
|
* @param {ol.Projection} projection Projection.
|
||||||
|
* @return {string|undefined} Tile URL.
|
||||||
|
*/
|
||||||
|
function(tileCoord, projection) {
|
||||||
goog.asserts.assert(ol.projection.equivalent(
|
goog.asserts.assert(ol.projection.equivalent(
|
||||||
projection, this.getProjection()));
|
projection, this.getProjection()));
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
@@ -97,7 +103,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
return imageUrl.replace(
|
return imageUrl.replace(
|
||||||
'{quadkey}', tileCoord.quadKey());
|
'{quadkey}', tileCoord.quadKey());
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
})));
|
})));
|
||||||
|
|
||||||
var transform = ol.projection.getTransformFromProjections(
|
var transform = ol.projection.getTransformFromProjections(
|
||||||
|
|||||||
@@ -60,7 +60,14 @@ ol.source.StaticImage.prototype.getImage =
|
|||||||
* @return {ol.ImageUrlFunctionType} Function.
|
* @return {ol.ImageUrlFunctionType} Function.
|
||||||
*/
|
*/
|
||||||
ol.source.StaticImage.createImageFunction = function(url) {
|
ol.source.StaticImage.createImageFunction = function(url) {
|
||||||
return function(extent, size, projection) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.Extent} extent Extent.
|
||||||
|
* @param {ol.Size} size Size.
|
||||||
|
* @param {ol.Projection} projection Projection.
|
||||||
|
* @return {string|undefined} URL.
|
||||||
|
*/
|
||||||
|
function(extent, size, projection) {
|
||||||
return url;
|
return url;
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -73,7 +73,12 @@ ol.source.WMTS = function(options) {
|
|||||||
* @return {ol.TileUrlFunctionType} Tile URL function.
|
* @return {ol.TileUrlFunctionType} Tile URL function.
|
||||||
*/
|
*/
|
||||||
function createFromWMTSTemplate(template) {
|
function createFromWMTSTemplate(template) {
|
||||||
return function(tileCoord) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
|
* @return {string|undefined} Tile URL.
|
||||||
|
*/
|
||||||
|
function(tileCoord) {
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
@@ -93,7 +98,7 @@ ol.source.WMTS = function(options) {
|
|||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;
|
var tileUrlFunction = ol.TileUrlFunction.nullTileUrlFunction;
|
||||||
|
|||||||
+37
-12
@@ -18,15 +18,21 @@ ol.TileUrlFunctionType;
|
|||||||
* @return {ol.TileUrlFunctionType} Tile URL function.
|
* @return {ol.TileUrlFunctionType} Tile URL function.
|
||||||
*/
|
*/
|
||||||
ol.TileUrlFunction.createFromTemplate = function(template) {
|
ol.TileUrlFunction.createFromTemplate = function(template) {
|
||||||
return function(tileCoord) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
|
* @param {ol.Projection} projection Projection.
|
||||||
|
* @return {string|undefined} Tile URL.
|
||||||
|
*/
|
||||||
|
function(tileCoord, projection) {
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
return template.replace('{z}', tileCoord.z)
|
return template.replace('{z}', '' + tileCoord.z)
|
||||||
.replace('{x}', tileCoord.x)
|
.replace('{x}', '' + tileCoord.x)
|
||||||
.replace('{y}', tileCoord.y);
|
.replace('{y}', '' + tileCoord.y);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -48,14 +54,21 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
|||||||
if (tileUrlFunctions.length === 1) {
|
if (tileUrlFunctions.length === 1) {
|
||||||
return tileUrlFunctions[0];
|
return tileUrlFunctions[0];
|
||||||
}
|
}
|
||||||
return function(tileCoord, projection) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
|
* @param {ol.Projection} projection Projection.
|
||||||
|
* @return {string|undefined} Tile URL.
|
||||||
|
*/
|
||||||
|
function(tileCoord, projection) {
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
var index = goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
|
var index =
|
||||||
|
goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
|
||||||
return tileUrlFunctions[index].call(this, tileCoord, projection);
|
return tileUrlFunctions[index].call(this, tileCoord, projection);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +82,13 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
|||||||
ol.TileUrlFunction.createFromParamsFunction =
|
ol.TileUrlFunction.createFromParamsFunction =
|
||||||
function(baseUrl, params, paramsFunction) {
|
function(baseUrl, params, paramsFunction) {
|
||||||
var tmpExtent = ol.extent.createEmptyExtent();
|
var tmpExtent = ol.extent.createEmptyExtent();
|
||||||
return function(tileCoord, projection) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
|
* @param {ol.Projection} projection Projection.
|
||||||
|
* @return {string|undefined} Tile URL.
|
||||||
|
*/
|
||||||
|
function(tileCoord, projection) {
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
@@ -82,7 +101,7 @@ ol.TileUrlFunction.createFromParamsFunction =
|
|||||||
return paramsFunction.call(this, baseUrl, params,
|
return paramsFunction.call(this, baseUrl, params,
|
||||||
extent, size, projection);
|
extent, size, projection);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -105,7 +124,13 @@ ol.TileUrlFunction.nullTileUrlFunction = function(tileCoord, projection) {
|
|||||||
ol.TileUrlFunction.withTileCoordTransform =
|
ol.TileUrlFunction.withTileCoordTransform =
|
||||||
function(transformFn, tileUrlFunction) {
|
function(transformFn, tileUrlFunction) {
|
||||||
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||||
return function(tileCoord, projection) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
|
* @param {ol.Projection} projection Projection.
|
||||||
|
* @return {string|undefined} Tile URL.
|
||||||
|
*/
|
||||||
|
function(tileCoord, projection) {
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
@@ -114,7 +139,7 @@ ol.TileUrlFunction.withTileCoordTransform =
|
|||||||
transformFn.call(this, tileCoord, projection, tmpTileCoord),
|
transformFn.call(this, tileCoord, projection, tmpTileCoord),
|
||||||
projection);
|
projection);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+16
-5
@@ -231,12 +231,17 @@ ol.View2D.prototype.getResolutionForValueFunction = function(opt_power) {
|
|||||||
var maxResolution = this.maxResolution_;
|
var maxResolution = this.maxResolution_;
|
||||||
var minResolution = this.minResolution_;
|
var minResolution = this.minResolution_;
|
||||||
var max = Math.log(maxResolution / minResolution) / Math.log(power);
|
var max = Math.log(maxResolution / minResolution) / Math.log(power);
|
||||||
return function(value) {
|
return (
|
||||||
|
/**
|
||||||
|
* @param {number} value Value.
|
||||||
|
* @return {number} Resolution.
|
||||||
|
*/
|
||||||
|
function(value) {
|
||||||
var resolution = maxResolution / Math.pow(power, value * max);
|
var resolution = maxResolution / Math.pow(power, value * max);
|
||||||
goog.asserts.assert(resolution >= minResolution &&
|
goog.asserts.assert(resolution >= minResolution &&
|
||||||
resolution <= maxResolution);
|
resolution <= maxResolution);
|
||||||
return resolution;
|
return resolution;
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -264,11 +269,17 @@ ol.View2D.prototype.getValueForResolutionFunction = function(opt_power) {
|
|||||||
var maxResolution = this.maxResolution_;
|
var maxResolution = this.maxResolution_;
|
||||||
var minResolution = this.minResolution_;
|
var minResolution = this.minResolution_;
|
||||||
var max = Math.log(maxResolution / minResolution) / Math.log(power);
|
var max = Math.log(maxResolution / minResolution) / Math.log(power);
|
||||||
return function(resolution) {
|
return (
|
||||||
var value = (Math.log(maxResolution / resolution) / Math.log(power)) / max;
|
/**
|
||||||
|
* @param {number} resolution Resolution.
|
||||||
|
* @return {number} Value.
|
||||||
|
*/
|
||||||
|
function(resolution) {
|
||||||
|
var value =
|
||||||
|
(Math.log(maxResolution / resolution) / Math.log(power)) / max;
|
||||||
goog.asserts.assert(value >= 0 && value <= 1);
|
goog.asserts.assert(value >= 0 && value <= 1);
|
||||||
return value;
|
return value;
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user