[core] Add feature state support to expression
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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)...
|
||||
|
||||
Reference in New Issue
Block a user