mapbox / mapnik-pool

manage a pool of mapnik map instances
Other
20 stars 22 forks source link

mapnik-pool

Build Status Coverage Status

mapnik-pool

If you want to use node-mapnik to render tiles in an async fashion for highest performance, you've come to the right place: you need a map pool. This is because you must ensure that when you call map.render no other threads are using that map instance. When you call an async function like map.render Node.js is creating a thread behind the scene.

install

npm install --save mapnik-pool

dependency structure

mapnik-pool is a peerDependency of node-mapnik: you bring your own Mapnik version, as long as its ~1.0.0.

example

var mapnik = require('mapnik'),
    mapnikPool = require('mapnik-pool')(mapnik),
    fs = require('fs');

var pool = mapnikPool.fromString(fs.readFileSync('mymap.xml', 'utf8'));

pool.acquire(function(err, map) {
    // pooled map
});

api

fromString(str, initOptions, mapOptions)