diff --git a/src/ol/tilecoord.js b/src/ol/tilecoord.js index 66ce92882d..7d7b74f869 100644 --- a/src/ol/tilecoord.js +++ b/src/ol/tilecoord.js @@ -1,6 +1,7 @@ goog.provide('ol.TileCoord'); goog.require('goog.array'); +goog.require('goog.asserts'); /** @@ -113,6 +114,23 @@ ol.TileCoord.getKeyZXY = function(z, x, y) { }; +/** + * @param {Array.=} opt_result Optional array to reuse. + * @return {Array.} Array of z, x, y. + */ +ol.TileCoord.prototype.getZXY = function(opt_result) { + if (goog.isDef(opt_result)) { + goog.asserts.assert(opt_result.length == 3); + opt_result[0] = this.z; + opt_result[1] = this.x; + opt_result[2] = this.y; + return opt_result; + } else { + return [this.z, this.x, this.y]; + } +}; + + /** * @return {number} Hash. */