Skip to content
πŸ”° Get GeoJSON of a OpenStreetMap's relation from the API.
Branch: master
Clone or download
dependabot and simonepri Update execa requirement from ^0.11.0 to ^1.0.0 (#5)
Updates the requirements on [execa](https://github.com/sindresorhus/execa) to permit the latest version.
- [Release notes](https://github.com/sindresorhus/execa/releases)
- [Commits](https://github.com/sindresorhus/execa/commits/v1.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
Latest commit d231201 Sep 3, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
media Add CLI (#2) Aug 10, 2018
.appveyor.yml Update CI scripts Aug 9, 2018
.editorconfig Add .editorconfig Nov 15, 2017
.gitattributes Update .gitattributes Aug 9, 2018
.gitignore Update .gitignore Aug 9, 2018
.npmrc Add .npmrc Nov 15, 2017
.travis.yml Update CI scripts Aug 9, 2018
LICENSE Update license Aug 9, 2018
README.md Update readme Aug 10, 2018
cli.js Add CLI (#2) Aug 10, 2018
codecov.yml Add codecov.yml Nov 15, 2017
index.js Fix codestyle Aug 9, 2018
package.json Update execa requirement from ^0.11.0 to ^1.0.0 (#5) Sep 3, 2018
test.js Add CLI (#2) Aug 10, 2018

README.md

osm-geojson

Mac/Linux Build Status Windows Build status Codecov Coverage report Known Vulnerabilities Dependency Status
XO Code Style used AVA Test Runner used Istanbul Test Coverage used NI Scaffolding System used NP Release System used
Latest version on npm Project license

πŸ”° Get GeoJSON of a OpenStreetMap's relation from the API.
Coded with ❀️ by Simone Primarosa.

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.

Param Type Description
osmid string Relation 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.

Param Type Description
map object Map 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.

You can’t perform that action at this time.