/usr/bin/mapnik-render is in node-mapnik 1.2.0-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 54 55 56 57 58 59 | #!/usr/bin/nodejs
var fs = require('fs');
var path = require('path');
var child_process = require('child_process');
var usage = 'usage: render.js <stylesheet> <image>';
var stylesheet = process.argv[2];
if (!stylesheet) {
console.log(usage);
process.exit(1);
}
var image = process.argv[3];
if (!image) {
console.log(usage);
process.exit(1);
}
var mapnik = require('mapnik');
function renderMap(stylesheet, image) {
var map = new mapnik.Map(600, 400);
map.loadSync(stylesheet);
map.zoomAll();
map.renderFileSync(image);
child_process.exec('open ' + image);
}
if (path.extname(stylesheet).match(/.mml/i)) {
try {
var carto = require('carto');
new carto.Renderer({
filename: stylesheet,
local_data_dir: path.dirname(stylesheet)
}).render(fs.readFileSync(stylesheet, 'utf-8'), function(err, output) {
if (err) {
if (Array.isArray(err)) {
err.forEach(function(e) {
carto.writeError(e, options);
});
}
process.exit(1);
} else {
fs.writeFileSync(
stylesheet.replace('mml', 'xml'),
output, 'utf-8');
stylesheet = stylesheet.replace('mml', 'xml');
renderMap(stylesheet, image);
}
});
} catch (e) {
console.log('Carto is required to render .mml files.');
process.exit(1);
}
} else {
renderMap(stylesheet, image);
}
|