summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/heatmap_layer_properties.cpp
blob: 947749a5adfd782d5b1d0a3fbe3155efb9fd3114 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.

#include <mbgl/style/layers/heatmap_layer_properties.hpp>

namespace mbgl {
namespace style {

HeatmapPaintProperties::Unevaluated HeatmapPaintProperties::Transitionable::transitioned(const TransitionParameters& parameters, Unevaluated&& prior) const {
    return Unevaluated {
        heatmapRadius.transition(parameters, std::move(prior.heatmapRadius)),
        heatmapWeight.transition(parameters, std::move(prior.heatmapWeight)),
        heatmapIntensity.transition(parameters, std::move(prior.heatmapIntensity)),
        heatmapColor.transition(parameters, std::move(prior.heatmapColor)),
        heatmapOpacity.transition(parameters, std::move(prior.heatmapOpacity)),
    };
}

HeatmapPaintProperties::Unevaluated HeatmapPaintProperties::Transitionable::untransitioned() const {
    return Unevaluated {
        Transitioning<PropertyValue<float>>(heatmapRadius.value),
        Transitioning<PropertyValue<float>>(heatmapWeight.value),
        Transitioning<PropertyValue<float>>(heatmapIntensity.value),
        Transitioning<ColorRampPropertyValue>(heatmapColor.value),
        Transitioning<PropertyValue<float>>(heatmapOpacity.value),
    };
}

bool HeatmapPaintProperties::Transitionable::hasDataDrivenPropertyDifference(const Transitionable& other) const {
    return false
        || heatmapRadius.value.hasDataDrivenPropertyDifference(other.heatmapRadius.value)
        || heatmapWeight.value.hasDataDrivenPropertyDifference(other.heatmapWeight.value)
        || heatmapIntensity.value.hasDataDrivenPropertyDifference(other.heatmapIntensity.value)
        || heatmapColor.value.hasDataDrivenPropertyDifference(other.heatmapColor.value)
        || heatmapOpacity.value.hasDataDrivenPropertyDifference(other.heatmapOpacity.value)
        ;
}

bool HeatmapPaintProperties::Unevaluated::hasTransition() const {
    return false
        || heatmapRadius.hasTransition()
        || heatmapWeight.hasTransition()
        || heatmapIntensity.hasTransition()
        || heatmapColor.hasTransition()
        || heatmapOpacity.hasTransition()
        ;
}

HeatmapPaintProperties::PossiblyEvaluated HeatmapPaintProperties::Unevaluated::evaluate(const PropertyEvaluationParameters& parameters) const {
    return PossiblyEvaluated {
        heatmapRadius.evaluate(typename HeatmapRadius::EvaluatorType(parameters, HeatmapRadius::defaultValue()), parameters.now),
        heatmapWeight.evaluate(typename HeatmapWeight::EvaluatorType(parameters, HeatmapWeight::defaultValue()), parameters.now),
        heatmapIntensity.evaluate(typename HeatmapIntensity::EvaluatorType(parameters, HeatmapIntensity::defaultValue()), parameters.now),
        heatmapColor.evaluate(typename HeatmapColor::EvaluatorType(parameters, HeatmapColor::defaultValue()), parameters.now),
        heatmapOpacity.evaluate(typename HeatmapOpacity::EvaluatorType(parameters, HeatmapOpacity::defaultValue()), parameters.now),
    };
}

HeatmapPaintProperties::Binders HeatmapPaintProperties::PossiblyEvaluated::createBinders(float z) const {
    return Binders {
        PaintPropertyBinder<float, typename attributes::a_radius::Type>::create(heatmapRadius, z, HeatmapRadius::defaultValue()),
        PaintPropertyBinder<float, typename attributes::a_weight::Type>::create(heatmapWeight, z, HeatmapWeight::defaultValue()),
    };
}

std::bitset<8> HeatmapPaintProperties::PossiblyEvaluated::constants() const {
    std::bitset<8> result;
    result.set(0, heatmapRadius.isConstant());
    result.set(1, heatmapWeight.isConstant());
    return result;
}

std::vector<std::string> HeatmapPaintProperties::PossiblyEvaluated::defines() const {
    std::vector<std::string> result;
    result.push_back(heatmapRadius.isConstant()
        ? std::string("#define HAS_UNIFORM_") + HeatmapRadius::Uniform::name()
        : std::string());
    result.push_back(heatmapWeight.isConstant()
        ? std::string("#define HAS_UNIFORM_") + HeatmapWeight::Uniform::name()
        : std::string());
    return result;
}

void HeatmapPaintProperties::Binders::populateVertexVectors(const GeometryTileFeature& feature, std::size_t length) {
    heatmapRadius->populateVertexVector(feature, length);
    heatmapWeight->populateVertexVector(feature, length);
}

void HeatmapPaintProperties::Binders::upload(gl::Context& context) {
    heatmapRadius->upload(context);
    heatmapWeight->upload(context);
}

HeatmapPaintProperties::Binders::AttributeBindings HeatmapPaintProperties::Binders::attributeBindings(const PossiblyEvaluated& currentProperties) const {
    return AttributeBindings {
        heatmapRadius->attributeBinding(currentProperties.heatmapRadius),
        heatmapWeight->attributeBinding(currentProperties.heatmapWeight),
    };
}

HeatmapPaintProperties::Binders::UniformValues HeatmapPaintProperties::Binders::uniformValues(float currentZoom, const PossiblyEvaluated& currentProperties) const {
    return UniformValues {
        typename InterpolationUniform<attributes::a_radius>::Value {
            heatmapRadius->interpolationFactor(currentZoom)
        },
        typename InterpolationUniform<attributes::a_weight>::Value {
            heatmapWeight->interpolationFactor(currentZoom)
        },
        typename uniforms::u_radius::Value {
            heatmapRadius->uniformValue(currentProperties.heatmapRadius)
        },
        typename uniforms::u_weight::Value {
            heatmapWeight->uniformValue(currentProperties.heatmapWeight)
        },
    };
}


} // namespace style
} // namespace mbgl