Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonepri/osm-geojson
🔰 Get GeoJSON of a OpenStreetMap's relation from the API.
https://github.com/simonepri/osm-geojson
api geojson maps openstreetmap
Last synced: 18 days ago
JSON representation
🔰 Get GeoJSON of a OpenStreetMap's relation from the API.
- Host: GitHub
- URL: https://github.com/simonepri/osm-geojson
- Owner: simonepri
- License: mit
- Created: 2017-11-15T23:36:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-07T04:14:51.000Z (over 3 years ago)
- Last Synced: 2024-10-20T14:27:34.266Z (24 days ago)
- Topics: api, geojson, maps, openstreetmap
- Language: JavaScript
- Size: 69.3 KB
- Stars: 49
- Watchers: 4
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
🔰 Get GeoJSON of a OpenStreetMap's relation from the API.
Coded with ❤️ by Simone Primarosa.
## Install
```
$ npm install --save osm-geojson
```## Usage
```js
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
```bash
Usage
$ osm-geojson
$ osm-geojson -l [:]+
Options
-l --list [:]+ 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
- **Simone Primarosa** - *Github* ([@simonepri][github:simonepri]) • *Twitter* ([@simoneprimarosa][twitter:simoneprimarosa])
See also the list of [contributors][contributors] who participated in this project.
## License
This project is licensed under the MIT License - see the [license][license] file for details.
[start]: https://github.com/simonepri/osm-geojson#start-of-content
[contributors]: https://github.com/simonepri/osm-geojson/contributors[license]: https://github.com/simonepri/osm-geojson/tree/master/license
[github:simonepri]: https://github.com/simonepri
[twitter:simoneprimarosa]: http://twitter.com/intent/user?screen_name=simoneprimarosa