osmparser

OpenStreetMap XML and PBF parser for Node.JS

npm install osmparser
6 downloads in the last week
24 downloads in the last month

node-osmparser

OpenStreetMap XML and PBF parser for Node.JS

Note: WIP - Currently only XML!

Basic usage example

var OSMParser = require('osmparser');

var parser = new OSMParser();

parser.on('node', function(data) {
  console.log(data);
});

parser.on('way', function(data) {
  console.log(data);
});

parser.on('relation', function(data) {
  console.log(data);
});

parser.on('error', function(err) {
  console.error(err);
});

parser.on('end', function(err) {
  console.log('done!');
});

parser.parse('/path/to/file.osm');

Filtering example

var OSMParser = require('osmparser');

var parser = new OSMParser();

parser.on('node', function(data) {
  console.log(data);
});

parser.on('way', function(data) {
  console.log(data);
});

parser.on('relation', function(data) {
  console.log(data);
});

parser.on('error', function(err) {
  console.error(err);
});

parser.on('end', function(err) {
  console.log('done!');
});

parser.filterNode = function(node, callback) {
  if (node.tags['place']) callback(null, node);
  else callback(null, null);
}

parser.filterWay = function(way, callback) {
  callback(null, null);
}

parser.filterRelation = function(relation, callback) {
  if (node.tags['water']) callback(null, node);
  else callback(null, null);
}

parser.parse('/path/to/file.osm');
npm loves you