From ff972a36b03f6c495268736334ebc468a1c1eafd Mon Sep 17 00:00:00 2001 From: javi Date: Thu, 27 Feb 2014 08:16:38 +0100 Subject: [PATCH] generate minimal cartocss, closes #37 --- lib/torque/provider.windshaft.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/torque/provider.windshaft.js b/lib/torque/provider.windshaft.js index fafc5f6..51b6244 100644 --- a/lib/torque/provider.windshaft.js +++ b/lib/torque/provider.windshaft.js @@ -183,8 +183,18 @@ }; }, - setCartoCSS: function(c) { + /*setCartoCSS: function(c) { this.options.cartocss = c; + },*/ + + setSteps: function(steps, opt) { + opt = opt || {}; + if (this.options.steps !== steps) { + this.options.steps = steps; + this.options.step = (this.options.end - this.options.start)/this.getSteps(); + this.options.step = this.options.step || 1; + if (!opt.silent) this.reload(); + } }, setOptions: function(opt) { @@ -343,6 +353,21 @@ return h; }, + _generateCartoCSS: function() { + var attr = { + '-torque-frame-count': this.options.steps, + '-torque-resolution': this.options.resolution, + '-torque-aggregation-function': "'" + this.options.countby + "'", + '-torque-time-attribute': "'" + this.options.column + "'", + '-torque-data-aggregation': this.options.cumulative ? 'cumulative': 'linear', + }; + var st = 'Map{'; + for (var k in attr) { + st += k + ":" + attr[k] + ";"; + } + return st + "}"; + }, + _fetchMap: function(callback) { var self = this; var layergroup = {}; @@ -361,7 +386,7 @@ "type": "torque", "options": { "cartocss_version": "1.0.0", - "cartocss": this.options.cartocss, + "cartocss": this._generateCartoCSS(), "sql": this.getSQL() } }]