mapbox / pbf

A low-level, lightweight protocol buffers implementation in JavaScript.
BSD 3-Clause "New" or "Revised" License
796 stars 106 forks source link

osm-file processing #108

Closed Jack8787 closed 4 years ago

Jack8787 commented 4 years ago

Hello, I'd like to figure out how, after all, pbf-files are processed by using pbf-module. I'm working with central-america-latest.osm.pbf, here is what I'm triing to do:

---- Pbf = require('pbf'), Example = require('./protobuf/example.js'); // so far, so good - the file example.js is compiled as described in the documentation

---- fs.createReadStream -> chunk -> var pbf = new Pbf(chunk) -> objs = Example.read(pbf) -> ? Error: Example.read is not a function. What could I miss in documentation? Maybe this module is not intended for streams?

kjvalencik commented 4 years ago

The pbf library does not directly support the PBF Format. You would need a high level wrapper that understands the repeating block format.

Additionally, protobuf does not support streams directly. When decoding a pbf OSM file, it would be necessary to buffer until an entire message is available to decode.