Skip to content

Instantly share code, notes, and snippets.

@morganherlocker
Created August 24, 2016 00:06
Show Gist options
  • Save morganherlocker/acd8d53d2441e20821e9d6a8581a64e7 to your computer and use it in GitHub Desktop.
Save morganherlocker/acd8d53d2441e20821e9d6a8581a64e7 to your computer and use it in GitHub Desktop.
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