@derhuerst/query-overpass
v2.0.1
Published
Query the OpenStreetMap Overpass API.
Downloads
162
Maintainers
Readme
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:
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'
}
} ]
Note: The Overpass API does not support extended Overpass Turbo queries, as they are an Overpass Turbo-specific feature.
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.