Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created March 10, 2016 20:57
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 tmcw/31ec3a95c4cb9b4a37f5 to your computer and use it in GitHub Desktop.
Save tmcw/31ec3a95c4cb9b4a37f5 to your computer and use it in GitHub Desktop.
'use strict';
var tileReduce = require('../../src');
var path = require('path');
var numFeatures = 0;
// TileReduce currently
tileReduce({
bbox: [-122.05862045288086, 36.93768132842635, -121.97296142578124, 37.00378647456494],
zoom: 15,
map: path.join(__dirname, '/count.js'),
sources: [{name: 'osm', mbtiles: path.join(__dirname, '../../test/fixtures/osm.mbtiles'), raw: true}]
})
.on('reduce', function(num) {
numFeatures += num;
})
.on('end', function() {
console.log('Features total: %d', numFeatures);
});
// Following the format of normal reduce methods
tileReduce({
bbox: [-122.05862045288086, 36.93768132842635, -121.97296142578124, 37.00378647456494],
zoom: 15,
map: path.join(__dirname, '/count.js'),
sources: [{name: 'osm', mbtiles: path.join(__dirname, '../../test/fixtures/osm.mbtiles'), raw: true}]
})
.reduce(function(numFeatures, num) {
return numFeatures + num;
}, 0)
.on('end', function() {
console.log('Features total: %d', numFeatures);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment