fixed pixel calculation to fetch data for a point

This commit is contained in:
javi 2015-11-14 19:27:36 +01:00
parent a822c369c7
commit c4fa9b3351

View File

@ -409,17 +409,16 @@ var Profiler = require('../profiler');
* 'pixel tollerance around click' How many pixels to search around the click point
* 'callback' function(rows) returns an array of the data for that point
*/
getDataForTorquePixel:function(tile,x,y,maxNo,tolerance,callback){
getDataForTorquePixel:function(tile, x, y, maxNo, tolerance, callback){
shift = 23 - tile.z
tolerance = tolerance || 20
var sql =""+
"with qr as (select * from xyz2range({x},{y},{z})) "+
"select *, ((quadkey_x & (255 << {shift})) >> {shift}) AS torque_tile_x, "+
"(255 - ((quadkey_y & (255 << {shift})) >> {shift})) AS torque_tile_y "+
"from {table}, qr "+
"where (quadkey between qr.min and qr.max) "+
"and ((((quadkey_x & (255 << {shift})) >> {shift}) - {torque_tile_x}) between -{tolerance} and {tolerance}) and (((255 - ((quadkey_y & (255 << {shift})) >> {shift})) - {torque_tile_y}) between -{tolerance} and {tolerance}) "+
var sql = [
"select * from {table}",
"where (quadkey between (xyz2range({x},{y},{z})).min and (xyz2range({x},{y},{z})).max) ",
"and (((quadkey_x & (255 << {shift})) >> {shift}) - {torque_tile_x}) between -{tolerance} and {tolerance}",
"and (((quadkey_y & (255 << {shift})) >> {shift}) - {torque_tile_y}) between -{tolerance} and {tolerance} ",
"limit {maxNo}"
].join(' ')
var query = format(sql,{
x: tile.x,
@ -434,7 +433,7 @@ var Profiler = require('../profiler');
})
this.sql(query,function(data){
if(data){
if(data) {
var rows = JSON.parse(data.responseText).rows;
callback(rows)
}