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 * '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 * '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 shift = 23 - tile.z
tolerance = tolerance || 20 tolerance = tolerance || 20
var sql =""+ var sql = [
"with qr as (select * from xyz2range({x},{y},{z})) "+ "select * from {table}",
"select *, ((quadkey_x & (255 << {shift})) >> {shift}) AS torque_tile_x, "+ "where (quadkey between (xyz2range({x},{y},{z})).min and (xyz2range({x},{y},{z})).max) ",
"(255 - ((quadkey_y & (255 << {shift})) >> {shift})) AS torque_tile_y "+ "and (((quadkey_x & (255 << {shift})) >> {shift}) - {torque_tile_x}) between -{tolerance} and {tolerance}",
"from {table}, qr "+ "and (((quadkey_y & (255 << {shift})) >> {shift}) - {torque_tile_y}) between -{tolerance} and {tolerance} ",
"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}) "+
"limit {maxNo}" "limit {maxNo}"
].join(' ')
var query = format(sql,{ var query = format(sql,{
x: tile.x, x: tile.x,
@ -434,7 +433,7 @@ var Profiler = require('../profiler');
}) })
this.sql(query,function(data){ this.sql(query,function(data){
if(data){ if(data) {
var rows = JSON.parse(data.responseText).rows; var rows = JSON.parse(data.responseText).rows;
callback(rows) callback(rows)
} }