Saltar al contenido principal
Esta página no tiene versión en español, así que te la mostramos en inglés.

openstreetmap@1.0.0

listFeatures(filter, [options])
query(overpassQL, [options])
request(method, path, body, [options])

This adaptor exports the following from common:

as()
combine()
cursor()
dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
group()
lastReferenceValue()
map()
merge()
scrubEmojis()
sourceValue()
util

Functions​

listFeatures​

listFeatures(filter, [options]) ⇒ Operation

List OpenStreetMap features which match some tags inside an area or bounding box, as a GeoJSON FeatureCollection. Every feature is a Point: ways and relations use the center of their bounding box. Feature properties are the OpenStreetMap tags plus @id, @version and @timestamp. The collection's timestamp is the time of the OpenStreetMap data Overpass searched, which can be used as the next changedSince.

ParamTypeDescription
filterFeatureFilterWhich features to fetch
[options]QueryOptionsOptional query options

This operation writes the following keys to state:

State KeyDescription
dataa GeoJSON FeatureCollection

Example: List the schools in a region

listFeatures({
tags: { amenity: 'school' },
area: { 'ISO3166-2': $.data.regionCode },
});

Example: List libraries, community centres and parks in a bounding box

listFeatures({
tags: [{ amenity: ['library', 'community_centre'] }, { leisure: 'park' }],
bbox: $.data.bbox,
});

Example: List shops changed since the last run

listFeatures({
tags: { shop: '*' },
area: { name: 'Example District', admin_level: '6' },
changedSince: $.lastRunTimestamp,
});

query​

query(overpassQL, [options]) ⇒ Operation

Run an Overpass QL query and write the matching OpenStreetMap elements to state.data. The adaptor adds the [out:json][timeout:N] settings, so don't include them in the query. See the Overpass QL docs.

ParamTypeDescription
overpassQLstringThe Overpass QL query to run
[options]QueryOptionsOptional query options

This operation writes the following keys to state:

State KeyDescription
dataan array of OpenStreetMap elements

Example: Fetch the schools inside a bounding box

query('nwr["amenity"="school"](51.47,-0.15,51.52,-0.05); out center;');

Example: Allow a slow query to run for up to 10 minutes

query($.data.overpassQuery, { queryTimeoutSeconds: 600 });

request​

request(method, path, body, [options]) ⇒ Operation

Make a general HTTP request to an Overpass API instance

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource, relative to the configured baseUrl
bodyobjectObject which will be attached to the request body
[options]RequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: Check the rate limit status of the Overpass instance

request('GET', 'status');

Interfaces​

FeatureFilter​

Which features to fetch. area or bbox is required.

Properties

NameTypeDescription
tagsobject | Array.<object>Tags to match. In an object, every tag must match. In an array of objects, any object may match. Values are a string, an array of strings (any of them), or '*' (any value).
areaobjectTags identifying the area to search inside, ie { 'ISO3166-2': 'XX-YY' } or { name: 'Example', admin_level: '4' }
bboxobjectBounding box to search inside, as { south, west, north, east } in decimal degrees
changedSincestringOnly return features created or modified after this date. Deleted features are not reported.

HttpState​

State object

Properties

NameDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

QueryOptions​

Options for running an Overpass query

Properties

NameTypeDescription
queryTimeoutSecondsnumberThe longest Overpass may run the query, in seconds, sent as [timeout:N]. Default: 180.

RequestOptions​

Options provided to the HTTP request

Properties

NameTypeDescription
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.
parseAsstringParse the response body as json, text or stream. By default will use the response headers.
timeoutMsnumberHow long to wait for a response, in milliseconds. Default: 300000 (5 minutes).