Skip to content

Commit

Permalink
Fix filter operator checking for nested condition
Browse files Browse the repository at this point in the history
  • Loading branch information
zmiao committed Apr 22, 2020
1 parent 12fe07b commit 69b4c2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions src/style-spec/feature_filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,11 @@ function compare(a, b) {

function geometryNeeded(filter) {
if (!Array.isArray(filter)) return false;
let needed = false;
for (let index = 0; index < filter.length; index++) {
const val = filter[index];
const op = Array.isArray(val) ? val[0] : val;
needed = needed || (op === 'within');
if (filter[0] === 'within') return true;
for (let index = 1; index < filter.length; index++) {
if (geometryNeeded(filter[index])) return true;
}
return needed;
return false;
}

function convertFilter(filter: ?Array<any>): mixed {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"type": "Feature",
"properties": {
"name": "ABC"
"number": [5]
},
"geometry": {
"type": "Point",
Expand All @@ -30,7 +30,7 @@
{
"type": "Feature",
"properties": {
"name": "ABC"
"number": [5]
},
"geometry": {
"type": "Point",
Expand Down Expand Up @@ -80,7 +80,7 @@
"id": "circle",
"type": "circle",
"source": "points",
"filter": ["all", ["in", "ABC", ["get", "name"]], ["within", {
"filter": ["all", ["in", 5, ["get", "number"]], ["==", ["within", {
"type": "Polygon",
"coordinates": [
[
Expand All @@ -91,7 +91,7 @@
[0, 0]
]
]
}]
}], true]
],
"paint": {
"circle-radius": 5,
Expand Down

0 comments on commit 69b4c2e

Please sign in to comment.