npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tiny-osmpbf

v1.0.0-beta.1

Published

smallest osm.pbf parser

Downloads

19,002

Readme

tiny-osmpbf

A lightweight parsing library for the osm.pbf format used for OpenStreetMap raw data. Written in pure javascript. Works in nodejs and the browser.

Background

Contrary to other osm pbf parsing libraries, tiny-osmpbf isn't purely optimized for speed, but mainly towards ease-of-use and small code footprint (it's less than 16kB minified and gzipped).

This is mainly achived by using two great alternatives to the typical go-to libraries for parsing pbf and decompressing zlib deflated data, namely mapbox's pbf library and tiny-inflate (a port of Joergen Ibsen's tiny inflate for C).

The second main difference is the synchronous API, which makes it easier to use the library (e.g. when integrating it into existing synchronous workflows). This comes at the cost of having to load the whole osmpbf input data into memory, so keep that in mind in case you're planning to parse larger files.

Usage

install via npm install --save tiny-osmpbf

Then

var tinyosmpbf = require('tiny-osmpbf');

var dataBuffer = … // e.g. from fs.readFileSync(…)

var osmData = tinyosmpbf(dataBuffer);

API

result = tinyosmpbf(dataBuffer [, handler])
  • dataBuffer – the pbf data to be parsed
  • handler – a callback function that is called for each parsed osm element (node, way and relation), optional
  • result – an object in JSON format containing both the metadata and osm elements from the parsed pbf file (if a custom handler is defined, the osm elements are not included here again)

Result

The returned data is in the OSM-JSON format used by the Overpass API. For example:

{
  "version": 0.6,
  "generator": "Overpass API prototype",
  "osm3s": {
    "timestamp_osm_base": "2016-05-01T00:00:00Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [
    {
      "type": "node",
      "id": 251429,
      "lat": 51.0326209,
      "lon": -0.9538873,
      "tags": {},
      "version": 3,
      "timestamp": "2010-10-31T20:48:14Z",
      "changeset": 6246399,
      "uid": 4745,
      "user": "Philip"
    },
    …
    {
      "type": "way",
      "id": 666,
      "nodes": [
        251714,
        …
      ],
      "tags": {
        "designation": "public_bridleway",
        "highway": "path"
      },
      "version": 10,
      "timestamp": "2016-03-20T14:37:06Z",
      "changeset": 37956794,
      "uid": 873940,
      "user": "Mike Baggaley"
    }
  ]
}

See Also