diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-10-28 16:39:50 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-02-02 09:44:42 -0800 |
commit | 141e995806576364d185626176c1b993fc519291 (patch) | |
tree | ecdc41fc7699f2a1a9e9456157348451ebe99597 /src/mbgl/style/data_driven_property_evaluator.hpp | |
parent | 6a6bddb4537004cc1bfc506e76772de74d33f3f7 (diff) | |
download | qtlocation-mapboxgl-141e995806576364d185626176c1b993fc519291.tar.gz |
[core] Add support for data-driven styling
Diffstat (limited to 'src/mbgl/style/data_driven_property_evaluator.hpp')
-rw-r--r-- | src/mbgl/style/data_driven_property_evaluator.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/mbgl/style/data_driven_property_evaluator.hpp b/src/mbgl/style/data_driven_property_evaluator.hpp new file mode 100644 index 0000000000..7a0ff9a094 --- /dev/null +++ b/src/mbgl/style/data_driven_property_evaluator.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include <mbgl/style/property_value.hpp> +#include <mbgl/style/property_evaluation_parameters.hpp> +#include <mbgl/style/possibly_evaluated_property_value.hpp> + +namespace mbgl { +namespace style { + +template <typename T> +class DataDrivenPropertyEvaluator { +public: + using ResultType = PossiblyEvaluatedPropertyValue<T>; + + DataDrivenPropertyEvaluator(const PropertyEvaluationParameters& parameters_, T defaultValue_) + : parameters(parameters_), + defaultValue(std::move(defaultValue_)) {} + + ResultType operator()(const Undefined&) const { + return ResultType(defaultValue); + } + + ResultType operator()(const T& constant) const { + return ResultType(constant); + } + + ResultType operator()(const CameraFunction<T>& function) const { + return ResultType(function.evaluate(parameters.z)); + } + + template <class Function> + ResultType operator()(const Function& function) const { + return ResultType(function); + } + +private: + const PropertyEvaluationParameters& parameters; + T defaultValue; +}; + +} // namespace style +} // namespace mbgl |