Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ahinz committed Jul 5, 2013
0 parents commit 680b655
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "opentreemap-tiler",
"version": "0.0.1-SNAPSHOT",
"description": "Wraps windshaft to provide tiles for OTM",
"repository": {
"type": "git",
"url": "https://github.com/azavea/OpenTreeMap-tiler.git"
},
"dependencies": {
"windshaft": "git+https://github.com/azavea/Windshaft#master",
"underscore": "~1.3"
},
"licenses": [{
"type": "BSD",
"url": "https://github.com/Vizzuality/Windshaft/blob/master/LICENCE"
}]
}
40 changes: 40 additions & 0 deletions tiler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var Windshaft = require('windshaft');
var _ = require('underscore');
var config = {
base_url: '/:cache_key/database/:dbname/table/:table',
base_url_notable: '/:cache_key/database/:dbname/table',
grainstore: {
datasource: {
user:'otm',
password:'otm',
host: 'localhost',
port: 5432 }
}, //see grainstore npm for other options
redis: {host: '127.0.0.1', port: 6379},
enable_cors: true,
postgres: { password: 'otm', user: 'otm' },
req2params: function(req, callback){

// no default interactivity. to enable specify the database column you'd like to interact with
req.params.interactivity = null;

// this is in case you want to test sql parameters eg ...png?sql=select * from my_table limit 10
req.params = _.extend({}, req.params);
_.extend(req.params, req.query);

// send the finished req object on
callback(null,req);
},
afterTileRender: function(req, res, tile, headers, callback) {
headers['Cache-Control'] = 'max-age=2592000'
console.log("HEADERS:")
console.log(headers)
callback(null, tile, headers);
}
};

// 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');

0 comments on commit 680b655

Please sign in to comment.