Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
osm2geojson-lite
Advanced tools
a lightweight yet faster osm (either in xml or in json formats) to geojson convertor - 4x faster than xmldom + osmtogeojson in most situations - implemented in pure JavaScript without any 3rd party dependency
A lightweight (not as lightweight as xml2geojson though) yet faster convertor for OSM data whatever in XML or JSON formats to GeoJSON - much faster (the more complex the data source is, the more performance advantages it posesses) than osmtogeojson in most situations - implemented in pure JavaScript without any 3rd party dependency.
An internal function inside query-geo-boundary → stripped out to handle OSM XML only xml2geojson-lite → this library that supports both OSM XML and OSM/Overpass JSON
Installation:
$ npm install osm2geojson-lite
Usage:
const osm2geojson = require('osm2geojson-lite');
let geojson = osm2geojson(osm);
<script src='your/path/to/osm2geojson-lite.js'/>
let geojson = osm2geojson(osm, opts);
osm2geojson(osm, opts)
Converts OSM data (XML/JSON) to GeoJSON.
osm
: the OSM XML data in String, or OSM/Overpass JSON as object or in Stringopts?
: optional, the options object, right now supports below properties/fields:
completeFeature/allFeatures
: the default value is false
. When it's set to true
, the returned geojson will include all elements that meet the specified conditions in FeatureCollection
format; otherwise, only the bare geometry of the first relation
element will be returned.renderTagged
: the default value is false
. When it's set to true
, the returned geojson will include all elements with tags (i.e., tagged) until suppressWay
changes its behavior a bit; otherwise only the unreferenced ones get returned.suppressWay/excludeWay
: the default value is true
. When it's set to true
, the returned FeatureCollection
will exclude any referenced ways even though they are tagged; otherwise the features of all tagged way
will be included, too.osmtogeojson
(with xmldom
for XML processing)osmtogeojson
by the one of this library$ cd bench
$ node o2gl-bench.js
$ node otg-bench.js
1. XML
-----------------------------------------------------
| zhucheng | hebei | tokyodo | usa |
+------------+------------+------------+------------+
| >2.5x | >4.0x | >3.0x | >3.0x |
-----------------------------------------------------
2. Overpass JSON
-----------------------------------------------------
| zhucheng | hebei | tokyodo | usa |
+------------+------------+------------+------------+
| >2.5x | >11.0x | >7.0x | >5.0x |
-----------------------------------------------------
ES5/ES6 features
Written in 2018 by tibetty xihua.duan@gmail.com
FAQs
a lightweight yet faster osm (either in xml or in json formats) to geojson convertor - 4x faster than xmldom + osmtogeojson in most situations - implemented in pure JavaScript without any 3rd party dependency
We found that osm2geojson-lite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.