summaryrefslogtreecommitdiff
path: root/include/mbgl/style/color_ramp_property_value.hpp
diff options
context:
space:
mode:
authorLauren Budorick <lauren@mapbox.com>2018-02-13 17:49:37 -0800
committerLauren Budorick <lauren@mapbox.com>2018-02-14 17:32:09 -0800
commit314c241ab965d9534af5d0645eb6b3557af3e9cc (patch)
tree200e73cc4854c9fd295145bed7154f09077eb295 /include/mbgl/style/color_ramp_property_value.hpp
parentb2c7becf19533ee186fab85ad1ce10aabfcb55ff (diff)
downloadqtlocation-mapboxgl-upstream/gradient-base_heatmap.tar.gz
Implement line-gradientupstream/gradient-base_heatmap
Diffstat (limited to 'include/mbgl/style/color_ramp_property_value.hpp')
-rw-r--r--include/mbgl/style/color_ramp_property_value.hpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/include/mbgl/style/color_ramp_property_value.hpp b/include/mbgl/style/color_ramp_property_value.hpp
new file mode 100644
index 0000000000..03d74fae0c
--- /dev/null
+++ b/include/mbgl/style/color_ramp_property_value.hpp
@@ -0,0 +1,49 @@
+#pragma once
+
+#include <mbgl/util/variant.hpp>
+#include <mbgl/style/undefined.hpp>
+#include <mbgl/style/function/camera_function.hpp>
+
+namespace mbgl {
+namespace style {
+
+/*
+ * Special-case implementation of (a subset of) the PropertyValue<T> interface
+ * used for building the HeatmapColor paint property traits class.
+ */
+class ColorRampPropertyValue {
+private:
+ std::shared_ptr<expression::Expression> value;
+
+ friend bool operator==(const ColorRampPropertyValue& lhs, const ColorRampPropertyValue& rhs) {
+ return (lhs.isUndefined() && rhs.isUndefined()) || (lhs.value && rhs.value && *(lhs.value) == *(rhs.value));
+ }
+
+ friend bool operator!=(const ColorRampPropertyValue& lhs, const ColorRampPropertyValue& rhs) {
+ return !(lhs == rhs);
+ }
+
+public:
+ ColorRampPropertyValue() : value(nullptr) {}
+ ColorRampPropertyValue(std::shared_ptr<expression::Expression> value_) : value(std::move(value_)) {}
+
+ bool isUndefined() const { return value.get() == nullptr; }
+
+ // noop, needed for batch evaluation of paint property values to compile
+ template <typename Evaluator>
+ Color evaluate(const Evaluator&, TimePoint = {}) const { return {}; }
+
+ Color evaluate(double rampEvaluationParameter) const {
+ const auto result = value->evaluate(expression::EvaluationContext({}, nullptr, {rampEvaluationParameter}));
+ return *expression::fromExpressionValue<Color>(*result);
+ }
+
+ bool isDataDriven() const { return false; }
+ bool hasDataDrivenPropertyDifference(const ColorRampPropertyValue&) const { return false; }
+
+ const expression::Expression& getExpression() const { return *value; }
+};
+
+
+} // namespace style
+} // namespace mbgl