blob: 0ebb37faa99fc0a7ae2a6a2cc3bc0d8aeb02ddd6 (
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
36
37
38
39
40
|
#include <mbgl/style/expression/is_constant.hpp>
namespace mbgl {
namespace style {
namespace expression {
bool isFeatureConstant(const Expression& expression) {
if (auto e = dynamic_cast<const CompoundExpressionBase*>(&expression)) {
const std::string name = e->getName();
optional<std::size_t> parameterCount = e->getParameterCount();
if (name == "get" && parameterCount && *parameterCount == 1) {
return false;
} else if (name == "has" && parameterCount && *parameterCount == 1) {
return false;
} else if (
name == "properties" ||
name == "geometry-type" ||
name == "id"
) {
return false;
}
}
bool featureConstant = true;
expression.eachChild([&](const Expression& e) {
if (featureConstant && !isFeatureConstant(e)) {
featureConstant = false;
}
});
return featureConstant;
}
bool isZoomConstant(const Expression& e) {
return isGlobalPropertyConstant(e, std::array<std::string, 1>{{"zoom"}});
}
} // namespace expression
} // namespace style
} // namespace mbgl
|