summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-07-31 14:21:47 -0700
committerGitHub <noreply@github.com>2018-07-31 14:21:47 -0700
commit9bdd765a02de75851a00ab85223d5d582a104757 (patch)
treebcb417a47808a4a94c171b083c7f2e2cce457107 /include
parent885f6e3c02138398d094e49243817a83349b4d50 (diff)
downloadqtlocation-mapboxgl-9bdd765a02de75851a00ab85223d5d582a104757.tar.gz
[core] Merge DataDrivenPropertyValue into PropertyValue (#12513)
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/annotation/annotation.hpp26
-rw-r--r--include/mbgl/style/conversion/color_ramp_property_value.hpp2
-rw-r--r--include/mbgl/style/conversion/data_driven_property_value.hpp78
-rw-r--r--include/mbgl/style/conversion/property_value.hpp25
-rw-r--r--include/mbgl/style/data_driven_property_value.hpp74
-rw-r--r--include/mbgl/style/layers/background_layer.hpp1
-rw-r--r--include/mbgl/style/layers/circle_layer.hpp43
-rw-r--r--include/mbgl/style/layers/fill_extrusion_layer.hpp19
-rw-r--r--include/mbgl/style/layers/fill_layer.hpp19
-rw-r--r--include/mbgl/style/layers/heatmap_layer.hpp13
-rw-r--r--include/mbgl/style/layers/hillshade_layer.hpp1
-rw-r--r--include/mbgl/style/layers/layer.hpp.ejs1
-rw-r--r--include/mbgl/style/layers/line_layer.hpp43
-rw-r--r--include/mbgl/style/layers/raster_layer.hpp1
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp151
-rw-r--r--include/mbgl/style/property_value.hpp68
16 files changed, 223 insertions, 342 deletions
diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp
index bbe479b5ba..8c099141c4 100644
--- a/include/mbgl/annotation/annotation.hpp
+++ b/include/mbgl/annotation/annotation.hpp
@@ -4,7 +4,7 @@
#include <mbgl/util/variant.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
+#include <mbgl/style/property_value.hpp>
#include <cstdint>
#include <vector>
@@ -34,35 +34,35 @@ using ShapeAnnotationGeometry = variant<
class LineAnnotation {
public:
LineAnnotation(ShapeAnnotationGeometry geometry_,
- style::DataDrivenPropertyValue<float> opacity_ = 1.0f,
- style::DataDrivenPropertyValue<float> width_ = 1.0f,
- style::DataDrivenPropertyValue<Color> color_ = Color::black())
+ style::PropertyValue<float> opacity_ = 1.0f,
+ style::PropertyValue<float> width_ = 1.0f,
+ style::PropertyValue<Color> color_ = Color::black())
: geometry(std::move(geometry_)),
opacity(std::move(opacity_)),
width(std::move(width_)),
color(std::move(color_)) {}
ShapeAnnotationGeometry geometry;
- style::DataDrivenPropertyValue<float> opacity;
- style::DataDrivenPropertyValue<float> width;
- style::DataDrivenPropertyValue<Color> color;
+ style::PropertyValue<float> opacity;
+ style::PropertyValue<float> width;
+ style::PropertyValue<Color> color;
};
class FillAnnotation {
public:
FillAnnotation(ShapeAnnotationGeometry geometry_,
- style::DataDrivenPropertyValue<float> opacity_ = 1.0f,
- style::DataDrivenPropertyValue<Color> color_ = Color::black(),
- style::DataDrivenPropertyValue<Color> outlineColor_ = {})
+ style::PropertyValue<float> opacity_ = 1.0f,
+ style::PropertyValue<Color> color_ = Color::black(),
+ style::PropertyValue<Color> outlineColor_ = {})
: geometry(std::move(geometry_)),
opacity(std::move(opacity_)),
color(std::move(color_)),
outlineColor(std::move(outlineColor_)) {}
ShapeAnnotationGeometry geometry;
- style::DataDrivenPropertyValue<float> opacity;
- style::DataDrivenPropertyValue<Color> color;
- style::DataDrivenPropertyValue<Color> outlineColor;
+ style::PropertyValue<float> opacity;
+ style::PropertyValue<Color> color;
+ style::PropertyValue<Color> outlineColor;
};
using Annotation = variant<
diff --git a/include/mbgl/style/conversion/color_ramp_property_value.hpp b/include/mbgl/style/conversion/color_ramp_property_value.hpp
index 87049b043b..17aa177420 100644
--- a/include/mbgl/style/conversion/color_ramp_property_value.hpp
+++ b/include/mbgl/style/conversion/color_ramp_property_value.hpp
@@ -9,7 +9,7 @@ namespace conversion {
template <>
struct Converter<ColorRampPropertyValue> {
- optional<ColorRampPropertyValue> operator()(const Convertible& value, Error& error, bool /* convertTokens */ = false) const;
+ optional<ColorRampPropertyValue> operator()(const Convertible& value, Error& error, bool /* allowDataExpressions */ = false, bool /* convertTokens */ = false) const;
};
} // namespace conversion
diff --git a/include/mbgl/style/conversion/data_driven_property_value.hpp b/include/mbgl/style/conversion/data_driven_property_value.hpp
deleted file mode 100644
index 2d8817ecf4..0000000000
--- a/include/mbgl/style/conversion/data_driven_property_value.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#pragma once
-
-#include <mbgl/style/data_driven_property_value.hpp>
-#include <mbgl/style/conversion.hpp>
-#include <mbgl/style/conversion/constant.hpp>
-#include <mbgl/style/conversion/function.hpp>
-#include <mbgl/style/expression/is_expression.hpp>
-#include <mbgl/style/expression/is_constant.hpp>
-#include <mbgl/style/expression/literal.hpp>
-#include <mbgl/style/expression/value.hpp>
-#include <mbgl/style/expression/parsing_context.hpp>
-
-namespace mbgl {
-namespace style {
-namespace conversion {
-
-template <class T>
-struct Converter<DataDrivenPropertyValue<T>> {
- optional<DataDrivenPropertyValue<T>> operator()(const Convertible& value, Error& error, bool convertTokens) const {
- using namespace mbgl::style::expression;
-
- if (isUndefined(value)) {
- return DataDrivenPropertyValue<T>();
- }
-
- optional<PropertyExpression<T>> expression;
-
- if (isExpression(value)) {
- ParsingContext ctx(valueTypeToExpressionType<T>());
- ParseResult parsed = ctx.parseLayerPropertyExpression(value);
- if (!parsed) {
- error.message = ctx.getCombinedErrors();
- return nullopt;
- }
- expression = PropertyExpression<T>(std::move(*parsed));
- } else if (isObject(value)) {
- expression = convertFunctionToExpression<T>(value, error, convertTokens);
- } else {
- optional<T> constant = convert<T>(value, error);
- if (!constant) {
- return nullopt;
- }
- return convertTokens ? maybeConvertTokens(*constant) : DataDrivenPropertyValue<T>(*constant);
- }
-
- if (!expression) {
- return nullopt;
- } else if (!(*expression).isFeatureConstant() || !(*expression).isZoomConstant()) {
- return { std::move(*expression) };
- } else if ((*expression).getExpression().getKind() == Kind::Literal) {
- optional<T> constant = fromExpressionValue<T>(
- static_cast<const Literal&>((*expression).getExpression()).getValue());
- if (!constant) {
- return nullopt;
- }
- return DataDrivenPropertyValue<T>(*constant);
- } else {
- assert(false);
- error.message = "expected a literal expression";
- return nullopt;
- }
- }
-
- template <class S>
- DataDrivenPropertyValue<T> maybeConvertTokens(const S& t) const {
- return DataDrivenPropertyValue<T>(t);
- };
-
- DataDrivenPropertyValue<T> maybeConvertTokens(const std::string& t) const {
- return hasTokens(t)
- ? DataDrivenPropertyValue<T>(PropertyExpression<T>(convertTokenStringToExpression(t)))
- : DataDrivenPropertyValue<T>(t);
- }
-};
-
-} // namespace conversion
-} // namespace style
-} // namespace mbgl
diff --git a/include/mbgl/style/conversion/property_value.hpp b/include/mbgl/style/conversion/property_value.hpp
index 4d13144dd7..fa6752867b 100644
--- a/include/mbgl/style/conversion/property_value.hpp
+++ b/include/mbgl/style/conversion/property_value.hpp
@@ -16,13 +16,9 @@ namespace conversion {
template <class T>
struct Converter<PropertyValue<T>> {
- optional<PropertyValue<T>> operator()(const Convertible& value, Error& error, bool convertTokens = false) const {
+ optional<PropertyValue<T>> operator()(const Convertible& value, Error& error, bool allowDataExpressions, bool convertTokens) const {
using namespace mbgl::style::expression;
- // Only icon-image and text-field support tokens, and they are both data-driven.
- assert(!convertTokens);
- (void)convertTokens;
-
if (isUndefined(value)) {
return PropertyValue<T>();
}
@@ -38,21 +34,21 @@ struct Converter<PropertyValue<T>> {
}
expression = PropertyExpression<T>(std::move(*parsed));
} else if (isObject(value)) {
- expression = convertFunctionToExpression<T>(value, error, false);
+ expression = convertFunctionToExpression<T>(value, error, convertTokens);
} else {
optional<T> constant = convert<T>(value, error);
if (!constant) {
return nullopt;
}
- return { *constant };
+ return convertTokens ? maybeConvertTokens(*constant) : PropertyValue<T>(*constant);
}
if (!expression) {
return nullopt;
- } else if (!(*expression).isFeatureConstant()) {
+ } else if (!allowDataExpressions && !(*expression).isFeatureConstant()) {
error.message = "data expressions not supported";
return nullopt;
- } else if (!(*expression).isZoomConstant()) {
+ } else if (!(*expression).isFeatureConstant() || !(*expression).isZoomConstant()) {
return { std::move(*expression) };
} else if ((*expression).getExpression().getKind() == Kind::Literal) {
optional<T> constant = fromExpressionValue<T>(
@@ -67,6 +63,17 @@ struct Converter<PropertyValue<T>> {
return nullopt;
}
}
+
+ template <class S>
+ PropertyValue<T> maybeConvertTokens(const S& t) const {
+ return PropertyValue<T>(t);
+ };
+
+ PropertyValue<T> maybeConvertTokens(const std::string& t) const {
+ return hasTokens(t)
+ ? PropertyValue<T>(PropertyExpression<T>(convertTokenStringToExpression(t)))
+ : PropertyValue<T>(t);
+ }
};
} // namespace conversion
diff --git a/include/mbgl/style/data_driven_property_value.hpp b/include/mbgl/style/data_driven_property_value.hpp
deleted file mode 100644
index baea861f62..0000000000
--- a/include/mbgl/style/data_driven_property_value.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-#pragma once
-
-#include <mbgl/util/variant.hpp>
-#include <mbgl/style/undefined.hpp>
-#include <mbgl/style/property_expression.hpp>
-
-namespace mbgl {
-namespace style {
-
-template <class T>
-class DataDrivenPropertyValue {
-private:
- using Value = variant<
- Undefined,
- T,
- PropertyExpression<T>>;
-
- Value value;
-
- friend bool operator==(const DataDrivenPropertyValue& lhs,
- const DataDrivenPropertyValue& rhs) {
- return lhs.value == rhs.value;
- }
-
- friend bool operator!=(const DataDrivenPropertyValue& lhs,
- const DataDrivenPropertyValue& rhs) {
- return !(lhs == rhs);
- }
-
-public:
- DataDrivenPropertyValue() = default;
- DataDrivenPropertyValue( T v) : value(std::move(v)) {}
- DataDrivenPropertyValue(PropertyExpression<T> v) : value(std::move(v)) {}
-
- bool isUndefined() const {
- return value.template is<Undefined>();
- }
-
- bool isDataDriven() const {
- return value.match(
- [] (const Undefined&) { return false; },
- [] (const T&) { return false; },
- [] (const PropertyExpression<T>& fn) { return !fn.isFeatureConstant(); }
- );
- }
-
- bool isZoomConstant() const {
- return value.match(
- [] (const Undefined&) { return true; },
- [] (const T&) { return true; },
- [] (const PropertyExpression<T>& fn) { return fn.isZoomConstant(); }
- );
- }
-
- const T & asConstant() const { return value.template get< T >(); }
- const PropertyExpression<T>& asExpression() const { return value.template get<PropertyExpression<T>>(); }
-
- template <class... Ts>
- auto match(Ts&&... ts) const {
- return value.match(std::forward<Ts>(ts)...);
- }
-
- template <typename Evaluator>
- auto evaluate(const Evaluator& evaluator, TimePoint = {}) const {
- return Value::visit(value, evaluator);
- }
-
- bool hasDataDrivenPropertyDifference(const DataDrivenPropertyValue<T>& other) const {
- return *this != other && (isDataDriven() || other.isDataDriven());
- }
-};
-
-} // namespace style
-} // namespace mbgl
diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp
index 903983844f..eab2681fec 100644
--- a/include/mbgl/style/layers/background_layer.hpp
+++ b/include/mbgl/style/layers/background_layer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp
index 942dd67503..89ef926221 100644
--- a/include/mbgl/style/layers/circle_layer.hpp
+++ b/include/mbgl/style/layers/circle_layer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
@@ -36,27 +35,27 @@ public:
// Paint properties
- static DataDrivenPropertyValue<float> getDefaultCircleRadius();
- DataDrivenPropertyValue<float> getCircleRadius() const;
- void setCircleRadius(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultCircleRadius();
+ PropertyValue<float> getCircleRadius() const;
+ void setCircleRadius(PropertyValue<float>);
void setCircleRadiusTransition(const TransitionOptions&);
TransitionOptions getCircleRadiusTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultCircleColor();
- DataDrivenPropertyValue<Color> getCircleColor() const;
- void setCircleColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultCircleColor();
+ PropertyValue<Color> getCircleColor() const;
+ void setCircleColor(PropertyValue<Color>);
void setCircleColorTransition(const TransitionOptions&);
TransitionOptions getCircleColorTransition() const;
- static DataDrivenPropertyValue<float> getDefaultCircleBlur();
- DataDrivenPropertyValue<float> getCircleBlur() const;
- void setCircleBlur(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultCircleBlur();
+ PropertyValue<float> getCircleBlur() const;
+ void setCircleBlur(PropertyValue<float>);
void setCircleBlurTransition(const TransitionOptions&);
TransitionOptions getCircleBlurTransition() const;
- static DataDrivenPropertyValue<float> getDefaultCircleOpacity();
- DataDrivenPropertyValue<float> getCircleOpacity() const;
- void setCircleOpacity(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultCircleOpacity();
+ PropertyValue<float> getCircleOpacity() const;
+ void setCircleOpacity(PropertyValue<float>);
void setCircleOpacityTransition(const TransitionOptions&);
TransitionOptions getCircleOpacityTransition() const;
@@ -84,21 +83,21 @@ public:
void setCirclePitchAlignmentTransition(const TransitionOptions&);
TransitionOptions getCirclePitchAlignmentTransition() const;
- static DataDrivenPropertyValue<float> getDefaultCircleStrokeWidth();
- DataDrivenPropertyValue<float> getCircleStrokeWidth() const;
- void setCircleStrokeWidth(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultCircleStrokeWidth();
+ PropertyValue<float> getCircleStrokeWidth() const;
+ void setCircleStrokeWidth(PropertyValue<float>);
void setCircleStrokeWidthTransition(const TransitionOptions&);
TransitionOptions getCircleStrokeWidthTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultCircleStrokeColor();
- DataDrivenPropertyValue<Color> getCircleStrokeColor() const;
- void setCircleStrokeColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultCircleStrokeColor();
+ PropertyValue<Color> getCircleStrokeColor() const;
+ void setCircleStrokeColor(PropertyValue<Color>);
void setCircleStrokeColorTransition(const TransitionOptions&);
TransitionOptions getCircleStrokeColorTransition() const;
- static DataDrivenPropertyValue<float> getDefaultCircleStrokeOpacity();
- DataDrivenPropertyValue<float> getCircleStrokeOpacity() const;
- void setCircleStrokeOpacity(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultCircleStrokeOpacity();
+ PropertyValue<float> getCircleStrokeOpacity() const;
+ void setCircleStrokeOpacity(PropertyValue<float>);
void setCircleStrokeOpacityTransition(const TransitionOptions&);
TransitionOptions getCircleStrokeOpacityTransition() const;
diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp
index e1c54f54ee..742bac8c7e 100644
--- a/include/mbgl/style/layers/fill_extrusion_layer.hpp
+++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
@@ -42,9 +41,9 @@ public:
void setFillExtrusionOpacityTransition(const TransitionOptions&);
TransitionOptions getFillExtrusionOpacityTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultFillExtrusionColor();
- DataDrivenPropertyValue<Color> getFillExtrusionColor() const;
- void setFillExtrusionColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultFillExtrusionColor();
+ PropertyValue<Color> getFillExtrusionColor() const;
+ void setFillExtrusionColor(PropertyValue<Color>);
void setFillExtrusionColorTransition(const TransitionOptions&);
TransitionOptions getFillExtrusionColorTransition() const;
@@ -66,15 +65,15 @@ public:
void setFillExtrusionPatternTransition(const TransitionOptions&);
TransitionOptions getFillExtrusionPatternTransition() const;
- static DataDrivenPropertyValue<float> getDefaultFillExtrusionHeight();
- DataDrivenPropertyValue<float> getFillExtrusionHeight() const;
- void setFillExtrusionHeight(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultFillExtrusionHeight();
+ PropertyValue<float> getFillExtrusionHeight() const;
+ void setFillExtrusionHeight(PropertyValue<float>);
void setFillExtrusionHeightTransition(const TransitionOptions&);
TransitionOptions getFillExtrusionHeightTransition() const;
- static DataDrivenPropertyValue<float> getDefaultFillExtrusionBase();
- DataDrivenPropertyValue<float> getFillExtrusionBase() const;
- void setFillExtrusionBase(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultFillExtrusionBase();
+ PropertyValue<float> getFillExtrusionBase() const;
+ void setFillExtrusionBase(PropertyValue<float>);
void setFillExtrusionBaseTransition(const TransitionOptions&);
TransitionOptions getFillExtrusionBaseTransition() const;
diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp
index dfbe69d7fe..d0b2a25bfe 100644
--- a/include/mbgl/style/layers/fill_layer.hpp
+++ b/include/mbgl/style/layers/fill_layer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
@@ -42,21 +41,21 @@ public:
void setFillAntialiasTransition(const TransitionOptions&);
TransitionOptions getFillAntialiasTransition() const;
- static DataDrivenPropertyValue<float> getDefaultFillOpacity();
- DataDrivenPropertyValue<float> getFillOpacity() const;
- void setFillOpacity(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultFillOpacity();
+ PropertyValue<float> getFillOpacity() const;
+ void setFillOpacity(PropertyValue<float>);
void setFillOpacityTransition(const TransitionOptions&);
TransitionOptions getFillOpacityTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultFillColor();
- DataDrivenPropertyValue<Color> getFillColor() const;
- void setFillColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultFillColor();
+ PropertyValue<Color> getFillColor() const;
+ void setFillColor(PropertyValue<Color>);
void setFillColorTransition(const TransitionOptions&);
TransitionOptions getFillColorTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultFillOutlineColor();
- DataDrivenPropertyValue<Color> getFillOutlineColor() const;
- void setFillOutlineColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultFillOutlineColor();
+ PropertyValue<Color> getFillOutlineColor() const;
+ void setFillOutlineColor(PropertyValue<Color>);
void setFillOutlineColorTransition(const TransitionOptions&);
TransitionOptions getFillOutlineColorTransition() const;
diff --git a/include/mbgl/style/layers/heatmap_layer.hpp b/include/mbgl/style/layers/heatmap_layer.hpp
index 4c434b2aff..53fd24aa6c 100644
--- a/include/mbgl/style/layers/heatmap_layer.hpp
+++ b/include/mbgl/style/layers/heatmap_layer.hpp
@@ -6,7 +6,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
@@ -37,15 +36,15 @@ public:
// Paint properties
- static DataDrivenPropertyValue<float> getDefaultHeatmapRadius();
- DataDrivenPropertyValue<float> getHeatmapRadius() const;
- void setHeatmapRadius(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultHeatmapRadius();
+ PropertyValue<float> getHeatmapRadius() const;
+ void setHeatmapRadius(PropertyValue<float>);
void setHeatmapRadiusTransition(const TransitionOptions&);
TransitionOptions getHeatmapRadiusTransition() const;
- static DataDrivenPropertyValue<float> getDefaultHeatmapWeight();
- DataDrivenPropertyValue<float> getHeatmapWeight() const;
- void setHeatmapWeight(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultHeatmapWeight();
+ PropertyValue<float> getHeatmapWeight() const;
+ void setHeatmapWeight(PropertyValue<float>);
void setHeatmapWeightTransition(const TransitionOptions&);
TransitionOptions getHeatmapWeightTransition() const;
diff --git a/include/mbgl/style/layers/hillshade_layer.hpp b/include/mbgl/style/layers/hillshade_layer.hpp
index 35664da46c..214576b120 100644
--- a/include/mbgl/style/layers/hillshade_layer.hpp
+++ b/include/mbgl/style/layers/hillshade_layer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs
index e15ff74f17..9d52973af4 100644
--- a/include/mbgl/style/layers/layer.hpp.ejs
+++ b/include/mbgl/style/layers/layer.hpp.ejs
@@ -13,7 +13,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp
index 4519296323..26e3b81fc9 100644
--- a/include/mbgl/style/layers/line_layer.hpp
+++ b/include/mbgl/style/layers/line_layer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
@@ -42,9 +41,9 @@ public:
PropertyValue<LineCapType> getLineCap() const;
void setLineCap(PropertyValue<LineCapType>);
- static DataDrivenPropertyValue<LineJoinType> getDefaultLineJoin();
- DataDrivenPropertyValue<LineJoinType> getLineJoin() const;
- void setLineJoin(DataDrivenPropertyValue<LineJoinType>);
+ static PropertyValue<LineJoinType> getDefaultLineJoin();
+ PropertyValue<LineJoinType> getLineJoin() const;
+ void setLineJoin(PropertyValue<LineJoinType>);
static PropertyValue<float> getDefaultLineMiterLimit();
PropertyValue<float> getLineMiterLimit() const;
@@ -56,15 +55,15 @@ public:
// Paint properties
- static DataDrivenPropertyValue<float> getDefaultLineOpacity();
- DataDrivenPropertyValue<float> getLineOpacity() const;
- void setLineOpacity(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultLineOpacity();
+ PropertyValue<float> getLineOpacity() const;
+ void setLineOpacity(PropertyValue<float>);
void setLineOpacityTransition(const TransitionOptions&);
TransitionOptions getLineOpacityTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultLineColor();
- DataDrivenPropertyValue<Color> getLineColor() const;
- void setLineColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultLineColor();
+ PropertyValue<Color> getLineColor() const;
+ void setLineColor(PropertyValue<Color>);
void setLineColorTransition(const TransitionOptions&);
TransitionOptions getLineColorTransition() const;
@@ -80,27 +79,27 @@ public:
void setLineTranslateAnchorTransition(const TransitionOptions&);
TransitionOptions getLineTranslateAnchorTransition() const;
- static DataDrivenPropertyValue<float> getDefaultLineWidth();
- DataDrivenPropertyValue<float> getLineWidth() const;
- void setLineWidth(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultLineWidth();
+ PropertyValue<float> getLineWidth() const;
+ void setLineWidth(PropertyValue<float>);
void setLineWidthTransition(const TransitionOptions&);
TransitionOptions getLineWidthTransition() const;
- static DataDrivenPropertyValue<float> getDefaultLineGapWidth();
- DataDrivenPropertyValue<float> getLineGapWidth() const;
- void setLineGapWidth(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultLineGapWidth();
+ PropertyValue<float> getLineGapWidth() const;
+ void setLineGapWidth(PropertyValue<float>);
void setLineGapWidthTransition(const TransitionOptions&);
TransitionOptions getLineGapWidthTransition() const;
- static DataDrivenPropertyValue<float> getDefaultLineOffset();
- DataDrivenPropertyValue<float> getLineOffset() const;
- void setLineOffset(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultLineOffset();
+ PropertyValue<float> getLineOffset() const;
+ void setLineOffset(PropertyValue<float>);
void setLineOffsetTransition(const TransitionOptions&);
TransitionOptions getLineOffsetTransition() const;
- static DataDrivenPropertyValue<float> getDefaultLineBlur();
- DataDrivenPropertyValue<float> getLineBlur() const;
- void setLineBlur(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultLineBlur();
+ PropertyValue<float> getLineBlur() const;
+ void setLineBlur(PropertyValue<float>);
void setLineBlurTransition(const TransitionOptions&);
TransitionOptions getLineBlurTransition() const;
diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp
index 8e7849c27d..c133c23484 100644
--- a/include/mbgl/style/layers/raster_layer.hpp
+++ b/include/mbgl/style/layers/raster_layer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index f068e2d060..8c0b45d796 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/data_driven_property_value.hpp>
#include <mbgl/util/color.hpp>
@@ -66,9 +65,9 @@ public:
PropertyValue<AlignmentType> getIconRotationAlignment() const;
void setIconRotationAlignment(PropertyValue<AlignmentType>);
- static DataDrivenPropertyValue<float> getDefaultIconSize();
- DataDrivenPropertyValue<float> getIconSize() const;
- void setIconSize(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultIconSize();
+ PropertyValue<float> getIconSize() const;
+ void setIconSize(PropertyValue<float>);
static PropertyValue<IconTextFitType> getDefaultIconTextFit();
PropertyValue<IconTextFitType> getIconTextFit() const;
@@ -78,13 +77,13 @@ public:
PropertyValue<std::array<float, 4>> getIconTextFitPadding() const;
void setIconTextFitPadding(PropertyValue<std::array<float, 4>>);
- static DataDrivenPropertyValue<std::string> getDefaultIconImage();
- DataDrivenPropertyValue<std::string> getIconImage() const;
- void setIconImage(DataDrivenPropertyValue<std::string>);
+ static PropertyValue<std::string> getDefaultIconImage();
+ PropertyValue<std::string> getIconImage() const;
+ void setIconImage(PropertyValue<std::string>);
- static DataDrivenPropertyValue<float> getDefaultIconRotate();
- DataDrivenPropertyValue<float> getIconRotate() const;
- void setIconRotate(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultIconRotate();
+ PropertyValue<float> getIconRotate() const;
+ void setIconRotate(PropertyValue<float>);
static PropertyValue<float> getDefaultIconPadding();
PropertyValue<float> getIconPadding() const;
@@ -94,13 +93,13 @@ public:
PropertyValue<bool> getIconKeepUpright() const;
void setIconKeepUpright(PropertyValue<bool>);
- static DataDrivenPropertyValue<std::array<float, 2>> getDefaultIconOffset();
- DataDrivenPropertyValue<std::array<float, 2>> getIconOffset() const;
- void setIconOffset(DataDrivenPropertyValue<std::array<float, 2>>);
+ static PropertyValue<std::array<float, 2>> getDefaultIconOffset();
+ PropertyValue<std::array<float, 2>> getIconOffset() const;
+ void setIconOffset(PropertyValue<std::array<float, 2>>);
- static DataDrivenPropertyValue<SymbolAnchorType> getDefaultIconAnchor();
- DataDrivenPropertyValue<SymbolAnchorType> getIconAnchor() const;
- void setIconAnchor(DataDrivenPropertyValue<SymbolAnchorType>);
+ static PropertyValue<SymbolAnchorType> getDefaultIconAnchor();
+ PropertyValue<SymbolAnchorType> getIconAnchor() const;
+ void setIconAnchor(PropertyValue<SymbolAnchorType>);
static PropertyValue<AlignmentType> getDefaultIconPitchAlignment();
PropertyValue<AlignmentType> getIconPitchAlignment() const;
@@ -114,45 +113,45 @@ public:
PropertyValue<AlignmentType> getTextRotationAlignment() const;
void setTextRotationAlignment(PropertyValue<AlignmentType>);
- static DataDrivenPropertyValue<std::string> getDefaultTextField();
- DataDrivenPropertyValue<std::string> getTextField() const;
- void setTextField(DataDrivenPropertyValue<std::string>);
+ static PropertyValue<std::string> getDefaultTextField();
+ PropertyValue<std::string> getTextField() const;
+ void setTextField(PropertyValue<std::string>);
- static DataDrivenPropertyValue<std::vector<std::string>> getDefaultTextFont();
- DataDrivenPropertyValue<std::vector<std::string>> getTextFont() const;
- void setTextFont(DataDrivenPropertyValue<std::vector<std::string>>);
+ static PropertyValue<std::vector<std::string>> getDefaultTextFont();
+ PropertyValue<std::vector<std::string>> getTextFont() const;
+ void setTextFont(PropertyValue<std::vector<std::string>>);
- static DataDrivenPropertyValue<float> getDefaultTextSize();
- DataDrivenPropertyValue<float> getTextSize() const;
- void setTextSize(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultTextSize();
+ PropertyValue<float> getTextSize() const;
+ void setTextSize(PropertyValue<float>);
- static DataDrivenPropertyValue<float> getDefaultTextMaxWidth();
- DataDrivenPropertyValue<float> getTextMaxWidth() const;
- void setTextMaxWidth(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultTextMaxWidth();
+ PropertyValue<float> getTextMaxWidth() const;
+ void setTextMaxWidth(PropertyValue<float>);
static PropertyValue<float> getDefaultTextLineHeight();
PropertyValue<float> getTextLineHeight() const;
void setTextLineHeight(PropertyValue<float>);
- static DataDrivenPropertyValue<float> getDefaultTextLetterSpacing();
- DataDrivenPropertyValue<float> getTextLetterSpacing() const;
- void setTextLetterSpacing(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultTextLetterSpacing();
+ PropertyValue<float> getTextLetterSpacing() const;
+ void setTextLetterSpacing(PropertyValue<float>);
- static DataDrivenPropertyValue<TextJustifyType> getDefaultTextJustify();
- DataDrivenPropertyValue<TextJustifyType> getTextJustify() const;
- void setTextJustify(DataDrivenPropertyValue<TextJustifyType>);
+ static PropertyValue<TextJustifyType> getDefaultTextJustify();
+ PropertyValue<TextJustifyType> getTextJustify() const;
+ void setTextJustify(PropertyValue<TextJustifyType>);
- static DataDrivenPropertyValue<SymbolAnchorType> getDefaultTextAnchor();
- DataDrivenPropertyValue<SymbolAnchorType> getTextAnchor() const;
- void setTextAnchor(DataDrivenPropertyValue<SymbolAnchorType>);
+ static PropertyValue<SymbolAnchorType> getDefaultTextAnchor();
+ PropertyValue<SymbolAnchorType> getTextAnchor() const;
+ void setTextAnchor(PropertyValue<SymbolAnchorType>);
static PropertyValue<float> getDefaultTextMaxAngle();
PropertyValue<float> getTextMaxAngle() const;
void setTextMaxAngle(PropertyValue<float>);
- static DataDrivenPropertyValue<float> getDefaultTextRotate();
- DataDrivenPropertyValue<float> getTextRotate() const;
- void setTextRotate(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultTextRotate();
+ PropertyValue<float> getTextRotate() const;
+ void setTextRotate(PropertyValue<float>);
static PropertyValue<float> getDefaultTextPadding();
PropertyValue<float> getTextPadding() const;
@@ -162,13 +161,13 @@ public:
PropertyValue<bool> getTextKeepUpright() const;
void setTextKeepUpright(PropertyValue<bool>);
- static DataDrivenPropertyValue<TextTransformType> getDefaultTextTransform();
- DataDrivenPropertyValue<TextTransformType> getTextTransform() const;
- void setTextTransform(DataDrivenPropertyValue<TextTransformType>);
+ static PropertyValue<TextTransformType> getDefaultTextTransform();
+ PropertyValue<TextTransformType> getTextTransform() const;
+ void setTextTransform(PropertyValue<TextTransformType>);
- static DataDrivenPropertyValue<std::array<float, 2>> getDefaultTextOffset();
- DataDrivenPropertyValue<std::array<float, 2>> getTextOffset() const;
- void setTextOffset(DataDrivenPropertyValue<std::array<float, 2>>);
+ static PropertyValue<std::array<float, 2>> getDefaultTextOffset();
+ PropertyValue<std::array<float, 2>> getTextOffset() const;
+ void setTextOffset(PropertyValue<std::array<float, 2>>);
static PropertyValue<bool> getDefaultTextAllowOverlap();
PropertyValue<bool> getTextAllowOverlap() const;
@@ -184,33 +183,33 @@ public:
// Paint properties
- static DataDrivenPropertyValue<float> getDefaultIconOpacity();
- DataDrivenPropertyValue<float> getIconOpacity() const;
- void setIconOpacity(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultIconOpacity();
+ PropertyValue<float> getIconOpacity() const;
+ void setIconOpacity(PropertyValue<float>);
void setIconOpacityTransition(const TransitionOptions&);
TransitionOptions getIconOpacityTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultIconColor();
- DataDrivenPropertyValue<Color> getIconColor() const;
- void setIconColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultIconColor();
+ PropertyValue<Color> getIconColor() const;
+ void setIconColor(PropertyValue<Color>);
void setIconColorTransition(const TransitionOptions&);
TransitionOptions getIconColorTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultIconHaloColor();
- DataDrivenPropertyValue<Color> getIconHaloColor() const;
- void setIconHaloColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultIconHaloColor();
+ PropertyValue<Color> getIconHaloColor() const;
+ void setIconHaloColor(PropertyValue<Color>);
void setIconHaloColorTransition(const TransitionOptions&);
TransitionOptions getIconHaloColorTransition() const;
- static DataDrivenPropertyValue<float> getDefaultIconHaloWidth();
- DataDrivenPropertyValue<float> getIconHaloWidth() const;
- void setIconHaloWidth(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultIconHaloWidth();
+ PropertyValue<float> getIconHaloWidth() const;
+ void setIconHaloWidth(PropertyValue<float>);
void setIconHaloWidthTransition(const TransitionOptions&);
TransitionOptions getIconHaloWidthTransition() const;
- static DataDrivenPropertyValue<float> getDefaultIconHaloBlur();
- DataDrivenPropertyValue<float> getIconHaloBlur() const;
- void setIconHaloBlur(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultIconHaloBlur();
+ PropertyValue<float> getIconHaloBlur() const;
+ void setIconHaloBlur(PropertyValue<float>);
void setIconHaloBlurTransition(const TransitionOptions&);
TransitionOptions getIconHaloBlurTransition() const;
@@ -226,33 +225,33 @@ public:
void setIconTranslateAnchorTransition(const TransitionOptions&);
TransitionOptions getIconTranslateAnchorTransition() const;
- static DataDrivenPropertyValue<float> getDefaultTextOpacity();
- DataDrivenPropertyValue<float> getTextOpacity() const;
- void setTextOpacity(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultTextOpacity();
+ PropertyValue<float> getTextOpacity() const;
+ void setTextOpacity(PropertyValue<float>);
void setTextOpacityTransition(const TransitionOptions&);
TransitionOptions getTextOpacityTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultTextColor();
- DataDrivenPropertyValue<Color> getTextColor() const;
- void setTextColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultTextColor();
+ PropertyValue<Color> getTextColor() const;
+ void setTextColor(PropertyValue<Color>);
void setTextColorTransition(const TransitionOptions&);
TransitionOptions getTextColorTransition() const;
- static DataDrivenPropertyValue<Color> getDefaultTextHaloColor();
- DataDrivenPropertyValue<Color> getTextHaloColor() const;
- void setTextHaloColor(DataDrivenPropertyValue<Color>);
+ static PropertyValue<Color> getDefaultTextHaloColor();
+ PropertyValue<Color> getTextHaloColor() const;
+ void setTextHaloColor(PropertyValue<Color>);
void setTextHaloColorTransition(const TransitionOptions&);
TransitionOptions getTextHaloColorTransition() const;
- static DataDrivenPropertyValue<float> getDefaultTextHaloWidth();
- DataDrivenPropertyValue<float> getTextHaloWidth() const;
- void setTextHaloWidth(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultTextHaloWidth();
+ PropertyValue<float> getTextHaloWidth() const;
+ void setTextHaloWidth(PropertyValue<float>);
void setTextHaloWidthTransition(const TransitionOptions&);
TransitionOptions getTextHaloWidthTransition() const;
- static DataDrivenPropertyValue<float> getDefaultTextHaloBlur();
- DataDrivenPropertyValue<float> getTextHaloBlur() const;
- void setTextHaloBlur(DataDrivenPropertyValue<float>);
+ static PropertyValue<float> getDefaultTextHaloBlur();
+ PropertyValue<float> getTextHaloBlur() const;
+ void setTextHaloBlur(PropertyValue<float>);
void setTextHaloBlurTransition(const TransitionOptions&);
TransitionOptions getTextHaloBlurTransition() const;
diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp
index 1b0f3d2ab0..86812e2301 100644
--- a/include/mbgl/style/property_value.hpp
+++ b/include/mbgl/style/property_value.hpp
@@ -10,44 +10,80 @@ namespace style {
template <class T>
class PropertyValue {
private:
- using Value = variant<Undefined, T, PropertyExpression<T>>;
+ using Value = variant<
+ Undefined,
+ T,
+ PropertyExpression<T>>;
+
Value value;
- friend bool operator==(const PropertyValue& lhs, const PropertyValue& rhs) {
+ friend bool operator==(const PropertyValue& lhs,
+ const PropertyValue& rhs) {
return lhs.value == rhs.value;
}
- friend bool operator!=(const PropertyValue& lhs, const PropertyValue& rhs) {
+ friend bool operator!=(const PropertyValue& lhs,
+ const PropertyValue& rhs) {
return !(lhs == rhs);
}
public:
- PropertyValue()
- : value() {}
+ PropertyValue() = default;
PropertyValue(T constant)
- : value(constant) {}
+ : value(std::move(constant)) {}
PropertyValue(PropertyExpression<T> expression)
- : value(expression) {
- assert(expression.isFeatureConstant());
+ : value(std::move(expression)) {}
+
+ bool isUndefined() const {
+ return value.template is<Undefined>();
+ }
+
+ bool isConstant() const {
+ return value.template is<T>();
+ }
+
+ bool isExpression() const {
+ return value.template is<PropertyExpression<T>>();
+ }
+
+ bool isDataDriven() const {
+ return value.match(
+ [] (const Undefined&) { return false; },
+ [] (const T&) { return false; },
+ [] (const PropertyExpression<T>& fn) { return !fn.isFeatureConstant(); }
+ );
+ }
+
+ bool isZoomConstant() const {
+ return value.match(
+ [] (const Undefined&) { return true; },
+ [] (const T&) { return true; },
+ [] (const PropertyExpression<T>& fn) { return fn.isZoomConstant(); }
+ );
}
- bool isUndefined() const { return value.which() == 0; }
- bool isConstant() const { return value.which() == 1; }
- bool isExpression() const { return value.which() == 2; }
- bool isDataDriven() const { return false; }
+ const T& asConstant() const {
+ return value.template get<T>();
+ }
- const T & asConstant() const { return value.template get< T >(); }
- const PropertyExpression<T>& asExpression() const { return value.template get<PropertyExpression<T>>(); }
+ const PropertyExpression<T>& asExpression() const {
+ return value.template get<PropertyExpression<T>>();
+ }
+
+ template <class... Ts>
+ auto match(Ts&&... ts) const {
+ return value.match(std::forward<Ts>(ts)...);
+ }
template <typename Evaluator>
auto evaluate(const Evaluator& evaluator, TimePoint = {}) const {
return Value::visit(value, evaluator);
}
- bool hasDataDrivenPropertyDifference(const PropertyValue<T>&) const {
- return false;
+ bool hasDataDrivenPropertyDifference(const PropertyValue<T>& other) const {
+ return *this != other && (isDataDriven() || other.isDataDriven());
}
};