Nail Polishing Minions

npm

Need private packages and team management tools?Check out npm Orgs. »

@derhuerst/query-overpass

2.0.0 • Public • Published

query-overpass

Query the OpenStreetMap Overpass API. Yet another implementation, because it

  • is isomorphic (works in the browser)
  • is lightweight (doesn't contain any sophisticated parser)
  • uses p-retry to resend requests

Other alternatives for you to evaluate:

npm version build status ISC-licensed chat on gitter support me on Patreon

Installing

npm install @derhuerst/query-overpass

Usage

Pass in a string of Overpass QL. Returns a Promise that will resolve with an array of elements.

const queryOverpass = require('@derhuerst/query-overpass')
 
queryOverpass(`
    [out:json][timeout:25];
    node(3378340880);
    out body;
`)
.then(console.log)
.catch(console.error)
[ {
    type: 'node',
    id: 3378340880,
    lat: 52.5145076,
    lon: 13.35011,
    tags: {
        artist: 'Friedrich Drake',
        artwork_type: 'statue',
        colour: 'gold',
        height: '66.9',
        image: 'https://upload.wikimedia.org/wikipedia/commons/2/2a/Victoria_Goldelse_Siegessaeule_Berlin.jpg',
        min_height: '58.6',
        name: 'Viktoria',
        'name:de': 'Siegessäule',
        'name:ru': 'Колонна победы',
        'name:zh': '勝利女神柱',
        reg_name: 'Goldelse',
        tourism: 'artwork',
        wheelchair: 'no'
    }
} ]

To use make requests from a web site, enable CORS using the fetchMode option:

queryOverpass(query, {fetchMode: 'cors'})

To use @derhuerst/query-overpass with a custom Overpass API endpoint, use the endpoint option:

queryOverpass(query, {endpoint: 'https://overpass.example.org'})

Related

  • osm-build-query – Build a query for the OSM Overpass API that retrieves all elements within the bounding feature.
  • osm-flatten-relation – Resolve an OpenStreetMap relation recursively.

Contributing

If you have a question or have difficulties using query-overpass, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

install

npm i @derhuerst/query-overpass

Downloadsweekly downloads

80

version

2.0.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability