Merge pull request #3815 from ahocevar/tilegrid-no-surprises
Simplify tilegrid API and internals
This commit is contained in:
@@ -192,7 +192,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
|
||||
tileLayerZ = this.tileLayerZs_[tileLayerZKey];
|
||||
} else {
|
||||
tileCoordOrigin =
|
||||
tileGrid.getTileCoordForCoordAndZInternal(center, tileLayerZKey);
|
||||
tileGrid.getTileCoordForCoordAndZ(center, tileLayerZKey);
|
||||
tileLayerZ = new ol.renderer.dom.TileLayerZ_(tileGrid, tileCoordOrigin);
|
||||
newTileLayerZKeys[tileLayerZKey] = true;
|
||||
this.tileLayerZs_[tileLayerZKey] = tileLayerZ;
|
||||
|
||||
@@ -118,6 +118,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
goog.array.map(
|
||||
resource.imageUrlSubdomains,
|
||||
function(subdomain) {
|
||||
var quadKeyTileCoord = [0, 0, 0];
|
||||
var imageUrl = resource.imageUrl
|
||||
.replace('{subdomain}', subdomain)
|
||||
.replace('{culture}', culture);
|
||||
@@ -135,8 +136,10 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return undefined;
|
||||
} else {
|
||||
return imageUrl.replace(
|
||||
'{quadkey}', ol.tilecoord.quadKey(tileCoord));
|
||||
ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1],
|
||||
-tileCoord[2] - 1, quadKeyTileCoord);
|
||||
return imageUrl.replace('{quadkey}', ol.tilecoord.quadKey(
|
||||
quadKeyTileCoord));
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -91,7 +91,8 @@ ol.source.TileDebug = function(options) {
|
||||
goog.base(this, {
|
||||
opaque: false,
|
||||
projection: options.projection,
|
||||
tileGrid: options.tileGrid
|
||||
tileGrid: options.tileGrid,
|
||||
wrapX: goog.isDef(options.wrapX) ? options.wrapX : true
|
||||
});
|
||||
|
||||
};
|
||||
@@ -108,8 +109,9 @@ ol.source.TileDebug.prototype.getTile = function(z, x, y) {
|
||||
} else {
|
||||
var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z));
|
||||
var tileCoord = [z, x, y];
|
||||
var text = ol.tilecoord.toString(
|
||||
this.getTileCoordForTileUrlFunction(tileCoord));
|
||||
var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
|
||||
var text = goog.isNull(textTileCoord) ? '' : ol.tilecoord.toString(
|
||||
this.getTileCoordForTileUrlFunction(textTileCoord));
|
||||
var tile = new ol.DebugTile_(tileCoord, tileSize, text);
|
||||
this.tileCache.set(tileCoordKey, tile);
|
||||
return tile;
|
||||
|
||||
@@ -217,8 +217,7 @@ ol.source.Tile.prototype.getTilePixelSize =
|
||||
|
||||
|
||||
/**
|
||||
* Handles x-axis wrapping and returns a tile coordinate transformed from the
|
||||
* internal tile scheme to the tile grid's tile scheme. When the tile coordinate
|
||||
* Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
|
||||
* is outside the resolution and extent range of the tile grid, `null` will be
|
||||
* returned.
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
@@ -235,8 +234,7 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction =
|
||||
if (this.getWrapX()) {
|
||||
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
|
||||
}
|
||||
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ?
|
||||
tileGrid.transformTileCoord(tileCoord) : null;
|
||||
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ? tileCoord : null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ ol.source.TileUTFGrid.prototype.getTemplate = function() {
|
||||
ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function(
|
||||
coordinate, resolution, callback, opt_this, opt_request) {
|
||||
if (!goog.isNull(this.tileGrid)) {
|
||||
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolutionInternal(
|
||||
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
|
||||
coordinate, resolution);
|
||||
var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile(
|
||||
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));
|
||||
|
||||
@@ -116,7 +116,7 @@ ol.source.TileVector.prototype.forEachFeatureAtCoordinateAndResolution =
|
||||
|
||||
var tileGrid = this.tileGrid_;
|
||||
var tiles = this.tiles_;
|
||||
var tileCoord = tileGrid.getTileCoordForCoordAndResolutionInternal(coordinate,
|
||||
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate,
|
||||
resolution);
|
||||
|
||||
var tileKey = this.getTileKeyZXY_(tileCoord[0], tileCoord[1], tileCoord[2]);
|
||||
@@ -250,7 +250,7 @@ ol.source.TileVector.prototype.getTileCoordForTileUrlFunction =
|
||||
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
|
||||
}
|
||||
return ol.tilecoord.withinExtentAndZ(tileCoord, tileGrid) ?
|
||||
tileGrid.transformTileCoord(tileCoord) : null;
|
||||
tileCoord : null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
|
||||
tileGrid = this.getTileGridForProjection(projectionObj);
|
||||
}
|
||||
|
||||
var tileCoord = tileGrid.getTileCoordForCoordAndResolutionInternal(
|
||||
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(
|
||||
coordinate, resolution);
|
||||
|
||||
if (tileGrid.getResolutions().length <= tileCoord[0]) {
|
||||
|
||||
@@ -159,7 +159,7 @@ ol.source.WMTS = function(options) {
|
||||
var localContext = {
|
||||
'TileMatrix': tileGrid.getMatrixId(tileCoord[0]),
|
||||
'TileCol': tileCoord[1],
|
||||
'TileRow': tileCoord[2]
|
||||
'TileRow': -tileCoord[2] - 1
|
||||
};
|
||||
goog.object.extend(localContext, dimensions);
|
||||
var url = template;
|
||||
|
||||
@@ -6,9 +6,10 @@ goog.require('ol.ImageTile');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileState');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.TileImage');
|
||||
goog.require('ol.tilegrid.Zoomify');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,8 +87,10 @@ ol.source.Zoomify = function(opt_options) {
|
||||
}
|
||||
resolutions.reverse();
|
||||
|
||||
var tileGrid = new ol.tilegrid.Zoomify({
|
||||
extent: [0, 0, size[0], size[1]],
|
||||
var extent = [0, -size[1], size[0], 0];
|
||||
var tileGrid = new ol.tilegrid.TileGrid({
|
||||
extent: extent,
|
||||
origin: ol.extent.getTopLeft(extent),
|
||||
resolutions: resolutions
|
||||
});
|
||||
|
||||
@@ -106,7 +109,7 @@ ol.source.Zoomify = function(opt_options) {
|
||||
} else {
|
||||
var tileCoordZ = tileCoord[0];
|
||||
var tileCoordX = tileCoord[1];
|
||||
var tileCoordY = tileCoord[2];
|
||||
var tileCoordY = -tileCoord[2] - 1;
|
||||
var tileIndex =
|
||||
tileCoordX +
|
||||
tileCoordY * tierSizeInTiles[tileCoordZ][0] +
|
||||
|
||||
@@ -26,33 +26,6 @@ ol.QuadKeyCharCode = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} quadKey Quad key.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
ol.tilecoord.createFromQuadKey = function(quadKey) {
|
||||
var z = quadKey.length, x = 0, y = 0;
|
||||
var mask = 1 << (z - 1);
|
||||
var i;
|
||||
for (i = 0; i < z; ++i) {
|
||||
switch (quadKey.charCodeAt(i)) {
|
||||
case ol.QuadKeyCharCode.ONE:
|
||||
x += mask;
|
||||
break;
|
||||
case ol.QuadKeyCharCode.TWO:
|
||||
y += mask;
|
||||
break;
|
||||
case ol.QuadKeyCharCode.THREE:
|
||||
x += mask;
|
||||
y += mask;
|
||||
break;
|
||||
}
|
||||
mask >>= 1;
|
||||
}
|
||||
return [z, x, y];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} str String that follows pattern “z/x/y” where x, y and z are
|
||||
* numbers.
|
||||
@@ -155,7 +128,7 @@ ol.tilecoord.wrapX = function(tileCoord, tileGrid, projection) {
|
||||
var worldWidth = ol.extent.getWidth(projectionExtent);
|
||||
var worldsAway = Math.ceil((projectionExtent[0] - center[0]) / worldWidth);
|
||||
center[0] += worldWidth * worldsAway;
|
||||
return tileGrid.getTileCoordForCoordAndZInternal(center, z);
|
||||
return tileGrid.getTileCoordForCoordAndZ(center, z);
|
||||
} else {
|
||||
return tileCoord;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ goog.provide('ol.tilegrid.TileGrid');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.functions');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol');
|
||||
@@ -75,7 +74,7 @@ ol.tilegrid.TileGrid = function(options) {
|
||||
|
||||
if (goog.isDef(extent) &&
|
||||
goog.isNull(this.origin_) && goog.isNull(this.origins_)) {
|
||||
this.origin_ = ol.extent.getBottomLeft(extent);
|
||||
this.origin_ = ol.extent.getTopLeft(extent);
|
||||
}
|
||||
|
||||
goog.asserts.assert(
|
||||
@@ -113,17 +112,6 @@ ol.tilegrid.TileGrid = function(options) {
|
||||
this.extent_ = goog.isDef(extent) ? extent : null;
|
||||
|
||||
|
||||
/**
|
||||
* TileCoord transform function for use with this tile grid. Transforms the
|
||||
* internal tile coordinates with bottom-left origin to the tile coordinates
|
||||
* used by the source's {@link ol.TileUrlFunction}.
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination tile coordinate.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
this.transformTileCoord = goog.isDef(options.transformTileCoord) ?
|
||||
options.transformTileCoord : goog.functions.identity;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.TileRange>}
|
||||
@@ -134,13 +122,11 @@ ol.tilegrid.TileGrid = function(options) {
|
||||
goog.asserts.assert(options.sizes.length == this.resolutions_.length,
|
||||
'number of sizes and resolutions must be equal');
|
||||
this.fullTileRanges_ = goog.array.map(options.sizes, function(size, z) {
|
||||
goog.asserts.assert(size[0] > 0, 'width must be > 0');
|
||||
goog.asserts.assert(size[0] !== 0, 'width must not be 0');
|
||||
goog.asserts.assert(size[1] !== 0, 'height must not be 0');
|
||||
var tileRange = new ol.TileRange(0, size[0] - 1, 0, size[1] - 1);
|
||||
if (tileRange.maxY < tileRange.minY) {
|
||||
tileRange.minY = size[1];
|
||||
tileRange.maxY = -1;
|
||||
}
|
||||
var tileRange = new ol.TileRange(
|
||||
Math.min(0, size[0]), Math.max(size[0] - 1, -1),
|
||||
Math.min(0, size[1]), Math.max(size[1] - 1, -1));
|
||||
if (this.minZoom <= z && z <= this.maxZoom && goog.isDef(extent)) {
|
||||
goog.asserts.assert(tileRange.containsTileRange(
|
||||
this.getTileRangeForExtentAndZ(extent, z)),
|
||||
@@ -380,29 +366,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent =
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
* @api
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution = function(
|
||||
coordinate, resolution, opt_tileCoord) {
|
||||
var tileCoord = this.getTileCoordForCoordAndResolutionInternal(
|
||||
coordinate, resolution, opt_tileCoord);
|
||||
this.transformTileCoord(tileCoord, tileCoord);
|
||||
return tileCoord;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the tile coordinate for the given map coordinate and resolution. This
|
||||
* method considers that coordinates that intersect tile boundaries should be
|
||||
* assigned the higher tile coordinate.
|
||||
*
|
||||
* The returned tile coordinate is the internal, untransformed one with
|
||||
* bottom-left origin.
|
||||
*
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination ol.TileCoord object.
|
||||
* @return {ol.TileCoord} Internal, untransformed tile coordinate.
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolutionInternal =
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution =
|
||||
function(coordinate, resolution, opt_tileCoord) {
|
||||
return this.getTileCoordForXYAndResolution_(
|
||||
coordinate[0], coordinate[1], resolution, false, opt_tileCoord);
|
||||
@@ -427,9 +391,10 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
|
||||
var origin = this.getOrigin(z);
|
||||
var tileSize = ol.size.toSize(this.getTileSize(z), this.tmpSize_);
|
||||
|
||||
var adjust = reverseIntersectionPolicy ? 0.5 : 0;
|
||||
var xFromOrigin = ((x - origin[0]) / resolution + adjust) | 0;
|
||||
var yFromOrigin = ((y - origin[1]) / resolution + adjust) | 0;
|
||||
var adjustX = reverseIntersectionPolicy ? 0.5 : 0;
|
||||
var adjustY = reverseIntersectionPolicy ? 0 : 0.5;
|
||||
var xFromOrigin = Math.floor((x - origin[0]) / resolution + adjustX);
|
||||
var yFromOrigin = Math.floor((y - origin[1]) / resolution + adjustY);
|
||||
var tileCoordX = scale * xFromOrigin / tileSize[0];
|
||||
var tileCoordY = scale * yFromOrigin / tileSize[1];
|
||||
|
||||
@@ -453,24 +418,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
* @api
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ = function(
|
||||
coordinate, z, opt_tileCoord) {
|
||||
var tileCoord = this.getTileCoordForCoordAndZInternal(
|
||||
coordinate, z, opt_tileCoord);
|
||||
this.transformTileCoord(tileCoord, tileCoord);
|
||||
return tileCoord;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get a tile coordinate given a map coordinate and zoom level. The returned
|
||||
* tile coordinate is the internal one, untransformed with bottom-left origin.
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @param {number} z Zoom level.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination ol.TileCoord object.
|
||||
* @return {ol.TileCoord} Internal, untransformed tile coordinate.
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZInternal =
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ =
|
||||
function(coordinate, z, opt_tileCoord) {
|
||||
var resolution = this.getResolution(z);
|
||||
return this.getTileCoordForXYAndResolution_(
|
||||
@@ -544,15 +492,10 @@ ol.tilegrid.TileGrid.prototype.getZForResolution = function(resolution) {
|
||||
* @private
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.calculateTileRanges_ = function(extent) {
|
||||
var extentWidth = ol.extent.getWidth(extent);
|
||||
var extentHeight = ol.extent.getHeight(extent);
|
||||
var fullTileRanges = new Array(this.resolutions_.length);
|
||||
var tileSize;
|
||||
for (var z = 0, zz = fullTileRanges.length; z < zz; ++z) {
|
||||
tileSize = ol.size.toSize(this.getTileSize(z), this.tmpSize_);
|
||||
fullTileRanges[z] = new ol.TileRange(
|
||||
0, Math.ceil(extentWidth / tileSize[0] / this.resolutions_[z]) - 1,
|
||||
0, Math.ceil(extentHeight / tileSize[1] / this.resolutions_[z]) - 1);
|
||||
var length = this.resolutions_.length;
|
||||
var fullTileRanges = new Array(length);
|
||||
for (var z = this.minZoom; z < length; ++z) {
|
||||
fullTileRanges[z] = this.getTileRangeForExtentAndZ(extent, z);
|
||||
}
|
||||
this.fullTileRanges_ = fullTileRanges;
|
||||
};
|
||||
@@ -579,13 +522,13 @@ ol.tilegrid.getForProjection = function(projection) {
|
||||
* @param {number|ol.Size=} opt_tileSize Tile size (default uses
|
||||
* ol.DEFAULT_TILE_SIZE).
|
||||
* @param {ol.extent.Corner=} opt_corner Extent corner (default is
|
||||
* ol.extent.Corner.BOTTOM_LEFT).
|
||||
* ol.extent.Corner.TOP_LEFT).
|
||||
* @return {ol.tilegrid.TileGrid} TileGrid instance.
|
||||
*/
|
||||
ol.tilegrid.createForExtent =
|
||||
function(extent, opt_maxZoom, opt_tileSize, opt_corner) {
|
||||
var corner = goog.isDef(opt_corner) ?
|
||||
opt_corner : ol.extent.Corner.BOTTOM_LEFT;
|
||||
opt_corner : ol.extent.Corner.TOP_LEFT;
|
||||
|
||||
var resolutions = ol.tilegrid.resolutionsFromExtent(
|
||||
extent, opt_maxZoom, opt_tileSize);
|
||||
@@ -616,8 +559,6 @@ ol.tilegrid.createXYZ = function(opt_options) {
|
||||
options.extent, options.maxZoom, options.tileSize);
|
||||
delete options.maxZoom;
|
||||
|
||||
options.transformTileCoord = ol.tilegrid.originTopLeftTileCoordTransform;
|
||||
|
||||
return new ol.tilegrid.TileGrid(options);
|
||||
};
|
||||
|
||||
@@ -686,23 +627,3 @@ ol.tilegrid.extentFromProjection = function(projection) {
|
||||
}
|
||||
return extent;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination tile coordinate.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
* @this {ol.tilegrid.TileGrid}
|
||||
*/
|
||||
ol.tilegrid.originTopLeftTileCoordTransform =
|
||||
function(tileCoord, opt_tileCoord) {
|
||||
if (goog.isNull(tileCoord)) {
|
||||
return null;
|
||||
}
|
||||
var z = tileCoord[0];
|
||||
var fullTileRange = this.getFullTileRange(z);
|
||||
var height = (goog.isNull(fullTileRange) || fullTileRange.minY < 0) ?
|
||||
0 : fullTileRange.getHeight();
|
||||
return ol.tilecoord.createOrUpdate(
|
||||
z, tileCoord[1], height - tileCoord[2] - 1, opt_tileCoord);
|
||||
};
|
||||
|
||||
@@ -38,8 +38,7 @@ ol.tilegrid.WMTS = function(options) {
|
||||
resolutions: options.resolutions,
|
||||
tileSize: options.tileSize,
|
||||
tileSizes: options.tileSizes,
|
||||
sizes: options.sizes,
|
||||
transformTileCoord: ol.tilegrid.originTopLeftTileCoordTransform
|
||||
sizes: options.sizes
|
||||
});
|
||||
|
||||
};
|
||||
@@ -116,7 +115,6 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet =
|
||||
metersPerUnit;
|
||||
var tileWidth = elt[tileWidthPropName];
|
||||
var tileHeight = elt[tileHeightPropName];
|
||||
var matrixHeight = elt['MatrixHeight'];
|
||||
if (switchOriginXY) {
|
||||
origins.push([elt[topLeftCornerPropName][1],
|
||||
elt[topLeftCornerPropName][0]]);
|
||||
@@ -127,7 +125,7 @@ ol.tilegrid.WMTS.createFromCapabilitiesMatrixSet =
|
||||
tileSizes.push(tileWidth == tileHeight ?
|
||||
tileWidth : [tileWidth, tileHeight]);
|
||||
// top-left origin, so height is negative
|
||||
sizes.push([elt['MatrixWidth'], -matrixHeight]);
|
||||
sizes.push([elt['MatrixWidth'], -elt['MatrixHeight']]);
|
||||
});
|
||||
|
||||
return new ol.tilegrid.WMTS({
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
goog.provide('ol.tilegrid.Zoomify');
|
||||
|
||||
goog.require('goog.math');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.tilecoord');
|
||||
goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Set the grid pattern for sources accessing Zoomify tiled-image servers.
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.tilegrid.TileGrid}
|
||||
* @param {olx.tilegrid.ZoomifyOptions=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
ol.tilegrid.Zoomify = function(opt_options) {
|
||||
var options = goog.isDef(opt_options) ? opt_options : options;
|
||||
|
||||
/** @type {Array.<ol.TileRange>} */
|
||||
var tileRangeByZ = goog.isDef(options.extent) ? [] : null;
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {ol.TileCoord=} opt_tileCoord Destination tile coordinate.
|
||||
* @return {ol.TileCoord} Tile coordinate.
|
||||
*/
|
||||
function transformTileCoord(tileCoord, opt_tileCoord) {
|
||||
var z = tileCoord[0];
|
||||
if (z < minZ || maxZ < z) {
|
||||
return null;
|
||||
}
|
||||
var n = Math.pow(2, z);
|
||||
var x = tileCoord[1];
|
||||
if (x < 0 || n <= x) {
|
||||
return null;
|
||||
}
|
||||
var y = tileCoord[2];
|
||||
if (y < -n || -1 < y) {
|
||||
return null;
|
||||
}
|
||||
if (!goog.isNull(tileRangeByZ)) {
|
||||
if (!tileRangeByZ[z].containsXY(x, -y - 1)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return ol.tilecoord.createOrUpdate(z, x, -y - 1, opt_tileCoord);
|
||||
}
|
||||
|
||||
goog.base(this, {
|
||||
origin: [0, 0],
|
||||
resolutions: options.resolutions,
|
||||
transformTileCoord: transformTileCoord
|
||||
});
|
||||
|
||||
if (goog.isDef(options.extent)) {
|
||||
var minZ = this.minZoom;
|
||||
var maxZ = this.maxZoom;
|
||||
tileRangeByZ = [];
|
||||
var z;
|
||||
for (z = 0; z <= maxZ; ++z) {
|
||||
if (z < minZ) {
|
||||
tileRangeByZ[z] = null;
|
||||
} else {
|
||||
tileRangeByZ[z] = this.getTileRangeForExtentAndZ(options.extent, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
goog.inherits(ol.tilegrid.Zoomify, ol.tilegrid.TileGrid);
|
||||
@@ -54,9 +54,12 @@ ol.TileUrlFunction.createFromTemplate = function(template) {
|
||||
} else {
|
||||
return template.replace(zRegEx, tileCoord[0].toString())
|
||||
.replace(xRegEx, tileCoord[1].toString())
|
||||
.replace(yRegEx, tileCoord[2].toString())
|
||||
.replace(yRegEx, function() {
|
||||
var y = -tileCoord[2] - 1;
|
||||
return y.toString();
|
||||
})
|
||||
.replace(dashYRegEx, function() {
|
||||
var y = (1 << tileCoord[0]) - tileCoord[2] - 1;
|
||||
var y = (1 << tileCoord[0]) + tileCoord[2];
|
||||
return y.toString();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user