summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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/line_layer.hpp1
-rw-r--r--include/mbgl/style/layers/raster_layer.hpp1
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp1
-rw-r--r--src/mbgl/style/layers/background_layer.cpp61
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp125
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer.cpp101
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp99
-rw-r--r--src/mbgl/style/layers/heatmap_layer.cpp77
-rw-r--r--src/mbgl/style/layers/hillshade_layer.cpp85
-rw-r--r--src/mbgl/style/layers/line_layer.cpp147
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp101
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp315
18 files changed, 659 insertions, 461 deletions
diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp
index 1f499884bb..7f48618346 100644
--- a/include/mbgl/style/layers/background_layer.hpp
+++ b/include/mbgl/style/layers/background_layer.hpp
@@ -24,6 +24,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Paint properties
diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp
index 6c511345f0..1ad16cd033 100644
--- a/include/mbgl/style/layers/circle_layer.hpp
+++ b/include/mbgl/style/layers/circle_layer.hpp
@@ -24,6 +24,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Paint properties
diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp
index d4655bd726..ef692e5708 100644
--- a/include/mbgl/style/layers/fill_extrusion_layer.hpp
+++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp
@@ -24,6 +24,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Paint properties
diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp
index 17dd66859c..174758a78e 100644
--- a/include/mbgl/style/layers/fill_layer.hpp
+++ b/include/mbgl/style/layers/fill_layer.hpp
@@ -24,6 +24,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Layout properties
diff --git a/include/mbgl/style/layers/heatmap_layer.hpp b/include/mbgl/style/layers/heatmap_layer.hpp
index ae3eb22214..0b740c470b 100644
--- a/include/mbgl/style/layers/heatmap_layer.hpp
+++ b/include/mbgl/style/layers/heatmap_layer.hpp
@@ -25,6 +25,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Paint properties
diff --git a/include/mbgl/style/layers/hillshade_layer.hpp b/include/mbgl/style/layers/hillshade_layer.hpp
index 4c52cd9a22..184e7c390d 100644
--- a/include/mbgl/style/layers/hillshade_layer.hpp
+++ b/include/mbgl/style/layers/hillshade_layer.hpp
@@ -24,6 +24,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Paint properties
diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp
index 9f0882765f..cef18d9fa8 100644
--- a/include/mbgl/style/layers/line_layer.hpp
+++ b/include/mbgl/style/layers/line_layer.hpp
@@ -27,6 +27,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Layout properties
diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp
index 50e9d6d20c..b1aa3a65b9 100644
--- a/include/mbgl/style/layers/raster_layer.hpp
+++ b/include/mbgl/style/layers/raster_layer.hpp
@@ -24,6 +24,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Paint properties
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index 8620869928..2cffd2294a 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -26,6 +26,7 @@ public:
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
StyleProperty getProperty(const std::string& name) const final;
+ Value serialize() const final;
// Layout properties
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index 68b07cba3c..0b7f0afe4f 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -148,6 +148,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 6u;
+
enum class Property : uint8_t {
BackgroundColor,
BackgroundOpacity,
@@ -169,8 +171,46 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"background-color-transition", toUint8(Property::BackgroundColorTransition)},
{"background-opacity-transition", toUint8(Property::BackgroundOpacityTransition)},
{"background-pattern-transition", toUint8(Property::BackgroundPatternTransition)}});
+
+StyleProperty getLayerProperty(const BackgroundLayer& layer, Property property) {
+ switch (property) {
+ case Property::BackgroundColor:
+ return makeStyleProperty(layer.getBackgroundColor());
+ case Property::BackgroundOpacity:
+ return makeStyleProperty(layer.getBackgroundOpacity());
+ case Property::BackgroundPattern:
+ return makeStyleProperty(layer.getBackgroundPattern());
+ case Property::BackgroundColorTransition:
+ return makeStyleProperty(layer.getBackgroundColorTransition());
+ case Property::BackgroundOpacityTransition:
+ return makeStyleProperty(layer.getBackgroundOpacityTransition());
+ case Property::BackgroundPatternTransition:
+ return makeStyleProperty(layer.getBackgroundPatternTransition());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const BackgroundLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value BackgroundLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> BackgroundLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -236,26 +276,7 @@ optional<Error> BackgroundLayer::setProperty(const std::string& name, const Conv
}
StyleProperty BackgroundLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::BackgroundColor:
- return makeStyleProperty(getBackgroundColor());
- case Property::BackgroundOpacity:
- return makeStyleProperty(getBackgroundOpacity());
- case Property::BackgroundPattern:
- return makeStyleProperty(getBackgroundPattern());
- case Property::BackgroundColorTransition:
- return makeStyleProperty(getBackgroundColorTransition());
- case Property::BackgroundOpacityTransition:
- return makeStyleProperty(getBackgroundOpacityTransition());
- case Property::BackgroundPatternTransition:
- return makeStyleProperty(getBackgroundPatternTransition());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> BackgroundLayer::mutableBaseImpl() const {
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index 7de6fef482..ca2f93306f 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -364,6 +364,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 22u;
+
enum class Property : uint8_t {
CircleBlur,
CircleColor,
@@ -417,8 +419,78 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"circle-stroke-width-transition", toUint8(Property::CircleStrokeWidthTransition)},
{"circle-translate-transition", toUint8(Property::CircleTranslateTransition)},
{"circle-translate-anchor-transition", toUint8(Property::CircleTranslateAnchorTransition)}});
+
+StyleProperty getLayerProperty(const CircleLayer& layer, Property property) {
+ switch (property) {
+ case Property::CircleBlur:
+ return makeStyleProperty(layer.getCircleBlur());
+ case Property::CircleColor:
+ return makeStyleProperty(layer.getCircleColor());
+ case Property::CircleOpacity:
+ return makeStyleProperty(layer.getCircleOpacity());
+ case Property::CirclePitchAlignment:
+ return makeStyleProperty(layer.getCirclePitchAlignment());
+ case Property::CirclePitchScale:
+ return makeStyleProperty(layer.getCirclePitchScale());
+ case Property::CircleRadius:
+ return makeStyleProperty(layer.getCircleRadius());
+ case Property::CircleStrokeColor:
+ return makeStyleProperty(layer.getCircleStrokeColor());
+ case Property::CircleStrokeOpacity:
+ return makeStyleProperty(layer.getCircleStrokeOpacity());
+ case Property::CircleStrokeWidth:
+ return makeStyleProperty(layer.getCircleStrokeWidth());
+ case Property::CircleTranslate:
+ return makeStyleProperty(layer.getCircleTranslate());
+ case Property::CircleTranslateAnchor:
+ return makeStyleProperty(layer.getCircleTranslateAnchor());
+ case Property::CircleBlurTransition:
+ return makeStyleProperty(layer.getCircleBlurTransition());
+ case Property::CircleColorTransition:
+ return makeStyleProperty(layer.getCircleColorTransition());
+ case Property::CircleOpacityTransition:
+ return makeStyleProperty(layer.getCircleOpacityTransition());
+ case Property::CirclePitchAlignmentTransition:
+ return makeStyleProperty(layer.getCirclePitchAlignmentTransition());
+ case Property::CirclePitchScaleTransition:
+ return makeStyleProperty(layer.getCirclePitchScaleTransition());
+ case Property::CircleRadiusTransition:
+ return makeStyleProperty(layer.getCircleRadiusTransition());
+ case Property::CircleStrokeColorTransition:
+ return makeStyleProperty(layer.getCircleStrokeColorTransition());
+ case Property::CircleStrokeOpacityTransition:
+ return makeStyleProperty(layer.getCircleStrokeOpacityTransition());
+ case Property::CircleStrokeWidthTransition:
+ return makeStyleProperty(layer.getCircleStrokeWidthTransition());
+ case Property::CircleTranslateTransition:
+ return makeStyleProperty(layer.getCircleTranslateTransition());
+ case Property::CircleTranslateAnchorTransition:
+ return makeStyleProperty(layer.getCircleTranslateAnchorTransition());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const CircleLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value CircleLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> CircleLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -584,58 +656,7 @@ optional<Error> CircleLayer::setProperty(const std::string& name, const Converti
}
StyleProperty CircleLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::CircleBlur:
- return makeStyleProperty(getCircleBlur());
- case Property::CircleColor:
- return makeStyleProperty(getCircleColor());
- case Property::CircleOpacity:
- return makeStyleProperty(getCircleOpacity());
- case Property::CirclePitchAlignment:
- return makeStyleProperty(getCirclePitchAlignment());
- case Property::CirclePitchScale:
- return makeStyleProperty(getCirclePitchScale());
- case Property::CircleRadius:
- return makeStyleProperty(getCircleRadius());
- case Property::CircleStrokeColor:
- return makeStyleProperty(getCircleStrokeColor());
- case Property::CircleStrokeOpacity:
- return makeStyleProperty(getCircleStrokeOpacity());
- case Property::CircleStrokeWidth:
- return makeStyleProperty(getCircleStrokeWidth());
- case Property::CircleTranslate:
- return makeStyleProperty(getCircleTranslate());
- case Property::CircleTranslateAnchor:
- return makeStyleProperty(getCircleTranslateAnchor());
- case Property::CircleBlurTransition:
- return makeStyleProperty(getCircleBlurTransition());
- case Property::CircleColorTransition:
- return makeStyleProperty(getCircleColorTransition());
- case Property::CircleOpacityTransition:
- return makeStyleProperty(getCircleOpacityTransition());
- case Property::CirclePitchAlignmentTransition:
- return makeStyleProperty(getCirclePitchAlignmentTransition());
- case Property::CirclePitchScaleTransition:
- return makeStyleProperty(getCirclePitchScaleTransition());
- case Property::CircleRadiusTransition:
- return makeStyleProperty(getCircleRadiusTransition());
- case Property::CircleStrokeColorTransition:
- return makeStyleProperty(getCircleStrokeColorTransition());
- case Property::CircleStrokeOpacityTransition:
- return makeStyleProperty(getCircleStrokeOpacityTransition());
- case Property::CircleStrokeWidthTransition:
- return makeStyleProperty(getCircleStrokeWidthTransition());
- case Property::CircleTranslateTransition:
- return makeStyleProperty(getCircleTranslateTransition());
- case Property::CircleTranslateAnchorTransition:
- return makeStyleProperty(getCircleTranslateAnchorTransition());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> CircleLayer::mutableBaseImpl() const {
diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp
index 2de27f3903..c9819f66f1 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer.cpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp
@@ -283,6 +283,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 16u;
+
enum class Property : uint8_t {
FillExtrusionBase,
FillExtrusionColor,
@@ -324,8 +326,66 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"fill-extrusion-translate-transition", toUint8(Property::FillExtrusionTranslateTransition)},
{"fill-extrusion-translate-anchor-transition", toUint8(Property::FillExtrusionTranslateAnchorTransition)},
{"fill-extrusion-vertical-gradient-transition", toUint8(Property::FillExtrusionVerticalGradientTransition)}});
+
+StyleProperty getLayerProperty(const FillExtrusionLayer& layer, Property property) {
+ switch (property) {
+ case Property::FillExtrusionBase:
+ return makeStyleProperty(layer.getFillExtrusionBase());
+ case Property::FillExtrusionColor:
+ return makeStyleProperty(layer.getFillExtrusionColor());
+ case Property::FillExtrusionHeight:
+ return makeStyleProperty(layer.getFillExtrusionHeight());
+ case Property::FillExtrusionOpacity:
+ return makeStyleProperty(layer.getFillExtrusionOpacity());
+ case Property::FillExtrusionPattern:
+ return makeStyleProperty(layer.getFillExtrusionPattern());
+ case Property::FillExtrusionTranslate:
+ return makeStyleProperty(layer.getFillExtrusionTranslate());
+ case Property::FillExtrusionTranslateAnchor:
+ return makeStyleProperty(layer.getFillExtrusionTranslateAnchor());
+ case Property::FillExtrusionVerticalGradient:
+ return makeStyleProperty(layer.getFillExtrusionVerticalGradient());
+ case Property::FillExtrusionBaseTransition:
+ return makeStyleProperty(layer.getFillExtrusionBaseTransition());
+ case Property::FillExtrusionColorTransition:
+ return makeStyleProperty(layer.getFillExtrusionColorTransition());
+ case Property::FillExtrusionHeightTransition:
+ return makeStyleProperty(layer.getFillExtrusionHeightTransition());
+ case Property::FillExtrusionOpacityTransition:
+ return makeStyleProperty(layer.getFillExtrusionOpacityTransition());
+ case Property::FillExtrusionPatternTransition:
+ return makeStyleProperty(layer.getFillExtrusionPatternTransition());
+ case Property::FillExtrusionTranslateTransition:
+ return makeStyleProperty(layer.getFillExtrusionTranslateTransition());
+ case Property::FillExtrusionTranslateAnchorTransition:
+ return makeStyleProperty(layer.getFillExtrusionTranslateAnchorTransition());
+ case Property::FillExtrusionVerticalGradientTransition:
+ return makeStyleProperty(layer.getFillExtrusionVerticalGradientTransition());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const FillExtrusionLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value FillExtrusionLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> FillExtrusionLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -463,46 +523,7 @@ optional<Error> FillExtrusionLayer::setProperty(const std::string& name, const C
}
StyleProperty FillExtrusionLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::FillExtrusionBase:
- return makeStyleProperty(getFillExtrusionBase());
- case Property::FillExtrusionColor:
- return makeStyleProperty(getFillExtrusionColor());
- case Property::FillExtrusionHeight:
- return makeStyleProperty(getFillExtrusionHeight());
- case Property::FillExtrusionOpacity:
- return makeStyleProperty(getFillExtrusionOpacity());
- case Property::FillExtrusionPattern:
- return makeStyleProperty(getFillExtrusionPattern());
- case Property::FillExtrusionTranslate:
- return makeStyleProperty(getFillExtrusionTranslate());
- case Property::FillExtrusionTranslateAnchor:
- return makeStyleProperty(getFillExtrusionTranslateAnchor());
- case Property::FillExtrusionVerticalGradient:
- return makeStyleProperty(getFillExtrusionVerticalGradient());
- case Property::FillExtrusionBaseTransition:
- return makeStyleProperty(getFillExtrusionBaseTransition());
- case Property::FillExtrusionColorTransition:
- return makeStyleProperty(getFillExtrusionColorTransition());
- case Property::FillExtrusionHeightTransition:
- return makeStyleProperty(getFillExtrusionHeightTransition());
- case Property::FillExtrusionOpacityTransition:
- return makeStyleProperty(getFillExtrusionOpacityTransition());
- case Property::FillExtrusionPatternTransition:
- return makeStyleProperty(getFillExtrusionPatternTransition());
- case Property::FillExtrusionTranslateTransition:
- return makeStyleProperty(getFillExtrusionTranslateTransition());
- case Property::FillExtrusionTranslateAnchorTransition:
- return makeStyleProperty(getFillExtrusionTranslateAnchorTransition());
- case Property::FillExtrusionVerticalGradientTransition:
- return makeStyleProperty(getFillExtrusionVerticalGradientTransition());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> FillExtrusionLayer::mutableBaseImpl() const {
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 757738dfef..914a23d96b 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -272,6 +272,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 14u;
+
enum class Property : uint8_t {
FillAntialias,
FillColor,
@@ -287,7 +289,7 @@ enum class Property : uint8_t {
FillPatternTransition,
FillTranslateTransition,
FillTranslateAnchorTransition,
- FillSortKey,
+ FillSortKey = kPaintPropertyCount,
};
template <typename T>
@@ -311,8 +313,64 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"fill-translate-transition", toUint8(Property::FillTranslateTransition)},
{"fill-translate-anchor-transition", toUint8(Property::FillTranslateAnchorTransition)},
{"fill-sort-key", toUint8(Property::FillSortKey)}});
+
+StyleProperty getLayerProperty(const FillLayer& layer, Property property) {
+ switch (property) {
+ case Property::FillAntialias:
+ return makeStyleProperty(layer.getFillAntialias());
+ case Property::FillColor:
+ return makeStyleProperty(layer.getFillColor());
+ case Property::FillOpacity:
+ return makeStyleProperty(layer.getFillOpacity());
+ case Property::FillOutlineColor:
+ return makeStyleProperty(layer.getFillOutlineColor());
+ case Property::FillPattern:
+ return makeStyleProperty(layer.getFillPattern());
+ case Property::FillTranslate:
+ return makeStyleProperty(layer.getFillTranslate());
+ case Property::FillTranslateAnchor:
+ return makeStyleProperty(layer.getFillTranslateAnchor());
+ case Property::FillAntialiasTransition:
+ return makeStyleProperty(layer.getFillAntialiasTransition());
+ case Property::FillColorTransition:
+ return makeStyleProperty(layer.getFillColorTransition());
+ case Property::FillOpacityTransition:
+ return makeStyleProperty(layer.getFillOpacityTransition());
+ case Property::FillOutlineColorTransition:
+ return makeStyleProperty(layer.getFillOutlineColorTransition());
+ case Property::FillPatternTransition:
+ return makeStyleProperty(layer.getFillPatternTransition());
+ case Property::FillTranslateTransition:
+ return makeStyleProperty(layer.getFillTranslateTransition());
+ case Property::FillTranslateAnchorTransition:
+ return makeStyleProperty(layer.getFillTranslateAnchorTransition());
+ case Property::FillSortKey:
+ return makeStyleProperty(layer.getFillSortKey());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const FillLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value FillLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> FillLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -442,44 +500,7 @@ optional<Error> FillLayer::setProperty(const std::string& name, const Convertibl
}
StyleProperty FillLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::FillAntialias:
- return makeStyleProperty(getFillAntialias());
- case Property::FillColor:
- return makeStyleProperty(getFillColor());
- case Property::FillOpacity:
- return makeStyleProperty(getFillOpacity());
- case Property::FillOutlineColor:
- return makeStyleProperty(getFillOutlineColor());
- case Property::FillPattern:
- return makeStyleProperty(getFillPattern());
- case Property::FillTranslate:
- return makeStyleProperty(getFillTranslate());
- case Property::FillTranslateAnchor:
- return makeStyleProperty(getFillTranslateAnchor());
- case Property::FillAntialiasTransition:
- return makeStyleProperty(getFillAntialiasTransition());
- case Property::FillColorTransition:
- return makeStyleProperty(getFillColorTransition());
- case Property::FillOpacityTransition:
- return makeStyleProperty(getFillOpacityTransition());
- case Property::FillOutlineColorTransition:
- return makeStyleProperty(getFillOutlineColorTransition());
- case Property::FillPatternTransition:
- return makeStyleProperty(getFillPatternTransition());
- case Property::FillTranslateTransition:
- return makeStyleProperty(getFillTranslateTransition());
- case Property::FillTranslateAnchorTransition:
- return makeStyleProperty(getFillTranslateAnchorTransition());
- case Property::FillSortKey:
- return makeStyleProperty(getFillSortKey());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> FillLayer::mutableBaseImpl() const {
diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp
index ba645a4a18..bfac173d63 100644
--- a/src/mbgl/style/layers/heatmap_layer.cpp
+++ b/src/mbgl/style/layers/heatmap_layer.cpp
@@ -204,6 +204,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 10u;
+
enum class Property : uint8_t {
HeatmapColor,
HeatmapIntensity,
@@ -233,8 +235,54 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"heatmap-opacity-transition", toUint8(Property::HeatmapOpacityTransition)},
{"heatmap-radius-transition", toUint8(Property::HeatmapRadiusTransition)},
{"heatmap-weight-transition", toUint8(Property::HeatmapWeightTransition)}});
+
+StyleProperty getLayerProperty(const HeatmapLayer& layer, Property property) {
+ switch (property) {
+ case Property::HeatmapColor:
+ return makeStyleProperty(layer.getHeatmapColor());
+ case Property::HeatmapIntensity:
+ return makeStyleProperty(layer.getHeatmapIntensity());
+ case Property::HeatmapOpacity:
+ return makeStyleProperty(layer.getHeatmapOpacity());
+ case Property::HeatmapRadius:
+ return makeStyleProperty(layer.getHeatmapRadius());
+ case Property::HeatmapWeight:
+ return makeStyleProperty(layer.getHeatmapWeight());
+ case Property::HeatmapColorTransition:
+ return makeStyleProperty(layer.getHeatmapColorTransition());
+ case Property::HeatmapIntensityTransition:
+ return makeStyleProperty(layer.getHeatmapIntensityTransition());
+ case Property::HeatmapOpacityTransition:
+ return makeStyleProperty(layer.getHeatmapOpacityTransition());
+ case Property::HeatmapRadiusTransition:
+ return makeStyleProperty(layer.getHeatmapRadiusTransition());
+ case Property::HeatmapWeightTransition:
+ return makeStyleProperty(layer.getHeatmapWeightTransition());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const HeatmapLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value HeatmapLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> HeatmapLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -324,34 +372,7 @@ optional<Error> HeatmapLayer::setProperty(const std::string& name, const Convert
}
StyleProperty HeatmapLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::HeatmapColor:
- return makeStyleProperty(getHeatmapColor());
- case Property::HeatmapIntensity:
- return makeStyleProperty(getHeatmapIntensity());
- case Property::HeatmapOpacity:
- return makeStyleProperty(getHeatmapOpacity());
- case Property::HeatmapRadius:
- return makeStyleProperty(getHeatmapRadius());
- case Property::HeatmapWeight:
- return makeStyleProperty(getHeatmapWeight());
- case Property::HeatmapColorTransition:
- return makeStyleProperty(getHeatmapColorTransition());
- case Property::HeatmapIntensityTransition:
- return makeStyleProperty(getHeatmapIntensityTransition());
- case Property::HeatmapOpacityTransition:
- return makeStyleProperty(getHeatmapOpacityTransition());
- case Property::HeatmapRadiusTransition:
- return makeStyleProperty(getHeatmapRadiusTransition());
- case Property::HeatmapWeightTransition:
- return makeStyleProperty(getHeatmapWeightTransition());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> HeatmapLayer::mutableBaseImpl() const {
diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp
index 26ecfadfcc..bfbd3d1d14 100644
--- a/src/mbgl/style/layers/hillshade_layer.cpp
+++ b/src/mbgl/style/layers/hillshade_layer.cpp
@@ -229,6 +229,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 12u;
+
enum class Property : uint8_t {
HillshadeAccentColor,
HillshadeExaggeration,
@@ -262,8 +264,58 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"hillshade-illumination-anchor-transition", toUint8(Property::HillshadeIlluminationAnchorTransition)},
{"hillshade-illumination-direction-transition", toUint8(Property::HillshadeIlluminationDirectionTransition)},
{"hillshade-shadow-color-transition", toUint8(Property::HillshadeShadowColorTransition)}});
+
+StyleProperty getLayerProperty(const HillshadeLayer& layer, Property property) {
+ switch (property) {
+ case Property::HillshadeAccentColor:
+ return makeStyleProperty(layer.getHillshadeAccentColor());
+ case Property::HillshadeExaggeration:
+ return makeStyleProperty(layer.getHillshadeExaggeration());
+ case Property::HillshadeHighlightColor:
+ return makeStyleProperty(layer.getHillshadeHighlightColor());
+ case Property::HillshadeIlluminationAnchor:
+ return makeStyleProperty(layer.getHillshadeIlluminationAnchor());
+ case Property::HillshadeIlluminationDirection:
+ return makeStyleProperty(layer.getHillshadeIlluminationDirection());
+ case Property::HillshadeShadowColor:
+ return makeStyleProperty(layer.getHillshadeShadowColor());
+ case Property::HillshadeAccentColorTransition:
+ return makeStyleProperty(layer.getHillshadeAccentColorTransition());
+ case Property::HillshadeExaggerationTransition:
+ return makeStyleProperty(layer.getHillshadeExaggerationTransition());
+ case Property::HillshadeHighlightColorTransition:
+ return makeStyleProperty(layer.getHillshadeHighlightColorTransition());
+ case Property::HillshadeIlluminationAnchorTransition:
+ return makeStyleProperty(layer.getHillshadeIlluminationAnchorTransition());
+ case Property::HillshadeIlluminationDirectionTransition:
+ return makeStyleProperty(layer.getHillshadeIlluminationDirectionTransition());
+ case Property::HillshadeShadowColorTransition:
+ return makeStyleProperty(layer.getHillshadeShadowColorTransition());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const HillshadeLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value HillshadeLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> HillshadeLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -364,38 +416,7 @@ optional<Error> HillshadeLayer::setProperty(const std::string& name, const Conve
}
StyleProperty HillshadeLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::HillshadeAccentColor:
- return makeStyleProperty(getHillshadeAccentColor());
- case Property::HillshadeExaggeration:
- return makeStyleProperty(getHillshadeExaggeration());
- case Property::HillshadeHighlightColor:
- return makeStyleProperty(getHillshadeHighlightColor());
- case Property::HillshadeIlluminationAnchor:
- return makeStyleProperty(getHillshadeIlluminationAnchor());
- case Property::HillshadeIlluminationDirection:
- return makeStyleProperty(getHillshadeIlluminationDirection());
- case Property::HillshadeShadowColor:
- return makeStyleProperty(getHillshadeShadowColor());
- case Property::HillshadeAccentColorTransition:
- return makeStyleProperty(getHillshadeAccentColorTransition());
- case Property::HillshadeExaggerationTransition:
- return makeStyleProperty(getHillshadeExaggerationTransition());
- case Property::HillshadeHighlightColorTransition:
- return makeStyleProperty(getHillshadeHighlightColorTransition());
- case Property::HillshadeIlluminationAnchorTransition:
- return makeStyleProperty(getHillshadeIlluminationAnchorTransition());
- case Property::HillshadeIlluminationDirectionTransition:
- return makeStyleProperty(getHillshadeIlluminationDirectionTransition());
- case Property::HillshadeShadowColorTransition:
- return makeStyleProperty(getHillshadeShadowColorTransition());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> HillshadeLayer::mutableBaseImpl() const {
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index caa7f44e0c..69c0af0958 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -441,6 +441,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 22u;
+
enum class Property : uint8_t {
LineBlur,
LineColor,
@@ -464,7 +466,7 @@ enum class Property : uint8_t {
LineTranslateTransition,
LineTranslateAnchorTransition,
LineWidthTransition,
- LineCap,
+ LineCap = kPaintPropertyCount,
LineJoin,
LineMiterLimit,
LineRoundLimit,
@@ -504,8 +506,88 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"line-miter-limit", toUint8(Property::LineMiterLimit)},
{"line-round-limit", toUint8(Property::LineRoundLimit)},
{"line-sort-key", toUint8(Property::LineSortKey)}});
+
+StyleProperty getLayerProperty(const LineLayer& layer, Property property) {
+ switch (property) {
+ case Property::LineBlur:
+ return makeStyleProperty(layer.getLineBlur());
+ case Property::LineColor:
+ return makeStyleProperty(layer.getLineColor());
+ case Property::LineDasharray:
+ return makeStyleProperty(layer.getLineDasharray());
+ case Property::LineGapWidth:
+ return makeStyleProperty(layer.getLineGapWidth());
+ case Property::LineGradient:
+ return makeStyleProperty(layer.getLineGradient());
+ case Property::LineOffset:
+ return makeStyleProperty(layer.getLineOffset());
+ case Property::LineOpacity:
+ return makeStyleProperty(layer.getLineOpacity());
+ case Property::LinePattern:
+ return makeStyleProperty(layer.getLinePattern());
+ case Property::LineTranslate:
+ return makeStyleProperty(layer.getLineTranslate());
+ case Property::LineTranslateAnchor:
+ return makeStyleProperty(layer.getLineTranslateAnchor());
+ case Property::LineWidth:
+ return makeStyleProperty(layer.getLineWidth());
+ case Property::LineBlurTransition:
+ return makeStyleProperty(layer.getLineBlurTransition());
+ case Property::LineColorTransition:
+ return makeStyleProperty(layer.getLineColorTransition());
+ case Property::LineDasharrayTransition:
+ return makeStyleProperty(layer.getLineDasharrayTransition());
+ case Property::LineGapWidthTransition:
+ return makeStyleProperty(layer.getLineGapWidthTransition());
+ case Property::LineGradientTransition:
+ return makeStyleProperty(layer.getLineGradientTransition());
+ case Property::LineOffsetTransition:
+ return makeStyleProperty(layer.getLineOffsetTransition());
+ case Property::LineOpacityTransition:
+ return makeStyleProperty(layer.getLineOpacityTransition());
+ case Property::LinePatternTransition:
+ return makeStyleProperty(layer.getLinePatternTransition());
+ case Property::LineTranslateTransition:
+ return makeStyleProperty(layer.getLineTranslateTransition());
+ case Property::LineTranslateAnchorTransition:
+ return makeStyleProperty(layer.getLineTranslateAnchorTransition());
+ case Property::LineWidthTransition:
+ return makeStyleProperty(layer.getLineWidthTransition());
+ case Property::LineCap:
+ return makeStyleProperty(layer.getLineCap());
+ case Property::LineJoin:
+ return makeStyleProperty(layer.getLineJoin());
+ case Property::LineMiterLimit:
+ return makeStyleProperty(layer.getLineMiterLimit());
+ case Property::LineRoundLimit:
+ return makeStyleProperty(layer.getLineRoundLimit());
+ case Property::LineSortKey:
+ return makeStyleProperty(layer.getLineSortKey());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const LineLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value LineLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> LineLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -716,68 +798,7 @@ optional<Error> LineLayer::setProperty(const std::string& name, const Convertibl
}
StyleProperty LineLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::LineBlur:
- return makeStyleProperty(getLineBlur());
- case Property::LineColor:
- return makeStyleProperty(getLineColor());
- case Property::LineDasharray:
- return makeStyleProperty(getLineDasharray());
- case Property::LineGapWidth:
- return makeStyleProperty(getLineGapWidth());
- case Property::LineGradient:
- return makeStyleProperty(getLineGradient());
- case Property::LineOffset:
- return makeStyleProperty(getLineOffset());
- case Property::LineOpacity:
- return makeStyleProperty(getLineOpacity());
- case Property::LinePattern:
- return makeStyleProperty(getLinePattern());
- case Property::LineTranslate:
- return makeStyleProperty(getLineTranslate());
- case Property::LineTranslateAnchor:
- return makeStyleProperty(getLineTranslateAnchor());
- case Property::LineWidth:
- return makeStyleProperty(getLineWidth());
- case Property::LineBlurTransition:
- return makeStyleProperty(getLineBlurTransition());
- case Property::LineColorTransition:
- return makeStyleProperty(getLineColorTransition());
- case Property::LineDasharrayTransition:
- return makeStyleProperty(getLineDasharrayTransition());
- case Property::LineGapWidthTransition:
- return makeStyleProperty(getLineGapWidthTransition());
- case Property::LineGradientTransition:
- return makeStyleProperty(getLineGradientTransition());
- case Property::LineOffsetTransition:
- return makeStyleProperty(getLineOffsetTransition());
- case Property::LineOpacityTransition:
- return makeStyleProperty(getLineOpacityTransition());
- case Property::LinePatternTransition:
- return makeStyleProperty(getLinePatternTransition());
- case Property::LineTranslateTransition:
- return makeStyleProperty(getLineTranslateTransition());
- case Property::LineTranslateAnchorTransition:
- return makeStyleProperty(getLineTranslateAnchorTransition());
- case Property::LineWidthTransition:
- return makeStyleProperty(getLineWidthTransition());
- case Property::LineCap:
- return makeStyleProperty(getLineCap());
- case Property::LineJoin:
- return makeStyleProperty(getLineJoin());
- case Property::LineMiterLimit:
- return makeStyleProperty(getLineMiterLimit());
- case Property::LineRoundLimit:
- return makeStyleProperty(getLineRoundLimit());
- case Property::LineSortKey:
- return makeStyleProperty(getLineSortKey());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> LineLayer::mutableBaseImpl() const {
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index 97c67de299..3222eebd73 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -283,6 +283,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 16u;
+
enum class Property : uint8_t {
RasterBrightnessMax,
RasterBrightnessMin,
@@ -324,8 +326,66 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"raster-opacity-transition", toUint8(Property::RasterOpacityTransition)},
{"raster-resampling-transition", toUint8(Property::RasterResamplingTransition)},
{"raster-saturation-transition", toUint8(Property::RasterSaturationTransition)}});
+
+StyleProperty getLayerProperty(const RasterLayer& layer, Property property) {
+ switch (property) {
+ case Property::RasterBrightnessMax:
+ return makeStyleProperty(layer.getRasterBrightnessMax());
+ case Property::RasterBrightnessMin:
+ return makeStyleProperty(layer.getRasterBrightnessMin());
+ case Property::RasterContrast:
+ return makeStyleProperty(layer.getRasterContrast());
+ case Property::RasterFadeDuration:
+ return makeStyleProperty(layer.getRasterFadeDuration());
+ case Property::RasterHueRotate:
+ return makeStyleProperty(layer.getRasterHueRotate());
+ case Property::RasterOpacity:
+ return makeStyleProperty(layer.getRasterOpacity());
+ case Property::RasterResampling:
+ return makeStyleProperty(layer.getRasterResampling());
+ case Property::RasterSaturation:
+ return makeStyleProperty(layer.getRasterSaturation());
+ case Property::RasterBrightnessMaxTransition:
+ return makeStyleProperty(layer.getRasterBrightnessMaxTransition());
+ case Property::RasterBrightnessMinTransition:
+ return makeStyleProperty(layer.getRasterBrightnessMinTransition());
+ case Property::RasterContrastTransition:
+ return makeStyleProperty(layer.getRasterContrastTransition());
+ case Property::RasterFadeDurationTransition:
+ return makeStyleProperty(layer.getRasterFadeDurationTransition());
+ case Property::RasterHueRotateTransition:
+ return makeStyleProperty(layer.getRasterHueRotateTransition());
+ case Property::RasterOpacityTransition:
+ return makeStyleProperty(layer.getRasterOpacityTransition());
+ case Property::RasterResamplingTransition:
+ return makeStyleProperty(layer.getRasterResamplingTransition());
+ case Property::RasterSaturationTransition:
+ return makeStyleProperty(layer.getRasterSaturationTransition());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const RasterLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value RasterLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> RasterLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -441,46 +501,7 @@ optional<Error> RasterLayer::setProperty(const std::string& name, const Converti
}
StyleProperty RasterLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::RasterBrightnessMax:
- return makeStyleProperty(getRasterBrightnessMax());
- case Property::RasterBrightnessMin:
- return makeStyleProperty(getRasterBrightnessMin());
- case Property::RasterContrast:
- return makeStyleProperty(getRasterContrast());
- case Property::RasterFadeDuration:
- return makeStyleProperty(getRasterFadeDuration());
- case Property::RasterHueRotate:
- return makeStyleProperty(getRasterHueRotate());
- case Property::RasterOpacity:
- return makeStyleProperty(getRasterOpacity());
- case Property::RasterResampling:
- return makeStyleProperty(getRasterResampling());
- case Property::RasterSaturation:
- return makeStyleProperty(getRasterSaturation());
- case Property::RasterBrightnessMaxTransition:
- return makeStyleProperty(getRasterBrightnessMaxTransition());
- case Property::RasterBrightnessMinTransition:
- return makeStyleProperty(getRasterBrightnessMinTransition());
- case Property::RasterContrastTransition:
- return makeStyleProperty(getRasterContrastTransition());
- case Property::RasterFadeDurationTransition:
- return makeStyleProperty(getRasterFadeDurationTransition());
- case Property::RasterHueRotateTransition:
- return makeStyleProperty(getRasterHueRotateTransition());
- case Property::RasterOpacityTransition:
- return makeStyleProperty(getRasterOpacityTransition());
- case Property::RasterResamplingTransition:
- return makeStyleProperty(getRasterResamplingTransition());
- case Property::RasterSaturationTransition:
- return makeStyleProperty(getRasterSaturationTransition());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> RasterLayer::mutableBaseImpl() const {
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 39c2f2a052..7154bffff2 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -1061,6 +1061,8 @@ using namespace conversion;
namespace {
+constexpr uint8_t kPaintPropertyCount = 28u;
+
enum class Property : uint8_t {
IconColor,
IconHaloBlur,
@@ -1090,7 +1092,7 @@ enum class Property : uint8_t {
TextOpacityTransition,
TextTranslateTransition,
TextTranslateAnchorTransition,
- IconAllowOverlap,
+ IconAllowOverlap = kPaintPropertyCount,
IconAnchor,
IconIgnorePlacement,
IconImage,
@@ -1208,8 +1210,172 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
{"text-transform", toUint8(Property::TextTransform)},
{"text-variable-anchor", toUint8(Property::TextVariableAnchor)},
{"text-writing-mode", toUint8(Property::TextWritingMode)}});
+
+StyleProperty getLayerProperty(const SymbolLayer& layer, Property property) {
+ switch (property) {
+ case Property::IconColor:
+ return makeStyleProperty(layer.getIconColor());
+ case Property::IconHaloBlur:
+ return makeStyleProperty(layer.getIconHaloBlur());
+ case Property::IconHaloColor:
+ return makeStyleProperty(layer.getIconHaloColor());
+ case Property::IconHaloWidth:
+ return makeStyleProperty(layer.getIconHaloWidth());
+ case Property::IconOpacity:
+ return makeStyleProperty(layer.getIconOpacity());
+ case Property::IconTranslate:
+ return makeStyleProperty(layer.getIconTranslate());
+ case Property::IconTranslateAnchor:
+ return makeStyleProperty(layer.getIconTranslateAnchor());
+ case Property::TextColor:
+ return makeStyleProperty(layer.getTextColor());
+ case Property::TextHaloBlur:
+ return makeStyleProperty(layer.getTextHaloBlur());
+ case Property::TextHaloColor:
+ return makeStyleProperty(layer.getTextHaloColor());
+ case Property::TextHaloWidth:
+ return makeStyleProperty(layer.getTextHaloWidth());
+ case Property::TextOpacity:
+ return makeStyleProperty(layer.getTextOpacity());
+ case Property::TextTranslate:
+ return makeStyleProperty(layer.getTextTranslate());
+ case Property::TextTranslateAnchor:
+ return makeStyleProperty(layer.getTextTranslateAnchor());
+ case Property::IconColorTransition:
+ return makeStyleProperty(layer.getIconColorTransition());
+ case Property::IconHaloBlurTransition:
+ return makeStyleProperty(layer.getIconHaloBlurTransition());
+ case Property::IconHaloColorTransition:
+ return makeStyleProperty(layer.getIconHaloColorTransition());
+ case Property::IconHaloWidthTransition:
+ return makeStyleProperty(layer.getIconHaloWidthTransition());
+ case Property::IconOpacityTransition:
+ return makeStyleProperty(layer.getIconOpacityTransition());
+ case Property::IconTranslateTransition:
+ return makeStyleProperty(layer.getIconTranslateTransition());
+ case Property::IconTranslateAnchorTransition:
+ return makeStyleProperty(layer.getIconTranslateAnchorTransition());
+ case Property::TextColorTransition:
+ return makeStyleProperty(layer.getTextColorTransition());
+ case Property::TextHaloBlurTransition:
+ return makeStyleProperty(layer.getTextHaloBlurTransition());
+ case Property::TextHaloColorTransition:
+ return makeStyleProperty(layer.getTextHaloColorTransition());
+ case Property::TextHaloWidthTransition:
+ return makeStyleProperty(layer.getTextHaloWidthTransition());
+ case Property::TextOpacityTransition:
+ return makeStyleProperty(layer.getTextOpacityTransition());
+ case Property::TextTranslateTransition:
+ return makeStyleProperty(layer.getTextTranslateTransition());
+ case Property::TextTranslateAnchorTransition:
+ return makeStyleProperty(layer.getTextTranslateAnchorTransition());
+ case Property::IconAllowOverlap:
+ return makeStyleProperty(layer.getIconAllowOverlap());
+ case Property::IconAnchor:
+ return makeStyleProperty(layer.getIconAnchor());
+ case Property::IconIgnorePlacement:
+ return makeStyleProperty(layer.getIconIgnorePlacement());
+ case Property::IconImage:
+ return makeStyleProperty(layer.getIconImage());
+ case Property::IconKeepUpright:
+ return makeStyleProperty(layer.getIconKeepUpright());
+ case Property::IconOffset:
+ return makeStyleProperty(layer.getIconOffset());
+ case Property::IconOptional:
+ return makeStyleProperty(layer.getIconOptional());
+ case Property::IconPadding:
+ return makeStyleProperty(layer.getIconPadding());
+ case Property::IconPitchAlignment:
+ return makeStyleProperty(layer.getIconPitchAlignment());
+ case Property::IconRotate:
+ return makeStyleProperty(layer.getIconRotate());
+ case Property::IconRotationAlignment:
+ return makeStyleProperty(layer.getIconRotationAlignment());
+ case Property::IconSize:
+ return makeStyleProperty(layer.getIconSize());
+ case Property::IconTextFit:
+ return makeStyleProperty(layer.getIconTextFit());
+ case Property::IconTextFitPadding:
+ return makeStyleProperty(layer.getIconTextFitPadding());
+ case Property::SymbolAvoidEdges:
+ return makeStyleProperty(layer.getSymbolAvoidEdges());
+ case Property::SymbolPlacement:
+ return makeStyleProperty(layer.getSymbolPlacement());
+ case Property::SymbolSortKey:
+ return makeStyleProperty(layer.getSymbolSortKey());
+ case Property::SymbolSpacing:
+ return makeStyleProperty(layer.getSymbolSpacing());
+ case Property::SymbolZOrder:
+ return makeStyleProperty(layer.getSymbolZOrder());
+ case Property::TextAllowOverlap:
+ return makeStyleProperty(layer.getTextAllowOverlap());
+ case Property::TextAnchor:
+ return makeStyleProperty(layer.getTextAnchor());
+ case Property::TextField:
+ return makeStyleProperty(layer.getTextField());
+ case Property::TextFont:
+ return makeStyleProperty(layer.getTextFont());
+ case Property::TextIgnorePlacement:
+ return makeStyleProperty(layer.getTextIgnorePlacement());
+ case Property::TextJustify:
+ return makeStyleProperty(layer.getTextJustify());
+ case Property::TextKeepUpright:
+ return makeStyleProperty(layer.getTextKeepUpright());
+ case Property::TextLetterSpacing:
+ return makeStyleProperty(layer.getTextLetterSpacing());
+ case Property::TextLineHeight:
+ return makeStyleProperty(layer.getTextLineHeight());
+ case Property::TextMaxAngle:
+ return makeStyleProperty(layer.getTextMaxAngle());
+ case Property::TextMaxWidth:
+ return makeStyleProperty(layer.getTextMaxWidth());
+ case Property::TextOffset:
+ return makeStyleProperty(layer.getTextOffset());
+ case Property::TextOptional:
+ return makeStyleProperty(layer.getTextOptional());
+ case Property::TextPadding:
+ return makeStyleProperty(layer.getTextPadding());
+ case Property::TextPitchAlignment:
+ return makeStyleProperty(layer.getTextPitchAlignment());
+ case Property::TextRadialOffset:
+ return makeStyleProperty(layer.getTextRadialOffset());
+ case Property::TextRotate:
+ return makeStyleProperty(layer.getTextRotate());
+ case Property::TextRotationAlignment:
+ return makeStyleProperty(layer.getTextRotationAlignment());
+ case Property::TextSize:
+ return makeStyleProperty(layer.getTextSize());
+ case Property::TextTransform:
+ return makeStyleProperty(layer.getTextTransform());
+ case Property::TextVariableAnchor:
+ return makeStyleProperty(layer.getTextVariableAnchor());
+ case Property::TextWritingMode:
+ return makeStyleProperty(layer.getTextWritingMode());
+ }
+ return {};
+}
+
+StyleProperty getLayerProperty(const SymbolLayer& layer, const std::string& name) {
+ const auto it = layerProperties.find(name.c_str());
+ if (it == layerProperties.end()) {
+ return {};
+ }
+ return getLayerProperty(layer, static_cast<Property>(it->second));
+}
+
} // namespace
+Value SymbolLayer::serialize() const {
+ auto result = Layer::serialize();
+ assert(result.getObject());
+ for (const auto& property : layerProperties) {
+ auto styleProperty = getLayerProperty(*this, static_cast<Property>(property.second));
+ if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue;
+ serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount);
+ }
+ return result;
+}
+
optional<Error> SymbolLayer::setProperty(const std::string& name, const Convertible& value) {
const auto it = layerProperties.find(name.c_str());
if (it == layerProperties.end()) {
@@ -1707,152 +1873,7 @@ optional<Error> SymbolLayer::setProperty(const std::string& name, const Converti
}
StyleProperty SymbolLayer::getProperty(const std::string& name) const {
- const auto it = layerProperties.find(name.c_str());
- if (it == layerProperties.end()) {
- return {};
- }
-
- switch (static_cast<Property>(it->second)) {
- case Property::IconColor:
- return makeStyleProperty(getIconColor());
- case Property::IconHaloBlur:
- return makeStyleProperty(getIconHaloBlur());
- case Property::IconHaloColor:
- return makeStyleProperty(getIconHaloColor());
- case Property::IconHaloWidth:
- return makeStyleProperty(getIconHaloWidth());
- case Property::IconOpacity:
- return makeStyleProperty(getIconOpacity());
- case Property::IconTranslate:
- return makeStyleProperty(getIconTranslate());
- case Property::IconTranslateAnchor:
- return makeStyleProperty(getIconTranslateAnchor());
- case Property::TextColor:
- return makeStyleProperty(getTextColor());
- case Property::TextHaloBlur:
- return makeStyleProperty(getTextHaloBlur());
- case Property::TextHaloColor:
- return makeStyleProperty(getTextHaloColor());
- case Property::TextHaloWidth:
- return makeStyleProperty(getTextHaloWidth());
- case Property::TextOpacity:
- return makeStyleProperty(getTextOpacity());
- case Property::TextTranslate:
- return makeStyleProperty(getTextTranslate());
- case Property::TextTranslateAnchor:
- return makeStyleProperty(getTextTranslateAnchor());
- case Property::IconColorTransition:
- return makeStyleProperty(getIconColorTransition());
- case Property::IconHaloBlurTransition:
- return makeStyleProperty(getIconHaloBlurTransition());
- case Property::IconHaloColorTransition:
- return makeStyleProperty(getIconHaloColorTransition());
- case Property::IconHaloWidthTransition:
- return makeStyleProperty(getIconHaloWidthTransition());
- case Property::IconOpacityTransition:
- return makeStyleProperty(getIconOpacityTransition());
- case Property::IconTranslateTransition:
- return makeStyleProperty(getIconTranslateTransition());
- case Property::IconTranslateAnchorTransition:
- return makeStyleProperty(getIconTranslateAnchorTransition());
- case Property::TextColorTransition:
- return makeStyleProperty(getTextColorTransition());
- case Property::TextHaloBlurTransition:
- return makeStyleProperty(getTextHaloBlurTransition());
- case Property::TextHaloColorTransition:
- return makeStyleProperty(getTextHaloColorTransition());
- case Property::TextHaloWidthTransition:
- return makeStyleProperty(getTextHaloWidthTransition());
- case Property::TextOpacityTransition:
- return makeStyleProperty(getTextOpacityTransition());
- case Property::TextTranslateTransition:
- return makeStyleProperty(getTextTranslateTransition());
- case Property::TextTranslateAnchorTransition:
- return makeStyleProperty(getTextTranslateAnchorTransition());
- case Property::IconAllowOverlap:
- return makeStyleProperty(getIconAllowOverlap());
- case Property::IconAnchor:
- return makeStyleProperty(getIconAnchor());
- case Property::IconIgnorePlacement:
- return makeStyleProperty(getIconIgnorePlacement());
- case Property::IconImage:
- return makeStyleProperty(getIconImage());
- case Property::IconKeepUpright:
- return makeStyleProperty(getIconKeepUpright());
- case Property::IconOffset:
- return makeStyleProperty(getIconOffset());
- case Property::IconOptional:
- return makeStyleProperty(getIconOptional());
- case Property::IconPadding:
- return makeStyleProperty(getIconPadding());
- case Property::IconPitchAlignment:
- return makeStyleProperty(getIconPitchAlignment());
- case Property::IconRotate:
- return makeStyleProperty(getIconRotate());
- case Property::IconRotationAlignment:
- return makeStyleProperty(getIconRotationAlignment());
- case Property::IconSize:
- return makeStyleProperty(getIconSize());
- case Property::IconTextFit:
- return makeStyleProperty(getIconTextFit());
- case Property::IconTextFitPadding:
- return makeStyleProperty(getIconTextFitPadding());
- case Property::SymbolAvoidEdges:
- return makeStyleProperty(getSymbolAvoidEdges());
- case Property::SymbolPlacement:
- return makeStyleProperty(getSymbolPlacement());
- case Property::SymbolSortKey:
- return makeStyleProperty(getSymbolSortKey());
- case Property::SymbolSpacing:
- return makeStyleProperty(getSymbolSpacing());
- case Property::SymbolZOrder:
- return makeStyleProperty(getSymbolZOrder());
- case Property::TextAllowOverlap:
- return makeStyleProperty(getTextAllowOverlap());
- case Property::TextAnchor:
- return makeStyleProperty(getTextAnchor());
- case Property::TextField:
- return makeStyleProperty(getTextField());
- case Property::TextFont:
- return makeStyleProperty(getTextFont());
- case Property::TextIgnorePlacement:
- return makeStyleProperty(getTextIgnorePlacement());
- case Property::TextJustify:
- return makeStyleProperty(getTextJustify());
- case Property::TextKeepUpright:
- return makeStyleProperty(getTextKeepUpright());
- case Property::TextLetterSpacing:
- return makeStyleProperty(getTextLetterSpacing());
- case Property::TextLineHeight:
- return makeStyleProperty(getTextLineHeight());
- case Property::TextMaxAngle:
- return makeStyleProperty(getTextMaxAngle());
- case Property::TextMaxWidth:
- return makeStyleProperty(getTextMaxWidth());
- case Property::TextOffset:
- return makeStyleProperty(getTextOffset());
- case Property::TextOptional:
- return makeStyleProperty(getTextOptional());
- case Property::TextPadding:
- return makeStyleProperty(getTextPadding());
- case Property::TextPitchAlignment:
- return makeStyleProperty(getTextPitchAlignment());
- case Property::TextRadialOffset:
- return makeStyleProperty(getTextRadialOffset());
- case Property::TextRotate:
- return makeStyleProperty(getTextRotate());
- case Property::TextRotationAlignment:
- return makeStyleProperty(getTextRotationAlignment());
- case Property::TextSize:
- return makeStyleProperty(getTextSize());
- case Property::TextTransform:
- return makeStyleProperty(getTextTransform());
- case Property::TextVariableAnchor:
- return makeStyleProperty(getTextVariableAnchor());
- case Property::TextWritingMode:
- return makeStyleProperty(getTextWritingMode());
- }
- return {};
+ return getLayerProperty(*this, name);
}
Mutable<Layer::Impl> SymbolLayer::mutableBaseImpl() const {