Clearer tile method names.
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user