diff --git a/CHANGELOG.md b/CHANGELOG.md index db0435ea..08ea77ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.0 + +* Add `basic-filters` option for filtering on Number or Boolean properties. [#110](https://github.com/mapbox/vtquery/pull/110) +* Remove tests for node v4 + v6 + ## 0.3.0 * now adding feature.id to response JSON [#90](https://github.com/mapbox/vtquery/pull/90) diff --git a/README.md b/README.md index b991e06f..b53c6f47 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,12 @@ The two major use cases for this library are: ### Table of Contents - [vtquery](#vtquery) + - [Parameters](#parameters) + - [Examples](#examples) ## vtquery -**Parameters** +### Parameters - `tiles` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** an array of tile objects with `buffer`, `z`, `x`, and `y` values - `LngLat` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>** a query point of longitude and latitude to query, `[lng, lat]` @@ -36,8 +38,11 @@ The two major use cases for this library are: Defaults to all geometry types. - `options.dedup` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** perform deduplication of features based on shared layers, geometry, IDs and matching properties. (optional, default `true`) + - `options.basic-filters` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)>?** an expression-like filter to include features with Numeric or Boolean properties + that match the filters based on the following conditions: `=, !=, <, <=, >, >=`. The first item must be the value "any" or "all" whether + any or all filters must evaluate to true. -**Examples** +### Examples ```javascript const vtquery = require('@mapbox/vtquery'); @@ -52,7 +57,8 @@ const options = { limit: 5, geometry: 'polygon', layers: ['building', 'parks'], - dedupe: true + dedupe: true, + 'basic-filters': ['all', [['population', '>', 10], ['population', '<', 1000]]] }; vtquery(tiles, [-122.4477, 37.7665], options, function(err, result) { diff --git a/lib/index.js b/lib/index.js index d7ab8896..71739bcc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -7,13 +7,16 @@ * @param {Array} LngLat a query point of longitude and latitude to query, `[lng, lat]` * @param {Object} [options] * @param {Number} [options.radius=0] the radius to query for features. If your radius is larger than - * the extent of an individual tile, include multiple nearby buffers to collect a realstic list of features + * the extent of an individual tile, include multiple nearby buffers to collect a realistic list of features * @param {Number} [options.limit=5] limit the number of results/features returned from the query. Minimum is 1, maximum is 1000 (to avoid pre allocating large amounts of memory) * @param {Array} [options.layers] an array of layer string names to query from. Default is all layers. * @param {String} [options.geometry] only return features of a particular geometry type. Can be `point`, `linestring`, or `polygon`. * Defaults to all geometry types. * @param {String} [options.dedup=true] perform deduplication of features based on shared layers, geometry, IDs and matching * properties. + * @param {Array} [options.basic-filters] - an expression-like filter to include features with Numeric or Boolean properties + * that match the filters based on the following conditions: `=, !=, <, <=, >, >=`. The first item must be the value "any" or "all" whether + * any or all filters must evaluate to true. * * @example * const vtquery = require('@mapbox/vtquery'); @@ -28,7 +31,8 @@ * limit: 5, * geometry: 'polygon', * layers: ['building', 'parks'], - * dedupe: true + * dedupe: true, + * 'basic-filters': ['all', [['population', '>', 10], ['population', '<', 1000]]] * }; * * vtquery(tiles, [-122.4477, 37.7665], options, function(err, result) { diff --git a/package-lock.json b/package-lock.json index 9de32a8a..cad28ea3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mapbox/vtquery", - "version": "0.3.1-basic-filter", + "version": "0.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b3f37363..c8c1dd53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapbox/vtquery", - "version": "0.3.1-basic-filter", + "version": "0.4.0", "description": "Get features from Mapbox Vector Tiles from a lng/lat query point", "url": "http://github.com/mapbox/vtquery", "main": "./lib/index.js",