osm2json

Implements a Node Transport Stream. Takes a readable stream of OSM XML and outputs a stream of JSON in the following format:

{
    "attrs": {
        "changeset": "50", 
        "id": "29", 
        "lat": "38.9003573", 
        "lon": "-77.0232578", 
        "timestamp": "2013-09-05T19:38:11Z", 
        "version": "1"
    }, 
    "tags": [
        {
            "k": "amenity", 
            "v": "place_of_worship"
        }
    ], 
    "type": "node"
}
{
  "type": "way",
  "attrs": {
    "id": "3",
    "version": "3",
    "timestamp": "2013-09-05T19:38:11Z",
    "changeset": "49"
  },
  "nodes": [{
    "ref": "19"
  }, {
    "ref": "20"
  }, {
    "ref": "21"
  }, {
    "ref": "22"
  }, {
    "ref": "26"
  }, {
    "ref": "27"
  }],
  "tags": [{
    "k": "name",
    "v": "York St"
  }]
}

##Example

var fs = require('fs')
  , Osm2Json = require('../lib/osm2json');
  
var rs = fs.createReadStream('./test.osm');

var osm2Json = new Osm2Json();

rs.pipe(osm2Json).pipe(process.stdout);

======================

See it on GitHub

Return to Code