summaryrefslogtreecommitdiff
path: root/include/mbgl/style/expression/is_constant.hpp
blob: 29e03ccbc01abffa913e38bb0b9487cf248048cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/compound_expression.hpp>

namespace mbgl {
namespace style {
namespace expression {

template <typename T>
bool isGlobalPropertyConstant(const Expression& expression, const T& properties) {
    if (auto e = dynamic_cast<const CompoundExpressionBase*>(&expression)) {
        for (const std::string& property : properties) {
            if (e->getName() == property) {
                return false;
            }
        }
    }
    
    bool isConstant = true;
    expression.eachChild([&](const Expression& e) {
        if (isConstant && !isGlobalPropertyConstant(e, properties)) {
            isConstant = false;
        }
    });
    return isConstant;
};

bool isFeatureConstant(const Expression& expression);
bool isZoomConstant(const Expression& e);


} // namespace expression
} // namespace style
} // namespace mbgl