Functions to get key from coord and coord from key

This commit is contained in:
Tim Schaub
2017-10-08 08:50:19 -06:00
parent 177156c293
commit 9fb7778156
2 changed files with 37 additions and 2 deletions

View File

@@ -31,6 +31,26 @@ ol.tilecoord.getKeyZXY = function(z, x, y) {
};
/**
* Get the key for a tile coord.
* @param {ol.TileCoord} tileCoord The tile coord.
* @return {string} Key.
*/
ol.tilecoord.getKey = function(tileCoord) {
return ol.tilecoord.getKeyZXY(tileCoord[0], tileCoord[1], tileCoord[2]);
};
/**
* Get a tile coord given a key.
* @param {string} key The tile coord key.
* @return {ol.TileCoord} The tile coord.
*/
ol.tilecoord.fromKey = function(key) {
return key.split('/').map(Number);
};
/**
* @param {ol.TileCoord} tileCoord Tile coord.
* @return {number} Hash.