summaryrefslogtreecommitdiff
path: root/src/mbgl/programs/symbol_program.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-07-13 18:14:12 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-07-20 11:56:30 -0700
commitc8edbb0500cbf4baf1d5fdb0e63679539e166585 (patch)
tree750f3b72b9e3b1c91ddbc0541cfc64d7d80ffe71 /src/mbgl/programs/symbol_program.hpp
parent6d7072162b764c2432c010cd463a5a2c0093d606 (diff)
downloadqtlocation-mapboxgl-c8edbb0500cbf4baf1d5fdb0e63679539e166585.tar.gz
[core] Replace {Source,Camera,Composite}Function with PropertyExpression
Diffstat (limited to 'src/mbgl/programs/symbol_program.hpp')
-rw-r--r--src/mbgl/programs/symbol_program.hpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp
index 51f9a48f7f..35b5821918 100644
--- a/src/mbgl/programs/symbol_program.hpp
+++ b/src/mbgl/programs/symbol_program.hpp
@@ -143,13 +143,13 @@ public:
ConstantSymbolSizeBinder(const float /*tileZoom*/, const style::Undefined&, const float defaultValue)
: layoutSize(defaultValue) {}
- ConstantSymbolSizeBinder(const float tileZoom, const style::CameraFunction<float>& function_, const float /*defaultValue*/)
- : layoutSize(function_.evaluate(tileZoom + 1)),
- function(function_) {
- const Range<float> zoomLevels = function_.getCoveringStops(tileZoom, tileZoom + 1);
+ ConstantSymbolSizeBinder(const float tileZoom, const style::PropertyExpression<float>& expression_, const float /*defaultValue*/)
+ : layoutSize(expression_.evaluate(tileZoom + 1)),
+ expression(expression_) {
+ const Range<float> zoomLevels = expression_.getCoveringStops(tileZoom, tileZoom + 1);
coveringRanges = std::make_tuple(
zoomLevels,
- Range<float> { function_.evaluate(zoomLevels.min), function_.evaluate(zoomLevels.max) }
+ Range<float> { expression_.evaluate(zoomLevels.min), expression_.evaluate(zoomLevels.max) }
);
}
@@ -157,7 +157,7 @@ public:
ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override {
float size = layoutSize;
- bool isZoomConstant = !(coveringRanges || function);
+ bool isZoomConstant = !(coveringRanges || expression);
if (coveringRanges) {
// Even though we could get the exact value of the camera function
// at z = currentZoom, we intentionally do not: instead, we interpolate
@@ -167,12 +167,12 @@ public:
const Range<float>& zoomLevels = std::get<0>(*coveringRanges);
const Range<float>& sizeLevels = std::get<1>(*coveringRanges);
float t = util::clamp(
- function->interpolationFactor(zoomLevels, currentZoom),
+ expression->interpolationFactor(zoomLevels, currentZoom),
0.0f, 1.0f
);
size = sizeLevels.min + t * (sizeLevels.max - sizeLevels.min);
- } else if (function) {
- size = function->evaluate(currentZoom);
+ } else if (expression) {
+ size = expression->evaluate(currentZoom);
}
const float unused = 0.0f;
@@ -181,7 +181,7 @@ public:
float layoutSize;
optional<std::tuple<Range<float>, Range<float>>> coveringRanges;
- optional<style::CameraFunction<float>> function;
+ optional<style::PropertyExpression<float>> expression;
};
class SourceFunctionSymbolSizeBinder final : public SymbolSizeBinder {
@@ -190,13 +190,13 @@ public:
using VertexVector = gl::VertexVector<Vertex>;
using VertexBuffer = gl::VertexBuffer<Vertex>;
- SourceFunctionSymbolSizeBinder(const float /*tileZoom*/, const style::SourceFunction<float>& function_, const float defaultValue_)
- : function(function_),
+ SourceFunctionSymbolSizeBinder(const float /*tileZoom*/, style::PropertyExpression<float> expression_, const float defaultValue_)
+ : expression(std::move(expression_)),
defaultValue(defaultValue_) {
}
Range<float> getVertexSizeData(const GeometryTileFeature& feature) override {
- const float size = function.evaluate(feature, defaultValue);
+ const float size = expression.evaluate(feature, defaultValue);
return { size, size };
};
@@ -205,30 +205,30 @@ public:
return { true, false, unused, unused, unused };
}
- style::SourceFunction<float> function;
+ style::PropertyExpression<float> expression;
const float defaultValue;
};
class CompositeFunctionSymbolSizeBinder final : public SymbolSizeBinder {
public:
- CompositeFunctionSymbolSizeBinder(const float tileZoom, const style::CompositeFunction<float>& function_, const float defaultValue_)
- : function(function_),
+ CompositeFunctionSymbolSizeBinder(const float tileZoom, style::PropertyExpression<float> expression_, const float defaultValue_)
+ : expression(std::move(expression_)),
defaultValue(defaultValue_),
layoutZoom(tileZoom + 1),
- coveringZoomStops(function.getCoveringStops(tileZoom, tileZoom + 1))
+ coveringZoomStops(expression.getCoveringStops(tileZoom, tileZoom + 1))
{}
Range<float> getVertexSizeData(const GeometryTileFeature& feature) override {
return {
- function.evaluate(coveringZoomStops.min, feature, defaultValue),
- function.evaluate(coveringZoomStops.max, feature, defaultValue)
+ expression.evaluate(coveringZoomStops.min, feature, defaultValue),
+ expression.evaluate(coveringZoomStops.max, feature, defaultValue)
};
};
ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override {
float sizeInterpolationT = util::clamp(
- function.interpolationFactor(coveringZoomStops, currentZoom),
+ expression.interpolationFactor(coveringZoomStops, currentZoom),
0.0f, 1.0f
);
@@ -236,7 +236,7 @@ public:
return { false, false, sizeInterpolationT, unused, unused };
}
- style::CompositeFunction<float> function;
+ style::PropertyExpression<float> expression;
const float defaultValue;
float layoutZoom;
Range<float> coveringZoomStops;