2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
require('../support/test-helper');
|
2018-06-22 23:31:05 +08:00
|
|
|
|
|
|
|
const assert = require('../support/assert');
|
|
|
|
const TestClient = require('../support/test-client');
|
2019-10-07 16:10:51 +08:00
|
|
|
const serverOptions = require('../../lib/server-options');
|
2018-06-22 23:31:05 +08:00
|
|
|
|
|
|
|
describe('layergroup metadata', function () {
|
2018-10-17 01:32:55 +08:00
|
|
|
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
|
|
|
|
|
|
|
|
before(function () {
|
2019-02-22 15:31:22 +08:00
|
|
|
serverOptions.renderer.mvt.usePostGIS = true;
|
2018-10-17 01:32:55 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
|
|
|
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
|
|
|
|
});
|
|
|
|
|
2020-05-26 22:56:50 +08:00
|
|
|
[1234, 'default_public', undefined].forEach(apiKey => {
|
2019-11-14 03:08:04 +08:00
|
|
|
it(`tiles base urls ${apiKey ? `with api key: ${apiKey}` : 'without api key'}`, function (done) {
|
2018-06-22 23:31:05 +08:00
|
|
|
const mapConfig = {
|
|
|
|
version: '1.7.0',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
type: 'cartodb',
|
|
|
|
options: {
|
2019-10-22 01:07:24 +08:00
|
|
|
sql: 'select * from populated_places_simple_reduced'
|
2018-06-22 23:31:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
const host = `https://localhost.localhost.lan:${global.environment.port}`;
|
|
|
|
|
2019-11-14 03:08:04 +08:00
|
|
|
const testClient = new TestClient(mapConfig, apiKey);
|
2018-06-22 23:31:05 +08:00
|
|
|
testClient.getLayergroup((err, body) => {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
let urlLayer = `${host}/api/v1/map/${body.layergroupid}/layer0/{z}/{x}/{y}.mvt`;
|
|
|
|
let urlNoLayer = `${host}/api/v1/map/${body.layergroupid}/{z}/{x}/{y}.mvt`;
|
|
|
|
|
2019-11-14 03:08:04 +08:00
|
|
|
if (apiKey) {
|
|
|
|
urlLayer += `?api_key=${apiKey}`;
|
|
|
|
urlNoLayer += `?api_key=${apiKey}`;
|
2018-06-22 23:31:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
assert.ok(body.layergroupid);
|
2019-10-22 01:41:03 +08:00
|
|
|
assert.strictEqual(body.metadata.layers[0].tilejson.vector.tiles[0], urlLayer);
|
|
|
|
assert.strictEqual(body.metadata.tilejson.vector.tiles[0], urlNoLayer);
|
|
|
|
assert.strictEqual(body.metadata.url.vector.urlTemplate, urlNoLayer);
|
2018-06-22 23:31:05 +08:00
|
|
|
|
|
|
|
testClient.drain(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|