Make tile URL functions more general
This commit is contained in:
@@ -91,6 +91,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
this.tileGrid = tileGrid;
|
this.tileGrid = tileGrid;
|
||||||
|
|
||||||
var culture = this.culture_;
|
var culture = this.culture_;
|
||||||
|
var sourceProjection = this.getProjection();
|
||||||
this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
this.tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
|
||||||
tileGrid.createTileCoordTransform(),
|
tileGrid.createTileCoordTransform(),
|
||||||
ol.TileUrlFunction.createFromTileUrlFunctions(
|
ol.TileUrlFunction.createFromTileUrlFunctions(
|
||||||
@@ -102,7 +103,6 @@ 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 {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -110,7 +110,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
|||||||
*/
|
*/
|
||||||
function(tileCoord, pixelRatio, projection) {
|
function(tileCoord, pixelRatio, projection) {
|
||||||
goog.asserts.assert(ol.proj.equivalent(
|
goog.asserts.assert(ol.proj.equivalent(
|
||||||
projection, this.getProjection()));
|
projection, sourceProjection));
|
||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ goog.require('ol.TileCoord');
|
|||||||
* A function that takes an {@link ol.TileCoord} for the tile coordinate,
|
* A function that takes an {@link ol.TileCoord} for the tile coordinate,
|
||||||
* a `{number}` representing the pixel ratio and an {@link ol.proj.Projection}
|
* a `{number}` representing the pixel ratio and an {@link ol.proj.Projection}
|
||||||
* for the projection as arguments and returns a `{string}` or
|
* for the projection as arguments and returns a `{string}` or
|
||||||
* undefined representing the tile URL. The this keyword inside the function
|
* undefined representing the tile URL.
|
||||||
* references the {@link ol.source.TileImage}.
|
|
||||||
*
|
*
|
||||||
* @typedef {function(this: ol.source.TileImage, ol.TileCoord,
|
* @typedef {function(ol.TileCoord, number,
|
||||||
* number, ol.proj.Projection): (string|undefined)}
|
* ol.proj.Projection): (string|undefined)}
|
||||||
* @todo stability experimental
|
* @todo stability experimental
|
||||||
*/
|
*/
|
||||||
ol.TileUrlFunctionType;
|
ol.TileUrlFunctionType;
|
||||||
@@ -34,7 +33,6 @@ ol.TileCoordTransformType;
|
|||||||
ol.TileUrlFunction.createFromTemplate = function(template) {
|
ol.TileUrlFunction.createFromTemplate = function(template) {
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.TileImage}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -72,7 +70,6 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.TileImage}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -84,15 +81,13 @@ ol.TileUrlFunction.createFromTileUrlFunctions = function(tileUrlFunctions) {
|
|||||||
} else {
|
} else {
|
||||||
var index =
|
var index =
|
||||||
goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
|
goog.math.modulo(tileCoord.hash(), tileUrlFunctions.length);
|
||||||
return tileUrlFunctions[index].call(
|
return tileUrlFunctions[index](tileCoord, pixelRatio, projection);
|
||||||
this, tileCoord, pixelRatio, projection);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.TileImage}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -114,7 +109,6 @@ ol.TileUrlFunction.withTileCoordTransform =
|
|||||||
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
|
||||||
return (
|
return (
|
||||||
/**
|
/**
|
||||||
* @this {ol.source.TileImage}
|
|
||||||
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
* @param {ol.TileCoord} tileCoord Tile Coordinate.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @param {ol.proj.Projection} projection Projection.
|
* @param {ol.proj.Projection} projection Projection.
|
||||||
@@ -124,9 +118,8 @@ ol.TileUrlFunction.withTileCoordTransform =
|
|||||||
if (goog.isNull(tileCoord)) {
|
if (goog.isNull(tileCoord)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
return tileUrlFunction.call(
|
return tileUrlFunction(
|
||||||
this,
|
transformFn(tileCoord, projection, tmpTileCoord),
|
||||||
transformFn.call(this, tileCoord, projection, tmpTileCoord),
|
|
||||||
pixelRatio,
|
pixelRatio,
|
||||||
projection);
|
projection);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user