From f5ce6e7839e4c39f616f6d22f89202c35bf3220e Mon Sep 17 00:00:00 2001 From: javi Date: Wed, 20 Nov 2013 15:01:52 +0100 Subject: [PATCH] cumulative working --- lib/torque/provider.json.js | 16 ++++++++++++++-- lib/torque/renderer/point.js | 9 ++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/torque/provider.json.js b/lib/torque/provider.json.js index f39b21c..0e2c91e 100644 --- a/lib/torque/provider.json.js +++ b/lib/torque/provider.json.js @@ -28,6 +28,10 @@ this.options.tiler_domain = options.tiler_domain || 'cartodb.com'; this.options.tiler_port = options.tiler_port || 80; + if (this.options.data_aggregation) { + this.options.cumulative = this.options.data_aggregation === 'cumulative'; + } + // check options if (options.resolution === undefined ) throw new Error("resolution should be provided"); if (options.steps === undefined ) throw new Error("steps should be provided"); @@ -70,7 +74,7 @@ } if(this.options.cumulative) { - dates = maxDateSlots * rows.length; + dates = (1 + maxDateSlots) * rows.length; } // reserve memory for all the dates @@ -117,7 +121,7 @@ // extend the latest to the end if(this.options.cumulative) { var lastDateSlot = dates[dates.length - 1]; - for (var j = lastDateSlot; j < maxDateSlots; ++j) { + for (var j = lastDateSlot; j <= maxDateSlots; ++j) { var rr = rowsPerSlot[j] || (rowsPerSlot[j] = []); rr.push([r, prev_val]); } @@ -361,6 +365,14 @@ refresh = true; } + if(opt.data_aggregation !== undefined) { + var c = opt.data_aggregation === 'cumulative'; + if (this.options.cumulative !== c) { + this.options.cumulative = c; + refresh = true; + } + } + if (refresh) this.reload(); return refresh; diff --git a/lib/torque/renderer/point.js b/lib/torque/renderer/point.js index 4ffde16..e38ab1a 100644 --- a/lib/torque/renderer/point.js +++ b/lib/torque/renderer/point.js @@ -29,7 +29,6 @@ this._ctx = canvas.getContext('2d'); this._sprites = []; // sprites per layer this._shader = null; - //carto.tree.Reference.set(torque['torque-reference']); this.setCartoCSS(this.options.cartocss || DEFAULT_CARTOCSS); } @@ -113,13 +112,13 @@ var prof = Profiler.metric('PointRenderer:renderTile').start(); var ctx = this._ctx; - - if(this.options.blendmode) { - ctx.globalCompositeOperation = this.options.blendmode; + var blendMode = shader.eval('comp-op') || this.options.blendmode; + if(blendMode) { + ctx.globalCompositeOperation = blendMode; } if (this.options.cumulative && key > tile.maxDate) { //TODO: precache because this tile is not going to change - key = tile.maxDate - 1; + key = tile.maxDate; } var tileMax = this.options.resolution * (256/this.options.resolution - 1) var activePixels = tile.timeCount[key];