Merge pull request #256 from CartoDB/pointcount

Added pointCount method
This commit is contained in:
acanimal 2016-02-24 15:00:12 +01:00
commit 178eb5700f
2 changed files with 31 additions and 2 deletions

View File

@ -241,7 +241,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
this.setKeys([key]);
},
/**
/**
* returns the array of keys being rendered
*/
getKeys: function() {
@ -388,6 +388,21 @@ GMapsTorqueLayer.prototype = torque.extend({},
}
return null;
},
/** return the number of points for a step */
pointCount: function(step) {
var t, tile;
step = step === undefined ? this.key: step;
var c = 0;
for(t in this._tiles) {
tile = this._tiles[t];
if (tile) {
c += tile.timeCount[step];
}
}
return c;
},
getValueForBBox: function(x, y, w, h) {
var xf = x + w, yf = y + h;
var sum = 0;

View File

@ -286,7 +286,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
this.setKeys([key], options);
},
/**
/**
* returns the array of keys being rendered
*/
getKeys: function() {
@ -472,6 +472,20 @@ L.TorqueLayer = L.CanvasLayer.extend({
return sum;
},
/** return the number of points for a step */
pointCount: function(step) {
var t, tile;
step = step === undefined ? this.key: step;
var c = 0;
for(t in this._tiles) {
tile = this._tiles[t];
if (tile) {
c += tile.timeCount[step];
}
}
return c;
},
invalidate: function() {
this.provider.reload();
},