GithubHelp home page GithubHelp logo

osm-p2p-import's Introduction

osm-p2p-import

Node.JS module and command line utility for importing OSM XML into an osm-p2p-db.

CLI Usage

USAGE: osm-p2p-import 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.

Module Usage

var importer = require('osm-p2p-import')
var OsmP2P = require('osm-p2p')
var fs = require('fs')

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

var osm = OsmP2P('./fun.db')

importer(osm, 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!
indexes generated

API

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

importer(osm, xmlStream[, opts], done)

  • osm: osm-p2p-db instance
  • 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.

XML Formatting

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

Install

With npm installed, run

Module

$ npm install osm-p2p-import

Command Line Utility

$ npm install --global osm-p2p-import

License

ISC

osm-p2p-import's People

Contributors

hackergrrl avatar noffle avatar sethvincent avatar

Stargazers

Mike DuPont avatar rae avatar Pete avatar  avatar

Watchers

 avatar  avatar

Forkers

sethvincent

osm-p2p-import's Issues

Ways not imported in not in the correct order

If the ways come before the nodes, they are not imported.
When using the following xml only the nodes are imported:

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API">
<meta osm_base="2017-03-21T16:24:02Z"/>
  <way id="-1" visible="true">
    <nd ref="-2"/>
    <nd ref="-3"/>
    <nd ref="-4"/>
    <nd ref="-5"/>
    <nd ref="-6"/>
    <tag k="highway" v="secondary"/>
    <tag k="name" v="Boulevard Kamanyola"/>
  </way>

  <node id="-2" lat="-11.6572028" lon="27.4691154" visible="true"/>
  <node id="-3" lat="-11.6570032" lon="27.4688649" visible="true"/>
  <node id="-4" lat="-11.6567879" lon="27.4684879" visible="true"/>
  <node id="-5" lat="-11.6557674" lon="27.4664466" visible="true"/>
  <node id="-6" lat="-11.655604" lon="27.4659408" visible="true"/>

</osm>

I noticed this behavior in osm-p2p-server and submitted a PR, maybe the base idea can be ported? digidem/osm-p2p-server#32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.