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

osm-p2p-db-importer

v2.0.4

Published

super fast imports from OSM XML into a fresh osm-p2p-db

Downloads

3

Readme

osm-p2p-db-importer

Fast imports from OSM XML into a fresh osm-p2p-db

This is useful if you have a very large OSM dataset that would otherwise be too slow to insert directly into osm-p2p-db.

How much faster?

smaller.xml: 1.4mb

  • osm-p2p-server: 10.5s
  • osm-p2p-db-importer: 7.3s

6.xml: 18mb

  • osm-p2p-server: 720+ seconds (stopped recording)
  • osm-p2p-db-importer: 73.3s

How does it work?

A fresh import is a special case that lets us make a key assumption:

  1. No historic data (no data in the import is an earlier revision of other data)

There is a lot of cost in ensuring consistency across the layers of osm-p2p-*, which can be potentially skipped if we know we don't need to worry about inconsistent data coming in.

This module skips multiple layers, accepting OSM XML data and generating LevelDB batch operations directly, without the osm-p2p-db, hyperkv, and hyperlog layers of processing in between. This isn't very stable in the long-term (since the things under the blankets of these modules may change), but for now it makes for some very quick data insertions into a fresh DB.

Usage

var importer = require('osm-p2p-db-importer')
var fs = require('fs')

var xml = fs.createReadStream('./hawaii.xml')

var dbPath = '/tmp/osm-p2p-ex'

importer(dbPath, xml, function (err) {
  console.log(err ? err : 'import done!')

  // OPTIONAL: wait for indexes to be generated
  var osmdb = require('osm-p2p')
  var osm = osmdb(dbPath)
  osm.ready(function () {
    console.log('indexes generated')
  })
})

outputs

done!

API

var importer = require('osm-p2p-db-importer')

importer(osmDir, xmlStream, opts, done)

  • osmDir: path to a directory where the osm-p2p-db will be located.
  • xmlStream: a readable stream of OSM XML data.
  • opts: options object. Currently accepts slow: true|false.
  • done: a callback function, receiving an error err or null.

importer.toLevel(db, xmlStream, done)

Like the above, except operating on a user-specified LevelUP instance, db. This is useful if you aren't using a filesystem-backed LevelDOWN as your back-end.

CLI Usage

USAGE: osm-p2p-db-importer [--slow] DBDIR [XMLFILE]

  Import OSM XML into an osm-p2p-db located at DBDIR. XMLFILE is a file
  containing OSM XML. If not specified, OSM XML is read from standard input.

  --slow, -s: skip fragile optimizations; import using the normal osm-p2p-db
              process.

XML Formatting

Anything that would be an acceptable upload to OSM v0.6's POST /api/0.6/changeset/:id/upload should work here.

Caveat: Changeset ID

Note that this module doesn't create a changeset for you. You will need to create one first, an ensure your XML has that changeset set.

Install

With npm installed, run

As a Library

$ npm install osm-p2p-db-importer

As a Command Line Utility

$ npm install --global osm-p2p-db-importer

License

ISC