Windshaft-cartodb/test/acceptance/ported/torque-zero-zero-test.js

92 lines
2.9 KiB
JavaScript
Raw Normal View History

'use strict';
require('../../support/test-helper');
2015-07-08 05:46:58 +08:00
var assert = require('../../support/assert');
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,
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,
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) {
assert.ok(!err, err);
try {
assert.deepEqual(JSON.parse(res.body), tile.expects);
} catch (ex) {
// With Proj 5.1 this bug has been fixed and the point appears in all tiles
assert.deepEqual(JSON.parse(res.body), tile.expects_fixed);
}
2015-07-08 05:46:58 +08:00
done();
});
});
});
});