diff --git a/src/ol/renderer/dom/domtilelayerrenderer.js b/src/ol/renderer/dom/domtilelayerrenderer.js index 89b7861f70..4fa5f7c3b9 100644 --- a/src/ol/renderer/dom/domtilelayerrenderer.js +++ b/src/ol/renderer/dom/domtilelayerrenderer.js @@ -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; diff --git a/src/ol/source/tileutfgridsource.js b/src/ol/source/tileutfgridsource.js index b5a7b7f8bb..b9a2069556 100644 --- a/src/ol/source/tileutfgridsource.js +++ b/src/ol/source/tileutfgridsource.js @@ -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())); diff --git a/src/ol/source/tilevectorsource.js b/src/ol/source/tilevectorsource.js index 3db1527301..bfb56a798d 100644 --- a/src/ol/source/tilevectorsource.js +++ b/src/ol/source/tilevectorsource.js @@ -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]); diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index b2fa897e0a..1bddb17a53 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -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]) { diff --git a/src/ol/tilecoord.js b/src/ol/tilecoord.js index d38bb9a9c7..3855ac1aec 100644 --- a/src/ol/tilecoord.js +++ b/src/ol/tilecoord.js @@ -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; } diff --git a/src/ol/tilegrid/tilegrid.js b/src/ol/tilegrid/tilegrid.js index de2def3e3e..af2f483092 100644 --- a/src/ol/tilegrid/tilegrid.js +++ b/src/ol/tilegrid/tilegrid.js @@ -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_(