diff --git a/doc/ol3.md b/doc/ol3.md index 41535ba745..3616345d42 100644 --- a/doc/ol3.md +++ b/doc/ol3.md @@ -175,14 +175,14 @@ TileGrid ySouth boolean origin(s) Coord|Array. tileSize goog.math.Size + forEachTileCoordChild(tileCoord, function(z, TileBounds)) + forEachTileCoordParent(tileCoord, function(z, TileBounds)) getExtentTileBounds(z, extent) -> TileBounds - getTileCoordCenter(tileCoord) -> goog.math.Coordinate getTileCoord(coordinate) -> TileCoord + getTileCoordCenter(tileCoord) -> goog.math.Coordinate getTileCoordExtent(tileCoord) -> ol.Extent getTileCoordResolution(tileCoord) -> number getZForResolution(resolution) -> number - forEachTileCoordChild(tileCoord, function(z, TileBounds)) - forEachTileCoordParent(tileCoord, function(z, TileBounds)) TileLayer tileGrid TileGrid diff --git a/src/ol/tilegrid.js b/src/ol/tilegrid.js index 0619ca2e8a..fe29122c81 100644 --- a/src/ol/tilegrid.js +++ b/src/ol/tilegrid.js @@ -86,18 +86,18 @@ ol.TileGrid = /** - * @return {boolean} X East. + * @param {ol.TileCoord} tileCoord Tile coordinate. + * @param {function(number, ol.TileBounds): boolean} callback Callback. */ -ol.TileGrid.prototype.getXEast = function() { - return this.xEast_; -}; - - -/** - * @return {boolean} Y South. - */ -ol.TileGrid.prototype.getYSouth = function() { - return this.ySouth_; +ol.TileGrid.prototype.forEachTileCoordParent = function(tileCoord, callback) { + var tileCoordExtent = this.getTileCoordExtent(tileCoord); + var z = tileCoord.z - 1; + while (z >= 0) { + if (callback(z, this.getExtentTileBounds(z, tileCoordExtent))) { + return; + } + --z; + } }; @@ -109,6 +109,20 @@ ol.TileGrid.prototype.getExtent = function() { }; +/** + * @param {number} z Z. + * @param {ol.Extent} extent Extent. + * @return {ol.TileBounds} Tile bounds. + */ +ol.TileGrid.prototype.getExtentTileBounds = function(z, extent) { + var topRight = new goog.math.Coordinate(extent.right, extent.top); + var bottomLeft = new goog.math.Coordinate(extent.left, extent.bottom); + return ol.TileBounds.boundingTileBounds( + this.getTileCoord(z, topRight), + this.getTileCoord(z, bottomLeft)); +}; + + /** * @return {number} Maximum resolution. */ @@ -150,20 +164,6 @@ ol.TileGrid.prototype.getResolutions = function() { }; -/** - * @param {number} z Z. - * @param {ol.Extent} extent Extent. - * @return {ol.TileBounds} Tile bounds. - */ -ol.TileGrid.prototype.getExtentTileBounds = function(z, extent) { - var topRight = new goog.math.Coordinate(extent.right, extent.top); - var bottomLeft = new goog.math.Coordinate(extent.left, extent.bottom); - return ol.TileBounds.boundingTileBounds( - this.getTileCoord(z, topRight), - this.getTileCoord(z, bottomLeft)); -}; - - /** * @param {number} z Z. * @param {goog.math.Coordinate} coordinate Coordinate. @@ -241,6 +241,16 @@ ol.TileGrid.prototype.getTileCoordExtent = function(tileCoord) { }; +/** + * @param {ol.TileCoord} tileCoord Tile coordinate. + * @return {number} Tile resolution. + */ +ol.TileGrid.prototype.getTileCoordResolution = function(tileCoord) { + goog.asserts.assert(0 <= tileCoord.z && tileCoord.z < this.numResolutions_); + return this.resolutions_[tileCoord.z]; +}; + + /** * @return {goog.math.Size} Tile size. */ @@ -250,12 +260,18 @@ ol.TileGrid.prototype.getTileSize = function() { /** - * @param {ol.TileCoord} tileCoord Tile coordinate. - * @return {number} Tile resolution. + * @return {boolean} X East. */ -ol.TileGrid.prototype.getTileCoordResolution = function(tileCoord) { - goog.asserts.assert(0 <= tileCoord.z && tileCoord.z < this.numResolutions_); - return this.resolutions_[tileCoord.z]; +ol.TileGrid.prototype.getXEast = function() { + return this.xEast_; +}; + + +/** + * @return {boolean} Y South. + */ +ol.TileGrid.prototype.getYSouth = function() { + return this.ySouth_; }; @@ -281,19 +297,3 @@ ol.TileGrid.prototype.getZForResolution = function(resolution) { } return this.numResolutions_ - 1; }; - - -/** - * @param {ol.TileCoord} tileCoord Tile coordinate. - * @param {function(number, ol.TileBounds): boolean} callback Callback. - */ -ol.TileGrid.prototype.forEachTileCoordParent = function(tileCoord, callback) { - var tileCoordExtent = this.getTileCoordExtent(tileCoord); - var z = tileCoord.z - 1; - while (z >= 0) { - if (callback(z, this.getExtentTileBounds(z, tileCoordExtent))) { - return; - } - --z; - } -};