From 44d4da8c2607aef0decd352bb84e5350c8c979b2 Mon Sep 17 00:00:00 2001 From: javi Date: Fri, 26 Jul 2013 17:48:48 +0200 Subject: [PATCH] refactor --- lib/torque/provider.json.js | 28 +++++++++++----------------- lib/torque/renderer/point.js | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/torque/provider.json.js b/lib/torque/provider.json.js index d0721df..c0016df 100644 --- a/lib/torque/provider.json.js +++ b/lib/torque/provider.json.js @@ -17,11 +17,12 @@ var json = function (options) { this._ready = false; - this.options = options; this._tileQueue = []; + this.options = options; // check options if (options.resolution === undefined ) throw new Error("resolution should be provided"); + if (options.steps === undefined ) throw new Error("steps should be provided"); if(options.start === undefined) { this.getKeySpan(); } else { @@ -208,32 +209,25 @@ }); }, - - // // the data range could be set by the user though ``start`` // option. It can be fecthed from the table when the start - // is not spcified + // is not specified. // getKeySpan: function() { - var max_col, min_col; + var max_col, min_col, max_tmpl, min_tmpl; if (this.options.is_time){ - max_col = format("date_part('epoch', max({column}))", { - column: this.options.column - }); - min_col = format("date_part('epoch', min({column}))", { - column: this.options.column - }); + max_tmpl = "date_part('epoch', max({column}))"; + min_tmpl = "date_part('epoch', min({column}))"; } else { - max_col = format("max({0})", { - column: this.options.column - }); - min_col = format("min({0})", { - column: this.options.column - }); + max_tmpl = "max({0})"; + min_tmpl = "min({0})"; } + max_col = format(max_tmpl, { column: this.options.column }); + min_col = format(min_tmpl, { column: this.options.column }); + var sql = format("SELECT st_xmax(st_envelope(st_collect(the_geom))) xmax,st_ymax(st_envelope(st_collect(the_geom))) ymax, st_xmin(st_envelope(st_collect(the_geom))) xmin, st_ymin(st_envelope(st_collect(the_geom))) ymin, {max_col} max, {min_col} min FROM {table}", { max_col: max_col, min_col: min_col, diff --git a/lib/torque/renderer/point.js b/lib/torque/renderer/point.js index 0c5b0de..2fbbfd6 100644 --- a/lib/torque/renderer/point.js +++ b/lib/torque/renderer/point.js @@ -15,7 +15,7 @@ // // this renderer just render points depending of the value - // + // function PointRenderer(canvas, options) { if (!canvas) { throw new Error("canvas can't be undefined");