summaryrefslogtreecommitdiff
path: root/src/mbgl/style/expression/compound_expression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/expression/compound_expression.cpp')
-rw-r--r--src/mbgl/style/expression/compound_expression.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp
index 689f8cdf34..3bd8a836df 100644
--- a/src/mbgl/style/expression/compound_expression.cpp
+++ b/src/mbgl/style/expression/compound_expression.cpp
@@ -224,10 +224,10 @@ Value featureIdAsExpressionValue(EvaluationContext params) {
});
};
-Value featurePropertyAsExpressionValue(EvaluationContext params, const std::string& key) {
+optional<Value> featurePropertyAsExpressionValue(EvaluationContext params, const std::string& key) {
assert(params.feature);
auto property = params.feature->getValue(key);
- return property ? toExpressionValue(*property) : Null;
+ return property ? toExpressionValue(*property) : optional<Value>();
};
optional<std::string> featureTypeAsString(FeatureType type) {
@@ -507,7 +507,8 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali
// Legacy Filters
define("filter-==", [](const EvaluationContext& params, const std::string& key, const Value &lhs) -> Result<bool> {
- return lhs == featurePropertyAsExpressionValue(params, key);
+ const auto rhs = featurePropertyAsExpressionValue(params, key);
+ return rhs ? lhs == *rhs : false;
});
define("filter-id-==", [](const EvaluationContext& params, const Value &lhs) -> Result<bool> {
@@ -624,7 +625,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali
if (varargs.size() < 2) return false;
assert(varargs[0].is<std::string>());
auto value = featurePropertyAsExpressionValue(params, varargs[0].get<std::string>());
- return std::find(varargs.begin() + 1, varargs.end(), value) != varargs.end();
+ return value ? std::find(varargs.begin() + 1, varargs.end(), *value) != varargs.end() : false;
});
return definitions;