diff --git a/lib/torque/provider/filterableJson.js b/lib/torque/provider/filterableJson.js index 8b99d4a..d36e495 100644 --- a/lib/torque/provider/filterableJson.js +++ b/lib/torque/provider/filterableJson.js @@ -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}) "+ - "limit {maxNo}" + 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) }