diff options
Diffstat (limited to 'include/mbgl/style/function/camera_function.hpp')
-rw-r--r-- | include/mbgl/style/function/camera_function.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/mbgl/style/function/camera_function.hpp b/include/mbgl/style/function/camera_function.hpp new file mode 100644 index 0000000000..a96978939d --- /dev/null +++ b/include/mbgl/style/function/camera_function.hpp @@ -0,0 +1,41 @@ +#pragma once + +#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>, + variant< + ExponentialStops<T>, + IntervalStops<T>>, + variant< + IntervalStops<T>>>; + + CameraFunction(Stops stops_) + : stops(std::move(stops_)) { + } + + T evaluate(float zoom) const { + return stops.match([&] (const auto& s) { + return s.evaluate(Value(double(zoom))); + }); + } + + friend bool operator==(const CameraFunction& lhs, + const CameraFunction& rhs) { + return lhs.stops == rhs.stops; + } + + Stops stops; +}; + +} // namespace style +} // namespace mbgl |