Giter VIP home page Giter VIP logo

node-osmparser's Introduction

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, relation);
  else callback(null, null);
}

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

node-osmparser's People

Contributors

mjaros avatar

Stargazers

Stefan Oderbolz avatar  avatar  avatar

Watchers

Aaron Lidman avatar  avatar

Forkers

sogko nvdnkpr

node-osmparser's Issues

Fails to install on newer versions of node

truncated...

../node-expat.cc:437:35: note: candidate is:
In file included from /home/peter/.node-gyp/0.11.12/src/node.h:61:0,
                 from ../node-expat.cc:1:
/home/peter/.node-gyp/0.11.12/deps/v8/include/v8.h:2469:16: note: v8::Local<v8::Value> v8::Function::Call(v8::Handle<v8::Value>, int, v8::Handle<v8::Value>*)
   Local<Value> Call(Handle<Value> recv, int argc, Handle<Value> argv[]);
                ^
/home/peter/.node-gyp/0.11.12/deps/v8/include/v8.h:2469:16: note:   no known conversion for argument 1 from ‘v8::Persistent<v8::Object, v8::NonCopyablePersistentTraits<v8::Object> >’ to ‘v8::Handle<v8::Value>’
../node-expat.cc: In static member function ‘static v8::Handle<v8::Value> Parser::SetEncoding(const int&)’:
../node-expat.cc:189:3: warning: control reaches end of non-void function [-Wreturn-type]
   }
   ^
../node-expat.cc: In static member function ‘static v8::Handle<v8::Value> Parser::Parse(const int&)’:
../node-expat.cc:139:3: warning: control reaches end of non-void function [-Wreturn-type]
   }
   ^
../node-expat.cc: In static member function ‘static v8::Handle<v8::Value> Parser::New(const int&)’:
../node-expat.cc:69:3: warning: control reaches end of non-void function [-Wreturn-type]
   }
   ^
make: *** [Release/obj.target/node_expat/node-expat.o] Error 1
make: Leaving directory `/var/www/pelias-play/node_modules/osmparser/node_modules/node-expat/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:107:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1045:12)
gyp ERR! System Linux 3.11.0-19-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/pelias-play/node_modules/osmparser/node_modules/node-expat
gyp ERR! node -v v0.11.12
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm http 304 https://registry.npmjs.org/xtend
npm http 304 https://registry.npmjs.org/errno
npm http 304 https://registry.npmjs.org/semver
npm http 304 https://registry.npmjs.org/prr
npm http 304 https://registry.npmjs.org/simple-bufferstream
npm http 304 https://registry.npmjs.org/bops
npm http 304 https://registry.npmjs.org/concat-stream
npm http GET https://registry.npmjs.org/object-keys
npm http GET https://registry.npmjs.org/is-object
npm http GET https://registry.npmjs.org/base64-js/0.0.2
npm http GET https://registry.npmjs.org/to-utf8/0.0.1
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/object-keys
npm WARN deprecated [email protected]: Please update to the latest object-keys
npm http 304 https://registry.npmjs.org/is-object
npm http 304 https://registry.npmjs.org/base64-js/0.0.2
npm http GET https://registry.npmjs.org/foreach
npm http GET https://registry.npmjs.org/indexof
npm http GET https://registry.npmjs.org/is
npm http 304 https://registry.npmjs.org/to-utf8/0.0.1
npm http 304 https://registry.npmjs.org/is
npm http 304 https://registry.npmjs.org/indexof
npm http 304 https://registry.npmjs.org/foreach

> [email protected] install /var/www/pelias-play/node_modules/osmparser/node_modules/leveldown
> node-gyp rebuild


node.js:709
    var cwd = process.cwd();
                      ^
Error: ENOENT, no such file or directory
    at Function.startup.resolveArgv0 (node.js:709:23)
    at startup (node.js:63:13)
    at node.js:803:3
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-expat
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.11.0-19-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "osmparser" "--save"
npm ERR! cwd /var/www/pelias-play
npm ERR! node -v v0.11.12
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /var/www/pelias-play/npm-debug.log
npm ERR! not ok code 0
peter@manta:/var/www/pelias-play$ node --version
v0.11.12

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.