Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add support for reading environment settings out of the mapnik_settin…

…gs.js before mapnik is loaded (sets us up for supporting ICU_DATA, PROJ_LIB, GDAL_DATA, etc)
  • Loading branch information...
commit cd74f909bcea110704d701fdb3fc0c3f2e1f4eda 1 parent 2db3420
@springmeyer springmeyer authored
Showing with 22 additions and 8 deletions.
  1. +22 −8 lib/mapnik.js
View
30 lib/mapnik.js
@@ -1,20 +1,34 @@
-var path = require('path'),
- _settings = require('./mapnik_settings'),
- mapnik = require('./_mapnik.node');
+var settings = require('./mapnik_settings');
+
+// set custom env settings before loading mapnik
+if (settings.env) {
+ var process_keys = Object.keys(process.env);
+ for (key in settings.env) {
+ if (process_keys.indexOf(key) == -1) {
+ console.log("Setting '" + key + "' to '"+ settings.env[key] + "'");
+ process.env[key] = settings.env[key];
+ } else {
+ console.warn("Setting '" + key + "=" + process.env[key] + "' detected in both process.env and mapnik.settings.env (leaving process.env untouched)");
+ }
+ }
+}
+
+var path = require('path');
+var mapnik = require('./_mapnik.node');
exports = module.exports = mapnik;
-exports.settings = _settings;
+exports.settings = settings;
exports.version = require('../package').version;
-if (_settings.paths.fonts) {
+if (settings.paths.fonts) {
// TODO - make async and warn if not successful
- mapnik.register_fonts(_settings.paths.fonts, {recurse: true});
+ mapnik.register_fonts(settings.paths.fonts, {recurse: true});
}
-if (_settings.paths.input_plugins) {
+if (settings.paths.input_plugins) {
// TODO - make async and warn if not successful
- mapnik.register_datasources(_settings.paths.input_plugins);
+ mapnik.register_datasources(settings.paths.input_plugins);
}
// TODO - move into mapnik core - http://trac.mapnik.org/ticket/602
Please sign in to comment.
Something went wrong with that request. Please try again.