forked from naturalatlas/tilestrata-vtile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (50 loc) · 1.68 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var tilestrata = require('tilestrata');
var vtileraster = require('tilestrata-vtile-raster');
var assertVTile = require('./utils/assertVTile.js');
var TileServer = tilestrata.TileServer;
var TileRequest = tilestrata.TileRequest;
var vtile = require('../index.js');
var assert = require('chai').assert;
var fs = require('fs');
describe('Provider Implementation "vtile"', function() {
describe('serve()', function() {
it('should render tile', function(done) {
var server = new TileServer();
var req = TileRequest.parse('/layer/5/5/12/tile.png');
var provider = vtile({
xml: __dirname + '/data/test.xml',
metatile: 1,
bufferSize: 128
});
provider.init(server, function(err) {
assert.isFalse(!!err, err);
provider.serve(server, req, function(err, buffer, headers) {
assert.isFalse(!!err, err);
assert.deepEqual(headers, {'Content-Type': 'application/x-protobuf'});
assert.instanceOf(buffer, Buffer);
assertVTile(5,5,12,buffer,__dirname + '/fixtures/world.pbf');
done();
});
});
});
it('should render tile w/metatile set', function(done) {
var server = new TileServer();
var req = TileRequest.parse('/layer/5/5/12/tile.png');
var provider = vtile({
xml: __dirname + '/data/test.xml',
metatile: 4,
bufferSize: 128
});
provider.init(server, function(err) {
assert.isFalse(!!err, err);
provider.serve(server, req, function(err, buffer, headers) {
assert.isFalse(!!err, err);
assert.deepEqual(headers, {'Content-Type': 'application/x-protobuf'});
assert.instanceOf(buffer, Buffer);
assertVTile(5,5,12,buffer,__dirname + '/fixtures/world_metatile.pbf');
done();
});
});
});
});
});