Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style spec bug with 'none' combiner filter #6817

Closed
ssaric opened this issue Jun 14, 2018 · 2 comments
Closed

Style spec bug with 'none' combiner filter #6817

ssaric opened this issue Jun 14, 2018 · 2 comments

Comments

@ssaric
Copy link
Contributor

ssaric commented Jun 14, 2018

mapbox-gl-js version:
Latest
browser:
Any

Steps to Trigger Behavior

Put a filter on layer with 'none' combiner.
As functions put two expressions. The style will not get validated.
Something like:

"filter": [
            "none",
            [
                ">",
                [
                    "number", ["get", "prop1"]
                ],
                10000
            ],
            [
                "<",
                [
                    "number",
                    [ "get",  "prop2" ]
                ],
                10000
            ]
        ],

The culprit lies here (src/style-spec/feature_filter/index.js):

switch (filter[0]) {
    case 'has':
        return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type';

    case 'in':
    case '!in':
    case '!has':
    case 'none':
        return false;

    case '==':
    case '!=':
    case '>':
    case '>=':
    case '<':
    case '<=':
        return filter.length === 3 && (Array.isArray(filter[1]) || Array.isArray(filter[2]));

    case 'any':
    case 'all':
        for (const f of filter.slice(1)) {
            if (!isExpressionFilter(f) && typeof f !== 'boolean') {
                return false;
            }
        }
        return true;

    default:
        return true;
    }

The none combiner should be with 'any' and 'all' as the documentation states

The "all", "any", and "none" filter operators are used to create compound filters. The values f0, ..., fn must be filter expressions themselves.

Although, blatantly moving this case will probably not fix the issue. Im just reporting it for now.

@jfirebaugh
Copy link
Contributor

Hi @sanjin-saric! The portion of the documentation you quoted is in the "Filter (deprecated syntax)" section. Expression-based filters do not support a "none" expression operator -- use ["!", ["any", ...]] instead.

@ssaric
Copy link
Contributor Author

ssaric commented Jun 18, 2018

Thanks!

andrewharvey pushed a commit to andrewharvey/mapbox-gl-js that referenced this issue Jul 9, 2018
- Collision debug still needs to be ignored (mapbox#3841)
- GL JS Regression mapbox#4860 not fixed yet (mapbox#9456)
- Pitched symbol queries still have order discrepancies (mapbox#6817)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants