0.8.4 • Published 4 years ago

osm-geojson v0.8.4

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

Install

$ npm install --save osm-geojson

Usage

const osmGeoJson = require('osm-geojson');

osmGeoJson.get('365331'); // Italy
// => { type: 'GeometryCollection', geometries: [ { type: 'MultiPolygon', coordinates: [Array] } ] }

osmGeoJson.getAll({'ITA': '365331', 'USA': '148838'}); // Italy
// => {
// 'ITA': { type: 'GeometryCollection', geometries: [ { type: 'MultiPolygon', coordinates: [Array] } ] },
// 'USA': { type: 'GeometryCollection', geometries: [ { type: 'MultiPolygon', coordinates: [Array] } ] }
// }

CLI

Install

To use the CLI just install the package globally.

$ npm install --g osm-geojson

Or run it with npx if you are not planning to use it more than once.

$ npx osm-geojson

Help

Usage
  $ osm-geojson <osmId>
  $ osm-geojson -l [<osmId>:<filename>]+
Options
  -l  --list [<osmId>:<filename>]+   To fetch a list of osmIds. Each relation
                                     will be saved in a file called
                                     filename.geojson
  -p --pretty                        To beautify the outputted JSON.
Examples
  $ osm-geojson 365331
  $ osm-geojson -p 365331
  $ osm-geojson -p 365331 > filename.geojson
  $ osm-geojson -l 365331:ita 148838:usa

API

get(osmid) ⇒ Promise.<object>

Returns the GeoJSON of a particular OSM relation id.

Returns: Promise.<object> - A promise that contains the GeoJSON of the given relation.

ParamTypeDescription
osmidstringRelation id from which extract the GeoJSON.

getAll(map) ⇒ Promise.<object>

Returns a map of GeoJSON of multiple OSM relation ids.

Returns: Promise.<object> - A promise that contains the map with the same keys of the map provided but with the GeoJSON of the given relation id as value.

ParamTypeDescription
mapobjectMap from a name to a relation id from which extract the GeoJSON.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the license file for details.