Skip to content

Instantly share code, notes, and snippets.

@flibbertigibbet
Created March 10, 2015 18:26
Show Gist options
  • Save flibbertigibbet/5a971283c1f87aa4f598 to your computer and use it in GitHub Desktop.
Save flibbertigibbet/5a971283c1f87aa4f598 to your computer and use it in GitHub Desktop.
Example standalone Windshaft configuration
var Windshaft = require('./lib/windshaft');
var _ = require('underscore');
var tablename = 'YOUR TABLENAME HERE';
var style = '#' + tablename + ' { ' +
'line-color: #EFF3FF; ' +
'line-width: 2; ' +
'} ';
var config = {
base_url: '/tiles',
base_url_notable: '/tiles',
grainstore: {
datasource: {
user:'DATABASE USERNAME HERE',
password: 'DATABASE USER PASSWORD HERE',
host: '127.0.0.1',
port: 5432,
geometry_field: 'the_geom_webmercator',
srid: 3857
}
}, //see grainstore npm for other options
redis: {host: '127.0.0.1', port: 6379},
enable_cors: true,
req2params: function(req, callback){
// to enable specify the database column you'd like to interact with
// req.params.interactivity = 'COLUMN NAME';
req.params.dbname = 'DATABASE NAME HERE';
req.params.table = tablename;
// this is in case you want to test sql parameters eg ...png?sql=select * from my_table limit 10
req.params = _.extend({}, req.params, {style: style});
_.extend(req.params, req.query);
// send the finished req object on
callback(null,req);
}
};
// Initialize tile server on port 4000
var ws = new Windshaft.Server(config);
ws.listen(4000);
console.log("map tiles are now being served out of: http://localhost:4000" + config.base_url + '/:z/:x/:y');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment