2015-09-26 01:21:20 +08:00
|
|
|
require('../../support/test_helper');
|
2015-07-08 05:46:58 +08:00
|
|
|
|
|
|
|
var assert = require('../../support/assert');
|
|
|
|
var testClient = require('./support/test_client');
|
|
|
|
|
2015-09-17 00:09:39 +08:00
|
|
|
var PortedServerOptions = require('./support/ported_server_options');
|
|
|
|
var BaseController = require('../../../lib/cartodb/controllers/base');
|
|
|
|
|
2015-07-08 05:46:58 +08:00
|
|
|
describe('blend png renderer', function() {
|
|
|
|
|
2015-09-17 00:09:39 +08:00
|
|
|
var req2paramsFn;
|
|
|
|
before(function() {
|
|
|
|
req2paramsFn = BaseController.prototype.req2params;
|
|
|
|
BaseController.prototype.req2params = PortedServerOptions.req2params;
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function() {
|
|
|
|
BaseController.prototype.req2params = req2paramsFn;
|
|
|
|
});
|
|
|
|
|
2015-07-08 05:46:58 +08:00
|
|
|
var IMAGE_TOLERANCE_PER_MIL = 20;
|
|
|
|
|
|
|
|
function plainTorqueMapConfig(plainColor) {
|
|
|
|
return {
|
|
|
|
version: '1.2.0',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
type: 'plain',
|
|
|
|
options: {
|
|
|
|
color: plainColor
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'torque',
|
|
|
|
options: {
|
|
|
|
sql: "SELECT * FROM populated_places_simple_reduced " +
|
|
|
|
"where the_geom && ST_MakeEnvelope(-90, 0, 90, 65)",
|
|
|
|
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 testScenarios = [
|
|
|
|
{
|
|
|
|
tile: {
|
|
|
|
z: 2,
|
|
|
|
x: 2,
|
|
|
|
y: 1,
|
|
|
|
layer: 'all',
|
|
|
|
format: 'png'
|
|
|
|
},
|
|
|
|
plainColor: 'white'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
tile: {
|
|
|
|
z: 2,
|
|
|
|
x: 1,
|
|
|
|
y: 1,
|
|
|
|
layer: 'all',
|
|
|
|
format: 'png'
|
|
|
|
},
|
|
|
|
plainColor: '#339900'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
function blendPngFixture(zxy) {
|
|
|
|
return './test/fixtures/blend/blend-plain-torque-' + zxy.join('.') + '.png';
|
|
|
|
}
|
|
|
|
|
|
|
|
testScenarios.forEach(function(testScenario) {
|
|
|
|
var tileRequest = testScenario.tile;
|
|
|
|
var zxy = [tileRequest.z, tileRequest.x, tileRequest.y];
|
|
|
|
it('tile all/' + zxy.join('/') + '.png', function (done) {
|
|
|
|
testClient.getTileLayer(plainTorqueMapConfig(testScenario.plainColor), tileRequest, function(err, res) {
|
2016-02-22 23:36:06 +08:00
|
|
|
assert.imageBufferIsSimilarToFile(res.body, blendPngFixture(zxy), IMAGE_TOLERANCE_PER_MIL,
|
|
|
|
function(err) {
|
|
|
|
assert.ok(!err);
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
);
|
2015-07-08 05:46:58 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|