build
This commit is contained in:
parent
6b0e946e41
commit
17f2c2aee0
12
dist/torque.full.js
vendored
12
dist/torque.full.js
vendored
File diff suppressed because one or more lines are too long
126
dist/torque.full.uncompressed.js
vendored
126
dist/torque.full.uncompressed.js
vendored
@ -2807,6 +2807,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
var bb = thisValue.bbox;
|
var bb = thisValue.bbox;
|
||||||
var xy = this._map.latLngToContainerPoint([bb[1].lat, bb[1].lon]);
|
var xy = this._map.latLngToContainerPoint([bb[1].lat, bb[1].lon]);
|
||||||
if(xy.x < xf && xy.y < yf){
|
if(xy.x < xf && xy.y < yf){
|
||||||
|
console.log("just before sum value ", this.Value.value)
|
||||||
sum += thisValue.value;
|
sum += thisValue.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3181,7 +3182,19 @@ var Profiler = require('../profiler');
|
|||||||
// reserve memory for all the dates
|
// reserve memory for all the dates
|
||||||
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
||||||
var timeCount = new Int32Array(maxDateSlots + 1);
|
var timeCount = new Int32Array(maxDateSlots + 1);
|
||||||
var renderData = new (this.options.valueDataType || type)(dates);
|
|
||||||
|
var val_keys = []
|
||||||
|
if(rows.length>0){
|
||||||
|
val_keys = Object.keys(rows[0]).filter(function(k){return (k.indexOf("vals__uint8") > -1) })
|
||||||
|
}
|
||||||
|
r
|
||||||
|
|
||||||
|
var renderData = []
|
||||||
|
|
||||||
|
val_keys.forEach(function(key,index){
|
||||||
|
renderData[index] = new (this.options.valueDataType || type)(dates);
|
||||||
|
}.bind(this))
|
||||||
|
|
||||||
var renderDataPos = new Uint32Array(dates);
|
var renderDataPos = new Uint32Array(dates);
|
||||||
|
|
||||||
prof_mem.inc(
|
prof_mem.inc(
|
||||||
@ -3208,15 +3221,28 @@ var Profiler = require('../profiler');
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dates = row.dates__uint16;
|
var dates = row.dates__uint16;
|
||||||
var vals = row.vals__uint8;
|
var val_keys = Object.keys(row).filter(function(k){return (k.indexOf("vals__uint8") > -1) })
|
||||||
|
var val_arr = []
|
||||||
|
val_keys.forEach(function(key){
|
||||||
|
var i = key.match(/vals__uint8_(\d+)/)[1]
|
||||||
|
val_arr[i] = row[key];
|
||||||
|
})
|
||||||
|
|
||||||
if (!this.options.cumulative) {
|
if (!this.options.cumulative) {
|
||||||
for (var j = 0, len = dates.length; j < len; ++j) {
|
for (var j = 0, len = dates.length; j < len; ++j) {
|
||||||
var rr = rowsPerSlot[dates[j]] || (rowsPerSlot[dates[j]] = []);
|
var rr = rowsPerSlot[dates[j]] || (rowsPerSlot[dates[j]] = []);
|
||||||
if(this.options.cumulative) {
|
//Stuart: Not sure I understand why this is here?
|
||||||
vals[j] += prev_val;
|
// if(this.options.cumulative) {
|
||||||
}
|
// vals[j] += prev_val;
|
||||||
prev_val = vals[j];
|
// }
|
||||||
rr.push([r, vals[j]]);
|
|
||||||
|
// prev_val = vals[j];
|
||||||
|
var all_vals = []
|
||||||
|
val_arr.forEach(function(vals){
|
||||||
|
all_vals.push(vals[j])
|
||||||
|
})
|
||||||
|
rr.push([r, all_vals]);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var valByDate = {}
|
var valByDate = {}
|
||||||
@ -3245,6 +3271,7 @@ var Profiler = require('../profiler');
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// for each timeslot search active buckets
|
// for each timeslot search active buckets
|
||||||
var renderDataIndex = 0;
|
var renderDataIndex = 0;
|
||||||
var timeSlotIndex = 0;
|
var timeSlotIndex = 0;
|
||||||
@ -3254,10 +3281,13 @@ var Profiler = require('../profiler');
|
|||||||
var slotRows = rowsPerSlot[i]
|
var slotRows = rowsPerSlot[i]
|
||||||
if(slotRows) {
|
if(slotRows) {
|
||||||
for (var r = 0; r < slotRows.length; ++r) {
|
for (var r = 0; r < slotRows.length; ++r) {
|
||||||
|
|
||||||
var rr = slotRows[r];
|
var rr = slotRows[r];
|
||||||
++c;
|
++c;
|
||||||
renderDataPos[renderDataIndex] = rr[0]
|
renderDataPos[renderDataIndex] = rr[0]
|
||||||
renderData[renderDataIndex] = rr[1];
|
rr[1].forEach(function(rrr,index){
|
||||||
|
renderData[index][renderDataIndex] = rrr;
|
||||||
|
})
|
||||||
++renderDataIndex;
|
++renderDataIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3346,7 +3376,6 @@ var Profiler = require('../profiler');
|
|||||||
subdomains = [null]; // no subdomain
|
subdomains = [null]; // no subdomain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var url;
|
var url;
|
||||||
if (options.no_cdn) {
|
if (options.no_cdn) {
|
||||||
url = this._host();
|
url = this._host();
|
||||||
@ -3363,6 +3392,7 @@ var Profiler = require('../profiler');
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTileData: function(coord, zoom, callback) {
|
getTileData: function(coord, zoom, callback) {
|
||||||
|
|
||||||
if(!this._ready) {
|
if(!this._ready) {
|
||||||
this._tileQueue.push([coord, zoom, callback]);
|
this._tileQueue.push([coord, zoom, callback]);
|
||||||
} else {
|
} else {
|
||||||
@ -3394,9 +3424,18 @@ var Profiler = require('../profiler');
|
|||||||
|
|
||||||
var column_conv = this.options.column;
|
var column_conv = this.options.column;
|
||||||
|
|
||||||
|
var agg_columns;
|
||||||
|
if(this.options.countby.indexOf(";") > 0){
|
||||||
|
agg_columns = this.options.countby.split(";")
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
agg_columns = [this.options.countby]
|
||||||
|
}
|
||||||
|
|
||||||
if(this.options.is_time) {
|
if(this.options.is_time) {
|
||||||
column_conv = format("date_part('epoch', {column})", this.options);
|
column_conv = format("date_part('epoch', {column})", this.options);
|
||||||
}
|
}
|
||||||
|
console.log("columns are ", this.options.countby)
|
||||||
|
|
||||||
var sql = "" +
|
var sql = "" +
|
||||||
"WITH " +
|
"WITH " +
|
||||||
@ -3406,8 +3445,13 @@ var Profiler = require('../profiler');
|
|||||||
", CDB_XYZ_Extent({x}, {y}, {zoom}) as ext " +
|
", CDB_XYZ_Extent({x}, {y}, {zoom}) as ext " +
|
||||||
")," +
|
")," +
|
||||||
"cte AS ( "+
|
"cte AS ( "+
|
||||||
" SELECT ST_SnapToGrid(i.the_geom_webmercator, p.res) g" +
|
" SELECT ST_SnapToGrid(i.the_geom_webmercator, p.res) g"
|
||||||
", {countby} c" +
|
|
||||||
|
agg_columns.forEach(function(col,index){
|
||||||
|
sql = sql + ", "+col+" c"+index
|
||||||
|
}.bind(this))
|
||||||
|
|
||||||
|
sql = sql +
|
||||||
", floor(({column_conv} - {start})/{step}) d" +
|
", floor(({column_conv} - {start})/{step}) d" +
|
||||||
" FROM ({_sql}) i, par p " +
|
" FROM ({_sql}) i, par p " +
|
||||||
" WHERE i.the_geom_webmercator && p.ext " +
|
" WHERE i.the_geom_webmercator && p.ext " +
|
||||||
@ -3415,14 +3459,20 @@ var Profiler = require('../profiler');
|
|||||||
") " +
|
") " +
|
||||||
"" +
|
"" +
|
||||||
"SELECT (st_x(g)-st_xmin(p.ext))/p.res x__uint8, " +
|
"SELECT (st_x(g)-st_xmin(p.ext))/p.res x__uint8, " +
|
||||||
" (st_y(g)-st_ymin(p.ext))/p.res y__uint8," +
|
" (st_y(g)-st_ymin(p.ext))/p.res y__uint8"
|
||||||
" array_agg(c) vals__uint8," +
|
|
||||||
" array_agg(d) dates__uint16" +
|
agg_columns.forEach(function(col,index){
|
||||||
|
sql = sql + ", array_agg(c"+index+") vals__uint8_"+index
|
||||||
|
}.bind(this))
|
||||||
|
|
||||||
|
sql = sql +
|
||||||
|
", array_agg(d) dates__uint16" +
|
||||||
// the tile_size where are needed because the overlaps query in cte subquery includes the points
|
// the tile_size where are needed because the overlaps query in cte subquery includes the points
|
||||||
// in the left and bottom borders of the tile
|
// in the left and bottom borders of the tile
|
||||||
" FROM cte, par p where (st_y(g)-st_ymin(p.ext))/p.res < tile_size and (st_x(g)-st_xmin(p.ext))/p.res < tile_size GROUP BY x__uint8, y__uint8";
|
" FROM cte, par p where (st_y(g)-st_ymin(p.ext))/p.res < tile_size and (st_x(g)-st_xmin(p.ext))/p.res < tile_size GROUP BY x__uint8, y__uint8";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var query = format(sql, this.options, {
|
var query = format(sql, this.options, {
|
||||||
zoom: zoom,
|
zoom: zoom,
|
||||||
x: coord.x,
|
x: coord.x,
|
||||||
@ -3431,6 +3481,8 @@ var Profiler = require('../profiler');
|
|||||||
_sql: this.getSQL()
|
_sql: this.getSQL()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("sql is ", query)
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.sql(query, function (data) {
|
this.sql(query, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -4205,10 +4257,12 @@ var Profiler = require('../profiler');
|
|||||||
.replace('{s}', subdomains[index])
|
.replace('{s}', subdomains[index])
|
||||||
|
|
||||||
var extra = this._extraParams();
|
var extra = this._extraParams();
|
||||||
|
|
||||||
torque.net.get( url + (extra ? "?" + extra: ''), function (data) {
|
torque.net.get( url + (extra ? "?" + extra: ''), function (data) {
|
||||||
prof_fetch_time.end();
|
prof_fetch_time.end();
|
||||||
if (data && data.responseText) {
|
if (data && data.responseText) {
|
||||||
var rows = JSON.parse(data.responseText);
|
var rows = JSON.parse(data.responseText);
|
||||||
|
console.log("tile data ", rows)
|
||||||
callback(self.proccessTile(rows, coord, zoom));
|
callback(self.proccessTile(rows, coord, zoom));
|
||||||
} else {
|
} else {
|
||||||
Profiler.metric('torque.provider.windshaft.tile.error').inc();
|
Profiler.metric('torque.provider.windshaft.tile.error').inc();
|
||||||
@ -4473,6 +4527,21 @@ var Profiler = require('../profiler');
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderVector(ctx,img,st){
|
||||||
|
var markerWidth = st['maker-width']
|
||||||
|
var direction = st['vector-direction']
|
||||||
|
var mag = st['vector-mag']
|
||||||
|
var lineWidth = st['marker-line-width']
|
||||||
|
var strokeStyle = st['marker-line-color']
|
||||||
|
ctx.lineWidth = lineWidth
|
||||||
|
ctx.strokeStyle = strokeStyle
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0,0);
|
||||||
|
ctx.lineTo(300,150);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
function renderSprite(ctx, img, st) {
|
function renderSprite(ctx, img, st) {
|
||||||
|
|
||||||
if(img.complete){
|
if(img.complete){
|
||||||
@ -4612,9 +4681,21 @@ var Filters = require('./torque_filters');
|
|||||||
generateSprite: function(shader, value, shaderVars) {
|
generateSprite: function(shader, value, shaderVars) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var prof = Profiler.metric('torque.renderer.point.generateSprite').start();
|
var prof = Profiler.metric('torque.renderer.point.generateSprite').start();
|
||||||
var st = shader.getStyle({
|
|
||||||
value: value
|
var values = {}
|
||||||
}, shaderVars);
|
|
||||||
|
if(value.length ==0){
|
||||||
|
values["value"] = value[0]
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
value.forEach(function(val,index){
|
||||||
|
values["value"+index] = val;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var st = shader.getStyle(values, shaderVars);
|
||||||
|
|
||||||
if(this._style === null || this._style !== st){
|
if(this._style === null || this._style !== st){
|
||||||
this._style = st;
|
this._style = st;
|
||||||
}
|
}
|
||||||
@ -4760,7 +4841,7 @@ var Filters = require('./torque_filters');
|
|||||||
var pixelIndex = tile.timeIndex[key];
|
var pixelIndex = tile.timeIndex[key];
|
||||||
for(var p = 0; p < activePixels; ++p) {
|
for(var p = 0; p < activePixels; ++p) {
|
||||||
var posIdx = tile.renderDataPos[pixelIndex + p];
|
var posIdx = tile.renderDataPos[pixelIndex + p];
|
||||||
var c = tile.renderData[pixelIndex + p];
|
var c = tile.renderData.map(function(a){return a[pixelIndex + p]});
|
||||||
if (c) {
|
if (c) {
|
||||||
var sp = sprites[c];
|
var sp = sprites[c];
|
||||||
if (sp === undefined) {
|
if (sp === undefined) {
|
||||||
@ -4816,6 +4897,7 @@ var Filters = require('./torque_filters');
|
|||||||
// return the value for x, y (tile coordinates)
|
// return the value for x, y (tile coordinates)
|
||||||
// null for no value
|
// null for no value
|
||||||
getValueFor: function(tile, step, px, py) {
|
getValueFor: function(tile, step, px, py) {
|
||||||
|
// console.log('getting value for tile ', tile, step, px, py)
|
||||||
var mercator = new torque.Mercator();
|
var mercator = new torque.Mercator();
|
||||||
var res = this.options.resolution;
|
var res = this.options.resolution;
|
||||||
var res2 = res >> 1;
|
var res2 = res >> 1;
|
||||||
@ -4826,13 +4908,15 @@ var Filters = require('./torque_filters');
|
|||||||
var pixelIndex = tile.timeIndex[step];
|
var pixelIndex = tile.timeIndex[step];
|
||||||
for(var p = 0; p < activePixels; ++p) {
|
for(var p = 0; p < activePixels; ++p) {
|
||||||
var posIdx = tile.renderDataPos[pixelIndex + p];
|
var posIdx = tile.renderDataPos[pixelIndex + p];
|
||||||
var c = tile.renderData[pixelIndex + p];
|
var c = [tile.renderData[0][pixelIndex + p], tile.renderData[1][pixelIndex + p]]
|
||||||
|
// console.log("tile.renderData ", tile.renderData[pixelIndex + p] )
|
||||||
if (c) {
|
if (c) {
|
||||||
var x = tile.x[posIdx];
|
var x = tile.x[posIdx];
|
||||||
var y = tileMax - tile.y[posIdx];
|
var y = tileMax - tile.y[posIdx];
|
||||||
var dx = px + res2 - x;
|
var dx = px + res2 - x;
|
||||||
var dy = py + res2 - y;
|
var dy = py + res2 - y;
|
||||||
if (dx >= 0 && dx < res && dy >= 0 && dy < res) {
|
if (dx >= 0 && dx < res && dy >= 0 && dy < res) {
|
||||||
|
// console.log('returning value ', c, " from ", tile.renderData[pixelIndex + p])
|
||||||
return {
|
return {
|
||||||
value: c,
|
value: c,
|
||||||
bbox: mercator.tilePixelBBox(
|
bbox: mercator.tilePixelBBox(
|
||||||
@ -13932,7 +14016,7 @@ module.exports={
|
|||||||
"url": "https://github.com/cartodb/carto",
|
"url": "https://github.com/cartodb/carto",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "http://github.com/cartodb/carto.git"
|
"url": "git+ssh://git@github.com/cartodb/carto.git"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "CartoDB",
|
"name": "CartoDB",
|
||||||
@ -14003,7 +14087,7 @@ module.exports={
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/cartodb/carto/issues"
|
"url": "https://github.com/cartodb/carto/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/cartodb/carto",
|
"homepage": "https://github.com/cartodb/carto#readme",
|
||||||
"_id": "carto@0.15.1-cdb1",
|
"_id": "carto@0.15.1-cdb1",
|
||||||
"_shasum": "62534c2975cbee073f10c6c14a0c7e889c9469e7",
|
"_shasum": "62534c2975cbee073f10c6c14a0c7e889c9469e7",
|
||||||
"_resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz",
|
"_resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz",
|
||||||
|
4
dist/torque.js
vendored
4
dist/torque.js
vendored
File diff suppressed because one or more lines are too long
122
dist/torque.uncompressed.js
vendored
122
dist/torque.uncompressed.js
vendored
@ -2814,6 +2814,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
|||||||
var bb = thisValue.bbox;
|
var bb = thisValue.bbox;
|
||||||
var xy = this._map.latLngToContainerPoint([bb[1].lat, bb[1].lon]);
|
var xy = this._map.latLngToContainerPoint([bb[1].lat, bb[1].lon]);
|
||||||
if(xy.x < xf && xy.y < yf){
|
if(xy.x < xf && xy.y < yf){
|
||||||
|
console.log("just before sum value ", this.Value.value)
|
||||||
sum += thisValue.value;
|
sum += thisValue.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3188,7 +3189,19 @@ var Profiler = require('../profiler');
|
|||||||
// reserve memory for all the dates
|
// reserve memory for all the dates
|
||||||
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
||||||
var timeCount = new Int32Array(maxDateSlots + 1);
|
var timeCount = new Int32Array(maxDateSlots + 1);
|
||||||
var renderData = new (this.options.valueDataType || type)(dates);
|
|
||||||
|
var val_keys = []
|
||||||
|
if(rows.length>0){
|
||||||
|
val_keys = Object.keys(rows[0]).filter(function(k){return (k.indexOf("vals__uint8") > -1) })
|
||||||
|
}
|
||||||
|
r
|
||||||
|
|
||||||
|
var renderData = []
|
||||||
|
|
||||||
|
val_keys.forEach(function(key,index){
|
||||||
|
renderData[index] = new (this.options.valueDataType || type)(dates);
|
||||||
|
}.bind(this))
|
||||||
|
|
||||||
var renderDataPos = new Uint32Array(dates);
|
var renderDataPos = new Uint32Array(dates);
|
||||||
|
|
||||||
prof_mem.inc(
|
prof_mem.inc(
|
||||||
@ -3215,15 +3228,28 @@ var Profiler = require('../profiler');
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dates = row.dates__uint16;
|
var dates = row.dates__uint16;
|
||||||
var vals = row.vals__uint8;
|
var val_keys = Object.keys(row).filter(function(k){return (k.indexOf("vals__uint8") > -1) })
|
||||||
|
var val_arr = []
|
||||||
|
val_keys.forEach(function(key){
|
||||||
|
var i = key.match(/vals__uint8_(\d+)/)[1]
|
||||||
|
val_arr[i] = row[key];
|
||||||
|
})
|
||||||
|
|
||||||
if (!this.options.cumulative) {
|
if (!this.options.cumulative) {
|
||||||
for (var j = 0, len = dates.length; j < len; ++j) {
|
for (var j = 0, len = dates.length; j < len; ++j) {
|
||||||
var rr = rowsPerSlot[dates[j]] || (rowsPerSlot[dates[j]] = []);
|
var rr = rowsPerSlot[dates[j]] || (rowsPerSlot[dates[j]] = []);
|
||||||
if(this.options.cumulative) {
|
//Stuart: Not sure I understand why this is here?
|
||||||
vals[j] += prev_val;
|
// if(this.options.cumulative) {
|
||||||
}
|
// vals[j] += prev_val;
|
||||||
prev_val = vals[j];
|
// }
|
||||||
rr.push([r, vals[j]]);
|
|
||||||
|
// prev_val = vals[j];
|
||||||
|
var all_vals = []
|
||||||
|
val_arr.forEach(function(vals){
|
||||||
|
all_vals.push(vals[j])
|
||||||
|
})
|
||||||
|
rr.push([r, all_vals]);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var valByDate = {}
|
var valByDate = {}
|
||||||
@ -3252,6 +3278,7 @@ var Profiler = require('../profiler');
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// for each timeslot search active buckets
|
// for each timeslot search active buckets
|
||||||
var renderDataIndex = 0;
|
var renderDataIndex = 0;
|
||||||
var timeSlotIndex = 0;
|
var timeSlotIndex = 0;
|
||||||
@ -3261,10 +3288,13 @@ var Profiler = require('../profiler');
|
|||||||
var slotRows = rowsPerSlot[i]
|
var slotRows = rowsPerSlot[i]
|
||||||
if(slotRows) {
|
if(slotRows) {
|
||||||
for (var r = 0; r < slotRows.length; ++r) {
|
for (var r = 0; r < slotRows.length; ++r) {
|
||||||
|
|
||||||
var rr = slotRows[r];
|
var rr = slotRows[r];
|
||||||
++c;
|
++c;
|
||||||
renderDataPos[renderDataIndex] = rr[0]
|
renderDataPos[renderDataIndex] = rr[0]
|
||||||
renderData[renderDataIndex] = rr[1];
|
rr[1].forEach(function(rrr,index){
|
||||||
|
renderData[index][renderDataIndex] = rrr;
|
||||||
|
})
|
||||||
++renderDataIndex;
|
++renderDataIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3353,7 +3383,6 @@ var Profiler = require('../profiler');
|
|||||||
subdomains = [null]; // no subdomain
|
subdomains = [null]; // no subdomain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var url;
|
var url;
|
||||||
if (options.no_cdn) {
|
if (options.no_cdn) {
|
||||||
url = this._host();
|
url = this._host();
|
||||||
@ -3370,6 +3399,7 @@ var Profiler = require('../profiler');
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTileData: function(coord, zoom, callback) {
|
getTileData: function(coord, zoom, callback) {
|
||||||
|
|
||||||
if(!this._ready) {
|
if(!this._ready) {
|
||||||
this._tileQueue.push([coord, zoom, callback]);
|
this._tileQueue.push([coord, zoom, callback]);
|
||||||
} else {
|
} else {
|
||||||
@ -3401,9 +3431,18 @@ var Profiler = require('../profiler');
|
|||||||
|
|
||||||
var column_conv = this.options.column;
|
var column_conv = this.options.column;
|
||||||
|
|
||||||
|
var agg_columns;
|
||||||
|
if(this.options.countby.indexOf(";") > 0){
|
||||||
|
agg_columns = this.options.countby.split(";")
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
agg_columns = [this.options.countby]
|
||||||
|
}
|
||||||
|
|
||||||
if(this.options.is_time) {
|
if(this.options.is_time) {
|
||||||
column_conv = format("date_part('epoch', {column})", this.options);
|
column_conv = format("date_part('epoch', {column})", this.options);
|
||||||
}
|
}
|
||||||
|
console.log("columns are ", this.options.countby)
|
||||||
|
|
||||||
var sql = "" +
|
var sql = "" +
|
||||||
"WITH " +
|
"WITH " +
|
||||||
@ -3413,8 +3452,13 @@ var Profiler = require('../profiler');
|
|||||||
", CDB_XYZ_Extent({x}, {y}, {zoom}) as ext " +
|
", CDB_XYZ_Extent({x}, {y}, {zoom}) as ext " +
|
||||||
")," +
|
")," +
|
||||||
"cte AS ( "+
|
"cte AS ( "+
|
||||||
" SELECT ST_SnapToGrid(i.the_geom_webmercator, p.res) g" +
|
" SELECT ST_SnapToGrid(i.the_geom_webmercator, p.res) g"
|
||||||
", {countby} c" +
|
|
||||||
|
agg_columns.forEach(function(col,index){
|
||||||
|
sql = sql + ", "+col+" c"+index
|
||||||
|
}.bind(this))
|
||||||
|
|
||||||
|
sql = sql +
|
||||||
", floor(({column_conv} - {start})/{step}) d" +
|
", floor(({column_conv} - {start})/{step}) d" +
|
||||||
" FROM ({_sql}) i, par p " +
|
" FROM ({_sql}) i, par p " +
|
||||||
" WHERE i.the_geom_webmercator && p.ext " +
|
" WHERE i.the_geom_webmercator && p.ext " +
|
||||||
@ -3422,14 +3466,20 @@ var Profiler = require('../profiler');
|
|||||||
") " +
|
") " +
|
||||||
"" +
|
"" +
|
||||||
"SELECT (st_x(g)-st_xmin(p.ext))/p.res x__uint8, " +
|
"SELECT (st_x(g)-st_xmin(p.ext))/p.res x__uint8, " +
|
||||||
" (st_y(g)-st_ymin(p.ext))/p.res y__uint8," +
|
" (st_y(g)-st_ymin(p.ext))/p.res y__uint8"
|
||||||
" array_agg(c) vals__uint8," +
|
|
||||||
" array_agg(d) dates__uint16" +
|
agg_columns.forEach(function(col,index){
|
||||||
|
sql = sql + ", array_agg(c"+index+") vals__uint8_"+index
|
||||||
|
}.bind(this))
|
||||||
|
|
||||||
|
sql = sql +
|
||||||
|
", array_agg(d) dates__uint16" +
|
||||||
// the tile_size where are needed because the overlaps query in cte subquery includes the points
|
// the tile_size where are needed because the overlaps query in cte subquery includes the points
|
||||||
// in the left and bottom borders of the tile
|
// in the left and bottom borders of the tile
|
||||||
" FROM cte, par p where (st_y(g)-st_ymin(p.ext))/p.res < tile_size and (st_x(g)-st_xmin(p.ext))/p.res < tile_size GROUP BY x__uint8, y__uint8";
|
" FROM cte, par p where (st_y(g)-st_ymin(p.ext))/p.res < tile_size and (st_x(g)-st_xmin(p.ext))/p.res < tile_size GROUP BY x__uint8, y__uint8";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var query = format(sql, this.options, {
|
var query = format(sql, this.options, {
|
||||||
zoom: zoom,
|
zoom: zoom,
|
||||||
x: coord.x,
|
x: coord.x,
|
||||||
@ -3438,6 +3488,8 @@ var Profiler = require('../profiler');
|
|||||||
_sql: this.getSQL()
|
_sql: this.getSQL()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("sql is ", query)
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.sql(query, function (data) {
|
this.sql(query, function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -4212,10 +4264,12 @@ var Profiler = require('../profiler');
|
|||||||
.replace('{s}', subdomains[index])
|
.replace('{s}', subdomains[index])
|
||||||
|
|
||||||
var extra = this._extraParams();
|
var extra = this._extraParams();
|
||||||
|
|
||||||
torque.net.get( url + (extra ? "?" + extra: ''), function (data) {
|
torque.net.get( url + (extra ? "?" + extra: ''), function (data) {
|
||||||
prof_fetch_time.end();
|
prof_fetch_time.end();
|
||||||
if (data && data.responseText) {
|
if (data && data.responseText) {
|
||||||
var rows = JSON.parse(data.responseText);
|
var rows = JSON.parse(data.responseText);
|
||||||
|
console.log("tile data ", rows)
|
||||||
callback(self.proccessTile(rows, coord, zoom));
|
callback(self.proccessTile(rows, coord, zoom));
|
||||||
} else {
|
} else {
|
||||||
Profiler.metric('torque.provider.windshaft.tile.error').inc();
|
Profiler.metric('torque.provider.windshaft.tile.error').inc();
|
||||||
@ -4480,6 +4534,21 @@ var Profiler = require('../profiler');
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderVector(ctx,img,st){
|
||||||
|
var markerWidth = st['maker-width']
|
||||||
|
var direction = st['vector-direction']
|
||||||
|
var mag = st['vector-mag']
|
||||||
|
var lineWidth = st['marker-line-width']
|
||||||
|
var strokeStyle = st['marker-line-color']
|
||||||
|
ctx.lineWidth = lineWidth
|
||||||
|
ctx.strokeStyle = strokeStyle
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0,0);
|
||||||
|
ctx.lineTo(300,150);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
function renderSprite(ctx, img, st) {
|
function renderSprite(ctx, img, st) {
|
||||||
|
|
||||||
if(img.complete){
|
if(img.complete){
|
||||||
@ -4619,9 +4688,21 @@ var Filters = require('./torque_filters');
|
|||||||
generateSprite: function(shader, value, shaderVars) {
|
generateSprite: function(shader, value, shaderVars) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var prof = Profiler.metric('torque.renderer.point.generateSprite').start();
|
var prof = Profiler.metric('torque.renderer.point.generateSprite').start();
|
||||||
var st = shader.getStyle({
|
|
||||||
value: value
|
var values = {}
|
||||||
}, shaderVars);
|
|
||||||
|
if(value.length ==0){
|
||||||
|
values["value"] = value[0]
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
value.forEach(function(val,index){
|
||||||
|
values["value"+index] = val;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var st = shader.getStyle(values, shaderVars);
|
||||||
|
|
||||||
if(this._style === null || this._style !== st){
|
if(this._style === null || this._style !== st){
|
||||||
this._style = st;
|
this._style = st;
|
||||||
}
|
}
|
||||||
@ -4767,7 +4848,7 @@ var Filters = require('./torque_filters');
|
|||||||
var pixelIndex = tile.timeIndex[key];
|
var pixelIndex = tile.timeIndex[key];
|
||||||
for(var p = 0; p < activePixels; ++p) {
|
for(var p = 0; p < activePixels; ++p) {
|
||||||
var posIdx = tile.renderDataPos[pixelIndex + p];
|
var posIdx = tile.renderDataPos[pixelIndex + p];
|
||||||
var c = tile.renderData[pixelIndex + p];
|
var c = tile.renderData.map(function(a){return a[pixelIndex + p]});
|
||||||
if (c) {
|
if (c) {
|
||||||
var sp = sprites[c];
|
var sp = sprites[c];
|
||||||
if (sp === undefined) {
|
if (sp === undefined) {
|
||||||
@ -4823,6 +4904,7 @@ var Filters = require('./torque_filters');
|
|||||||
// return the value for x, y (tile coordinates)
|
// return the value for x, y (tile coordinates)
|
||||||
// null for no value
|
// null for no value
|
||||||
getValueFor: function(tile, step, px, py) {
|
getValueFor: function(tile, step, px, py) {
|
||||||
|
// console.log('getting value for tile ', tile, step, px, py)
|
||||||
var mercator = new torque.Mercator();
|
var mercator = new torque.Mercator();
|
||||||
var res = this.options.resolution;
|
var res = this.options.resolution;
|
||||||
var res2 = res >> 1;
|
var res2 = res >> 1;
|
||||||
@ -4833,13 +4915,15 @@ var Filters = require('./torque_filters');
|
|||||||
var pixelIndex = tile.timeIndex[step];
|
var pixelIndex = tile.timeIndex[step];
|
||||||
for(var p = 0; p < activePixels; ++p) {
|
for(var p = 0; p < activePixels; ++p) {
|
||||||
var posIdx = tile.renderDataPos[pixelIndex + p];
|
var posIdx = tile.renderDataPos[pixelIndex + p];
|
||||||
var c = tile.renderData[pixelIndex + p];
|
var c = [tile.renderData[0][pixelIndex + p], tile.renderData[1][pixelIndex + p]]
|
||||||
|
// console.log("tile.renderData ", tile.renderData[pixelIndex + p] )
|
||||||
if (c) {
|
if (c) {
|
||||||
var x = tile.x[posIdx];
|
var x = tile.x[posIdx];
|
||||||
var y = tileMax - tile.y[posIdx];
|
var y = tileMax - tile.y[posIdx];
|
||||||
var dx = px + res2 - x;
|
var dx = px + res2 - x;
|
||||||
var dy = py + res2 - y;
|
var dy = py + res2 - y;
|
||||||
if (dx >= 0 && dx < res && dy >= 0 && dy < res) {
|
if (dx >= 0 && dx < res && dy >= 0 && dy < res) {
|
||||||
|
// console.log('returning value ', c, " from ", tile.renderData[pixelIndex + p])
|
||||||
return {
|
return {
|
||||||
value: c,
|
value: c,
|
||||||
bbox: mercator.tilePixelBBox(
|
bbox: mercator.tilePixelBBox(
|
||||||
|
Loading…
Reference in New Issue
Block a user