Skip to content

Instantly share code, notes, and snippets.

@anandthakker
Created April 15, 2015 14:39
Show Gist options
  • Save anandthakker/087beda9342da7452f78 to your computer and use it in GitHub Desktop.
Save anandthakker/087beda9342da7452f78 to your computer and use it in GitHub Desktop.
omnivore-to-mbtiles
#!/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