Last active
May 3, 2016 20:21
-
-
Save morganherlocker/d29c0af413be70a8ef4540df0d9b66d9 to your computer and use it in GitHub Desktop.
tile-reduce + cheap-ruler example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tileReduce = require('tile-reduce'); | |
var path = require('path'); | |
tileReduce({ | |
zoom: 14, | |
map: path.join(__dirname, '/process.js'), | |
sources: [ | |
{name: 'ways', mbtiles: 'ways.mbtiles')} | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createRuler = require('cheap-ruler'); | |
module.exports = function(data, tile, writeData, done) { | |
var ruler = createRuler.fromTile(tile[1], tile[2]); | |
var length = 0; | |
data.ways.ways.features.forEach(function(way){ | |
length += ruler.lineDistance(way.geometry.coordinates); | |
}); | |
done(null, length); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment