refactor
This commit is contained in:
parent
28818ebee7
commit
44d4da8c26
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user