Some refactoring and cleaning up rounding errors in tile math. Added

debugging mechanism.
This commit is contained in:
Matthew Perry
2012-02-05 11:17:02 -08:00
parent be4db93e9b
commit 6ff3b895c9
2 changed files with 48 additions and 36 deletions

View File

@@ -29,6 +29,7 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
* {DOMElement}
*/
element: null,
debugElement: null,
/**
* APIProperty: prefix
@@ -176,7 +177,20 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
for (var i=0, len=layers.length; i<len; i++) {
layer = layers[i];
var info = layer.getTileInfo( lonLat );
var tile = layer.getTile( lonLat );
if (this.debugElement) {
var debug = "<ul>";
debug += "<li>i :" + info.i + "</li>";
debug += "<li>j :" + info.j + "</li>";
debug += "<li>globalrow :" + info.globalRow + "</li>";
debug += "<li>globalcol :" + info.globalCol + "</li>";
debug += "<li>gridrow :" + info.gridRow + "</li>";
debug += "<li>gridcol :" + info.gridCol + "</li>";
debug += "<li>gridrow offset :" + info.gridRowOffset + "</li>";
debug += "<li>gridcol offset :" + info.gridColOffset + "</li>";
debug += "</ul>";
this.debugElement.innerHTML = debug;
}
var tile = info.tile;
/*
TODO Sanity checks
if ((Math.floor(info.i) >= tileSize) ||