summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/style/conversion/constant.hpp5
-rw-r--r--include/mbgl/style/expression/value.hpp7
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp6
-rw-r--r--include/mbgl/style/types.hpp7
m---------mapbox-gl-js0
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java10
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java2
-rw-r--r--platform/android/src/conversion/constant.hpp4
-rwxr-xr-xscripts/generate-style-code.js3
-rw-r--r--scripts/style-spec.js1
-rw-r--r--src/mbgl/layout/symbol_instance.cpp2
-rw-r--r--src/mbgl/layout/symbol_instance.hpp4
-rw-r--r--src/mbgl/layout/symbol_layout.cpp45
-rw-r--r--src/mbgl/layout/symbol_layout.hpp2
-rw-r--r--src/mbgl/style/conversion/constant.cpp18
-rw-r--r--src/mbgl/style/conversion/function.cpp4
-rw-r--r--src/mbgl/style/conversion/property_value.cpp1
-rw-r--r--src/mbgl/style/expression/value.cpp20
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp25
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.hpp4
-rw-r--r--src/mbgl/text/placement.cpp4
-rw-r--r--src/mbgl/text/placement.hpp2
-rw-r--r--test/text/cross_tile_symbol_index.test.cpp2
24 files changed, 139 insertions, 45 deletions
diff --git a/include/mbgl/style/conversion/constant.hpp b/include/mbgl/style/conversion/constant.hpp
index 3a5833be64..f82029c885 100644
--- a/include/mbgl/style/conversion/constant.hpp
+++ b/include/mbgl/style/conversion/constant.hpp
@@ -59,6 +59,11 @@ struct Converter<std::vector<std::string>> {
optional<std::vector<std::string>> operator()(const Convertible& value, Error& error) const;
};
+template <>
+struct Converter<RadialOffsetType> {
+ optional<RadialOffsetType> operator()(const Convertible& value, Error& error) const;
+};
+
} // namespace conversion
} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/expression/value.hpp b/include/mbgl/style/expression/value.hpp
index 91239d083f..5cb0535184 100644
--- a/include/mbgl/style/expression/value.hpp
+++ b/include/mbgl/style/expression/value.hpp
@@ -114,6 +114,13 @@ struct ValueConverter<std::vector<T>> {
};
template <>
+struct ValueConverter<RadialOffsetType> {
+ static type::Type expressionType() { return type::Array(type::Number); }
+ static Value toExpressionValue(const mbgl::style::RadialOffsetType& value);
+ static optional<RadialOffsetType> fromExpressionValue(const Value& v);
+};
+
+template <>
struct ValueConverter<Position> {
static type::Type expressionType() { return type::Array(type::Number, 3); }
static Value toExpressionValue(const mbgl::style::Position& value);
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index 2493df6046..ee0c91fd14 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -162,9 +162,9 @@ public:
const PropertyValue<AlignmentType>& getTextPitchAlignment() const;
void setTextPitchAlignment(const PropertyValue<AlignmentType>&);
- static PropertyValue<float> getDefaultTextRadialOffset();
- const PropertyValue<float>& getTextRadialOffset() const;
- void setTextRadialOffset(const PropertyValue<float>&);
+ static PropertyValue<RadialOffsetType> getDefaultTextRadialOffset();
+ const PropertyValue<RadialOffsetType>& getTextRadialOffset() const;
+ void setTextRadialOffset(const PropertyValue<RadialOffsetType>&);
static PropertyValue<float> getDefaultTextRotate();
const PropertyValue<float>& getTextRotate() const;
diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp
index 13a2e50f01..06e549e37d 100644
--- a/include/mbgl/style/types.hpp
+++ b/include/mbgl/style/types.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
+#include <vector>
namespace mbgl {
@@ -120,5 +121,11 @@ enum class LightAnchorType: bool {
Viewport
};
+class RadialOffsetType: public std::vector<float> {
+public:
+ template <typename... Args>
+ RadialOffsetType(Args&&... args) : std::vector<float>(std::forward<Args>(args)...) {}
+};
+
} // namespace style
} // namespace mbgl
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject 3abd5d518bade8d83eb609598b861432a83f869
+Subproject 6d54ca68702ab1db707f372d0f7b49ddcd1fadf
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
index 3f2771a307..dc35fb85cc 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java
@@ -2298,18 +2298,18 @@ public class PropertyFactory {
/**
* Radial offset of text, in the direction of the symbol's anchor. Useful in combination with {@link PropertyFactory#textVariableAnchor}, which doesn't support the two-dimensional {@link PropertyFactory#textOffset}.
*
- * @param value a Float value
- * @return property wrapper around Float
+ * @param value a Float[] value
+ * @return property wrapper around Float[]
*/
- public static PropertyValue<Float> textRadialOffset(Float value) {
+ public static PropertyValue<Float[]> textRadialOffset(Float[] value) {
return new LayoutPropertyValue<>("text-radial-offset", value);
}
/**
* Radial offset of text, in the direction of the symbol's anchor. Useful in combination with {@link PropertyFactory#textVariableAnchor}, which doesn't support the two-dimensional {@link PropertyFactory#textOffset}.
*
- * @param value a Float value
- * @return property wrapper around Float
+ * @param value a Float[] value
+ * @return property wrapper around Float[]
*/
public static PropertyValue<Expression> textRadialOffset(Expression value) {
return new LayoutPropertyValue<>("text-radial-offset", value);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
index 1d8bad7e8e..89d1ffd0cc 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
@@ -484,13 +484,13 @@ public class SymbolLayer extends Layer {
/**
* Get the TextRadialOffset property
*
- * @return property wrapper value around Float
+ * @return property wrapper value around Float[]
*/
@NonNull
@SuppressWarnings("unchecked")
- public PropertyValue<Float> getTextRadialOffset() {
+ public PropertyValue<Float[]> getTextRadialOffset() {
checkThread();
- return (PropertyValue<Float>) new PropertyValue("text-radial-offset", nativeGetTextRadialOffset());
+ return (PropertyValue<Float[]>) new PropertyValue("text-radial-offset", nativeGetTextRadialOffset());
}
/**
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
index 60e305d607..515962e325 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
@@ -611,7 +611,7 @@ public class SymbolLayerTest extends BaseLayerTest {
assertNull(layer.getTextRadialOffset().getValue());
// Set and Get
- Float propertyValue = 0.3f;
+ Float[] propertyValue = new Float[] {};
layer.setProperties(textRadialOffset(propertyValue));
assertEquals(layer.getTextRadialOffset().getValue(), propertyValue);
}
diff --git a/platform/android/src/conversion/constant.hpp b/platform/android/src/conversion/constant.hpp
index 839e6e84dc..298fb7faa1 100644
--- a/platform/android/src/conversion/constant.hpp
+++ b/platform/android/src/conversion/constant.hpp
@@ -81,6 +81,10 @@ struct Converter<jni::Local<jni::Object<>>, std::vector<float>> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::vector<float>& value) const;
};
+template <>
+struct Converter<jni::Local<jni::Object<>>, style::RadialOffsetType> : public Converter<jni::Local<jni::Object<>>, std::vector<float>> {
+};
+
template <class T>
struct Converter<jni::Local<jni::Object<>>, T, typename std::enable_if_t<std::is_enum<T>::value>> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const T& value) const {
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js
index 1f26e6fd86..04ace18354 100755
--- a/scripts/generate-style-code.js
+++ b/scripts/generate-style-code.js
@@ -60,6 +60,9 @@ global.evaluatedType = function (property) {
if (/position/.test(property.name)) {
return 'Position';
}
+ if (/-radial-offset/.test(property.name)) {
+ return 'RadialOffsetType';
+ }
switch (property.type) {
case 'boolean':
return 'bool';
diff --git a/scripts/style-spec.js b/scripts/style-spec.js
index 8a9c9d4144..3d7ea605d5 100644
--- a/scripts/style-spec.js
+++ b/scripts/style-spec.js
@@ -1 +1,2 @@
var spec = module.exports = require('../mapbox-gl-js/src/style-spec/reference/v8');
+delete spec.layout_symbol['text-writing-mode'];
diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp
index 133cdec698..da26c26b59 100644
--- a/src/mbgl/layout/symbol_instance.cpp
+++ b/src/mbgl/layout/symbol_instance.cpp
@@ -81,7 +81,7 @@ SymbolInstance::SymbolInstance(Anchor& anchor_,
std::u16string key_,
const float overscaling,
const float rotate,
- float radialTextOffset_) :
+ Point<float> radialTextOffset_) :
sharedData(std::move(sharedData_)),
anchor(anchor_),
// 'hasText' depends on finding at least one glyph in the shaping that's also in the GlyphPositionMap
diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp
index 48bb2f0cbc..c0fe5177cf 100644
--- a/src/mbgl/layout/symbol_instance.hpp
+++ b/src/mbgl/layout/symbol_instance.hpp
@@ -59,7 +59,7 @@ public:
std::u16string key,
const float overscaling,
const float rotate,
- float radialTextOffset);
+ Point<float> radialTextOffset);
optional<size_t> getDefaultHorizontalPlacedTextIndex() const;
const GeometryCoordinates& line() const;
@@ -98,7 +98,7 @@ public:
optional<size_t> placedVerticalTextIndex;
optional<size_t> placedIconIndex;
float textBoxScale;
- float radialTextOffset;
+ Point<float> radialTextOffset;
bool singleLine;
uint32_t crossTileID = 0;
};
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index d269ca4144..6548281a06 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -225,26 +225,27 @@ Shaping& shapingForTextJustifyType(ShapedTextOrientations& shapedTextOrientation
} // namespace
// static
-Point<float> SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, float radialOffset) {
+Point<float> SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, Point<float> radialOffset) {
Point<float> result{};
// solve for r where r^2 + r^2 = radialOffset^2
const float sqrt2 = 1.41421356237f;
- const float hypotenuse = radialOffset / sqrt2;
+ const float hypotenuseX = radialOffset.x / sqrt2;
+ const float hypotenuseY = radialOffset.y / sqrt2;
switch (anchor) {
case SymbolAnchorType::TopRight:
case SymbolAnchorType::TopLeft:
- result.y = hypotenuse - baselineOffset;
+ result.y = hypotenuseY - baselineOffset;
break;
case SymbolAnchorType::BottomRight:
case SymbolAnchorType::BottomLeft:
- result.y = -hypotenuse + baselineOffset;
+ result.y = -hypotenuseY + baselineOffset;
break;
case SymbolAnchorType::Bottom:
- result.y = -radialOffset + baselineOffset;
+ result.y = -radialOffset.y + baselineOffset;
break;
case SymbolAnchorType::Top:
- result.y = radialOffset - baselineOffset;
+ result.y = radialOffset.y - baselineOffset;
break;
default:
break;
@@ -253,17 +254,17 @@ Point<float> SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, float r
switch (anchor) {
case SymbolAnchorType::TopRight:
case SymbolAnchorType::BottomRight:
- result.x = -hypotenuse;
+ result.x = -hypotenuseX;
break;
case SymbolAnchorType::TopLeft:
case SymbolAnchorType::BottomLeft:
- result.x = hypotenuse;
+ result.x = hypotenuseX;
break;
case SymbolAnchorType::Left:
- result.x = radialOffset;
+ result.x = radialOffset.x;
break;
case SymbolAnchorType::Right:
- result.x = -radialOffset;
+ result.x = -radialOffset.x;
break;
default:
break;
@@ -272,6 +273,22 @@ Point<float> SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, float r
return result;
}
+namespace {
+
+Point<float> handleRadialTextOffset(const std::vector<float>& value) {
+ switch (value.size())
+ {
+ case 0:
+ return { 0.0f, 0.0f };
+ case 1:
+ return { value[0] * util::ONE_EM, value[0] * util::ONE_EM };
+ default:
+ return { value[0] * util::ONE_EM, value[1] * util::ONE_EM };
+ };
+}
+
+} // namespace
+
void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions& glyphPositions,
const ImageMap& imageMap, const ImagePositions& imagePositions) {
const bool isPointPlacement = layout->get<SymbolPlacement>() == SymbolPlacementType::Point;
@@ -306,15 +323,15 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions
return result;
};
const std::vector<style::TextVariableAnchorType> variableTextAnchor = layout->evaluate<TextVariableAnchor>(zoom, feature);
- const float radialOffset = layout->evaluate<TextRadialOffset>(zoom, feature);
+ const Point<float> radialOffset = handleRadialTextOffset(layout->evaluate<TextRadialOffset>(zoom, feature));
const SymbolAnchorType textAnchor = layout->evaluate<TextAnchor>(zoom, feature);
if (variableTextAnchor.empty()) {
// Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector
// is calculated at placement time instead of layout time
- if (radialOffset > 0.0f) {
+ if (radialOffset.x > 0.0f && radialOffset.y > 0.0f) {
// The style spec says don't use `text-offset` and `text-radial-offset` together
// but doesn't actually specify what happens if you use both. We go with the radial offset.
- textOffset = evaluateRadialOffset(textAnchor, radialOffset * util::ONE_EM);
+ textOffset = evaluateRadialOffset(textAnchor, radialOffset);
} else {
textOffset = { layout->evaluate<TextOffset>(zoom, feature)[0] * util::ONE_EM,
layout->evaluate<TextOffset>(zoom, feature)[1] * util::ONE_EM};
@@ -424,7 +441,7 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex,
const float iconPadding = layout->get<IconPadding>() * tilePixelRatio;
const float textMaxAngle = layout->get<TextMaxAngle>() * util::DEG2RAD;
const float rotation = layout->evaluate<IconRotate>(zoom, feature);
- const float radialTextOffset = layout->evaluate<TextRadialOffset>(zoom, feature) * util::ONE_EM;
+ const Point<float> radialTextOffset = handleRadialTextOffset(layout->evaluate<TextRadialOffset>(zoom, feature));
const SymbolPlacementType textPlacement = layout->get<TextRotationAlignment>() != AlignmentType::Map
? SymbolPlacementType::Point
: layout->get<SymbolPlacement>();
diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp
index 581c3ccb04..82bbc1179b 100644
--- a/src/mbgl/layout/symbol_layout.hpp
+++ b/src/mbgl/layout/symbol_layout.hpp
@@ -45,7 +45,7 @@ public:
const std::string bucketLeaderID;
std::vector<SymbolInstance> symbolInstances;
- static Point<float> evaluateRadialOffset(style::SymbolAnchorType anchor, float radialOffset);
+ static Point<float> evaluateRadialOffset(style::SymbolAnchorType anchor, Point<float> radialOffset);
private:
void addFeature(const size_t,
diff --git a/src/mbgl/style/conversion/constant.cpp b/src/mbgl/style/conversion/constant.cpp
index 0fcaab433b..0ed5fad425 100644
--- a/src/mbgl/style/conversion/constant.cpp
+++ b/src/mbgl/style/conversion/constant.cpp
@@ -168,6 +168,24 @@ optional<std::vector<std::string>> Converter<std::vector<std::string>>::operator
return result;
}
+optional<RadialOffsetType> Converter<RadialOffsetType>::operator()(const Convertible& value, Error& error) const {
+ Converter<std::vector<float>> arrayConverter;
+ if (auto val = arrayConverter(value, error)) {
+ RadialOffsetType result = std::move(*val);
+ return result;
+ }
+
+ Converter<float> numberConverter;
+ if (auto val = numberConverter(value, error)) {
+ RadialOffsetType result(2, *val);
+ return result;
+ }
+
+ error.message = "value must be an array of numbers or a number";
+
+ return nullopt;
+}
+
} // namespace conversion
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/conversion/function.cpp b/src/mbgl/style/conversion/function.cpp
index 086bc4e277..ade5a5dc5e 100644
--- a/src/mbgl/style/conversion/function.cpp
+++ b/src/mbgl/style/conversion/function.cpp
@@ -153,6 +153,10 @@ template optional<PropertyExpression<TranslateAnchorType>>
template optional<PropertyExpression<Formatted>>
convertFunctionToExpression<Formatted>(const Convertible&, Error&, bool);
+template optional<PropertyExpression<RadialOffsetType>>
+ convertFunctionToExpression<RadialOffsetType>(const Convertible&, Error&, bool);
+
+
// Ad-hoc Converters for double and int64_t. We should replace float with double wholesale,
// and promote the int64_t Converter to general use (and it should check that the input is
// an integer).
diff --git a/src/mbgl/style/conversion/property_value.cpp b/src/mbgl/style/conversion/property_value.cpp
index 6e1d747324..91e61ec5cb 100644
--- a/src/mbgl/style/conversion/property_value.cpp
+++ b/src/mbgl/style/conversion/property_value.cpp
@@ -80,6 +80,7 @@ template optional<PropertyValue<TextJustifyType>> Converter<PropertyValue<TextJu
template optional<PropertyValue<TextTransformType>> Converter<PropertyValue<TextTransformType>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const;
template optional<PropertyValue<TranslateAnchorType>> Converter<PropertyValue<TranslateAnchorType>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const;
template optional<PropertyValue<mbgl::style::expression::Formatted>> Converter<PropertyValue<mbgl::style::expression::Formatted>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const;
+template optional<PropertyValue<RadialOffsetType>> Converter<PropertyValue<RadialOffsetType>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const;
} // namespace conversion
} // namespace style
diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp
index 7e11efaa09..6fce98e4d6 100644
--- a/src/mbgl/style/expression/value.cpp
+++ b/src/mbgl/style/expression/value.cpp
@@ -276,6 +276,22 @@ optional<Position> ValueConverter<Position>::fromExpressionValue(const Value& v)
return pos ? optional<Position>(Position(*pos)) : optional<Position>();
}
+Value ValueConverter<RadialOffsetType>::toExpressionValue(const mbgl::style::RadialOffsetType& value) {
+ return ValueConverter<std::vector<float>>::toExpressionValue(value);
+}
+
+optional<RadialOffsetType> ValueConverter<RadialOffsetType>::fromExpressionValue(const Value& v) {
+ if (auto val = ValueConverter<std::vector<float>>::fromExpressionValue(v)) {
+ RadialOffsetType result(std::move(*val));
+ return result;
+ }
+ if (auto val = ValueConverter<float>::fromExpressionValue(v)) {
+ RadialOffsetType result(2, *val);
+ return result;
+ }
+ return nullopt;
+}
+
template <typename T>
Value ValueConverter<T, std::enable_if_t< std::is_enum<T>::value >>::toExpressionValue(const T& value) {
return std::string(Enum<T>::toString(value));
@@ -374,6 +390,10 @@ template struct ValueConverter<HillshadeIlluminationAnchorType>;
template type::Type valueTypeToExpressionType<LightAnchorType>();
template struct ValueConverter<LightAnchorType>;
+template<> type::Type valueTypeToExpressionType<RadialOffsetType>() {
+ return valueTypeToExpressionType<std::vector<float>>();
+}
+
} // namespace expression
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 6748fbd4aa..c5a32acd12 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -605,15 +605,15 @@ void SymbolLayer::setTextPitchAlignment(const PropertyValue<AlignmentType>& valu
baseImpl = std::move(impl_);
observer->onLayerChanged(*this);
}
-PropertyValue<float> SymbolLayer::getDefaultTextRadialOffset() {
+PropertyValue<RadialOffsetType> SymbolLayer::getDefaultTextRadialOffset() {
return TextRadialOffset::defaultValue();
}
-const PropertyValue<float>& SymbolLayer::getTextRadialOffset() const {
+const PropertyValue<RadialOffsetType>& SymbolLayer::getTextRadialOffset() const {
return impl().layout.get<TextRadialOffset>();
}
-void SymbolLayer::setTextRadialOffset(const PropertyValue<float>& value) {
+void SymbolLayer::setTextRadialOffset(const PropertyValue<RadialOffsetType>& value) {
if (value == getTextRadialOffset())
return;
auto impl_ = mutableImpl();
@@ -1606,7 +1606,7 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
}
- if (property == Property::IconRotate || property == Property::IconSize || property == Property::SymbolSortKey || property == Property::TextLetterSpacing || property == Property::TextMaxWidth || property == Property::TextRadialOffset || property == Property::TextRotate || property == Property::TextSize) {
+ if (property == Property::IconRotate || property == Property::IconSize || property == Property::SymbolSortKey || property == Property::TextLetterSpacing || property == Property::TextMaxWidth || property == Property::TextRotate || property == Property::TextSize) {
Error error;
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
if (!typedValue) {
@@ -1638,11 +1638,6 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
return nullopt;
}
- if (property == Property::TextRadialOffset) {
- setTextRadialOffset(*typedValue);
- return nullopt;
- }
-
if (property == Property::TextRotate) {
setTextRotate(*typedValue);
return nullopt;
@@ -1739,6 +1734,18 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
}
+ if (property == Property::TextRadialOffset) {
+ Error error;
+ optional<PropertyValue<RadialOffsetType>> typedValue = convert<PropertyValue<RadialOffsetType>>(value, error, true, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ setTextRadialOffset(*typedValue);
+ return nullopt;
+
+ }
+
if (property == Property::TextTransform) {
Error error;
optional<PropertyValue<TextTransformType>> typedValue = convert<PropertyValue<TextTransformType>>(value, error, true, false);
diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp
index 0c2bcd2661..4215819abe 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.hpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.hpp
@@ -184,9 +184,9 @@ struct TextPitchAlignment : LayoutProperty<AlignmentType> {
static AlignmentType defaultValue() { return AlignmentType::Auto; }
};
-struct TextRadialOffset : DataDrivenLayoutProperty<float> {
+struct TextRadialOffset : DataDrivenLayoutProperty<RadialOffsetType> {
static constexpr const char *name() { return "text-radial-offset"; }
- static float defaultValue() { return 0; }
+ static RadialOffsetType defaultValue() { return { 0, 0 }; }
};
struct TextRotate : DataDrivenLayoutProperty<float> {
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index f7d13dcb26..c28842069a 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -85,7 +85,7 @@ void Placement::placeLayer(const RenderLayer& layer, const mat4& projMatrix, boo
}
namespace {
-Point<float> calculateVariableLayoutOffset(style::SymbolAnchorType anchor, float width, float height, float radialOffset, float textBoxScale) {
+Point<float> calculateVariableLayoutOffset(style::SymbolAnchorType anchor, float width, float height, Point<float> radialOffset, float textBoxScale) {
AnchorAlignment alignment = AnchorAlignment::getAnchorAlignment(anchor);
float shiftX = -(alignment.horizontalAlign - 0.5f) * width;
float shiftY = -(alignment.verticalAlign - 0.5f) * height;
@@ -410,7 +410,7 @@ void Placement::updateLayerBuckets(const RenderLayer& layer, const TransformStat
}
namespace {
-Point<float> calculateVariableRenderShift(style::SymbolAnchorType anchor, float width, float height, float radialOffset, float textBoxScale, float renderTextSize) {
+Point<float> calculateVariableRenderShift(style::SymbolAnchorType anchor, float width, float height, Point<float> radialOffset, float textBoxScale, float renderTextSize) {
AnchorAlignment alignment = AnchorAlignment::getAnchorAlignment(anchor);
float shiftX = -(alignment.horizontalAlign - 0.5f) * width;
float shiftY = -(alignment.verticalAlign - 0.5f) * height;
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index 2a6a2e1d6e..6a372c1a58 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -33,7 +33,7 @@ public:
class VariableOffset {
public:
- float radialOffset;
+ Point<float> radialOffset;
float width;
float height;
style::TextVariableAnchorType anchor;
diff --git a/test/text/cross_tile_symbol_index.test.cpp b/test/text/cross_tile_symbol_index.test.cpp
index 7cef287b00..e0979b8835 100644
--- a/test/text/cross_tile_symbol_index.test.cpp
+++ b/test/text/cross_tile_symbol_index.test.cpp
@@ -18,7 +18,7 @@ SymbolInstance makeSymbolInstance(float x, float y, std::u16string key) {
auto sharedData = std::make_shared<SymbolInstanceSharedData>(std::move(line),
shaping, nullopt, layout_, 0.0f, placementType,
textOffset, positions);
- return SymbolInstance(anchor, std::move(sharedData), shaping, nullopt, 0, 0, placementType, textOffset, 0, 0, iconOffset, subfeature, 0, 0, key, 0, 0, 0.0f);
+ return SymbolInstance(anchor, std::move(sharedData), shaping, nullopt, 0, 0, placementType, textOffset, 0, 0, iconOffset, subfeature, 0, 0, key, 0, 0, Point<float>());
}