We can likely use isExpressionFilter at
|
function getPropertyFromFilter(filter, properties) { |
|
if (styleSpec.expression.isExpression(filter)) { |
|
getPropertyFromExpression(filter, properties); |
|
} |
|
|
|
// Warning: Below code should put in to an else conditions, |
|
// but since the `isExpression` can not tell it is a expression or filter syntax I put it outsied the else |
|
// this could reduce the performance or cause some potential bugs, we must keep an eye on this. |
|
|
|
// else { |
|
let subFilter = []; |
|
for (let i = 0; i < filter.length; i++) { |
|
if (typeof filter[i] === 'object' && filter[i] instanceof Array) { |
|
subFilter.push(filter[i]); |
|
} |
|
} |
|
|
|
if (subFilter.length > 0) { |
|
subFilter.forEach(sfilter => { |
|
getPropertyFromFilter(sfilter, properties); |
|
}) |
|
} else { |
|
if (filter.length >= 3 && typeof filter[1] === 'string') { |
|
if (filter[1].indexOf('$') === -1) { |
|
properties.push(filter[1]); |
|
} |
|
|
|
} |
|
} |
|
// } |
|
} |
to clean up that code and avoid the commented else block.
This is getting exposed at mapbox/mapbox-gl-js#9530
We can likely use
isExpressionFilteratvtshaver/lib/styleToFilters.js
Lines 82 to 112 in b0d8eb4
This is getting exposed at mapbox/mapbox-gl-js#9530