|
|
|
@ -424,11 +424,53 @@ var Profiler = require('../profiler');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* `tile` the tile the point resides on
|
|
|
|
|
* `x` the x pixel coord on the tile
|
|
|
|
|
* 'y' the y pixel coord on the tile
|
|
|
|
|
* 'maxNo' the maximum number of points to return
|
|
|
|
|
* '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){
|
|
|
|
|
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 query = format(sql,{
|
|
|
|
|
x: tile.x,
|
|
|
|
|
y: tile.y,
|
|
|
|
|
z: tile.z,
|
|
|
|
|
table: this.options.table,
|
|
|
|
|
torque_tile_x: x,
|
|
|
|
|
torque_tile_y: y,
|
|
|
|
|
maxNo: maxNo,
|
|
|
|
|
shift: shift,
|
|
|
|
|
tolerance: tolerance
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.sql(query,function(data){
|
|
|
|
|
if(data){
|
|
|
|
|
var rows = JSON.parse(data.responseText).rows;
|
|
|
|
|
callback(rows)
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
callback(null)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* `coord` object like {x : tilex, y: tiley }
|
|
|
|
|
* `zoom` quadtree zoom level
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
_getTileData: function(coord, zoom, callback) {
|
|
|
|
|
var prof_fetch_time = Profiler.metric('ProviderJSON:tile_fetch_time').start()
|
|
|
|
|
this.table = this.options.table;
|
|
|
|
|