Skip to content

Instantly share code, notes, and snippets.

@samuelleach
Forked from morganherlocker/index.js
Created May 3, 2016 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelleach/88dd7dd8528db74fb6f2ff0f4b064620 to your computer and use it in GitHub Desktop.
Save samuelleach/88dd7dd8528db74fb6f2ff0f4b064620 to your computer and use it in GitHub Desktop.
tile-reduce + cheap-ruler example
var tileReduce = require('tile-reduce');
var path = require('path');
tileReduce({
zoom: 14,
map: path.join(__dirname, '/process.js'),
sources: [
{name: 'ways', mbtiles: 'ways.mbtiles')}
]
});
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