2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
require('../../support/test-helper');
|
2015-07-08 05:46:58 +08:00
|
|
|
|
|
|
|
var assert = require('../../support/assert');
|
2019-10-07 16:44:45 +08:00
|
|
|
var testClient = require('./support/test-client');
|
2015-07-08 05:46:58 +08:00
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
describe('torque tiles at 0,0 point', function () {
|
2015-07-08 05:46:58 +08:00
|
|
|
/*
|
|
|
|
Tiles are represented as in:
|
|
|
|
|
|
|
|
---------
|
|
|
|
| TL | TR |
|
|
|
|
|--(0,0)--|
|
|
|
|
| BL | BR |
|
|
|
|
---------
|
|
|
|
*/
|
|
|
|
|
|
|
|
var tiles = [
|
|
|
|
{
|
|
|
|
what: 'tl',
|
|
|
|
x: 3,
|
|
|
|
y: 3,
|
2018-07-11 18:25:50 +08:00
|
|
|
expects: [],
|
2019-10-22 01:07:24 +08:00
|
|
|
expects_fixed: [{ x__uint8: 1, y__uint8: 0, vals__uint8: [1], dates__uint16: [0] }]
|
2015-07-08 05:46:58 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
what: 'tr',
|
|
|
|
x: 4,
|
|
|
|
y: 3,
|
2018-07-11 18:25:50 +08:00
|
|
|
expects: [],
|
2019-10-22 01:07:24 +08:00
|
|
|
expects_fixed: [{ x__uint8: 0, y__uint8: 0, vals__uint8: [1], dates__uint16: [0] }]
|
2015-07-08 05:46:58 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
what: 'bl',
|
|
|
|
x: 3,
|
|
|
|
y: 4,
|
2019-10-22 01:07:24 +08:00
|
|
|
expects: [{ x__uint8: 1, y__uint8: 1, vals__uint8: [1], dates__uint16: [0] }]
|
2015-07-08 05:46:58 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
what: 'br',
|
|
|
|
x: 4,
|
|
|
|
y: 4,
|
2019-10-22 01:07:24 +08:00
|
|
|
expects: [{ x__uint8: 0, y__uint8: 1, vals__uint8: [1], dates__uint16: [0] }]
|
2015-07-08 05:46:58 +08:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
tiles.forEach(function (tile) {
|
|
|
|
it(tile.what, function (done) {
|
2015-07-08 05:46:58 +08:00
|
|
|
var query = 'select 1 cartodb_id,' +
|
|
|
|
' ST_Transform(ST_SetSRID(ST_MakePoint(0, 0), 4326), 3857) the_geom_webmercator';
|
2019-10-22 01:07:24 +08:00
|
|
|
var mapConfig = {
|
2015-07-08 05:46:58 +08:00
|
|
|
version: '1.3.0',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
type: 'torque',
|
|
|
|
options: {
|
|
|
|
sql: query,
|
|
|
|
cartocss: [
|
|
|
|
'Map {',
|
|
|
|
' -torque-time-attribute: "cartodb_id";',
|
|
|
|
' -torque-aggregation-function: "count(cartodb_id)";',
|
|
|
|
' -torque-frame-count: 1;',
|
|
|
|
' -torque-animation-duration: 15;',
|
|
|
|
' -torque-resolution: 128',
|
|
|
|
'}',
|
|
|
|
'#layer {',
|
|
|
|
' marker-fill: #fff;',
|
|
|
|
' marker-fill-opacity: 0.4;',
|
|
|
|
' marker-width: 1;',
|
|
|
|
'}'
|
|
|
|
].join(' '),
|
|
|
|
cartocss_version: '2.3.0'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
testClient.getTorque(mapConfig, 0, 3, tile.x, tile.y, function (err, res) {
|
2018-07-11 18:25:50 +08:00
|
|
|
assert.ok(!err, err);
|
|
|
|
try {
|
2019-10-22 01:52:51 +08:00
|
|
|
assert.deepStrictEqual(JSON.parse(res.body), tile.expects);
|
2018-07-11 18:25:50 +08:00
|
|
|
} catch (ex) {
|
|
|
|
// With Proj 5.1 this bug has been fixed and the point appears in all tiles
|
2019-10-22 01:52:51 +08:00
|
|
|
assert.deepStrictEqual(JSON.parse(res.body), tile.expects_fixed);
|
2018-07-11 18:25:50 +08:00
|
|
|
}
|
2015-07-08 05:46:58 +08:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|