Created
April 15, 2015 14:39
-
-
Save anandthakker/087beda9342da7452f78 to your computer and use it in GitHub Desktop.
omnivore-to-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
#!/usr/bin/env node | |
/** | |
* Convert the given omnivore-compatible vector source into an mbtiles | |
* file of vector tiles. | |
*/ | |
var path = require('path') | |
var multi = require('multimeter')(process) | |
var tilelive = require('tilelive') | |
require('tilelive-omnivore').registerProtocols(tilelive) | |
require('mbtiles').registerProtocols(tilelive) | |
if(process.argv.length < 4) { | |
console.log('Usage: ', process.argv[0], process.argv[1], ' source.shp dest.mbtiles') | |
process.exit() | |
} | |
var srcuri = 'omnivore://' + path.resolve(process.cwd(), process.argv[2]) | |
var dsturi = 'mbtiles://' + path.resolve(process.cwd(), process.argv[3]) | |
multi.drop({width: 40}, function (bar) { | |
tilelive.copy(srcuri, dsturi, { | |
type: 'scanline', | |
minzoom: 0, | |
maxzoom: 13, | |
progress: function(stats, p) { | |
bar.percent(p.percentage) | |
} | |
}, function (err) { | |
if (err) throw err; | |
console.log('\n\nFinished') | |
process.exit() | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment