dynamosm-importer

0.0.3 • Public • Published

dynamosm-importer

Stream some sql queries to a postgres database. Plus some tools for converting geojsons into sql on their way into the database

cli

On Max OS X, requires greadlink, which you can install by running

brew install coreutils

dynamosm-importer

Given a url pointing at an osm.pbf, download the file, convert to geojson using minjur, and import to postgres.

export PGDB=my_database
dynamosm-importer "insert into my_table values ({geojson}) http://url/to/some.osm.pbf

dynamosm-importStream

export PGDB=my_database
cat line-delimited-geojsons.file | dynamosm-importStream "insert into my_table values ({geojson})"

js

querify

A transform stream that

  • turns geojson strings in sql json literals
  • will format a query for you, replacing {geojson}
  • escapes any pesky single quotes that would otherwise ruin your sqlized json

DynamosmImporter

A writable stream that accepts sql queries, writing them to a postgres database in transactions/batches.

example

var split = require('split');
var querify = require('..').querify;
var DynamosmImporter('..');
 
var options = {
  batchSize: 200,
  dbname: my_database,
  dbuser: my_user
}
 
fs.createReadStream('somefilewithlinedelimitedGeoJSONs')
  .pipe(split())
  .pipe(querify('insert into some_table values ({geojson})'))
  .pipe(DynamosmImporter(options))
  .on('finish', function() {
    console.log('all inserts completed');
  });

Readme

Keywords

none

Package Sidebar

Install

npm i dynamosm-importer

Weekly Downloads

0

Version

0.0.3

License

none

Last publish

Collaborators

  • ian29