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

obj2osm

v2.0.1

Published

Generate OSM XML from a stream of OSM JSON objects

Downloads

1,262

Readme

obj2osm

Build Status npm js-standard-style

Generate OSM XML from a stream of objects matching OSM JSON

Table of Contents

Install

npm install obj2osm

Example

var toxml = require('../')
var from2Array = require('from2-array')

var input = require('../test/fixture.json')

var bounds = {
  minlat: 38.89958342598271,
  maxlat: 38.90385833966776,
  minlon: -77.02514648437499,
  maxlon: -77.01965332031249
}

from2Array.obj(input)
  .pipe(toxml({bounds: bounds}))
  .pipe(process.stdout)

output:

$ node osm.js
<?xml version="1.0" encoding="UTF-8"?><osm version="0.6" generator="obj2osm"><bounds minlat="38.89958342598271" maxlat="38.90385833966776" minlon="-77.02514648437499" maxlon="-77.01965332031249"/><node lat="38.90094671136515" lon="-77.02313139881134" timestamp="2015-12-31T20:50:35.826Z" id="1db08fd46c5a7c01" version="334fd5b5114e0ae69c151978640cd5692c9fb639c7565ba48b0cd2700e1d8547"/><way timestamp="2015-12-31T20:50:35.842Z" id="29ac0c8f50e630e9" version="57f9ec2913db5e568976372afa8997255fdb614cff48ca01565f2ddee3687bc8"><nd ref="1db08fd46c5a7c01"/><nd ref="8c50fa92c3ce91d7"/><nd ref="83c1be761a9f4148"/><nd ref="1db08fd46c5a7c01"/><tag k="area" v="yes"/></way><node lat="38.90068996279713" lon="-77.02327892030715" timestamp="2015-12-31T20:50:35.849Z" id="8c50fa92c3ce91d7" version="8f32080b4501459d8a904c568e2a0c7de92de435fab8c7d16ae2b39851046991"><tag k="amenity" v="cafe"/></node><relation timestamp="2015-12-31T20:50:35.855Z" id="83c1be761a9f4148" version="0443c3916e92250149c8086ed21b2265cb6af161dbf63a17e30a7d3c8a0cb0b1"><member ref="8c50fa92c3ce91d7" type="node" role=""/></relation></osm>

API

var toxml = require('obj2osm')

var stream = toxml(opts)

Where:

  • opts.root - Root XML element (default: osm, set to null to output XML with no root)
  • opts.generator - Generator attribute for the root element (default: obj2osm)
  • opts.bounds - Optional bounds to include at start of XML, either {minlat: <Number>, maxlat: <Number>, minlon: <Number>, maxlon: <Number>} or [[minLat, maxLat], [minLon, maxLon]]

Returns a transform object stream that expects a stream of objects matching OSM JSON format as input and produces osm xml output or osmChange XML output if input objects have an action property set to one of: create|modify|delete.

Node object format:

  • node.type - 'node'
  • node.id - id string
  • node.version - version string
  • node.lat - latitude in degrees
  • node.lon - longitude in degrees
  • node.tags - Object of tag key-value pairs: {tagKey: 'tagValue', amenity: 'cafe'}

Way object format:

  • way.type - 'way'
  • way.id - id string
  • way.version - version string
  • way.nodes - array of node IDs
  • way.tags - Object of tag key-value pairs

Relation object format:

  • relation.type - relation.type
  • relation.id - id string
  • relation.version - version string
  • relation.members - array of member objects: {type: 'node|way|relation', ref: 'id', role: 'role'}
  • relation.tags - Object of tag key-value pairs

Contribute

PRs welcome. Please follow JS Standard Style.

License

BSD