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.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp
index cc1d58025b..53512ce89e 100644
--- a/src/mbgl/style/expression/compound_expression.cpp
+++ b/src/mbgl/style/expression/compound_expression.cpp
@@ -234,8 +234,12 @@ Value featureIdAsExpressionValue(EvaluationContext params) {
optional<Value> featurePropertyAsExpressionValue(EvaluationContext params, const std::string& key) {
assert(params.feature);
- auto property = params.feature->getValue(key);
- return property ? toExpressionValue(*property) : optional<Value>();
+ const PropertyMap& properties = params.feature->getProperties();
+ const auto it = properties.find(key);
+ if (it == properties.cend()) {
+ return optional<Value>();
+ }
+ return toExpressionValue(it->second);
};
optional<std::string> featureTypeAsString(FeatureType type) {
@@ -255,9 +259,7 @@ optional<std::string> featureTypeAsString(FeatureType type) {
optional<double> featurePropertyAsDouble(EvaluationContext params, const std::string& key) {
assert(params.feature);
- auto property = params.feature->getValue(key);
- if (!property) return {};
- return property->match(
+ return params.feature->getValue(key).match(
[](double value) { return value; },
[](uint64_t value) { return optional<double>(static_cast<double>(value)); },
[](int64_t value) { return optional<double>(static_cast<double>(value)); },
@@ -267,9 +269,7 @@ optional<double> featurePropertyAsDouble(EvaluationContext params, const std::st
optional<std::string> featurePropertyAsString(EvaluationContext params, const std::string& key) {
assert(params.feature);
- auto property = params.feature->getValue(key);
- if (!property) return {};
- return property->match(
+ return params.feature->getValue(key).match(
[](std::string value) { return value; },
[](auto) { return optional<std::string>(); }
);
@@ -376,7 +376,8 @@ const auto& hasContextCompoundExpression() {
};
}
- return params.feature->getValue(key) ? true : false;
+ const PropertyMap& properties = params.feature->getProperties();
+ return properties.find(key) != properties.cend();
});
return signature;
}
@@ -396,11 +397,12 @@ const auto& getContextCompoundExpression() {
};
}
- auto propertyValue = params.feature->getValue(key);
- if (!propertyValue) {
+ const PropertyMap& properties = params.feature->getProperties();
+ const auto it = properties.find(key);
+ if (it == properties.cend()) {
return Null;
}
- return Value(toExpressionValue(*propertyValue));
+ return toExpressionValue(it->second);
});
return signature;
}
@@ -817,7 +819,8 @@ const auto& filterIdGreaterOrEqualThanStringCompoundExpression() {
const auto& filterHasCompoundExpression() {
static auto signature = detail::makeSignature("filter-has", [](const EvaluationContext& params, const std::string& key) -> Result<bool> {
assert(params.feature);
- return bool(params.feature->getValue(key));
+ const PropertyMap& properties = params.feature->getProperties();
+ return properties.find(key) != properties.cend();
});
return signature;
}