{"id":15466020,"url":"https://github.com/jhermsmeier/node-osm-pbf-stream","last_synced_at":"2025-09-01T20:37:39.623Z","repository":{"id":39004705,"uuid":"71335617","full_name":"jhermsmeier/node-osm-pbf-stream","owner":"jhermsmeier","description":"OpenStreetMap Protocol Buffer Stream","archived":false,"fork":false,"pushed_at":"2018-12-23T10:00:46.000Z","size":37,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-08T07:54:58.435Z","etag":null,"topics":["openstreetmap","osm","pbf","protobuf"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jhermsmeier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-19T08:30:07.000Z","updated_at":"2020-11-27T21:58:35.000Z","dependencies_parsed_at":"2022-08-25T21:11:02.548Z","dependency_job_id":null,"html_url":"https://github.com/jhermsmeier/node-osm-pbf-stream","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhermsmeier%2Fnode-osm-pbf-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhermsmeier%2Fnode-osm-pbf-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhermsmeier%2Fnode-osm-pbf-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhermsmeier%2Fnode-osm-pbf-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhermsmeier","download_url":"https://codeload.github.com/jhermsmeier/node-osm-pbf-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234036447,"owners_count":18769558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openstreetmap","osm","pbf","protobuf"],"created_at":"2024-10-02T01:04:36.408Z","updated_at":"2025-01-15T12:13:41.695Z","avatar_url":"https://github.com/jhermsmeier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# osm-pbf-stream\n[![npm](https://img.shields.io/npm/v/osm-pbf-stream.svg?style=flat-square)](https://npmjs.com/package/osm-pbf-stream)\n[![npm license](https://img.shields.io/npm/l/osm-pbf-stream.svg?style=flat-square)](https://npmjs.com/package/osm-pbf-stream)\n[![npm downloads](https://img.shields.io/npm/dm/osm-pbf-stream.svg?style=flat-square)](https://npmjs.com/package/osm-pbf-stream)\n[![build status](https://img.shields.io/travis/jhermsmeier/node-osm-pbf-stream.svg?style=flat-square)](https://travis-ci.org/jhermsmeier/node-osm-pbf-stream)\n\nOpenStreetMap Protocol Buffer Stream\n\n## Install via [npm](https://npmjs.com)\n\n```sh\n$ npm install --save osm-pbf-stream\n```\n\n## Index\n\u003c!-- MarkdownTOC --\u003e\n\n- [What](#what)\n- [Usage](#usage)\n- [Speed](#speed)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n## What\n\nAs OpenStreetMap's `.osm.pbf` files aren't pure Protocol Buffer messages, but are in a chunked, size delimited (and optionally, compressed) [custom crafted format](http://wiki.openstreetmap.org/wiki/PBF_Format) – this parses out the Protobuf message chunks.\n\nSo, `osm.pbf` goes in, `pbf` comes out.\n\n## Usage\n\n```js\nvar OsmPbf = require( 'osm-pbf-stream' )\n```\n\n```js\nvar pbfStream = fs.createReadStream( 'berlin-latest.osm.pbf' )\n  .pipe( new OsmPbf.BlobParser() )\n  .on( 'header', ... )\n  .on( 'blob', ... )\n```\n\n```js\n// Now you can process the Protocol Buffer stream\n// with a streaming Protobuf parser, like `pbs`\nvar pbs = require( 'pbs' )\nvar osmSchema = fs.readFileSync( 'osmformat.proto', 'utf8' )\nvar messages = pbs( osmSchema )\n\nvar decoder = messages.PrimitiveBlock.decode()\n\ndecoder.primitivegroup( function( group, next ) {\n  console.log( 'PrimitiveGroup.nodes', group.dense || group.nodes )\n  next()\n})\n\ndecoder.once( 'finish', function() {\n  console.log( 'EOD' )\n})\n\n// Pipe the PBF stream to the decoder\npbfStream.pipe( decoder )\n```\n\n## Speed\n\nWith the ~49 MB test file, it processes about 50 MB/s on a MacBook Pro.\n\n```\nBlobParser\n  ✓ 1MB chunk size (986ms)\n  ✓ Default (16KB) chunk size (1009ms)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhermsmeier%2Fnode-osm-pbf-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhermsmeier%2Fnode-osm-pbf-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhermsmeier%2Fnode-osm-pbf-stream/lists"}