-
-
Save samuelleach/88dd7dd8528db74fb6f2ff0f4b064620 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