summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoung Hahn <young@mapbox.com>2016-09-21 19:07:33 -0400
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-09-21 16:07:33 -0700
commit6a2ce352d1eec6dc166e351e06c6b10c633eb07c (patch)
tree58e5682522a544cd9db5c1052d538148565be9da
parent673d8f90f24a89871905e80ef1bfd7970e61dc6c (diff)
downloadqtlocation-mapboxgl-6a2ce352d1eec6dc166e351e06c6b10c633eb07c.tar.gz
Better handling for undefined icon|text-rotation-alignment (#6253)
* [core, ios, android] Use `auto` value for properties with calculated defaults * Fix render tests
-rw-r--r--include/mbgl/style/types.hpp2
-rw-r--r--package.json4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java6
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java16
-rw-r--r--platform/android/src/style/conversion/types_string_values.hpp3
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.h2
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer.h15
-rw-r--r--platform/darwin/test/MGLSymbolStyleLayerTests.m24
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp6
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.cpp24
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.hpp6
-rw-r--r--src/mbgl/style/types.cpp2
12 files changed, 67 insertions, 43 deletions
diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp
index 34e5642ec6..1f2f5c3105 100644
--- a/include/mbgl/style/types.hpp
+++ b/include/mbgl/style/types.hpp
@@ -58,7 +58,7 @@ enum class SymbolPlacementType : bool {
enum class AlignmentType : uint8_t {
Map,
Viewport,
- Undefined,
+ Auto,
};
enum class TextJustifyType : uint8_t {
diff --git a/package.json b/package.json
index 992092866d..6b2a9f6d1e 100644
--- a/package.json
+++ b/package.json
@@ -21,8 +21,8 @@
"ejs": "^2.4.1",
"express": "^4.11.1",
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#de2ab007455aa2587c552694c68583f94c9f2747",
- "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#83b1a3e5837d785af582efd5ed1a212f2df6a4ae",
- "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#5b2e5749e85ad4241b5b4e4e54d2fa98e8920f34",
+ "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#a6c95d33ff5ced2c0d7df995fd89eb557c0a353c",
+ "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#e05680a27f93d7284fce31b9b42a19c80df96b13",
"mkdirp": "^0.5.1",
"node-cmake": "^1.2.1",
"request": "^2.72.0",
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
index a31f1adb54..bae91313a6 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
@@ -62,10 +62,12 @@ public abstract class Property<T> {
//icon-rotation-alignment
public static final String ICON_ROTATION_ALIGNMENT_MAP = "map";
public static final String ICON_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
+ public static final String ICON_ROTATION_ALIGNMENT_AUTO = "auto";
@StringDef({
ICON_ROTATION_ALIGNMENT_MAP,
ICON_ROTATION_ALIGNMENT_VIEWPORT,
+ ICON_ROTATION_ALIGNMENT_AUTO,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ICON_ROTATION_ALIGNMENT {}
@@ -88,10 +90,12 @@ public abstract class Property<T> {
//text-pitch-alignment
public static final String TEXT_PITCH_ALIGNMENT_MAP = "map";
public static final String TEXT_PITCH_ALIGNMENT_VIEWPORT = "viewport";
+ public static final String TEXT_PITCH_ALIGNMENT_AUTO = "auto";
@StringDef({
TEXT_PITCH_ALIGNMENT_MAP,
TEXT_PITCH_ALIGNMENT_VIEWPORT,
+ TEXT_PITCH_ALIGNMENT_AUTO,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TEXT_PITCH_ALIGNMENT {}
@@ -99,10 +103,12 @@ public abstract class Property<T> {
//text-rotation-alignment
public static final String TEXT_ROTATION_ALIGNMENT_MAP = "map";
public static final String TEXT_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
+ public static final String TEXT_ROTATION_ALIGNMENT_AUTO = "auto";
@StringDef({
TEXT_ROTATION_ALIGNMENT_MAP,
TEXT_ROTATION_ALIGNMENT_VIEWPORT,
+ TEXT_ROTATION_ALIGNMENT_AUTO,
})
@Retention(RetentionPolicy.SOURCE)
public @interface TEXT_ROTATION_ALIGNMENT {}
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 4d4a924dab..e360831d0a 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
@@ -322,7 +322,7 @@ public class PropertyFactory {
}
/**
- * The line's offset perpendicular to its direction. Values may be positive or negative, where positive indicates "rightwards" (if you were moving in the direction of the line) and negative indicates "leftwards."
+ * The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset.
*
* @param value a Float value
* @return property wrapper around Float
@@ -332,7 +332,7 @@ public class PropertyFactory {
}
/**
- * The line's offset perpendicular to its direction. Values may be positive or negative, where positive indicates "rightwards" (if you were moving in the direction of the line) and negative indicates "leftwards."
+ * The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset.
*
* @param function a wrapper function for Float
* @return property wrapper around a Float function
@@ -1282,7 +1282,7 @@ public class PropertyFactory {
}
/**
- * Orientation of icon when map is rotated.
+ * Orientation of icon when map is rotated. Aligns icon to the plane of the viewport when set to `viewport` or the plane of the map when set to `map`. Selecting `auto` defaults to `map` for line placement and `viewport` for symbol placement
*
* @param value a String value
* @return property wrapper around String
@@ -1292,7 +1292,7 @@ public class PropertyFactory {
}
/**
- * Orientation of icon when map is rotated.
+ * Orientation of icon when map is rotated. Aligns icon to the plane of the viewport when set to `viewport` or the plane of the map when set to `map`. Selecting `auto` defaults to `map` for line placement and `viewport` for symbol placement
*
* @param function a wrapper function for String
* @return property wrapper around a String function
@@ -1462,7 +1462,7 @@ public class PropertyFactory {
}
/**
- * Aligns text to the plane of the `viewport` or the `map` when the map is pitched. Matches `text-rotation-alignment` if unspecified.
+ * Orientation of text when map is pitched. Aligns text to the plane of the viewport when set to `viewport` or the plane of the map when set to `map`. Matches `text-rotation-alignment` if `auto`.
*
* @param value a String value
* @return property wrapper around String
@@ -1472,7 +1472,7 @@ public class PropertyFactory {
}
/**
- * Aligns text to the plane of the `viewport` or the `map` when the map is pitched. Matches `text-rotation-alignment` if unspecified.
+ * Orientation of text when map is pitched. Aligns text to the plane of the viewport when set to `viewport` or the plane of the map when set to `map`. Matches `text-rotation-alignment` if `auto`.
*
* @param function a wrapper function for String
* @return property wrapper around a String function
@@ -1482,7 +1482,7 @@ public class PropertyFactory {
}
/**
- * Orientation of text when map is rotated.
+ * Orientation of text when map is rotated. Aligns text to the plane of the viewport when set to `viewport` or the plane of the map when set to `map`. Selecting `auto` defaults to the plane of the `map` for line placement and the `viewport` for symbol placement.
*
* @param value a String value
* @return property wrapper around String
@@ -1492,7 +1492,7 @@ public class PropertyFactory {
}
/**
- * Orientation of text when map is rotated.
+ * Orientation of text when map is rotated. Aligns text to the plane of the viewport when set to `viewport` or the plane of the map when set to `map`. Selecting `auto` defaults to the plane of the `map` for line placement and the `viewport` for symbol placement.
*
* @param function a wrapper function for String
* @return property wrapper around a String function
diff --git a/platform/android/src/style/conversion/types_string_values.hpp b/platform/android/src/style/conversion/types_string_values.hpp
index 35cdb1cbc9..d44de733d4 100644
--- a/platform/android/src/style/conversion/types_string_values.hpp
+++ b/platform/android/src/style/conversion/types_string_values.hpp
@@ -81,6 +81,9 @@ namespace conversion {
case mbgl::style::AlignmentType::Viewport:
return "viewport";
break;
+ case mbgl::style::AlignmentType::Auto:
+ return "auto";
+ break;
default:
throw std::runtime_error("Not implemented");
}
diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h
index 34f8e74dfa..ec338f65b6 100644
--- a/platform/darwin/src/MGLLineStyleLayer.h
+++ b/platform/darwin/src/MGLLineStyleLayer.h
@@ -138,7 +138,7 @@ typedef NS_ENUM(NSUInteger, MGLLineStyleLayerLineTranslateAnchor) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> lineGapWidth;
/**
- The line's offset perpendicular to its direction. Values may be positive or negative, where positive indicates "rightwards" (if you were moving in the direction of the line) and negative indicates "leftwards."
+ The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset.
This property is measured in points.
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h
index c900518b9b..75fe2c1213 100644
--- a/platform/darwin/src/MGLSymbolStyleLayer.h
+++ b/platform/darwin/src/MGLSymbolStyleLayer.h
@@ -14,6 +14,7 @@ typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerSymbolPlacement) {
typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerIconRotationAlignment) {
MGLSymbolStyleLayerIconRotationAlignmentMap,
MGLSymbolStyleLayerIconRotationAlignmentViewport,
+ MGLSymbolStyleLayerIconRotationAlignmentAuto,
};
typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerIconTextFit) {
@@ -26,11 +27,13 @@ typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerIconTextFit) {
typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextPitchAlignment) {
MGLSymbolStyleLayerTextPitchAlignmentMap,
MGLSymbolStyleLayerTextPitchAlignmentViewport,
+ MGLSymbolStyleLayerTextPitchAlignmentAuto,
};
typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextRotationAlignment) {
MGLSymbolStyleLayerTextRotationAlignmentMap,
MGLSymbolStyleLayerTextRotationAlignmentViewport,
+ MGLSymbolStyleLayerTextRotationAlignmentAuto,
};
typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextJustify) {
@@ -137,9 +140,9 @@ typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextTranslateAnchor) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> iconOptional;
/**
- Orientation of icon when map is rotated.
+ Orientation of icon when map is rotated. Aligns icon to the plane of the viewport when set to `MGLSymbolStyleLayerIconRotationAlignmentViewport` or the plane of the map when set to `MGLSymbolStyleLayerIconRotationAlignmentMap`. Selecting `MGLSymbolStyleLayerIconRotationAlignmentAuto` defaults to `MGLSymbolStyleLayerIconRotationAlignmentMap` for line placement and `MGLSymbolStyleLayerIconRotationAlignmentViewport` for symbol placement
- The default value of this property is an `NSValue` object containing `MGLSymbolStyleLayerIconRotationAlignmentViewport`. Set this property to `nil` to reset it to the default value.
+ The default value of this property is an `NSValue` object containing `MGLSymbolStyleLayerIconRotationAlignmentAuto`. Set this property to `nil` to reset it to the default value.
This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored.
*/
@@ -220,16 +223,18 @@ typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerTextTranslateAnchor) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> iconOffset;
/**
- Aligns text to the plane of the `MGLSymbolStyleLayerTextPitchAlignmentViewport` or the `MGLSymbolStyleLayerTextPitchAlignmentMap` when the map is pitched. Matches `textRotationAlignment` if unspecified.
+ Orientation of text when map is pitched. Aligns text to the plane of the viewport when set to `MGLSymbolStyleLayerTextPitchAlignmentViewport` or the plane of the map when set to `MGLSymbolStyleLayerTextPitchAlignmentMap`. Matches `textRotationAlignment` if `MGLSymbolStyleLayerTextPitchAlignmentAuto`.
+
+ The default value of this property is an `NSValue` object containing `MGLSymbolStyleLayerTextPitchAlignmentAuto`. Set this property to `nil` to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored.
*/
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> textPitchAlignment;
/**
- Orientation of text when map is rotated.
+ Orientation of text when map is rotated. Aligns text to the plane of the viewport when set to `MGLSymbolStyleLayerTextRotationAlignmentViewport` or the plane of the map when set to `MGLSymbolStyleLayerTextRotationAlignmentMap`. Selecting `MGLSymbolStyleLayerTextRotationAlignmentAuto` defaults to the plane of the `MGLSymbolStyleLayerTextRotationAlignmentMap` for line placement and the `MGLSymbolStyleLayerTextRotationAlignmentViewport` for symbol placement.
- The default value of this property is an `NSValue` object containing `MGLSymbolStyleLayerTextRotationAlignmentViewport`. Set this property to `nil` to reset it to the default value.
+ The default value of this property is an `NSValue` object containing `MGLSymbolStyleLayerTextRotationAlignmentAuto`. Set this property to `nil` to reset it to the default value.
This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored.
*/
diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.m b/platform/darwin/test/MGLSymbolStyleLayerTests.m
index dbd8f50482..deee9f47ed 100644
--- a/platform/darwin/test/MGLSymbolStyleLayerTests.m
+++ b/platform/darwin/test/MGLSymbolStyleLayerTests.m
@@ -22,7 +22,7 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie
layer.iconAllowOverlap = [MGLRuntimeStylingHelper testBool];
layer.iconIgnorePlacement = [MGLRuntimeStylingHelper testBool];
layer.iconOptional = [MGLRuntimeStylingHelper testBool];
- layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerIconRotationAlignment)];
+ layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)];
layer.iconSize = [MGLRuntimeStylingHelper testNumber];
layer.iconTextFit = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTextFitHeight type:@encode(MGLSymbolStyleLayerIconTextFit)];
layer.iconTextFitPadding = [MGLRuntimeStylingHelper testPadding];
@@ -31,8 +31,8 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie
layer.iconPadding = [MGLRuntimeStylingHelper testNumber];
layer.iconKeepUpright = [MGLRuntimeStylingHelper testBool];
layer.iconOffset = [MGLRuntimeStylingHelper testOffset];
- layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentViewport type:@encode(MGLSymbolStyleLayerTextPitchAlignment)];
- layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerTextRotationAlignment)];
+ layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)];
+ layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)];
layer.textField = [MGLRuntimeStylingHelper testString];
layer.textFont = [MGLRuntimeStylingHelper testFont];
layer.textSize = [MGLRuntimeStylingHelper testNumber];
@@ -72,7 +72,7 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie
XCTAssertEqualObjects(gLayer.iconAllowOverlap, [MGLRuntimeStylingHelper testBool]);
XCTAssertEqualObjects(gLayer.iconIgnorePlacement, [MGLRuntimeStylingHelper testBool]);
XCTAssertEqualObjects(gLayer.iconOptional, [MGLRuntimeStylingHelper testBool]);
- XCTAssert([(NSValue *)gLayer.iconRotationAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]], @"%@ is not equal to %@", gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]);
+ XCTAssert([(NSValue *)gLayer.iconRotationAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]], @"%@ is not equal to %@", gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]);
XCTAssertEqualObjects(gLayer.iconSize, [MGLRuntimeStylingHelper testNumber]);
XCTAssert([(NSValue *)gLayer.iconTextFit isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTextFitHeight type:@encode(MGLSymbolStyleLayerIconTextFit)]], @"%@ is not equal to %@", gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerIconTextFitHeight type:@encode(MGLSymbolStyleLayerIconTextFit)]);
XCTAssertEqualObjects(gLayer.iconTextFitPadding, [MGLRuntimeStylingHelper testPadding]);
@@ -81,8 +81,8 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie
XCTAssertEqualObjects(gLayer.iconPadding, [MGLRuntimeStylingHelper testNumber]);
XCTAssertEqualObjects(gLayer.iconKeepUpright, [MGLRuntimeStylingHelper testBool]);
XCTAssertEqualObjects(gLayer.iconOffset, [MGLRuntimeStylingHelper testOffset]);
- XCTAssert([(NSValue *)gLayer.textPitchAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentViewport type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]], @"%@ is not equal to %@", gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentViewport type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]);
- XCTAssert([(NSValue *)gLayer.textRotationAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]], @"%@ is not equal to %@", gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]);
+ XCTAssert([(NSValue *)gLayer.textPitchAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]], @"%@ is not equal to %@", gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]);
+ XCTAssert([(NSValue *)gLayer.textRotationAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]], @"%@ is not equal to %@", gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]);
XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testString]);
XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFont]);
XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumber]);
@@ -121,7 +121,7 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie
layer.iconAllowOverlap = [MGLRuntimeStylingHelper testBoolFunction];
layer.iconIgnorePlacement = [MGLRuntimeStylingHelper testBoolFunction];
layer.iconOptional = [MGLRuntimeStylingHelper testBoolFunction];
- layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerIconRotationAlignment)];
+ layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)];
layer.iconSize = [MGLRuntimeStylingHelper testNumberFunction];
layer.iconTextFit = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconTextFitHeight type:@encode(MGLSymbolStyleLayerIconTextFit)];
layer.iconTextFitPadding = [MGLRuntimeStylingHelper testPaddingFunction];
@@ -130,8 +130,8 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie
layer.iconPadding = [MGLRuntimeStylingHelper testNumberFunction];
layer.iconKeepUpright = [MGLRuntimeStylingHelper testBoolFunction];
layer.iconOffset = [MGLRuntimeStylingHelper testOffsetFunction];
- layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextPitchAlignmentViewport type:@encode(MGLSymbolStyleLayerTextPitchAlignment)];
- layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerTextRotationAlignment)];
+ layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)];
+ layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)];
layer.textField = [MGLRuntimeStylingHelper testStringFunction];
layer.textFont = [MGLRuntimeStylingHelper testFontFunction];
layer.textSize = [MGLRuntimeStylingHelper testNumberFunction];
@@ -170,7 +170,7 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie
XCTAssertEqualObjects(gLayer.iconAllowOverlap, [MGLRuntimeStylingHelper testBoolFunction]);
XCTAssertEqualObjects(gLayer.iconIgnorePlacement, [MGLRuntimeStylingHelper testBoolFunction]);
XCTAssertEqualObjects(gLayer.iconOptional, [MGLRuntimeStylingHelper testBoolFunction]);
- XCTAssertEqualObjects(gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]);
+ XCTAssertEqualObjects(gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerIconRotationAlignment)]);
XCTAssertEqualObjects(gLayer.iconSize, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerIconTextFitHeight type:@encode(MGLSymbolStyleLayerIconTextFit)]);
XCTAssertEqualObjects(gLayer.iconTextFitPadding, [MGLRuntimeStylingHelper testPaddingFunction]);
@@ -179,8 +179,8 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithLayerIdentifie
XCTAssertEqualObjects(gLayer.iconPadding, [MGLRuntimeStylingHelper testNumberFunction]);
XCTAssertEqualObjects(gLayer.iconKeepUpright, [MGLRuntimeStylingHelper testBoolFunction]);
XCTAssertEqualObjects(gLayer.iconOffset, [MGLRuntimeStylingHelper testOffsetFunction]);
- XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextPitchAlignmentViewport type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]);
- XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextRotationAlignmentViewport type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]);
+ XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextPitchAlignmentAuto type:@encode(MGLSymbolStyleLayerTextPitchAlignment)]);
+ XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolStyleLayerTextRotationAlignmentAuto type:@encode(MGLSymbolStyleLayerTextRotationAlignment)]);
XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testStringFunction]);
XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFontFunction]);
XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumberFunction]);
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index c9fd2c0988..6b4d7400da 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -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 {
diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp
index 1039951f5e..e85f3a90f9 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.cpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.cpp
@@ -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;
diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp
index e4560ab486..fefa0ae05e 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.hpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.hpp
@@ -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 };
diff --git a/src/mbgl/style/types.cpp b/src/mbgl/style/types.cpp
index be0b217134..bf2ba8a793 100644
--- a/src/mbgl/style/types.cpp
+++ b/src/mbgl/style/types.cpp
@@ -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, {