This commit is contained in:
javi 2014-12-19 08:41:12 +01:00
parent 306afd8b92
commit 57d3d169a1
2 changed files with 8 additions and 9 deletions

View File

@ -146,8 +146,8 @@ var heat = require('./simpleheat');
// //
// renders all the layers (and frames for each layer) from cartocss // renders all the layers (and frames for each layer) from cartocss
// //
renderTile: function(tile, key) { renderTile: function(tile, key, pos) {
this._renderTile(tile, 0, 0, null, null); this._renderTile(tile, key, 0, null, null, null, pos);
/*var prof = Profiler.metric('torque.renderer.point.renderLayers').start(); /*var prof = Profiler.metric('torque.renderer.point.renderLayers').start();
var layers = this._shader.getLayers(); var layers = this._shader.getLayers();
for(var i = 0, n = layers.length; i < n; ++i ) { for(var i = 0, n = layers.length; i < n; ++i ) {
@ -182,7 +182,7 @@ var heat = require('./simpleheat');
// renders a tile in the canvas for key defined in // renders a tile in the canvas for key defined in
// the torque tile // the torque tile
// //
_renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars) { _renderTile: function(tile, key, frame_offset, sprites, shader, shaderVars, pos) {
if(!this._canvas || !this._heat) return; if(!this._canvas || !this._heat) return;
var prof = Profiler.metric('torque.renderer.point.renderTile').start(); var prof = Profiler.metric('torque.renderer.point.renderTile').start();
@ -198,8 +198,7 @@ var heat = require('./simpleheat');
if(c) { if(c) {
var x = tile.x[posIdx]; var x = tile.x[posIdx];
var y = tileMax - tile.y[posIdx]; // flip mercator var y = tileMax - tile.y[posIdx]; // flip mercator
this._heat.add([x, y, c]); this._heat.add([pos.x + x, pos.y + y, c]);
this._ctx.fillRect(x, y, 2, 2);
} }
} }
} }
@ -207,6 +206,7 @@ var heat = require('./simpleheat');
}, },
flush: function() { flush: function() {
this._ctx.setTransform(1, 0, 0, 1, 0, 0);
if(!this._heat) return; if(!this._heat) return;
this._heat.draw(); this._heat.draw();
this._heat.clear(); this._heat.clear();

View File

@ -110,15 +110,14 @@ simpleheat.prototype = {
// draw a grayscale heatmap by putting a blurred circle at each data point // draw a grayscale heatmap by putting a blurred circle at each data point
for (var i = 0, len = this._data.length, p; i < len; i++) { for (var i = 0, len = this._data.length, p; i < len; i++) {
p = this._data[i]; p = this._data[i];
ctx.globalAlpha = Math.max(p[2] / this._max, minOpacity === undefined ? 0.05 : minOpacity); ctx.globalAlpha = Math.max(p[2] / this._max, minOpacity === undefined ? 0.05 : minOpacity);
ctx.drawImage(this._circle, p[0] - this._r, p[1] - this._r); ctx.drawImage(this._circle, p[0] - this._r, p[1] - this._r);
} }
// colorize the heatmap, using opacity value of each pixel to get the right color from our gradient // colorize the heatmap, using opacity value of each pixel to get the right color from our gradient
//var colored = ctx.getImageData(0, 0, this._width, this._height); var colored = ctx.getImageData(0, 0, this._canvas.width, this._canvas.height);
//this._colorize(colored.data, this._grad); this._colorize(colored.data, this._grad);
//ctx.putImageData(colored, 0, 0); ctx.putImageData(colored, 0, 0);
return this; return this;
}, },