Clearer tile method names.

This commit is contained in:
tschaub
2012-02-27 16:47:11 -07:00
parent 89e8a872a5
commit fd595e6282

View File

@@ -179,32 +179,35 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
var id;
if (this.json) {
var resolution = this.utfgridResolution;
var code = this.resolveCode(this.json.grid[
Math.floor((j) / resolution)
].charCodeAt(
Math.floor((i) / resolution)
));
id = this.json.keys[code];
var row = Math.floor(j / resolution);
var col = Math.floor(i / resolution);
var charCode = this.json.grid[row].charCodeAt(col);
var index = this.indexFromCharCode(charCode);
id = this.json.keys[index];
}
return id;
},
/**
* Method: resolveCode
* Resolve the UTF-8 encoding stored in grids to simple number values.
* See the UTFGrid spec for details.
* Method: indexFromCharCode
* Given a character code for one of the UTFGrid "grid" characters,
* resolve the integer index for the feature id in the UTFGrid "keys"
* array.
*
* Parameters:
* key - {Integer}
* charCode - {Integer}
*
* Returns:
* {Integer} Adjusted key for non-escaped chars
* {Integer} Index for the feature id from the keys array.
*/
resolveCode: function(key) {
if (key >= 93) key--;
if (key >= 35) key--;
key -= 32;
return key;
indexFromCharCode: function(charCode) {
if (charCode >= 93) {
charCode--;
}
if (charCode >= 35) {
charCode --;
}
return charCode - 32;
},
/**