summaryrefslogtreecommitdiff
path: root/include/mbgl/style
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/style')
-rw-r--r--include/mbgl/style/conversion/rotation.hpp18
-rw-r--r--include/mbgl/style/conversion_impl.hpp6
-rw-r--r--include/mbgl/style/expression/value.hpp8
-rw-r--r--include/mbgl/style/layers/background_layer.hpp1
-rw-r--r--include/mbgl/style/layers/circle_layer.hpp1
-rw-r--r--include/mbgl/style/layers/fill_extrusion_layer.hpp1
-rw-r--r--include/mbgl/style/layers/fill_layer.hpp1
-rw-r--r--include/mbgl/style/layers/heatmap_layer.hpp1
-rw-r--r--include/mbgl/style/layers/hillshade_layer.hpp1
-rw-r--r--include/mbgl/style/layers/layer.hpp.ejs5
-rw-r--r--include/mbgl/style/layers/line_layer.hpp1
-rw-r--r--include/mbgl/style/layers/location_indicator_layer.hpp12
-rw-r--r--include/mbgl/style/layers/raster_layer.hpp1
-rw-r--r--include/mbgl/style/rotation.hpp25
14 files changed, 69 insertions, 13 deletions
diff --git a/include/mbgl/style/conversion/rotation.hpp b/include/mbgl/style/conversion/rotation.hpp
new file mode 100644
index 0000000000..86d67240fd
--- /dev/null
+++ b/include/mbgl/style/conversion/rotation.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/rotation.hpp>
+#include <mbgl/util/optional.hpp>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+
+template <>
+struct Converter<style::Rotation> {
+ optional<style::Rotation> operator()(const Convertible& value, Error& error) const;
+};
+
+} // namespace conversion
+} // namespace style
+} // namespace mbgl
diff --git a/include/mbgl/style/conversion_impl.hpp b/include/mbgl/style/conversion_impl.hpp
index 79e9301842..8652a355f1 100644
--- a/include/mbgl/style/conversion_impl.hpp
+++ b/include/mbgl/style/conversion_impl.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/expression/image.hpp>
#include <mbgl/style/layer.hpp>
#include <mbgl/style/property_value.hpp>
+#include <mbgl/style/rotation.hpp>
#include <mbgl/style/transition_options.hpp>
#include <mbgl/util/feature.hpp>
#include <mbgl/util/geojson.hpp>
@@ -343,6 +344,11 @@ struct ValueFactory<Position> {
}
};
+template <>
+struct ValueFactory<Rotation> {
+ static Value make(const Rotation& rotation) { return {rotation.getAngle()}; }
+};
+
template <typename T>
Value makeValue(T&& arg) {
return ValueFactory<std::decay_t<T>>::make(std::forward<T>(arg));
diff --git a/include/mbgl/style/expression/value.hpp b/include/mbgl/style/expression/value.hpp
index 902f5ae209..6f12bb9336 100644
--- a/include/mbgl/style/expression/value.hpp
+++ b/include/mbgl/style/expression/value.hpp
@@ -5,6 +5,7 @@
#include <mbgl/style/expression/image.hpp>
#include <mbgl/style/expression/type.hpp>
#include <mbgl/style/position.hpp>
+#include <mbgl/style/rotation.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/enum.hpp>
@@ -147,6 +148,13 @@ std::vector<optional<T>> fromExpressionValues(const std::vector<optional<Value>>
return result;
}
+template <>
+struct ValueConverter<Rotation> {
+ static type::Type expressionType() { return type::Number; }
+ static Value toExpressionValue(const mbgl::style::Rotation& value);
+ static optional<Rotation> fromExpressionValue(const Value& v);
+};
+
} // namespace expression
} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp
index 9fdfd3ac92..2a46b2fc21 100644
--- a/include/mbgl/style/layers/background_layer.hpp
+++ b/include/mbgl/style/layers/background_layer.hpp
@@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp
index dd5b674002..f0e9787caa 100644
--- a/include/mbgl/style/layers/circle_layer.hpp
+++ b/include/mbgl/style/layers/circle_layer.hpp
@@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp
index ca33c6c3f8..3e4973b82c 100644
--- a/include/mbgl/style/layers/fill_extrusion_layer.hpp
+++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp
@@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp
index 4a1f09cca0..fb386c4b11 100644
--- a/include/mbgl/style/layers/fill_layer.hpp
+++ b/include/mbgl/style/layers/fill_layer.hpp
@@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
diff --git a/include/mbgl/style/layers/heatmap_layer.hpp b/include/mbgl/style/layers/heatmap_layer.hpp
index 588aaa81df..371e9a8aa4 100644
--- a/include/mbgl/style/layers/heatmap_layer.hpp
+++ b/include/mbgl/style/layers/heatmap_layer.hpp
@@ -8,7 +8,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
diff --git a/include/mbgl/style/layers/hillshade_layer.hpp b/include/mbgl/style/layers/hillshade_layer.hpp
index c501e80b8d..7149fb46dd 100644
--- a/include/mbgl/style/layers/hillshade_layer.hpp
+++ b/include/mbgl/style/layers/hillshade_layer.hpp
@@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs
index a083829f60..a81aaa9e16 100644
--- a/include/mbgl/style/layers/layer.hpp.ejs
+++ b/include/mbgl/style/layers/layer.hpp.ejs
@@ -15,7 +15,12 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
+<% if (type === 'location-indicator') { -%>
+#include <mbgl/style/rotation.hpp>
+<% } -%>
+<% if (type === 'symbol') { -%>
#include <mbgl/style/expression/formatted.hpp>
+<% } -%>
#include <mbgl/util/color.hpp>
<% if (type === 'line' || type === 'symbol') { -%>
diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp
index 2186f16669..7d7da47bf9 100644
--- a/include/mbgl/style/layers/line_layer.hpp
+++ b/include/mbgl/style/layers/line_layer.hpp
@@ -8,7 +8,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>
#include <vector>
diff --git a/include/mbgl/style/layers/location_indicator_layer.hpp b/include/mbgl/style/layers/location_indicator_layer.hpp
index e9e67c1a20..f112664dab 100644
--- a/include/mbgl/style/layers/location_indicator_layer.hpp
+++ b/include/mbgl/style/layers/location_indicator_layer.hpp
@@ -7,7 +7,7 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
+#include <mbgl/style/rotation.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -22,10 +22,6 @@ public:
// Layout properties
- static PropertyValue<float> getDefaultBearing();
- const PropertyValue<float>& getBearing() const;
- void setBearing(const PropertyValue<float>&);
-
static PropertyValue<expression::Image> getDefaultBearingImage();
const PropertyValue<expression::Image>& getBearingImage() const;
void setBearingImage(const PropertyValue<expression::Image>&);
@@ -66,6 +62,12 @@ public:
void setAccuracyRadiusColorTransition(const TransitionOptions&);
TransitionOptions getAccuracyRadiusColorTransition() const;
+ static PropertyValue<Rotation> getDefaultBearing();
+ const PropertyValue<Rotation>& getBearing() const;
+ void setBearing(const PropertyValue<Rotation>&);
+ void setBearingTransition(const TransitionOptions&);
+ TransitionOptions getBearingTransition() const;
+
static PropertyValue<float> getDefaultBearingImageSize();
const PropertyValue<float>& getBearingImageSize() const;
void setBearingImageSize(const PropertyValue<float>&);
diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp
index df82c93660..78fa3db23b 100644
--- a/include/mbgl/style/layers/raster_layer.hpp
+++ b/include/mbgl/style/layers/raster_layer.hpp
@@ -7,7 +7,6 @@
#include <mbgl/style/layer.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/property_value.hpp>
-#include <mbgl/style/expression/formatted.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
diff --git a/include/mbgl/style/rotation.hpp b/include/mbgl/style/rotation.hpp
new file mode 100644
index 0000000000..862ede93b7
--- /dev/null
+++ b/include/mbgl/style/rotation.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+namespace mbgl {
+namespace style {
+
+// Could be made a template class if needed
+// template <size_t Period>
+// size_t period() const noexcept { return Period; }
+class Rotation {
+public:
+ Rotation() = default;
+ Rotation(double angle_) : angle(angle_) {}
+ double period() const noexcept { return 360.0; }
+ double getAngle() const noexcept { return angle; }
+
+ friend bool operator==(const Rotation& lhs, const Rotation& rhs) { return lhs.angle == rhs.angle; }
+
+ friend bool operator!=(const Rotation& lhs, const Rotation& rhs) { return !(lhs == rhs); }
+
+private:
+ double angle;
+};
+
+} // namespace style
+} // namespace mbgl