Created
September 25, 2014 22:05
-
-
Save aaronlidman/5a1982e810ce76e537de to your computer and use it in GitHub Desktop.
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 osmium = require('osmium'); | |
levelup = require('levelup'); | |
var db = levelup('./test.ldb'); | |
var count = 0; | |
var reader = new osmium.Reader(process.argv[2], { | |
'node': true | |
}); | |
function nextBuffer() { | |
console.log('buffer', count); | |
var buffer = reader.read(); | |
if (!buffer) return false; | |
var batch = []; | |
while (object = buffer.next()) { | |
batch.push({ | |
type: 'put', | |
key: object.id, | |
value: JSON.stringify(object) | |
}); | |
} | |
db.batch(batch, function(err) { | |
if (err) return console.log(err); | |
// return setTimeout(nextBuffer, 2500); | |
return nextBuffer(); | |
}); | |
count++; | |
} | |
nextBuffer(); |
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
{ | |
"name": "openstreetreports", | |
"version": "0.0.0", | |
"description": "", | |
"main": "", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "BSD", | |
"dependencies": { | |
"leveldown": "^0.10.1", | |
"levelup": "^0.19.0", | |
"osmium": "https://github.com/osmcode/node-osmium/tarball/master" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment