How to use the mapnik.versions 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 CartoDB / Windshaft / test / acceptance / server_gettile.js View on Github external
});

    // See http://github.com/CartoDB/Windshaft/issues/100
    var test_strictness = function(done) {
        var nonStrictMapConfig = TestClient.singleLayerMapConfig(
            "SELECT 1 as cartodb_id, 'SRID=3857;POINT(666 666)'::geometry as the_geom",
            "#test_table{point-transform: 'scale(100)';}"
        );
        var testClient = new TestClient(nonStrictMapConfig);
        testClient.getTile(0, 0, 0, {strict: 1}, function(err) {
            assert.ok(err);
            done();
        });
    };
    var test_strict_lbl = "unused directives are not tolerated if strict";
    if ( semver.satisfies(mapnik.versions.mapnik, '2.3.x') ) {
      // Strictness handling changed in 2.3.x, possibly a bug:
      // see http://github.com/mapnik/mapnik/issues/2301
      console.warn("Strictness test skipped due to http://github.com/mapnik/mapnik/issues/2301");
      it.skip(test_strict_lbl,  test_strictness);
    }
    else {
      it.skip(test_strict_lbl,  test_strictness);
    }

    it('high cpu regression with mapnik <2.3.x', function(done) {
        var sql = [
            "SELECT 'my polygon name here' AS name,",
            "st_envelope(st_buffer(st_transform(",
            "st_setsrid(st_makepoint(-26.6592894004,49.7990296995),4326),3857),10000000)) AS the_geom",
            "FROM generate_series(-6,6) x",
            "UNION ALL",
github CartoDB / Windshaft / test / support / server_options.js View on Github external
module.exports = function(opts) {
    
    var config = {
        base_url: '/database/:dbname/table/:table',
        base_url_notable: '/database/:dbname',
        grainstore: {
          datasource: global.environment.postgres,
          cachedir: global.environment.millstone.cache_basedir,
          mapnik_version: global.environment.mapnik_version || mapnik.versions.mapnik,
          gc_prob: 0 // run the garbage collector at each invocation
        },
        redis: global.environment.redis,
        enable_cors: global.environment.enable_cors,
        unbuffered_logging: true, // for smoother teardown from tests
        log_format: null, // do not log anything
        req2params: function(req, callback){

            if ( req.query.testUnexpectedError ) {
              callback('test unexpected error');
              return;
            }

            // no default interactivity. to enable specify the database column you'd like to interact with
            req.params.interactivity = null;
github CartoDB / Windshaft / test / integration / static_maps.js View on Github external
describe('static_maps', function() {

//    var redisPool = new RedisPool(global.environment.redis);
//    var mapStore  = new windshaft.storage.MapStore({ pool: redisPool });

    var rendererFactory = new windshaft.renderer.Factory({
        mapnik: {
            grainstore: {
                datasource: global.environment.postgres,
                cachedir: global.environment.millstone.cache_basedir,
                mapnik_version: global.environment.mapnik_version || mapnik.versions.mapnik,
                gc_prob: 0 // run the garbage collector at each invocation
            },
            mapnik: {
                poolSize: 4,//require('os').cpus().length,
                metatile: 1,
                bufferSize: 64,
                snapToGrid: false,
                clipByBox2d: false, // this requires postgis >=2.2 and geos >=3.5
                scale_factors: [1, 2],
                limits: {
                    render: 0,
                    cacheOnTimeout: true
                }
            }
        },
        http: {
github CartoDB / Windshaft / lib / windshaft / server.js View on Github external
module.exports = function(opts){
    var opts = opts || {};
    if ( ! opts.grainstore ) opts.grainstore = {};

    if (!opts.grainstore.mapnik_version) {
        opts.grainstore.mapnik_version = mapnik.versions.mapnik;
    }

    // Be nice and warn if configured mapnik version is != instaled mapnik version
    if (mapnik.versions.mapnik != opts.grainstore.mapnik_version) {
        console.warn('WARNING: detected mapnik version (' + mapnik.versions.mapnik + ')' +
            ' != configured mapnik version (' + opts.grainstore.mapnik_version + ')');
    }

    // Set carto renderer configuration for MMLStore
    if ( ! opts.grainstore.carto_env ) opts.grainstore.carto_env = {};
    var cenv = opts.grainstore.carto_env;
    if ( ! cenv.validation_data ) cenv.validation_data = {};
    if ( ! cenv.validation_data.fonts ) {
      mapnik.register_system_fonts();
      mapnik.register_default_fonts();
      var available_fonts = _.keys(mapnik.fontFiles());
github mapbox / mapbox-studio-classic / lib / source.js View on Github external
return l;
    });
    opts.json = JSON.stringify({ vector_layers: data.vector_layers });

    // If there are raster layers present add a default style for each.
    if (rasters.length) opts.Stylesheet = [{
        id: 'rasters.mss',
        data: rasters.map(function(r) {
            return '#' + r + ' { raster-opacity:1; raster-scaling:bilinear; }';
        }).join('\n')
    }];

    var xml;
    try {
        xml = new carto.Renderer(null, {
            mapnik_version: mapnik.versions.mapnik
        }).render(tm.sortkeys(opts));
    } catch(err) {
        return callback(err);
    }
    return callback(null, xml);
};
github mapbox / mapbox-studio-classic / lib / style.js View on Github external
// Styles can provide a hidden _properties key with
            // layer-specific property overrides. Current workaround to layer
            // properties that could (?) eventually be controlled via carto.
            properties: (data._properties && data._properties[layer.id]) || {},
            srs:tm.srs['900913']
        }; });

        opts.Stylesheet = _(data.styles).map(function(style,basename) { return {
            id: basename,
            data: style
        }; });

        var xml;
        try {
            xml = new carto.Renderer(null, {
                mapnik_version: mapnik.versions.mapnik
            }).render(tm.sortkeys(opts));
        } catch(err) {
            return callback(err);
        }
        return callback(null, xml);
    });
};
github CartoDB / Windshaft / test / support / test_client.js View on Github external
var redisClient = require('redis').createClient(global.environment.redis.port);

mapnik.register_system_fonts();
mapnik.register_default_fonts();
var cartoEnv = {
    validation_data: {
        fonts: _.keys(mapnik.fontFiles())
    }
};

var rendererOptions = global.environment.renderer;
var grainstoreOptions = {
    carto_env: cartoEnv,
    datasource: global.environment.postgres,
    cachedir: global.environment.millstone.cache_basedir,
    mapnik_version: global.environment.mapnik_version || mapnik.versions.mapnik
};
var rendererFactoryOptions = {
    mapnik: {
        grainstore: grainstoreOptions,
        mapnik: rendererOptions.mapnik
    },
    torque: rendererOptions.torque,
    http: rendererOptions.http
};

function TestClient(mapConfig, overrideOptions, onTileErrorStrategy) {
    var options = _.extend({}, rendererFactoryOptions);
    overrideOptions = overrideOptions || {};
    _.each(overrideOptions, function(overrideConfig, key) {
        options[key] = _.extend({}, options[key], overrideConfig);
    });
github CartoDB / Windshaft / lib / windshaft / server.js View on Github external
getVersion: function() {
          var version = {};
          version.windshaft = require('../../package.json').version;
          version.grainstore = grainstore.version();
          version.node_mapnik = mapnik.version;
          version.mapnik = mapnik.versions.mapnik;
          return version;
        }
    });
github mapbox / mapbox-studio-classic / lib / source.js View on Github external
var Bridge = require('tilelive-bridge');
var xray = require('tilelive-vector').xray;
var TileJSON = require('tilejson');
var tilelive = require('tilelive');
var CachingTileJSON = require('./cache');
var CachingBridge = require('./cache');
var mapnik = require('mapnik');
var mapnikref = require('mapnik-reference');
var upload = require('mapbox-upload');
var progress = require('progress-stream');
var task = require('./task');
var zlib = require('zlib');
var abaculus = require('abaculus');
var getExtent = require('mapnik-omnivore').getCenterAndExtent;

var datasources_spec = mapnikref.load(mapnik.versions.mapnik).datasources;


var defaults = {
    name:'',
    description:'',
    attribution:'',
    minzoom:0,
    maxzoom:6,
    center:[0,0,3],
    Layer:[],
    _prefs: {
        saveCenter: true,
        disabled: [],
        inspector: false,
        mapid: '',
        rev: ''
github mapbox / mapbox-studio-classic / lib / server.js View on Github external
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
var mapnik_omnivore = require('mapnik-omnivore');
var printer = require('abaculus');
var task = require('./task');
var getport = require('getport');
var app = express();
var saferstringify = require('safer-stringify');
var gazetteer = require('gazetteer');
var carto = require('carto');
var version = require('./../package.json').version.replace(/^\s+|\s+$/g, '');
var nocache = Math.random().toString(36).substr(-8);
var logger = require('fastlog')('', 'debug', '<${timestamp}> ${level}');
var mapnik = require('mapnik');
if (!carto.tree.Reference.setVersion(mapnik.versions.mapnik)) {
    throw new Error("Could not set mapnik version to " + mapnik.versions.mapnik);
}

app.use(bodyParser.json());
app.use(require('./oauth'));
app.use(app.router);
app.use('/app', express.static(__dirname + '/../app', { maxAge:3600e3 }));
app.use('/ext', express.static(__dirname + '/../ext', { maxAge:3600e3 }));
app.use('/base', express.static(require('mapbox-base-css').dirname, { maxAge:3600e3 }));

middleware.style = [
    middleware.auth,
    middleware.exporting,
    middleware.loadStyle
];