an openstreetmap XML and PBF data parser
npm install osm-read#### osm-read - an openstreetmap XML and PBF parser for node.js and the browser
1. Introduction
2. Usage Examples
1. Simple Usage Example
2. Parse OSM XML from URL Example
3. PBF random access parser
3. Version Upgrade Guide
4. TODOs
5. License
6. 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
------------------------------------------------------------------------
#### Continuous Integration

------------------------------------------------------------------------
#### Simple Usage Example
The following code is used to parse openstreetmap XML or PBF files in a
SAX parser like callback way.
``javascript
var parser = 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));
},
relation: function(relation){
console.log('relation: ' + JSON.stringify(relation));
},
error: function(msg){
console.log('error: ' + msg);
}
});
// you can pause the parser
parser.pause();
// and resume it again
parser.resume();
`
------------------------------------------------------------------------
#### Parse PBF in the browser
The browser bundle 'osm-read-pbf.js' provides a global variable 'pbfParser'
with a 'parse' method.
Example, see also example/pbf.html:
`html`
As an alternative to passing an URL in "filePath", the option "buffer" can be
used to pass an already loaded ArrayBuffer object:
`javascript
var buf = ... // e.g. xhr.response
pbfParser.parse({
buffer: buf,
...
`
A third alternative is to let the user choose a local file using the
HTML5 File API, passing the file object as "file" option: