Better handling for undefined icon|text-rotation-alignment (#6253)
* [core, ios, android] Use `auto` value for properties with calculated defaults * Fix render tests
This commit is contained in:
committed by
John Firebaugh
parent
673d8f90f2
commit
6a2ce352d1
@@ -144,7 +144,7 @@ void SymbolLayer::setIconOptional(PropertyValue<bool> value) {
|
||||
impl->observer->onLayerLayoutPropertyChanged(*this);
|
||||
}
|
||||
PropertyValue<AlignmentType> SymbolLayer::getDefaultIconRotationAlignment() {
|
||||
return { AlignmentType::Viewport };
|
||||
return { AlignmentType::Auto };
|
||||
}
|
||||
|
||||
PropertyValue<AlignmentType> SymbolLayer::getIconRotationAlignment() const {
|
||||
@@ -270,7 +270,7 @@ void SymbolLayer::setIconOffset(PropertyValue<std::array<float, 2>> value) {
|
||||
impl->observer->onLayerLayoutPropertyChanged(*this);
|
||||
}
|
||||
PropertyValue<AlignmentType> SymbolLayer::getDefaultTextPitchAlignment() {
|
||||
return { AlignmentType::Undefined };
|
||||
return { AlignmentType::Auto };
|
||||
}
|
||||
|
||||
PropertyValue<AlignmentType> SymbolLayer::getTextPitchAlignment() const {
|
||||
@@ -284,7 +284,7 @@ void SymbolLayer::setTextPitchAlignment(PropertyValue<AlignmentType> value) {
|
||||
impl->observer->onLayerLayoutPropertyChanged(*this);
|
||||
}
|
||||
PropertyValue<AlignmentType> SymbolLayer::getDefaultTextRotationAlignment() {
|
||||
return { AlignmentType::Viewport };
|
||||
return { AlignmentType::Auto };
|
||||
}
|
||||
|
||||
PropertyValue<AlignmentType> SymbolLayer::getTextRotationAlignment() const {
|
||||
|
||||
@@ -35,19 +35,29 @@ std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters&
|
||||
SymbolLayoutProperties layoutProperties = layout;
|
||||
|
||||
CalculationParameters p(parameters.tileID.overscaledZ);
|
||||
layoutProperties.symbolPlacement.calculate(p);
|
||||
if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) {
|
||||
layoutProperties.iconRotationAlignment.value = AlignmentType::Map;
|
||||
layoutProperties.textRotationAlignment.value = AlignmentType::Map;
|
||||
layoutProperties.recalculate(p);
|
||||
|
||||
if (layoutProperties.iconRotationAlignment.value == AlignmentType::Auto) {
|
||||
if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) {
|
||||
layoutProperties.iconRotationAlignment.value = AlignmentType::Map;
|
||||
} else {
|
||||
layoutProperties.iconRotationAlignment.value = AlignmentType::Viewport;
|
||||
}
|
||||
}
|
||||
|
||||
if (layoutProperties.textRotationAlignment.value == AlignmentType::Auto) {
|
||||
if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) {
|
||||
layoutProperties.textRotationAlignment.value = AlignmentType::Map;
|
||||
} else {
|
||||
layoutProperties.textRotationAlignment.value = AlignmentType::Viewport;
|
||||
}
|
||||
}
|
||||
|
||||
// If unspecified `text-pitch-alignment` inherits `text-rotation-alignment`
|
||||
if (layoutProperties.textPitchAlignment.value == AlignmentType::Undefined) {
|
||||
if (layoutProperties.textPitchAlignment.value == AlignmentType::Auto) {
|
||||
layoutProperties.textPitchAlignment.value = layoutProperties.textRotationAlignment.value;
|
||||
}
|
||||
|
||||
layoutProperties.recalculate(p);
|
||||
|
||||
layoutProperties.textSize.calculate(CalculationParameters(18));
|
||||
float textMaxSize = layoutProperties.textSize;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
LayoutProperty<bool> iconAllowOverlap { false };
|
||||
LayoutProperty<bool> iconIgnorePlacement { false };
|
||||
LayoutProperty<bool> iconOptional { false };
|
||||
LayoutProperty<AlignmentType> iconRotationAlignment { AlignmentType::Viewport };
|
||||
LayoutProperty<AlignmentType> iconRotationAlignment { AlignmentType::Auto };
|
||||
LayoutProperty<float> iconSize { 1 };
|
||||
LayoutProperty<IconTextFitType> iconTextFit { IconTextFitType::None };
|
||||
LayoutProperty<std::array<float, 4>> iconTextFitPadding { {{ 0, 0, 0, 0 }} };
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
LayoutProperty<float> iconPadding { 2 };
|
||||
LayoutProperty<bool> iconKeepUpright { false };
|
||||
LayoutProperty<std::array<float, 2>> iconOffset { {{ 0, 0 }} };
|
||||
LayoutProperty<AlignmentType> textPitchAlignment { AlignmentType::Undefined };
|
||||
LayoutProperty<AlignmentType> textRotationAlignment { AlignmentType::Viewport };
|
||||
LayoutProperty<AlignmentType> textPitchAlignment { AlignmentType::Auto };
|
||||
LayoutProperty<AlignmentType> textRotationAlignment { AlignmentType::Auto };
|
||||
LayoutProperty<std::string> textField { "" };
|
||||
LayoutProperty<std::vector<std::string>> textFont { { "Open Sans Regular", "Arial Unicode MS Regular" } };
|
||||
LayoutProperty<float> textSize { 16 };
|
||||
|
||||
@@ -79,7 +79,7 @@ MBGL_DEFINE_ENUM(TextTransformType, {
|
||||
MBGL_DEFINE_ENUM(AlignmentType, {
|
||||
{ AlignmentType::Map, "map" },
|
||||
{ AlignmentType::Viewport, "viewport" },
|
||||
{ AlignmentType::Undefined, "undefined" },
|
||||
{ AlignmentType::Auto, "auto" },
|
||||
});
|
||||
|
||||
MBGL_DEFINE_ENUM(IconTextFitType, {
|
||||
|
||||
Reference in New Issue
Block a user