Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const im: mapnik.Image = new mapnik.Image(256, 256);
map.render(im, function xxx(err: Error, im: mapnik.Image) {
if (err) throw err;
im.encode('png', function xxxx(err: Error, buffer: Buffer) {
if (err) throw err;
fs.writeFile('map.png', buffer, function xxxxx(err: Error | null) {
if (err) throw err;
console.log('saved map image to map.png');
});
});
});
});
// new mapnik.Image.open("xxx").save("xx");
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins, 'shape.input'));
const ds: mapnik.Datasource = new mapnik.Datasource({type: 'shape', file: 'test/data/world_merc.shp'});
const featureset: mapnik.Featureset = ds.featureset();
const geojson: any = {
type: "FeatureCollection",
features: [
]
};
let feat: mapnik.FeaturesetNext = featureset.next();
while (feat) {
geojson.features.push(JSON.parse(feat.toJSON()));
feat = featureset.next();
}
fs.writeFileSync("output.geojson", JSON.stringify(geojson, null, 2));
var mapnik = require('mapnik'),
mapnikPool = require('mapnik-pool')(mapnik),
mercator = new(require('sphericalmercator'))(),
nfs = require('node-fs'),
request = require('request'),
path = require('path'),
fs = require('fs');
mapnik.register_default_input_plugins();
// register geojson as a datasource in mapnik
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'geojson.input'));
// create a space to hold pools of maps for repeat referencing
mapnik.pools = {};
var Tiles = function( koop ){
this.mapnikHeader = '<map>';
this.mapnikFooter = '</map>';
this.buildTableQuery = function( table, fields ){
var select = "(Select geom, ";
var list = [];
fields.forEach(function(field, i){
list.push("feature->'properties'->>'"+field.name+"' as "+field.name);
});
var mapnik = require('mapnik');
var path = require('path');
var fs = require('fs');
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins, 'geojson.input'));
var fixtures = {
"zero-point": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": []
},
"properties": {}
}
]
},
"zero-line": {
const path = require('path');
const mapnik = require('mapnik');
const mapnikPool = require('mapnik-pool')(mapnik);
const parse = require('./parse');
const postgisInput = path.resolve(mapnik.settings.paths.input_plugins, 'postgis.input');
mapnik.register_datasource(postgisInput);
const srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over';
const PostgisSource = function PostgisSource(uri, callback) {
const options = parse(uri);
const { layerName } = options;
delete options.layerName;
const datasource = new mapnik.Datasource(options);
const layer = new mapnik.Layer(layerName);
layer.datasource = datasource;
const map = new mapnik.Map(256, 256, srs);
map.add_layer(layer);