Preliminary working implementation.. still lots of slop to clean up

This commit is contained in:
Matthew Perry
2012-02-05 09:33:32 -08:00
parent 92cbac468c
commit be4db93e9b
2 changed files with 19 additions and 7 deletions

View File

@@ -172,11 +172,24 @@ OpenLayers.Layer.UTFGrid = OpenLayers.Class(OpenLayers.Layer.Grid, {
getTile: function(loc) {
var info = this.getTileInfo(loc);
var res = this.getServerResolution();
var gridOrigin = this.grid[0][0].bounds;
var gridColOffset = (gridOrigin.left - this.tileOrigin.lon) / (res * this.tileSize.w);
var gridRowOffset = (this.tileOrigin.lat - gridOrigin.top) / (res * this.tileSize.h);
var fx = (loc.lon - this.tileOrigin.lon) / (res * this.tileSize.w);
var fy = (this.tileOrigin.lat - loc.lat) / (res * this.tileSize.h);
var globalCol = Math.floor(fx);
var globalRow = Math.floor(fy);
var row = globalRow - Math.floor(gridRowOffset);
var col = globalCol - Math.floor(gridColOffset);
var tile = null;
//TODO how to find the tile instance given a lonLat
var row = this.grid[1]; //info.row];
if (typeof(row) !== 'undefined' && row !== null) {
tile = row[1]; //info.col];
var therow = this.grid[row];
if (typeof(therow) !== 'undefined' && therow !== null) {
tile = therow[col];
}
return tile;
},