summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp4
-rw-r--r--scripts/style-spec.js3
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp103
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.hpp6
4 files changed, 73 insertions, 43 deletions
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index c7082f232d..93275e6dd2 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -38,6 +38,10 @@ public:
const PropertyValue<bool>& getSymbolAvoidEdges() const;
void setSymbolAvoidEdges(const PropertyValue<bool>&);
+ static PropertyValue<float> getDefaultSymbolSortKey();
+ const PropertyValue<float>& getSymbolSortKey() const;
+ void setSymbolSortKey(const PropertyValue<float>&);
+
static PropertyValue<SymbolZOrderType> getDefaultSymbolZOrder();
const PropertyValue<SymbolZOrderType>& getSymbolZOrder() const;
void setSymbolZOrder(const PropertyValue<SymbolZOrderType>&);
diff --git a/scripts/style-spec.js b/scripts/style-spec.js
index 19b7378cf8..8a9c9d4144 100644
--- a/scripts/style-spec.js
+++ b/scripts/style-spec.js
@@ -1,4 +1 @@
var spec = module.exports = require('../mapbox-gl-js/src/style-spec/reference/v8');
-
-// Make temporary modifications here when Native doesn't have all features that JS has.
-delete spec.layout_symbol['symbol-sort-key'];
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index c8d7816180..0284ba0d3c 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -108,6 +108,22 @@ void SymbolLayer::setSymbolAvoidEdges(const PropertyValue<bool>& value) {
baseImpl = std::move(impl_);
observer->onLayerChanged(*this);
}
+PropertyValue<float> SymbolLayer::getDefaultSymbolSortKey() {
+ return SymbolSortKey::defaultValue();
+}
+
+const PropertyValue<float>& SymbolLayer::getSymbolSortKey() const {
+ return impl().layout.get<SymbolSortKey>();
+}
+
+void SymbolLayer::setSymbolSortKey(const PropertyValue<float>& value) {
+ if (value == getSymbolSortKey())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->layout.get<SymbolSortKey>() = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
PropertyValue<SymbolZOrderType> SymbolLayer::getDefaultSymbolZOrder() {
return SymbolZOrder::defaultValue();
}
@@ -1333,6 +1349,7 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
SymbolPlacement,
SymbolSpacing,
SymbolAvoidEdges,
+ SymbolSortKey,
SymbolZOrder,
IconAllowOverlap,
IconIgnorePlacement,
@@ -1374,6 +1391,7 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
{ "symbol-placement", static_cast<uint8_t>(Property::SymbolPlacement) },
{ "symbol-spacing", static_cast<uint8_t>(Property::SymbolSpacing) },
{ "symbol-avoid-edges", static_cast<uint8_t>(Property::SymbolAvoidEdges) },
+ { "symbol-sort-key", static_cast<uint8_t>(Property::SymbolSortKey) },
{ "symbol-z-order", static_cast<uint8_t>(Property::SymbolZOrder) },
{ "icon-allow-overlap", static_cast<uint8_t>(Property::IconAllowOverlap) },
{ "icon-ignore-placement", static_cast<uint8_t>(Property::IconIgnorePlacement) },
@@ -1520,54 +1538,18 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
}
- if (property == Property::SymbolZOrder) {
+ if (property == Property::SymbolSortKey || property == Property::IconSize || property == Property::IconRotate || property == Property::TextSize || property == Property::TextMaxWidth || property == Property::TextLetterSpacing || property == Property::TextRadialOffset || property == Property::TextRotate) {
Error error;
- optional<PropertyValue<SymbolZOrderType>> typedValue = convert<PropertyValue<SymbolZOrderType>>(value, error, false, false);
- if (!typedValue) {
- return error;
- }
-
- setSymbolZOrder(*typedValue);
- return nullopt;
-
- }
-
- if (property == Property::IconRotationAlignment || property == Property::IconPitchAlignment || property == Property::TextPitchAlignment || property == Property::TextRotationAlignment) {
- Error error;
- optional<PropertyValue<AlignmentType>> typedValue = convert<PropertyValue<AlignmentType>>(value, error, false, false);
+ optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
if (!typedValue) {
return error;
}
- if (property == Property::IconRotationAlignment) {
- setIconRotationAlignment(*typedValue);
- return nullopt;
- }
-
- if (property == Property::IconPitchAlignment) {
- setIconPitchAlignment(*typedValue);
- return nullopt;
- }
-
- if (property == Property::TextPitchAlignment) {
- setTextPitchAlignment(*typedValue);
+ if (property == Property::SymbolSortKey) {
+ setSymbolSortKey(*typedValue);
return nullopt;
}
- if (property == Property::TextRotationAlignment) {
- setTextRotationAlignment(*typedValue);
- return nullopt;
- }
-
- }
-
- if (property == Property::IconSize || property == Property::IconRotate || property == Property::TextSize || property == Property::TextMaxWidth || property == Property::TextLetterSpacing || property == Property::TextRadialOffset || property == Property::TextRotate) {
- Error error;
- optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
- if (!typedValue) {
- return error;
- }
-
if (property == Property::IconSize) {
setIconSize(*typedValue);
return nullopt;
@@ -1605,6 +1587,47 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
}
+ if (property == Property::SymbolZOrder) {
+ Error error;
+ optional<PropertyValue<SymbolZOrderType>> typedValue = convert<PropertyValue<SymbolZOrderType>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ setSymbolZOrder(*typedValue);
+ return nullopt;
+
+ }
+
+ if (property == Property::IconRotationAlignment || property == Property::IconPitchAlignment || property == Property::TextPitchAlignment || property == Property::TextRotationAlignment) {
+ Error error;
+ optional<PropertyValue<AlignmentType>> typedValue = convert<PropertyValue<AlignmentType>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ if (property == Property::IconRotationAlignment) {
+ setIconRotationAlignment(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::IconPitchAlignment) {
+ setIconPitchAlignment(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::TextPitchAlignment) {
+ setTextPitchAlignment(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::TextRotationAlignment) {
+ setTextRotationAlignment(*typedValue);
+ return nullopt;
+ }
+
+ }
+
if (property == Property::IconTextFit) {
Error error;
optional<PropertyValue<IconTextFitType>> typedValue = convert<PropertyValue<IconTextFitType>>(value, error, false, false);
diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp
index 6b6e86fc3e..caefbad137 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.hpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.hpp
@@ -27,6 +27,11 @@ struct SymbolAvoidEdges : LayoutProperty<bool> {
static bool defaultValue() { return false; }
};
+struct SymbolSortKey : DataDrivenLayoutProperty<float> {
+ static constexpr const char *name() { return "symbol-sort-key"; }
+ static float defaultValue() { return 0; }
+};
+
struct SymbolZOrder : LayoutProperty<SymbolZOrderType> {
static constexpr const char *name() { return "symbol-z-order"; }
static SymbolZOrderType defaultValue() { return SymbolZOrderType::Auto; }
@@ -270,6 +275,7 @@ class SymbolLayoutProperties : public Properties<
SymbolPlacement,
SymbolSpacing,
SymbolAvoidEdges,
+ SymbolSortKey,
SymbolZOrder,
IconAllowOverlap,
IconIgnorePlacement,