adding filters to be able to filter by multiple conditions
This commit is contained in:
parent
26d0d40e35
commit
eaba6ee4dc
@ -19,6 +19,7 @@
|
|||||||
var tileJSON = function (options) {
|
var tileJSON = function (options) {
|
||||||
this._ready = false;
|
this._ready = false;
|
||||||
this._tileQueue = [];
|
this._tileQueue = [];
|
||||||
|
this._filters = {}
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
|
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
|
||||||
@ -49,6 +50,13 @@
|
|||||||
this.reload()
|
this.reload()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setFilter:function(variable, start,end){
|
||||||
|
this._filters[variable] = {type:'range', start:start,end:end)
|
||||||
|
this.reload();
|
||||||
|
},
|
||||||
|
_removefilter:function(variable){
|
||||||
|
this._filters[variable] = undefined
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* return the torque tile encoded in an efficient javascript
|
* return the torque tile encoded in an efficient javascript
|
||||||
* structure:
|
* structure:
|
||||||
@ -60,16 +68,16 @@
|
|||||||
*/
|
*/
|
||||||
createProccessTileWorker:function(){
|
createProccessTileWorker:function(){
|
||||||
var workerFunction = "var proccessTile ="+ this.proccessTileSerial.toString()
|
var workerFunction = "var proccessTile ="+ this.proccessTileSerial.toString()
|
||||||
var wrapper = "; self.onmessage = function(e){var data = JSON.parse(e.data); JSON.stringify(self.postMessage(proccessTile(data.rows,data.coord, data.zoom, data.options)))}"
|
var wrapper = "; self.onmessage = function(e){var data = JSON.parse(e.data); JSON.stringify(self.postMessage(proccessTile(data.response,data.coord, data.zoom, data.options)))}"
|
||||||
var script = workerFunction + wrapper;
|
var script = workerFunction + wrapper;
|
||||||
var blob = new Blob([script], {type: "text/javascript"})
|
var blob = new Blob([script], {type: "text/javascript"})
|
||||||
var worker = new Worker(window.URL.createObjectURL(blob))
|
var worker = new Worker(window.URL.createObjectURL(blob))
|
||||||
return worker
|
return worker
|
||||||
},
|
},
|
||||||
|
|
||||||
proccessTile:function(rows,coord,zoom,callback){
|
proccessTile:function(response,coord,zoom,callback){
|
||||||
if(typeof(Worker) === "undefined"){
|
if(typeof(Worker) === "undefined"){
|
||||||
callback(this.proccessTileSerial(rows,coord,zoom, this.options))
|
callback(this.proccessTileSerial(response,coord,zoom, this.options))
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
var worker = this.createProccessTileWorker()
|
var worker = this.createProccessTileWorker()
|
||||||
@ -79,20 +87,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var workerSafeOptions= {
|
var workerSafeOptions= {
|
||||||
x : new this.options.coordinates_data_type(rows.length),
|
|
||||||
y : new this.options.coordinates_data_type(rows.length),
|
|
||||||
cumulative: this.options.cumulative,
|
cumulative: this.options.cumulative,
|
||||||
valueDataType: this.options.valueDataType,
|
valueDataType: this.options.valueDataType,
|
||||||
resolution: this.options.resolution,
|
resolution: this.options.resolution,
|
||||||
}
|
}
|
||||||
worker.postMessage(JSON.stringify({rows: rows, coord: {x:coord.x,y:coord.y}, zoom:zoom, options: workerSafeOptions}))
|
worker.postMessage(JSON.stringify({response: response, coord: {x:coord.x,y:coord.y}, zoom:zoom, options: workerSafeOptions}))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
proccessTileSerial: function(rows, coord, zoom,options) {
|
proccessTileSerial: function(response, coord, zoom,options) {
|
||||||
var r;
|
var r;
|
||||||
var x = options.x || new options.coordinates_data_type(rows.length);
|
var data = JSON.parse(response)
|
||||||
var y = options.y || new options.coordinates_data_type(rows.length);
|
var rows = data.pixels
|
||||||
|
var histograms = data.histograms
|
||||||
|
|
||||||
|
var x = options.x || new Uint8Array(rows.length);
|
||||||
|
var y = options.y || new Uint8Array(rows.length);
|
||||||
|
|
||||||
// count number of dates
|
// count number of dates
|
||||||
var dates = 0;
|
var dates = 0;
|
||||||
@ -189,7 +199,8 @@
|
|||||||
timeIndex: timeIndex,
|
timeIndex: timeIndex,
|
||||||
renderDataPos: renderDataPos,
|
renderDataPos: renderDataPos,
|
||||||
renderData: renderData,
|
renderData: renderData,
|
||||||
maxDate: maxDateSlots
|
maxDate: maxDateSlots,
|
||||||
|
histogram: histograms
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -300,8 +311,8 @@
|
|||||||
}
|
}
|
||||||
torque.net.get( url , function (data) {
|
torque.net.get( url , function (data) {
|
||||||
if (data && data.responseText) {
|
if (data && data.responseText) {
|
||||||
var rows = JSON.parse(data.responseText);
|
|
||||||
self.proccessTile(rows.pixels, coord, zoom,callback.bind(self));
|
self.proccessTile(data.responseText, coord, zoom,callback.bind(self));
|
||||||
} else {
|
} else {
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user