Merge pull request #2539 from elemoine/tilecoord

Change ol.TileCoord to Array.<number>
This commit is contained in:
Éric Lemoine
2014-08-18 10:21:35 +02:00
29 changed files with 318 additions and 323 deletions

View File

@@ -12,6 +12,7 @@ goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.source.State');
goog.require('ol.source.TileImage');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid.XYZ');
@@ -120,7 +121,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
return undefined;
} else {
return imageUrl.replace(
'{quadkey}', tileCoord.quadKey());
'{quadkey}', ol.tilecoord.quadKey(tileCoord));
}
});
})));

View File

@@ -6,6 +6,7 @@ goog.require('ol.TileCoord');
goog.require('ol.TileState');
goog.require('ol.dom');
goog.require('ol.source.Tile');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid.TileGrid');
@@ -25,7 +26,7 @@ ol.DebugTile_ = function(tileCoord, tileGrid) {
* @private
* @type {number}
*/
this.tileSize_ = tileGrid.getTileSize(tileCoord.z);
this.tileSize_ = tileGrid.getTileSize(tileCoord[0]);
/**
* @private
@@ -56,7 +57,8 @@ ol.DebugTile_.prototype.getImage = function(opt_context) {
context.textAlign = 'center';
context.textBaseline = 'middle';
context.font = '24px sans-serif';
context.fillText(this.tileCoord.toString(), tileSize / 2, tileSize / 2);
context.fillText(ol.tilecoord.toString(this.tileCoord),
tileSize / 2, tileSize / 2);
this.canvasByContext_[key] = context.canvas;
return context.canvas;
@@ -121,7 +123,7 @@ ol.source.TileDebug.prototype.getTile = function(z, x, y) {
if (this.tileCache_.containsKey(tileCoordKey)) {
return /** @type {!ol.DebugTile_} */ (this.tileCache_.get(tileCoordKey));
} else {
var tile = new ol.DebugTile_(new ol.TileCoord(z, x, y), this.tileGrid);
var tile = new ol.DebugTile_([z, x, y], this.tileGrid);
this.tileCache_.set(tileCoordKey, tile);
return tile;
}

View File

@@ -110,7 +110,7 @@ ol.source.TileImage.prototype.getTile =
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
} else {
goog.asserts.assert(projection);
var tileCoord = new ol.TileCoord(z, x, y);
var tileCoord = [z, x, y];
var tileUrl = this.tileUrlFunction(tileCoord, pixelRatio, projection);
var tile = new this.tileClass(
tileCoord,

View File

@@ -4,9 +4,9 @@ goog.provide('ol.source.TileOptions');
goog.require('goog.functions');
goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.TileCoord');
goog.require('ol.TileRange');
goog.require('ol.source.Source');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid.TileGrid');
@@ -133,7 +133,7 @@ ol.source.Tile.prototype.getGutter = function() {
* @return {string} Key.
* @protected
*/
ol.source.Tile.prototype.getKeyZXY = ol.TileCoord.getKeyZXY;
ol.source.Tile.prototype.getKeyZXY = ol.tilecoord.getKeyZXY;
/**

View File

@@ -184,15 +184,15 @@ ol.source.TileVector.prototype.loadFeatures =
var tiles = this.tiles_;
var z = tileGrid.getZForResolution(resolution);
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
var tileCoord = new ol.TileCoord(z, 0, 0);
var tileCoord = [z, 0, 0];
var x, y;
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
var tileKey = this.getTileKeyZXY_(z, x, y);
if (!(tileKey in tiles)) {
tileCoord.z = z;
tileCoord.x = x;
tileCoord.y = y;
tileCoord[0] = z;
tileCoord[1] = x;
tileCoord[2] = y;
tileCoordTransform(tileCoord, projection, tileCoord);
var url = tileUrlFunction(tileCoord, 1, projection);
if (goog.isDef(url)) {

View File

@@ -18,6 +18,7 @@ goog.require('ol.proj');
goog.require('ol.source.TileImage');
goog.require('ol.source.wms');
goog.require('ol.source.wms.ServerType');
goog.require('ol.tilecoord');
@@ -150,14 +151,14 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, resolution);
if (tileGrid.getResolutions().length <= tileCoord.z) {
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
}
var tileResolution = tileGrid.getResolution(tileCoord.z);
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(
tileCoord, this.tmpExtent_);
var tileSize = tileGrid.getTileSize(tileCoord.z);
var tileSize = tileGrid.getTileSize(tileCoord[0]);
var gutter = this.gutter_;
if (gutter !== 0) {
@@ -285,7 +286,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ =
if (urls.length == 1) {
url = urls[0];
} else {
var index = goog.math.modulo(tileCoord.hash(), urls.length);
var index = goog.math.modulo(ol.tilecoord.hash(tileCoord), urls.length);
url = urls[index];
}
return goog.uri.utils.appendParamsFromMap(url, params);
@@ -376,7 +377,7 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
tileGrid = this.getTileGridForProjection(projection);
}
if (tileGrid.getResolutions().length <= tileCoord.z) {
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
}
@@ -384,10 +385,10 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
pixelRatio = 1;
}
var tileResolution = tileGrid.getResolution(tileCoord.z);
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(
tileCoord, this.tmpExtent_);
var tileSize = tileGrid.getTileSize(tileCoord.z);
var tileSize = tileGrid.getTileSize(tileCoord[0]);
var gutter = this.gutter_;
if (gutter !== 0) {

View File

@@ -109,9 +109,9 @@ ol.source.WMTS = function(options) {
return undefined;
} else {
var localContext = {
'TileMatrix': tileGrid.getMatrixId(tileCoord.z),
'TileCol': tileCoord.x,
'TileRow': tileCoord.y
'TileMatrix': tileGrid.getMatrixId(tileCoord[0]),
'TileCol': tileCoord[1],
'TileRow': tileCoord[2]
};
goog.object.extend(localContext, dimensions);
var url = template;
@@ -138,7 +138,7 @@ ol.source.WMTS = function(options) {
}
var tmpExtent = ol.extent.createEmpty();
var tmpTileCoord = new ol.TileCoord(0, 0, 0);
var tmpTileCoord = [0, 0, 0];
tileUrlFunction = ol.TileUrlFunction.withTileCoordTransform(
/**
* @param {ol.TileCoord} tileCoord Tile coordinate.
@@ -148,11 +148,11 @@ ol.source.WMTS = function(options) {
*/
function(tileCoord, projection, opt_tileCoord) {
goog.asserts.assert(!goog.isNull(tileGrid));
if (tileGrid.getResolutions().length <= tileCoord.z) {
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return null;
}
var x = tileCoord.x;
var y = -tileCoord.y - 1;
var x = tileCoord[1];
var y = -tileCoord[2] - 1;
var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
var extent = projection.getExtent();
@@ -161,16 +161,16 @@ ol.source.WMTS = function(options) {
ol.extent.getWidth(extent) /
ol.extent.getWidth(tileExtent));
x = goog.math.modulo(x, numCols);
tmpTileCoord.z = tileCoord.z;
tmpTileCoord.x = x;
tmpTileCoord.y = tileCoord.y;
tmpTileCoord[0] = tileCoord[0];
tmpTileCoord[1] = x;
tmpTileCoord[2] = tileCoord[2];
tileExtent = tileGrid.getTileCoordExtent(tmpTileCoord, tmpExtent);
}
if (!ol.extent.intersects(tileExtent, extent) ||
ol.extent.touches(tileExtent, extent)) {
return null;
}
return new ol.TileCoord(tileCoord.z, x, y);
return [tileCoord[0], x, y];
},
tileUrlFunction);

View File

@@ -105,12 +105,16 @@ ol.source.Zoomify = function(opt_options) {
if (goog.isNull(tileCoord)) {
return undefined;
} else {
var tileIndex = tileCoord.x +
tileCoord.y * tierSizeInTiles[tileCoord.z][0] +
tileCountUpToTier[tileCoord.z];
var tileCoordZ = tileCoord[0];
var tileCoordX = tileCoord[1];
var tileCoordY = tileCoord[2];
var tileIndex =
tileCoordX +
tileCoordY * tierSizeInTiles[tileCoordZ][0] +
tileCountUpToTier[tileCoordZ];
var tileGroup = (tileIndex / ol.DEFAULT_TILE_SIZE) | 0;
return url + 'TileGroup' + tileGroup + '/' +
tileCoord.z + '-' + tileCoord.x + '-' + tileCoord.y + '.jpg';
tileCoordZ + '-' + tileCoordX + '-' + tileCoordY + '.jpg';
}
});