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

@ -412,14 +412,13 @@ var Profiler = require('../profiler');
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,