2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
var testHelper = require('../support/test-helper');
|
2016-02-04 17:26:31 +08:00
|
|
|
var assert = require('../support/assert');
|
|
|
|
|
2019-10-07 15:40:50 +08:00
|
|
|
var cartodbServer = require('../../lib/server');
|
2019-10-07 16:44:45 +08:00
|
|
|
var ServerOptions = require('./ported/support/ported-server-options');
|
|
|
|
var testClient = require('./ported/support/test-client');
|
2016-02-04 17:26:31 +08:00
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
describe('overviews_queries', function () {
|
2018-04-16 22:16:23 +08:00
|
|
|
var server;
|
2016-02-04 17:26:31 +08:00
|
|
|
|
2018-04-16 22:16:23 +08:00
|
|
|
before(function () {
|
|
|
|
server = cartodbServer(ServerOptions);
|
|
|
|
server.setMaxListeners(0);
|
|
|
|
});
|
2016-02-04 17:26:31 +08:00
|
|
|
|
|
|
|
var IMAGE_EQUALS_TOLERANCE_PER_MIL = 2;
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
after(function () {
|
2016-02-04 17:26:31 +08:00
|
|
|
testHelper.rmdirRecursiveSync(global.environment.millstone.cache_basedir);
|
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
function imageCompareFn (fixture, done) {
|
|
|
|
return function (err, tile) {
|
2016-02-04 17:26:31 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
2016-02-22 23:36:06 +08:00
|
|
|
var referenceImagePath = './test/fixtures/' + fixture;
|
|
|
|
assert.imageBufferIsSimilarToFile(tile.body, referenceImagePath, IMAGE_EQUALS_TOLERANCE_PER_MIL, done);
|
2016-02-04 17:26:31 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('should not use overview for tables without overviews', function (done) {
|
|
|
|
testClient.getTile(testClient.defaultTableMapConfig('test_table'), 1, 0, 0,
|
|
|
|
imageCompareFn('test_table_1_0_0.png', done)
|
|
|
|
);
|
2016-02-04 17:26:31 +08:00
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('should not use overview for tables without overviews at z=2', function (done) {
|
|
|
|
testClient.getTile(testClient.defaultTableMapConfig('test_table'), 2, 1, 1,
|
|
|
|
imageCompareFn('test_table_2_1_1.png', done)
|
|
|
|
);
|
2016-02-04 17:26:31 +08:00
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('should not use overview for tables without overviews at z=2', function (done) {
|
|
|
|
testClient.getTile(testClient.defaultTableMapConfig('test_table'), 3, 3, 3,
|
|
|
|
imageCompareFn('test_table_3_3_3.png', done)
|
|
|
|
);
|
2016-02-04 17:26:31 +08:00
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('should use overview for zoom level 1', function (done) {
|
|
|
|
testClient.getTile(testClient.defaultTableMapConfig('test_table_overviews'), 1, 0, 0,
|
|
|
|
imageCompareFn('_vovw_1_test_table_1_0_0.png', done)
|
|
|
|
);
|
2016-02-04 17:26:31 +08:00
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('should use overview for zoom level 1', function (done) {
|
|
|
|
testClient.getTile(testClient.defaultTableMapConfig('test_table_overviews'), 2, 1, 1,
|
|
|
|
imageCompareFn('_vovw_2_test_table_2_1_1.png', done)
|
|
|
|
);
|
2016-02-04 17:26:31 +08:00
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('should not use overview for zoom level 3', function (done) {
|
|
|
|
testClient.getTile(testClient.defaultTableMapConfig('test_table_overviews'), 3, 3, 3,
|
|
|
|
imageCompareFn('test_table_3_3_3.png', done)
|
|
|
|
);
|
2016-02-04 17:26:31 +08:00
|
|
|
});
|
|
|
|
});
|