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