[core] Add feature state support to expression

This commit is contained in:
Juha Alanen
2019-08-21 16:21:46 +03:00
committed by Juha Alanen
parent e51fafd4eb
commit 75d18e32fc
4 changed files with 40 additions and 0 deletions

View File

@@ -49,6 +49,16 @@ public:
}
);
}
template <class Feature>
T evaluate(const Feature& feature, float zoom, const FeatureState& featureState, T defaultValue) const {
return this->match(
[&] (const T& constant_) { return constant_; },
[&] (const style::PropertyExpression<T>& expression) {
return expression.evaluate(zoom, feature, featureState, defaultValue);
}
);
}
};
template <class T>

View File

@@ -180,11 +180,28 @@ public:
});
}
template <class T>
static T evaluate(float z, const GeometryTileFeature& feature, const FeatureState& state,
const PossiblyEvaluatedPropertyValue<T>& v, const T& defaultValue) {
return v.match(
[&] (const T& t) {
return t;
},
[&] (const PropertyExpression<T>& t) {
return t.evaluate(z, feature, state, defaultValue);
});
}
template <class P>
auto evaluate(float z, const GeometryTileFeature& feature) const {
return evaluate(z, feature, this->template get<P>(), P::defaultValue());
}
template <class P>
auto evaluate(float z, const GeometryTileFeature& feature, const FeatureState& state) const {
return evaluate(z, feature, state, this->template get<P>(), P::defaultValue());
}
Evaluated evaluate(float z, const GeometryTileFeature& feature) const {
return Evaluated {
evaluate<Ps>(z, feature)...