refactor
This commit is contained in:
parent
28818ebee7
commit
44d4da8c26
@ -17,11 +17,12 @@
|
|||||||
|
|
||||||
var json = function (options) {
|
var json = function (options) {
|
||||||
this._ready = false;
|
this._ready = false;
|
||||||
this.options = options;
|
|
||||||
this._tileQueue = [];
|
this._tileQueue = [];
|
||||||
|
this.options = options;
|
||||||
|
|
||||||
// check options
|
// check options
|
||||||
if (options.resolution === undefined ) throw new Error("resolution should be provided");
|
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) {
|
if(options.start === undefined) {
|
||||||
this.getKeySpan();
|
this.getKeySpan();
|
||||||
} else {
|
} else {
|
||||||
@ -208,32 +209,25 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// the data range could be set by the user though ``start``
|
// the data range could be set by the user though ``start``
|
||||||
// option. It can be fecthed from the table when the start
|
// option. It can be fecthed from the table when the start
|
||||||
// is not spcified
|
// is not specified.
|
||||||
//
|
//
|
||||||
getKeySpan: function() {
|
getKeySpan: function() {
|
||||||
var max_col, min_col;
|
var max_col, min_col, max_tmpl, min_tmpl;
|
||||||
|
|
||||||
if (this.options.is_time){
|
if (this.options.is_time){
|
||||||
max_col = format("date_part('epoch', max({column}))", {
|
max_tmpl = "date_part('epoch', max({column}))";
|
||||||
column: this.options.column
|
min_tmpl = "date_part('epoch', min({column}))";
|
||||||
});
|
|
||||||
min_col = format("date_part('epoch', min({column}))", {
|
|
||||||
column: this.options.column
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
max_col = format("max({0})", {
|
max_tmpl = "max({0})";
|
||||||
column: this.options.column
|
min_tmpl = "min({0})";
|
||||||
});
|
|
||||||
min_col = format("min({0})", {
|
|
||||||
column: this.options.column
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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}", {
|
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,
|
max_col: max_col,
|
||||||
min_col: min_col,
|
min_col: min_col,
|
||||||
|
Loading…
Reference in New Issue
Block a user