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

144 lines
4.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 png renderer', function () {
2015-07-08 05:46:58 +08:00
var IMAGE_TOLERANCE_PER_MIL = 20;
2019-10-22 01:07:24 +08:00
var torquePngPointsMapConfig = {
2015-07-08 05:46:58 +08:00
version: '1.2.0',
layers: [
{
type: 'torque',
options: {
2019-10-22 01:07:24 +08:00
sql: 'SELECT * FROM populated_places_simple_reduced where the_geom' +
' && ST_MakeEnvelope(-90, 0, 90, 65)',
2015-07-08 05:46:58 +08:00
cartocss: [
'Map {',
' buffer-size:0;',
' -torque-frame-count:1;',
' -torque-animation-duration:30;',
' -torque-time-attribute:"cartodb_id";',
' -torque-aggregation-function:"count(cartodb_id)";',
' -torque-resolution:1;',
' -torque-data-aggregation:linear;',
'}',
'#populated_places_simple_reduced{',
' comp-op: multiply;',
' marker-fill-opacity: 1;',
' marker-line-color: #FFF;',
' marker-line-width: 0;',
' marker-line-opacity: 1;',
' marker-type: rectangle;',
' marker-width: 3;',
' marker-fill: #FFCC00;',
'}'
].join(' '),
cartocss_version: '2.3.0'
}
}
]
};
var tileRequests = [
{
z: 2,
x: 2,
y: 1,
layer: 0,
format: 'torque.png'
},
{
z: 2,
x: 1,
y: 1,
layer: 0,
format: 'torque.png'
}
];
2019-10-22 01:07:24 +08:00
function torquePngFixture (zxy) {
2015-07-08 05:46:58 +08:00
return './test/fixtures/torque/populated_places_simple_reduced-' + zxy.join('.') + '.png';
}
2019-10-22 01:07:24 +08:00
tileRequests.forEach(function (tileRequest) {
var z = tileRequest.z;
var x = tileRequest.x;
var y = tileRequest.y;
2015-07-08 05:46:58 +08:00
var zxy = [z, x, y];
it('tile ' + zxy.join('/') + '.torque.png', function (done) {
2019-10-22 01:07:24 +08:00
testClient.getTileLayer(torquePngPointsMapConfig, tileRequest, function (err, res) {
2019-10-25 00:38:37 +08:00
assert.ifError(err);
2016-02-22 23:36:06 +08:00
assert.imageBufferIsSimilarToFile(res.body, torquePngFixture(zxy), IMAGE_TOLERANCE_PER_MIL,
2019-10-22 01:07:24 +08:00
function (err) {
2016-02-22 23:36:06 +08:00
assert.ok(!err);
done();
}
);
2015-07-08 05:46:58 +08:00
});
});
});
var mapConfigTorqueOffset = {
version: '1.3.0',
layers: [
{
type: 'torque',
options: {
2019-10-22 01:07:24 +08:00
sql: 'SELECT * FROM populated_places_simple_reduced',
2015-07-08 05:46:58 +08:00
cartocss: [
'Map {',
'buffer-size:0;',
'-torque-frame-count:1;',
'-torque-animation-duration:30;',
'-torque-time-attribute:"cartodb_id";',
'-torque-aggregation-function:"count(cartodb_id)";',
'-torque-resolution:2;',
'-torque-data-aggregation:linear;',
'}',
'',
'#populated_places_simple_reduced{',
' comp-op: lighter;',
' marker-fill-opacity: 0.9;',
' marker-line-color: #2167AB;',
' marker-line-width: 5;',
' marker-line-opacity: 1;',
' marker-type: ellipse;',
' marker-width: 6;',
' marker-fill: #FF9900;',
'}',
'#populated_places_simple_reduced[frame-offset=1] {',
' marker-width:8;',
' marker-fill-opacity:0.45; ',
'}',
'#populated_places_simple_reduced[frame-offset=2] {',
' marker-width:10;',
' marker-fill-opacity:0.225; ',
'}'
].join(' '),
cartocss_version: '2.3.0'
}
}
]
};
2019-10-22 01:07:24 +08:00
it('torque static map with offset', function (done) {
var w = 600;
var h = 400;
2015-07-08 05:46:58 +08:00
2019-10-22 01:07:24 +08:00
testClient.getStaticBbox(mapConfigTorqueOffset, -170, -87, 170, 87, w, h, function (err, res, img) {
2015-07-08 05:46:58 +08:00
if (err) {
return done(err);
}
assert.strictEqual(img.width(), w);
assert.strictEqual(img.height(), h);
2015-07-08 05:46:58 +08:00
done();
});
});
});