How to use the mapnik.settings function in mapnik

To help you get started, we’ve selected a few mapnik examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mapbox / preprocessorcerer / preprocessors / togeojson-gpx.preprocessor.js View on Github external
'use strict';
const gdal = require('gdal');
const fs = require('fs');
const mkdirp = require('mkdirp');
const queue = require('queue-async');
const spawn = require('child_process').spawn;
const path = require('path');
const digest = require('@mapbox/mapnik-omnivore').digest;
const mapnik = require('mapnik');
const invalid = require('../lib/invalid');
const mapnik_index = mapnik.settings.paths.mapnik_index;
if (!fs.existsSync(mapnik_index)) {
  throw new Error('mapnik-index does not exist at ' + mapnik_index);
}

// disable in production
// gdal.verbose();

module.exports = function(infile, outdirectory, callback) {
  mkdirp(outdirectory, (err) => {
    if (err) return callback(err);

    const geojson_files = [];
    let ds_gpx;
    let full_feature_cnt = 0;
    const wgs84 = gdal.SpatialReference.fromEPSG(4326);
github mapbox / preprocessorcerer / preprocessors / spatial-index.preprocessor.js View on Github external
'use strict';
const path = require('path');
const fs = require('fs');
const spawn = require('child_process').spawn;
const mapnik = require('mapnik');
const mapnik_index = mapnik.settings.paths.mapnik_index;
const invalid = require('../lib/invalid');
if (!fs.existsSync(mapnik_index)) {
  throw new Error('mapnik-index does not exist at ' + mapnik_index);
}

const mkdirp = require('mkdirp');

module.exports = function(infile, outdir, callback) {
  // outfile will be used for both the copied original and the index file
  const outfile = path.join(outdir, path.basename(infile));

  // Create copy of original file into new dir
  function copy(finished) {
    fs.createReadStream(infile)
      .once('error', callback)
      .pipe(fs.createWriteStream(outfile))
github stepankuzmin / tilelive-postgis / src / index.js View on Github external
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);