Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
an openstreetmap XML and PBF data parser for node.js and the browser
JavaScript Protocol Buffer HTML Shell

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.npmignore
AUTHORS
COPYING
README
README.dev
package.json

README

osm-read - an openstreetmap XML and PBF parser for node.js

1) Introduction
2) Simple Usage Example
3) PBF random access parser
4) TODOs
5) Contact

------------------------------------------------------------------------
Introduction

osm-read parses openstreetmap XML and PBF files as described in
http://wiki.openstreetmap.org/wiki/OSM_XML and
http://wiki.openstreetmap.org/wiki/PBF_Format


------------------------------------------------------------------------
Simple Usage Example

The following code is used to parse openstreetmap XML or PBF files in a
SAX parser like callback way.

osmread.parse({
    filePath: 'path/to/osm.xml',
    endDocument: function(){
        console.log('document end');
    },
    bounds: function(bounds){
        console.log('bounds: ' + JSON.stringify(bounds));
    },
    node: function(node){
        console.log('node: ' + JSON.stringify(node));
    },
    way: function(way){
        console.log('way: ' + JSON.stringify(way));
    },
    error: function(msg){
        console.log('error: ' + msg);
    }
});


------------------------------------------------------------------------
PBF random access parser

The following code allows to create a random access openstreetmap PBF
file parser:

osmread.createPbfParser({
    filePath: 'path/to/osm.pbf',
    callback: function(err, parser){
        if(err){
            // TODO handle error
        }

        parser.readBlock(parser.findFileBlocksByBlobType('OSMHeader'), function(err, block){
            console.log('header block');
            console.log(block);

            parser.close(function(err){
                if(err){
                    // TODO handle error
                }
            });
        });
    });
});

Don't forget to close the parse after usage!


------------------------------------------------------------------------
TODOs

* parse timestamps


------------------------------------------------------------------------
Contact

* author: Markus Pielmeier <markus.pielmeier@gmail.com>
Something went wrong with that request. Please try again.