Class: Filter

Filter(query)

A Filter into OSM data. A simplified version of Overpass QL.

Either a single query (e.g. node[amenity=restaurant];) or a combined query (e.g. (node[amenity=restaurant];way[amenity=restaurant];);).
A single query statement consists of a type (e.g. 'node', 'way', 'relation', 'nwr' (node, way or relation)) and optional filters:

  • (Not) Equals (=, !=): [amenity=restaurant] or ["amenity"="restaurant"] resp. ["amenity"!="restaurant"].
  • Regular Expression: [amenity~"^(restaurant|cafe)$"] resp. negated: [amenity!~"^(restaurant|cafe)$"]
  • Key regular expression: [~"cycleway"~"left"] (key has to match cycleway and its value match left)
  • Key (not) exists: [amenity] or ["amenity"] resp. [!amenity]
  • Array search: [cuisine^kebap]: search for cuisine tags which exactly include 'kebap' (semicolon-separated values, e.g. cuisine=kebap;pizza).
  • String search: [name%cafe]: search for name tags which are similar to cafe, e.g. "cafĂ©". (see https://github.com/plepe/strsearch2regexp for details).
More advanced queries are not supported.

Constructor

new Filter(query)

Parameters:
Name Type Description
query string | object
Source:

Methods

isSupersetOf(Filter)

compare this filter with an other filter.
Parameters:
Name Type Description
Filter other the other filter.
Source:
Returns:
boolean true, if the current filter is equal other or a super-set of other.

match(ob) → {boolean}

Check if an object matches this filter
Parameters:
Name Type Description
ob OverpassNode | OverpassWay | OverpassRelation an object from Overpass API
Source:
Returns:
Type
boolean

properties() → {number}

Source:
Returns:
properties which are required for this filter
Type
number

toLokijs(optionsopt) → {object}

Convert query to LokiJS query for local database. If the property 'needMatch' is set on the returned object, an additional match() should be executed for each returned object, as the query can't be fully compiled (and the 'needMatch' property removed).
Parameters:
Name Type Attributes Description
options object <optional>
Additional options
Source:
Returns:
Type
object

toQl(optionsopt) → {string}

Convert query to Overpass QL
Parameters:
Name Type Attributes Description
options object <optional>
Additional options
Properties
Name Type Attributes Default Description
inputSet string <optional>
'' Specify input set (e.g.'.foo').
outputSet string <optional>
'' Specify output set (e.g.'.foo').
Source:
Returns:
Type
string

toString() → {string}

Convert query to a string representation
Source:
Returns:
Type
string