summaryrefslogtreecommitdiff
path: root/include/mbgl/style/function/exponential_stops.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/style/function/exponential_stops.hpp')
-rw-r--r--include/mbgl/style/function/exponential_stops.hpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/include/mbgl/style/function/exponential_stops.hpp b/include/mbgl/style/function/exponential_stops.hpp
index 051f5aa9aa..1c57ec6f5d 100644
--- a/include/mbgl/style/function/exponential_stops.hpp
+++ b/include/mbgl/style/function/exponential_stops.hpp
@@ -22,26 +22,29 @@ public:
base(base_) {
}
- optional<T> evaluate(const Value& value) const {
+ optional<T> evaluate(float z) const {
if (stops.empty()) {
assert(false);
return T();
}
- optional<float> z = numericValue<float>(value);
- if (!z) {
- return T();
- }
-
- auto it = stops.upper_bound(*z);
+ auto it = stops.upper_bound(z);
if (it == stops.end()) {
return stops.rbegin()->second;
} else if (it == stops.begin()) {
return stops.begin()->second;
} else {
return util::interpolate(std::prev(it)->second, it->second,
- util::interpolationFactor(base, { std::prev(it)->first, it->first }, *z));
+ util::interpolationFactor(base, { std::prev(it)->first, it->first }, z));
+ }
+ }
+
+ optional<T> evaluate(const Value& value) const {
+ optional<float> z = numericValue<float>(value);
+ if (!z) {
+ return T();
}
+ return evaluate(*z);
}
friend bool operator==(const ExponentialStops& lhs,