blob: 5a0f5ffe4a8e0969493a782a0557451bced00512 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#pragma once
#include <mbgl/style/function/convert.hpp>
#include <mbgl/style/function/exponential_stops.hpp>
#include <mbgl/style/function/interval_stops.hpp>
#include <mbgl/util/interpolate.hpp>
#include <mbgl/util/variant.hpp>
namespace mbgl {
namespace style {
template <class T>
class CameraFunction {
public:
using Stops = std::conditional_t<
util::Interpolatable<T>::value,
variant<
ExponentialStops<T>,
IntervalStops<T>>,
variant<
IntervalStops<T>>>;
CameraFunction(Stops stops_)
: stops(std::move(stops_)),
expression(stops.match([&] (const auto& s) {
return expression::Convert::toExpression(s);
}))
{}
T evaluate(float zoom) const {
auto result = expression->evaluate<T>(expression::EvaluationParameters { zoom });
if (!result) return T();
return *result;
}
friend bool operator==(const CameraFunction& lhs,
const CameraFunction& rhs) {
return lhs.stops == rhs.stops;
}
bool useIntegerZoom = false;
// retained for compatibility with pre-expression function API
Stops stops;
private:
std::shared_ptr<expression::Expression> expression;
};
} // namespace style
} // namespace mbgl
|