-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
executable file
·53 lines (47 loc) · 1.03 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 extend = require('lodash/extend');
var Backend = require('./backend.js');
module.exports = function() {
var options = {
xml: null,
metatile: 1,
resolution: 4,
bufferSize: 128,
tileSize: 256,
scale: 1,
format: 'png',
interactivity: false,
autoLoadFonts: true
};
for (var i = 0, n = arguments.length; i < n; i++) {
extend(options, arguments[i]);
}
var source;
/**
* Initializes the mapnik datasource.
*
* @param {TileServer} server
* @param {function} callback(err, fn)
* @return {void}
*/
function initialize(server, callback) {
source = new Backend(server, options);
source.initialize(callback);
}
/**
* Renders a tile and returns the result as a buffer (PNG),
* plus the headers that should accompany it.
*
* @param {TileServer} server
* @param {TileRequest} req
* @param {function} callback(err, buffer, headers)
* @return {void}
*/
function serve(server, req, callback) {
source.getTile(req, callback);
}
return {
name: 'vtile-raster',
init: initialize,
serve: serve
};
};