Return transformed tile coordinates from ol.TileGrid's API methods

This commit is contained in:
Andreas Hocevar
2015-06-12 09:47:32 +02:00
parent acab0ebd57
commit 4b3aac32c3
6 changed files with 45 additions and 6 deletions

View File

@@ -192,7 +192,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
tileLayerZ = this.tileLayerZs_[tileLayerZKey];
} else {
tileCoordOrigin =
tileGrid.getTileCoordForCoordAndZ(center, tileLayerZKey);
tileGrid.getTileCoordForCoordAndZInternal(center, tileLayerZKey);
tileLayerZ = new ol.renderer.dom.TileLayerZ_(tileGrid, tileCoordOrigin);
newTileLayerZKeys[tileLayerZKey] = true;
this.tileLayerZs_[tileLayerZKey] = tileLayerZ;

View File

@@ -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.getTileCoordForCoordAndResolution(
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolutionInternal(
coordinate, resolution);
var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile(
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));

View File

@@ -114,7 +114,7 @@ ol.source.TileVector.prototype.forEachFeatureAtCoordinateAndResolution =
var tileGrid = this.tileGrid_;
var tiles = this.tiles_;
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate,
var tileCoord = tileGrid.getTileCoordForCoordAndResolutionInternal(coordinate,
resolution);
var tileKey = this.getTileKeyZXY_(tileCoord[0], tileCoord[1], tileCoord[2]);

View File

@@ -140,7 +140,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
tileGrid = this.getTileGridForProjection(projectionObj);
}
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(
var tileCoord = tileGrid.getTileCoordForCoordAndResolutionInternal(
coordinate, resolution);
if (tileGrid.getResolutions().length <= tileCoord[0]) {

View File

@@ -155,7 +155,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.getTileCoordForCoordAndZ(center, z);
return tileGrid.getTileCoordForCoordAndZInternal(center, z);
} else {
return tileCoord;
}

View File

@@ -382,6 +382,28 @@ ol.tilegrid.TileGrid.prototype.getTileCoordExtent =
*/
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 =
function(coordinate, resolution, opt_tileCoord) {
return this.getTileCoordForXYAndResolution_(
coordinate[0], coordinate[1], resolution, false, opt_tileCoord);
};
@@ -431,7 +453,24 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForXYAndResolution_ = function(
* @return {ol.TileCoord} Tile coordinate.
* @api
*/
ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndZ =
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 =
function(coordinate, z, opt_tileCoord) {
var resolution = this.getResolution(z);
return this.getTileCoordForXYAndResolution_(