[core] LayerProperty -> StyleProperty

This commit is contained in:
Mikhail Pozdnyakov
2019-09-25 23:31:56 +03:00
parent b5862c2127
commit e78c31c4b5
25 changed files with 206 additions and 206 deletions

View File

@@ -349,22 +349,22 @@ Value makeValue(T&& arg) {
}
template <typename T>
LayerProperty makeLayerProperty(const PropertyValue<T>& value) {
return value.match([](const Undefined&) -> LayerProperty { return {}; },
[](const T& t) -> LayerProperty {
return {makeValue(t), LayerProperty::Kind::Constant};
StyleProperty makeStyleProperty(const PropertyValue<T>& value) {
return value.match([](const Undefined&) -> StyleProperty { return {}; },
[](const T& t) -> StyleProperty {
return {makeValue(t), StyleProperty::Kind::Constant};
},
[](const PropertyExpression<T>& fn) -> LayerProperty {
return {fn.getExpression().serialize(), LayerProperty::Kind::Expression};
[](const PropertyExpression<T>& fn) -> StyleProperty {
return {fn.getExpression().serialize(), StyleProperty::Kind::Expression};
});
}
inline LayerProperty makeLayerProperty(const TransitionOptions& value) {
return {makeValue(value), LayerProperty::Kind::Transition};
inline StyleProperty makeStyleProperty(const TransitionOptions& value) {
return {makeValue(value), StyleProperty::Kind::Transition};
}
inline LayerProperty makeLayerProperty(const ColorRampPropertyValue& value) {
return {makeValue(value), LayerProperty::Kind::Expression};
inline StyleProperty makeStyleProperty(const ColorRampPropertyValue& value) {
return {makeValue(value), StyleProperty::Kind::Expression};
}
} // namespace conversion

View File

@@ -66,10 +66,10 @@ struct LayerTypeInfo {
const enum class TileKind : uint8_t { Geometry, Raster, RasterDEM, NotRequired } tileKind;
};
struct LayerProperty {
struct StyleProperty {
enum class Kind : uint8_t { Undefined, Constant, Expression, Transition };
LayerProperty(Value value_, Kind kind_) : value(std::move(value_)), kind(kind_) {}
LayerProperty() = default;
StyleProperty(Value value_, Kind kind_) : value(std::move(value_)), kind(kind_) {}
StyleProperty() = default;
const Value value;
const Kind kind = Kind::Undefined;
};
@@ -123,7 +123,7 @@ public:
const conversion::Convertible& value) = 0;
optional<conversion::Error> setVisibility(const conversion::Convertible& value);
virtual LayerProperty getPaintProperty(const std::string&) const = 0;
virtual StyleProperty getPaintProperty(const std::string&) const = 0;
// Private implementation
// TODO : We should not have public mutable data members.

View File

@@ -24,7 +24,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Paint properties

View File

@@ -24,7 +24,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Paint properties

View File

@@ -71,7 +71,7 @@ public:
// Dynamic properties
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string&) const final;
StyleProperty getPaintProperty(const std::string&) const final;
// Private implementation
class Impl;

View File

@@ -24,7 +24,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Paint properties

View File

@@ -24,7 +24,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Paint properties

View File

@@ -25,7 +25,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Paint properties

View File

@@ -24,7 +24,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Paint properties

View File

@@ -40,7 +40,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
<% if (layoutProperties.length) { -%>
// Layout properties

View File

@@ -27,7 +27,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Layout properties

View File

@@ -24,7 +24,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Paint properties

View File

@@ -26,7 +26,7 @@ public:
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
LayerProperty getPaintProperty(const std::string& name) const final;
StyleProperty getPaintProperty(const std::string& name) const final;
// Layout properties

View File

@@ -150,7 +150,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
BackgroundColor,
BackgroundOpacity,
BackgroundPattern,
@@ -244,7 +244,7 @@ optional<Error> BackgroundLayer::setPaintProperty(const std::string& name, const
return Error{"layer doesn't support this property"};
}
LayerProperty BackgroundLayer::getPaintProperty(const std::string& name) const {
StyleProperty BackgroundLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -252,17 +252,17 @@ LayerProperty BackgroundLayer::getPaintProperty(const std::string& name) const {
switch (static_cast<Property>(it->second)) {
case Property::BackgroundColor:
return makeLayerProperty(getBackgroundColor());
return makeStyleProperty(getBackgroundColor());
case Property::BackgroundOpacity:
return makeLayerProperty(getBackgroundOpacity());
return makeStyleProperty(getBackgroundOpacity());
case Property::BackgroundPattern:
return makeLayerProperty(getBackgroundPattern());
return makeStyleProperty(getBackgroundPattern());
case Property::BackgroundColorTransition:
return makeLayerProperty(getBackgroundColorTransition());
return makeStyleProperty(getBackgroundColorTransition());
case Property::BackgroundOpacityTransition:
return makeLayerProperty(getBackgroundOpacityTransition());
return makeStyleProperty(getBackgroundOpacityTransition());
case Property::BackgroundPatternTransition:
return makeLayerProperty(getBackgroundPatternTransition());
return makeStyleProperty(getBackgroundPatternTransition());
}
return {};
}

View File

@@ -366,7 +366,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
CircleBlur,
CircleColor,
CircleOpacity,
@@ -597,7 +597,7 @@ optional<Error> CircleLayer::setPaintProperty(const std::string& name, const Con
return Error{"layer doesn't support this property"};
}
LayerProperty CircleLayer::getPaintProperty(const std::string& name) const {
StyleProperty CircleLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -605,49 +605,49 @@ LayerProperty CircleLayer::getPaintProperty(const std::string& name) const {
switch (static_cast<Property>(it->second)) {
case Property::CircleBlur:
return makeLayerProperty(getCircleBlur());
return makeStyleProperty(getCircleBlur());
case Property::CircleColor:
return makeLayerProperty(getCircleColor());
return makeStyleProperty(getCircleColor());
case Property::CircleOpacity:
return makeLayerProperty(getCircleOpacity());
return makeStyleProperty(getCircleOpacity());
case Property::CirclePitchAlignment:
return makeLayerProperty(getCirclePitchAlignment());
return makeStyleProperty(getCirclePitchAlignment());
case Property::CirclePitchScale:
return makeLayerProperty(getCirclePitchScale());
return makeStyleProperty(getCirclePitchScale());
case Property::CircleRadius:
return makeLayerProperty(getCircleRadius());
return makeStyleProperty(getCircleRadius());
case Property::CircleStrokeColor:
return makeLayerProperty(getCircleStrokeColor());
return makeStyleProperty(getCircleStrokeColor());
case Property::CircleStrokeOpacity:
return makeLayerProperty(getCircleStrokeOpacity());
return makeStyleProperty(getCircleStrokeOpacity());
case Property::CircleStrokeWidth:
return makeLayerProperty(getCircleStrokeWidth());
return makeStyleProperty(getCircleStrokeWidth());
case Property::CircleTranslate:
return makeLayerProperty(getCircleTranslate());
return makeStyleProperty(getCircleTranslate());
case Property::CircleTranslateAnchor:
return makeLayerProperty(getCircleTranslateAnchor());
return makeStyleProperty(getCircleTranslateAnchor());
case Property::CircleBlurTransition:
return makeLayerProperty(getCircleBlurTransition());
return makeStyleProperty(getCircleBlurTransition());
case Property::CircleColorTransition:
return makeLayerProperty(getCircleColorTransition());
return makeStyleProperty(getCircleColorTransition());
case Property::CircleOpacityTransition:
return makeLayerProperty(getCircleOpacityTransition());
return makeStyleProperty(getCircleOpacityTransition());
case Property::CirclePitchAlignmentTransition:
return makeLayerProperty(getCirclePitchAlignmentTransition());
return makeStyleProperty(getCirclePitchAlignmentTransition());
case Property::CirclePitchScaleTransition:
return makeLayerProperty(getCirclePitchScaleTransition());
return makeStyleProperty(getCirclePitchScaleTransition());
case Property::CircleRadiusTransition:
return makeLayerProperty(getCircleRadiusTransition());
return makeStyleProperty(getCircleRadiusTransition());
case Property::CircleStrokeColorTransition:
return makeLayerProperty(getCircleStrokeColorTransition());
return makeStyleProperty(getCircleStrokeColorTransition());
case Property::CircleStrokeOpacityTransition:
return makeLayerProperty(getCircleStrokeOpacityTransition());
return makeStyleProperty(getCircleStrokeOpacityTransition());
case Property::CircleStrokeWidthTransition:
return makeLayerProperty(getCircleStrokeWidthTransition());
return makeStyleProperty(getCircleStrokeWidthTransition());
case Property::CircleTranslateTransition:
return makeLayerProperty(getCircleTranslateTransition());
return makeStyleProperty(getCircleTranslateTransition());
case Property::CircleTranslateAnchorTransition:
return makeLayerProperty(getCircleTranslateAnchorTransition());
return makeStyleProperty(getCircleTranslateAnchorTransition());
}
return {};
}

View File

@@ -47,7 +47,7 @@ optional<Error> CustomLayer::setLayoutProperty(const std::string&, const Convert
return Error { "layer doesn't support this property" };
}
LayerProperty CustomLayer::getPaintProperty(const std::string&) const {
StyleProperty CustomLayer::getPaintProperty(const std::string&) const {
return {};
}

View File

@@ -285,7 +285,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
FillExtrusionBase,
FillExtrusionColor,
FillExtrusionHeight,
@@ -479,7 +479,7 @@ optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, co
return Error{"layer doesn't support this property"};
}
LayerProperty FillExtrusionLayer::getPaintProperty(const std::string& name) const {
StyleProperty FillExtrusionLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -487,37 +487,37 @@ LayerProperty FillExtrusionLayer::getPaintProperty(const std::string& name) cons
switch (static_cast<Property>(it->second)) {
case Property::FillExtrusionBase:
return makeLayerProperty(getFillExtrusionBase());
return makeStyleProperty(getFillExtrusionBase());
case Property::FillExtrusionColor:
return makeLayerProperty(getFillExtrusionColor());
return makeStyleProperty(getFillExtrusionColor());
case Property::FillExtrusionHeight:
return makeLayerProperty(getFillExtrusionHeight());
return makeStyleProperty(getFillExtrusionHeight());
case Property::FillExtrusionOpacity:
return makeLayerProperty(getFillExtrusionOpacity());
return makeStyleProperty(getFillExtrusionOpacity());
case Property::FillExtrusionPattern:
return makeLayerProperty(getFillExtrusionPattern());
return makeStyleProperty(getFillExtrusionPattern());
case Property::FillExtrusionTranslate:
return makeLayerProperty(getFillExtrusionTranslate());
return makeStyleProperty(getFillExtrusionTranslate());
case Property::FillExtrusionTranslateAnchor:
return makeLayerProperty(getFillExtrusionTranslateAnchor());
return makeStyleProperty(getFillExtrusionTranslateAnchor());
case Property::FillExtrusionVerticalGradient:
return makeLayerProperty(getFillExtrusionVerticalGradient());
return makeStyleProperty(getFillExtrusionVerticalGradient());
case Property::FillExtrusionBaseTransition:
return makeLayerProperty(getFillExtrusionBaseTransition());
return makeStyleProperty(getFillExtrusionBaseTransition());
case Property::FillExtrusionColorTransition:
return makeLayerProperty(getFillExtrusionColorTransition());
return makeStyleProperty(getFillExtrusionColorTransition());
case Property::FillExtrusionHeightTransition:
return makeLayerProperty(getFillExtrusionHeightTransition());
return makeStyleProperty(getFillExtrusionHeightTransition());
case Property::FillExtrusionOpacityTransition:
return makeLayerProperty(getFillExtrusionOpacityTransition());
return makeStyleProperty(getFillExtrusionOpacityTransition());
case Property::FillExtrusionPatternTransition:
return makeLayerProperty(getFillExtrusionPatternTransition());
return makeStyleProperty(getFillExtrusionPatternTransition());
case Property::FillExtrusionTranslateTransition:
return makeLayerProperty(getFillExtrusionTranslateTransition());
return makeStyleProperty(getFillExtrusionTranslateTransition());
case Property::FillExtrusionTranslateAnchorTransition:
return makeLayerProperty(getFillExtrusionTranslateAnchorTransition());
return makeStyleProperty(getFillExtrusionTranslateAnchorTransition());
case Property::FillExtrusionVerticalGradientTransition:
return makeLayerProperty(getFillExtrusionVerticalGradientTransition());
return makeStyleProperty(getFillExtrusionVerticalGradientTransition());
}
return {};
}

View File

@@ -258,7 +258,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
FillAntialias,
FillColor,
FillOpacity,
@@ -431,7 +431,7 @@ optional<Error> FillLayer::setPaintProperty(const std::string& name, const Conve
return Error{"layer doesn't support this property"};
}
LayerProperty FillLayer::getPaintProperty(const std::string& name) const {
StyleProperty FillLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -439,33 +439,33 @@ LayerProperty FillLayer::getPaintProperty(const std::string& name) const {
switch (static_cast<Property>(it->second)) {
case Property::FillAntialias:
return makeLayerProperty(getFillAntialias());
return makeStyleProperty(getFillAntialias());
case Property::FillColor:
return makeLayerProperty(getFillColor());
return makeStyleProperty(getFillColor());
case Property::FillOpacity:
return makeLayerProperty(getFillOpacity());
return makeStyleProperty(getFillOpacity());
case Property::FillOutlineColor:
return makeLayerProperty(getFillOutlineColor());
return makeStyleProperty(getFillOutlineColor());
case Property::FillPattern:
return makeLayerProperty(getFillPattern());
return makeStyleProperty(getFillPattern());
case Property::FillTranslate:
return makeLayerProperty(getFillTranslate());
return makeStyleProperty(getFillTranslate());
case Property::FillTranslateAnchor:
return makeLayerProperty(getFillTranslateAnchor());
return makeStyleProperty(getFillTranslateAnchor());
case Property::FillAntialiasTransition:
return makeLayerProperty(getFillAntialiasTransition());
return makeStyleProperty(getFillAntialiasTransition());
case Property::FillColorTransition:
return makeLayerProperty(getFillColorTransition());
return makeStyleProperty(getFillColorTransition());
case Property::FillOpacityTransition:
return makeLayerProperty(getFillOpacityTransition());
return makeStyleProperty(getFillOpacityTransition());
case Property::FillOutlineColorTransition:
return makeLayerProperty(getFillOutlineColorTransition());
return makeStyleProperty(getFillOutlineColorTransition());
case Property::FillPatternTransition:
return makeLayerProperty(getFillPatternTransition());
return makeStyleProperty(getFillPatternTransition());
case Property::FillTranslateTransition:
return makeLayerProperty(getFillTranslateTransition());
return makeStyleProperty(getFillTranslateTransition());
case Property::FillTranslateAnchorTransition:
return makeLayerProperty(getFillTranslateAnchorTransition());
return makeStyleProperty(getFillTranslateAnchorTransition());
}
return {};
}

View File

@@ -206,7 +206,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
HeatmapColor,
HeatmapIntensity,
HeatmapOpacity,
@@ -332,7 +332,7 @@ optional<Error> HeatmapLayer::setPaintProperty(const std::string& name, const Co
return Error{"layer doesn't support this property"};
}
LayerProperty HeatmapLayer::getPaintProperty(const std::string& name) const {
StyleProperty HeatmapLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -340,25 +340,25 @@ LayerProperty HeatmapLayer::getPaintProperty(const std::string& name) const {
switch (static_cast<Property>(it->second)) {
case Property::HeatmapColor:
return makeLayerProperty(getHeatmapColor());
return makeStyleProperty(getHeatmapColor());
case Property::HeatmapIntensity:
return makeLayerProperty(getHeatmapIntensity());
return makeStyleProperty(getHeatmapIntensity());
case Property::HeatmapOpacity:
return makeLayerProperty(getHeatmapOpacity());
return makeStyleProperty(getHeatmapOpacity());
case Property::HeatmapRadius:
return makeLayerProperty(getHeatmapRadius());
return makeStyleProperty(getHeatmapRadius());
case Property::HeatmapWeight:
return makeLayerProperty(getHeatmapWeight());
return makeStyleProperty(getHeatmapWeight());
case Property::HeatmapColorTransition:
return makeLayerProperty(getHeatmapColorTransition());
return makeStyleProperty(getHeatmapColorTransition());
case Property::HeatmapIntensityTransition:
return makeLayerProperty(getHeatmapIntensityTransition());
return makeStyleProperty(getHeatmapIntensityTransition());
case Property::HeatmapOpacityTransition:
return makeLayerProperty(getHeatmapOpacityTransition());
return makeStyleProperty(getHeatmapOpacityTransition());
case Property::HeatmapRadiusTransition:
return makeLayerProperty(getHeatmapRadiusTransition());
return makeStyleProperty(getHeatmapRadiusTransition());
case Property::HeatmapWeightTransition:
return makeLayerProperty(getHeatmapWeightTransition());
return makeStyleProperty(getHeatmapWeightTransition());
}
return {};
}

View File

@@ -231,7 +231,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
HillshadeAccentColor,
HillshadeExaggeration,
HillshadeHighlightColor,
@@ -371,7 +371,7 @@ optional<Error> HillshadeLayer::setPaintProperty(const std::string& name, const
return Error{"layer doesn't support this property"};
}
LayerProperty HillshadeLayer::getPaintProperty(const std::string& name) const {
StyleProperty HillshadeLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -379,29 +379,29 @@ LayerProperty HillshadeLayer::getPaintProperty(const std::string& name) const {
switch (static_cast<Property>(it->second)) {
case Property::HillshadeAccentColor:
return makeLayerProperty(getHillshadeAccentColor());
return makeStyleProperty(getHillshadeAccentColor());
case Property::HillshadeExaggeration:
return makeLayerProperty(getHillshadeExaggeration());
return makeStyleProperty(getHillshadeExaggeration());
case Property::HillshadeHighlightColor:
return makeLayerProperty(getHillshadeHighlightColor());
return makeStyleProperty(getHillshadeHighlightColor());
case Property::HillshadeIlluminationAnchor:
return makeLayerProperty(getHillshadeIlluminationAnchor());
return makeStyleProperty(getHillshadeIlluminationAnchor());
case Property::HillshadeIlluminationDirection:
return makeLayerProperty(getHillshadeIlluminationDirection());
return makeStyleProperty(getHillshadeIlluminationDirection());
case Property::HillshadeShadowColor:
return makeLayerProperty(getHillshadeShadowColor());
return makeStyleProperty(getHillshadeShadowColor());
case Property::HillshadeAccentColorTransition:
return makeLayerProperty(getHillshadeAccentColorTransition());
return makeStyleProperty(getHillshadeAccentColorTransition());
case Property::HillshadeExaggerationTransition:
return makeLayerProperty(getHillshadeExaggerationTransition());
return makeStyleProperty(getHillshadeExaggerationTransition());
case Property::HillshadeHighlightColorTransition:
return makeLayerProperty(getHillshadeHighlightColorTransition());
return makeStyleProperty(getHillshadeHighlightColorTransition());
case Property::HillshadeIlluminationAnchorTransition:
return makeLayerProperty(getHillshadeIlluminationAnchorTransition());
return makeStyleProperty(getHillshadeIlluminationAnchorTransition());
case Property::HillshadeIlluminationDirectionTransition:
return makeLayerProperty(getHillshadeIlluminationDirectionTransition());
return makeStyleProperty(getHillshadeIlluminationDirectionTransition());
case Property::HillshadeShadowColorTransition:
return makeLayerProperty(getHillshadeShadowColorTransition());
return makeStyleProperty(getHillshadeShadowColorTransition());
}
return {};
}

View File

@@ -192,7 +192,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
<% for (const property of paintProperties) { -%>
<%- camelize(property.name) %>,
<% } -%>
@@ -265,7 +265,7 @@ optional<Error> <%- camelize(type) %>Layer::setPaintProperty(const std::string&
return Error{"layer doesn't support this property"};
}
LayerProperty <%- camelize(type) %>Layer::getPaintProperty(const std::string& name) const {
StyleProperty <%- camelize(type) %>Layer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -274,11 +274,11 @@ LayerProperty <%- camelize(type) %>Layer::getPaintProperty(const std::string& na
switch (static_cast<Property>(it->second)) {
<% for (const property of paintProperties) { -%>
case Property::<%- camelize(property.name) %>:
return makeLayerProperty(get<%- camelize(property.name) %>());
return makeStyleProperty(get<%- camelize(property.name) %>());
<% } -%>
<% for (const property of paintProperties) { -%>
case Property::<%- camelize(property.name) %>Transition:
return makeLayerProperty(get<%- camelize(property.name) %>Transition());
return makeStyleProperty(get<%- camelize(property.name) %>Transition());
<% } -%>
}
return {};

View File

@@ -432,7 +432,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
LineBlur,
LineColor,
LineDasharray,
@@ -668,7 +668,7 @@ optional<Error> LineLayer::setPaintProperty(const std::string& name, const Conve
return Error{"layer doesn't support this property"};
}
LayerProperty LineLayer::getPaintProperty(const std::string& name) const {
StyleProperty LineLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -676,49 +676,49 @@ LayerProperty LineLayer::getPaintProperty(const std::string& name) const {
switch (static_cast<Property>(it->second)) {
case Property::LineBlur:
return makeLayerProperty(getLineBlur());
return makeStyleProperty(getLineBlur());
case Property::LineColor:
return makeLayerProperty(getLineColor());
return makeStyleProperty(getLineColor());
case Property::LineDasharray:
return makeLayerProperty(getLineDasharray());
return makeStyleProperty(getLineDasharray());
case Property::LineGapWidth:
return makeLayerProperty(getLineGapWidth());
return makeStyleProperty(getLineGapWidth());
case Property::LineGradient:
return makeLayerProperty(getLineGradient());
return makeStyleProperty(getLineGradient());
case Property::LineOffset:
return makeLayerProperty(getLineOffset());
return makeStyleProperty(getLineOffset());
case Property::LineOpacity:
return makeLayerProperty(getLineOpacity());
return makeStyleProperty(getLineOpacity());
case Property::LinePattern:
return makeLayerProperty(getLinePattern());
return makeStyleProperty(getLinePattern());
case Property::LineTranslate:
return makeLayerProperty(getLineTranslate());
return makeStyleProperty(getLineTranslate());
case Property::LineTranslateAnchor:
return makeLayerProperty(getLineTranslateAnchor());
return makeStyleProperty(getLineTranslateAnchor());
case Property::LineWidth:
return makeLayerProperty(getLineWidth());
return makeStyleProperty(getLineWidth());
case Property::LineBlurTransition:
return makeLayerProperty(getLineBlurTransition());
return makeStyleProperty(getLineBlurTransition());
case Property::LineColorTransition:
return makeLayerProperty(getLineColorTransition());
return makeStyleProperty(getLineColorTransition());
case Property::LineDasharrayTransition:
return makeLayerProperty(getLineDasharrayTransition());
return makeStyleProperty(getLineDasharrayTransition());
case Property::LineGapWidthTransition:
return makeLayerProperty(getLineGapWidthTransition());
return makeStyleProperty(getLineGapWidthTransition());
case Property::LineGradientTransition:
return makeLayerProperty(getLineGradientTransition());
return makeStyleProperty(getLineGradientTransition());
case Property::LineOffsetTransition:
return makeLayerProperty(getLineOffsetTransition());
return makeStyleProperty(getLineOffsetTransition());
case Property::LineOpacityTransition:
return makeLayerProperty(getLineOpacityTransition());
return makeStyleProperty(getLineOpacityTransition());
case Property::LinePatternTransition:
return makeLayerProperty(getLinePatternTransition());
return makeStyleProperty(getLinePatternTransition());
case Property::LineTranslateTransition:
return makeLayerProperty(getLineTranslateTransition());
return makeStyleProperty(getLineTranslateTransition());
case Property::LineTranslateAnchorTransition:
return makeLayerProperty(getLineTranslateAnchorTransition());
return makeStyleProperty(getLineTranslateAnchorTransition());
case Property::LineWidthTransition:
return makeLayerProperty(getLineWidthTransition());
return makeStyleProperty(getLineWidthTransition());
}
return {};
}

View File

@@ -285,7 +285,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
RasterBrightnessMax,
RasterBrightnessMin,
RasterContrast,
@@ -444,7 +444,7 @@ optional<Error> RasterLayer::setPaintProperty(const std::string& name, const Con
return Error{"layer doesn't support this property"};
}
LayerProperty RasterLayer::getPaintProperty(const std::string& name) const {
StyleProperty RasterLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -452,37 +452,37 @@ LayerProperty RasterLayer::getPaintProperty(const std::string& name) const {
switch (static_cast<Property>(it->second)) {
case Property::RasterBrightnessMax:
return makeLayerProperty(getRasterBrightnessMax());
return makeStyleProperty(getRasterBrightnessMax());
case Property::RasterBrightnessMin:
return makeLayerProperty(getRasterBrightnessMin());
return makeStyleProperty(getRasterBrightnessMin());
case Property::RasterContrast:
return makeLayerProperty(getRasterContrast());
return makeStyleProperty(getRasterContrast());
case Property::RasterFadeDuration:
return makeLayerProperty(getRasterFadeDuration());
return makeStyleProperty(getRasterFadeDuration());
case Property::RasterHueRotate:
return makeLayerProperty(getRasterHueRotate());
return makeStyleProperty(getRasterHueRotate());
case Property::RasterOpacity:
return makeLayerProperty(getRasterOpacity());
return makeStyleProperty(getRasterOpacity());
case Property::RasterResampling:
return makeLayerProperty(getRasterResampling());
return makeStyleProperty(getRasterResampling());
case Property::RasterSaturation:
return makeLayerProperty(getRasterSaturation());
return makeStyleProperty(getRasterSaturation());
case Property::RasterBrightnessMaxTransition:
return makeLayerProperty(getRasterBrightnessMaxTransition());
return makeStyleProperty(getRasterBrightnessMaxTransition());
case Property::RasterBrightnessMinTransition:
return makeLayerProperty(getRasterBrightnessMinTransition());
return makeStyleProperty(getRasterBrightnessMinTransition());
case Property::RasterContrastTransition:
return makeLayerProperty(getRasterContrastTransition());
return makeStyleProperty(getRasterContrastTransition());
case Property::RasterFadeDurationTransition:
return makeLayerProperty(getRasterFadeDurationTransition());
return makeStyleProperty(getRasterFadeDurationTransition());
case Property::RasterHueRotateTransition:
return makeLayerProperty(getRasterHueRotateTransition());
return makeStyleProperty(getRasterHueRotateTransition());
case Property::RasterOpacityTransition:
return makeLayerProperty(getRasterOpacityTransition());
return makeStyleProperty(getRasterOpacityTransition());
case Property::RasterResamplingTransition:
return makeLayerProperty(getRasterResamplingTransition());
return makeStyleProperty(getRasterResamplingTransition());
case Property::RasterSaturationTransition:
return makeLayerProperty(getRasterSaturationTransition());
return makeStyleProperty(getRasterSaturationTransition());
}
return {};
}

View File

@@ -1104,7 +1104,7 @@ using namespace conversion;
namespace {
enum class Property {
enum class Property : uint8_t {
IconColor,
IconHaloBlur,
IconHaloColor,
@@ -1367,7 +1367,7 @@ optional<Error> SymbolLayer::setPaintProperty(const std::string& name, const Con
return Error{"layer doesn't support this property"};
}
LayerProperty SymbolLayer::getPaintProperty(const std::string& name) const {
StyleProperty SymbolLayer::getPaintProperty(const std::string& name) const {
const auto it = paintProperties.find(name.c_str());
if (it == paintProperties.end()) {
return {};
@@ -1375,61 +1375,61 @@ LayerProperty SymbolLayer::getPaintProperty(const std::string& name) const {
switch (static_cast<Property>(it->second)) {
case Property::IconColor:
return makeLayerProperty(getIconColor());
return makeStyleProperty(getIconColor());
case Property::IconHaloBlur:
return makeLayerProperty(getIconHaloBlur());
return makeStyleProperty(getIconHaloBlur());
case Property::IconHaloColor:
return makeLayerProperty(getIconHaloColor());
return makeStyleProperty(getIconHaloColor());
case Property::IconHaloWidth:
return makeLayerProperty(getIconHaloWidth());
return makeStyleProperty(getIconHaloWidth());
case Property::IconOpacity:
return makeLayerProperty(getIconOpacity());
return makeStyleProperty(getIconOpacity());
case Property::IconTranslate:
return makeLayerProperty(getIconTranslate());
return makeStyleProperty(getIconTranslate());
case Property::IconTranslateAnchor:
return makeLayerProperty(getIconTranslateAnchor());
return makeStyleProperty(getIconTranslateAnchor());
case Property::TextColor:
return makeLayerProperty(getTextColor());
return makeStyleProperty(getTextColor());
case Property::TextHaloBlur:
return makeLayerProperty(getTextHaloBlur());
return makeStyleProperty(getTextHaloBlur());
case Property::TextHaloColor:
return makeLayerProperty(getTextHaloColor());
return makeStyleProperty(getTextHaloColor());
case Property::TextHaloWidth:
return makeLayerProperty(getTextHaloWidth());
return makeStyleProperty(getTextHaloWidth());
case Property::TextOpacity:
return makeLayerProperty(getTextOpacity());
return makeStyleProperty(getTextOpacity());
case Property::TextTranslate:
return makeLayerProperty(getTextTranslate());
return makeStyleProperty(getTextTranslate());
case Property::TextTranslateAnchor:
return makeLayerProperty(getTextTranslateAnchor());
return makeStyleProperty(getTextTranslateAnchor());
case Property::IconColorTransition:
return makeLayerProperty(getIconColorTransition());
return makeStyleProperty(getIconColorTransition());
case Property::IconHaloBlurTransition:
return makeLayerProperty(getIconHaloBlurTransition());
return makeStyleProperty(getIconHaloBlurTransition());
case Property::IconHaloColorTransition:
return makeLayerProperty(getIconHaloColorTransition());
return makeStyleProperty(getIconHaloColorTransition());
case Property::IconHaloWidthTransition:
return makeLayerProperty(getIconHaloWidthTransition());
return makeStyleProperty(getIconHaloWidthTransition());
case Property::IconOpacityTransition:
return makeLayerProperty(getIconOpacityTransition());
return makeStyleProperty(getIconOpacityTransition());
case Property::IconTranslateTransition:
return makeLayerProperty(getIconTranslateTransition());
return makeStyleProperty(getIconTranslateTransition());
case Property::IconTranslateAnchorTransition:
return makeLayerProperty(getIconTranslateAnchorTransition());
return makeStyleProperty(getIconTranslateAnchorTransition());
case Property::TextColorTransition:
return makeLayerProperty(getTextColorTransition());
return makeStyleProperty(getTextColorTransition());
case Property::TextHaloBlurTransition:
return makeLayerProperty(getTextHaloBlurTransition());
return makeStyleProperty(getTextHaloBlurTransition());
case Property::TextHaloColorTransition:
return makeLayerProperty(getTextHaloColorTransition());
return makeStyleProperty(getTextHaloColorTransition());
case Property::TextHaloWidthTransition:
return makeLayerProperty(getTextHaloWidthTransition());
return makeStyleProperty(getTextHaloWidthTransition());
case Property::TextOpacityTransition:
return makeLayerProperty(getTextOpacityTransition());
return makeStyleProperty(getTextOpacityTransition());
case Property::TextTranslateTransition:
return makeLayerProperty(getTextTranslateTransition());
return makeStyleProperty(getTextTranslateTransition());
case Property::TextTranslateAnchorTransition:
return makeLayerProperty(getTextTranslateAnchorTransition());
return makeStyleProperty(getTextTranslateAnchorTransition());
}
return {};
}

View File

@@ -953,17 +953,17 @@ TEST(Map, UniversalStyleGetter) {
Layer* lineLayer = test.map.getStyle().getLayer("line");
ASSERT_TRUE(lineLayer);
LayerProperty nonexistent = lineLayer->getPaintProperty("nonexistent");
StyleProperty nonexistent = lineLayer->getPaintProperty("nonexistent");
ASSERT_FALSE(nonexistent.value);
EXPECT_EQ(LayerProperty::Kind::Undefined, nonexistent.kind);
EXPECT_EQ(StyleProperty::Kind::Undefined, nonexistent.kind);
LayerProperty undefined = lineLayer->getPaintProperty("line-blur");
StyleProperty undefined = lineLayer->getPaintProperty("line-blur");
ASSERT_FALSE(undefined.value);
EXPECT_EQ(LayerProperty::Kind::Undefined, undefined.kind);
EXPECT_EQ(StyleProperty::Kind::Undefined, undefined.kind);
LayerProperty lineColor = lineLayer->getPaintProperty("line-color");
StyleProperty lineColor = lineLayer->getPaintProperty("line-color");
ASSERT_TRUE(lineColor.value);
EXPECT_EQ(LayerProperty::Kind::Constant, lineColor.kind);
EXPECT_EQ(StyleProperty::Kind::Constant, lineColor.kind);
ASSERT_TRUE(lineColor.value.getObject());
const auto& color = *(lineColor.value.getObject());
EXPECT_EQ(1.0, *color.at("r").getDouble());
@@ -971,21 +971,21 @@ TEST(Map, UniversalStyleGetter) {
EXPECT_EQ(0.0, *color.at("b").getDouble());
EXPECT_EQ(1.0, *color.at("a").getDouble());
LayerProperty lineOpacity = lineLayer->getPaintProperty("line-opacity");
StyleProperty lineOpacity = lineLayer->getPaintProperty("line-opacity");
ASSERT_TRUE(lineOpacity.value);
EXPECT_EQ(LayerProperty::Kind::Constant, lineOpacity.kind);
EXPECT_EQ(StyleProperty::Kind::Constant, lineOpacity.kind);
ASSERT_TRUE(lineOpacity.value.getDouble());
EXPECT_EQ(0.5, *lineOpacity.value.getDouble());
LayerProperty lineOpacityTransition = lineLayer->getPaintProperty("line-opacity-transition");
StyleProperty lineOpacityTransition = lineLayer->getPaintProperty("line-opacity-transition");
ASSERT_TRUE(lineOpacityTransition.value);
EXPECT_EQ(LayerProperty::Kind::Transition, lineOpacityTransition.kind);
EXPECT_EQ(StyleProperty::Kind::Transition, lineOpacityTransition.kind);
ASSERT_TRUE(lineOpacityTransition.value.getArray());
EXPECT_EQ(3u, lineOpacityTransition.value.getArray()->size());
LayerProperty lineWidth = lineLayer->getPaintProperty("line-width");
StyleProperty lineWidth = lineLayer->getPaintProperty("line-width");
ASSERT_TRUE(lineWidth.value);
EXPECT_EQ(LayerProperty::Kind::Expression, lineWidth.kind);
EXPECT_EQ(StyleProperty::Kind::Expression, lineWidth.kind);
ASSERT_TRUE(lineWidth.value.getArray());
const auto& expression = *lineWidth.value.getArray();