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) { getTile: function(loc) {
var info = this.getTileInfo(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; var tile = null;
//TODO how to find the tile instance given a lonLat var therow = this.grid[row];
var row = this.grid[1]; //info.row]; if (typeof(therow) !== 'undefined' && therow !== null) {
if (typeof(row) !== 'undefined' && row !== null) { tile = therow[col];
tile = row[1]; //info.col];
} }
return tile; return tile;
}, },

View File

@@ -27,9 +27,9 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
url: null, url: null,
/** /**
* Property: imgDiv * Property: json
* TODO * TODO
* {HTMLImageElement} The image for this tile. * {Object} The image for this tile.
*/ */
json: null, json: null,
@@ -111,7 +111,6 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
* TODO Investigate JSONP method to avoid xbrowser polucy * TODO Investigate JSONP method to avoid xbrowser polucy
* *
grid = function(e) { grid = function(e) {
console.log("-----------");
console.log(e); console.log(e);
}; };