summaryrefslogtreecommitdiff
path: root/include/mbgl/style/heatmap_color_property_value.hpp
diff options
context:
space:
mode:
authorVladimir Agafonkin <agafonkin@gmail.com>2018-02-15 17:38:23 +0200
committerGitHub <noreply@github.com>2018-02-15 17:38:23 +0200
commit82de856c94bbc090ba30186011610da5e233e277 (patch)
treebb8d4eb20901b4ac852520465d2487f6d5729852 /include/mbgl/style/heatmap_color_property_value.hpp
parent1fdec7a5c1babc0cd36a110ce372175a5252d45e (diff)
downloadqtlocation-mapboxgl-82de856c94bbc090ba30186011610da5e233e277.tar.gz
[core, ios, macos, android, node] Heatmap layer (#11046)
Co-Authored-By: Konstantin Käfer <mail@kkaefer.com> Co-Authored-By: Anand Thakker <anandthakker@users.noreply.github.com> Co-Authored-By: Minh Nguyễn <1ec5@users.noreply.github.com>
Diffstat (limited to 'include/mbgl/style/heatmap_color_property_value.hpp')
-rw-r--r--include/mbgl/style/heatmap_color_property_value.hpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/include/mbgl/style/heatmap_color_property_value.hpp b/include/mbgl/style/heatmap_color_property_value.hpp
new file mode 100644
index 0000000000..130639c6e2
--- /dev/null
+++ b/include/mbgl/style/heatmap_color_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 HeatmapColorPropertyValue {
+private:
+ std::shared_ptr<expression::Expression> value;
+
+ friend bool operator==(const HeatmapColorPropertyValue& lhs, const HeatmapColorPropertyValue& rhs) {
+ return (lhs.isUndefined() && rhs.isUndefined()) || (lhs.value && rhs.value && *(lhs.value) == *(rhs.value));
+ }
+
+ friend bool operator!=(const HeatmapColorPropertyValue& lhs, const HeatmapColorPropertyValue& rhs) {
+ return !(lhs == rhs);
+ }
+
+public:
+ HeatmapColorPropertyValue() : value(nullptr) {}
+ HeatmapColorPropertyValue(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 heatmapDensity) const {
+ const auto result = value->evaluate(expression::EvaluationContext({}, nullptr, {heatmapDensity}));
+ return *expression::fromExpressionValue<Color>(*result);
+ }
+
+ bool isDataDriven() const { return false; }
+ bool hasDataDrivenPropertyDifference(const HeatmapColorPropertyValue&) const { return false; }
+
+ const expression::Expression& getExpression() const { return *value; }
+};
+
+
+} // namespace style
+} // namespace mbgl