Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var through2 = require('through2')
var byline = require('byline')
process.stdin
.pipe(byline.createStream())
.pipe(through2(function(chunk, enc, next){
var data = JSON.parse(chunk.toString())
this.push(toGeoJSON(data))
next()
}))
.pipe(process.stdout)
function toGeoJSON (data) {
if(data.type === 'node') {
// return transformed node
} else if(data.type === 'way') {
// return transformed way
} else if(data.type === 'relation') {
// return transformed relation
} else throw new Error('Unknown type detected: ' + data.type)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment