Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osm2json

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osm2json

Converts an OSM XML file to OSM JSON objects as a transform stream

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

osm2json

npm

Streaming parser from OSM XML to OSM JSON objects

Implements a Node Transport Stream. Takes a readable stream of OSM XML and outputs a stream of objects compatible with Overpass OSM JSON. Also reads OsmChange XML and outputs the same format but with an additional property action which is one of create, modify, delete. Uses sax-js to work in both node and the browser.

Table of Contents

Install

npm install osm2json

Usage

var fs = require('fs')
var Osm2Json = require('../lib/osm2json')

var rs = fs.createReadableStream(__dirname + './test.osm')

rs.pipe(new Osm2Json()).pipe(process.stdout)

Example Output

// node
{
  type: 'node',
  id: 1,
  version: 0,
  timestamp: '2013-09-05T19:38:11.187Z',
  uid: 1,
  user: 'gregor',
  lat: 0,
  lon: 0,
  tags: { null: 'island' }
}

// way
{
  type: 'way',
  id: 3,
  version: 3,
  timestamp: '2013-09-05T19:38:11Z',
  changeset: 49,
  nodes: [ 19, 20, 21, 22, 26, 27 ],
  tags: { name: 'York St' }
}

// relation
{
  type: 'relation',
  id: 1,
  members: [
    {
      type: 'relation',
      ref: 1745069,
      role: ''
    },
    {
      type: 'relation',
      ref: 172789,
      role: ''
    }
  ],
  tags: {
    from: 'Konrad-Adenauer-Platz',
    name: 'VRS 636'
  }
}

API

var Osm2Json = require('osm2json')

var stream = new Osm2Json(opts)

Create a transform stream with:

  • opts.coerceIds - coerce ids to Number (defaults to true)

The readable side of the stream is in objectMode.

Contribute

PRs welcome. Right now this could do with some tests. If you are feeling ambitious, this could be sped up by using node-expat on node. The interface is similar to sax-js and it should be possible to wrap this to use sax-js on the browser and node-expat on the server using the browserify browser field

License

MIT (c) 2016, Digital Democracy.

Keywords

FAQs

Package last updated on 20 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc