[android, ios, macos] Generate symbol-placement: line-center wrappers
This commit is contained in:
@@ -92,6 +92,10 @@ public final class Property {
|
||||
* The label is placed along the line of the geometry. Can only be used on LineString and Polygon geometries.
|
||||
*/
|
||||
public static final String SYMBOL_PLACEMENT_LINE = "line";
|
||||
/**
|
||||
* The label is placed at the center of the line of the geometry. Can only be used on LineString and Polygon geometries. Note that a single feature in a vector tile may contain multiple line geometries.
|
||||
*/
|
||||
public static final String SYMBOL_PLACEMENT_LINE_CENTER = "line-center";
|
||||
|
||||
/**
|
||||
* Label placement relative to its geometry.
|
||||
@@ -99,6 +103,7 @@ public final class Property {
|
||||
@StringDef({
|
||||
SYMBOL_PLACEMENT_POINT,
|
||||
SYMBOL_PLACEMENT_LINE,
|
||||
SYMBOL_PLACEMENT_LINE_CENTER,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SYMBOL_PLACEMENT {}
|
||||
@@ -106,7 +111,7 @@ public final class Property {
|
||||
// ICON_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of icons.
|
||||
|
||||
/**
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns icons east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns icon x-axes with the line.
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns icons east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE} or {@link Property#SYMBOL_PLACEMENT_LINE_CENTER}, aligns icon x-axes with the line.
|
||||
*/
|
||||
public static final String ICON_ROTATION_ALIGNMENT_MAP = "map";
|
||||
/**
|
||||
@@ -114,7 +119,7 @@ public final class Property {
|
||||
*/
|
||||
public static final String ICON_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
|
||||
/**
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_MAP}.
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE} or {@link Property#SYMBOL_PLACEMENT_LINE_CENTER}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_MAP}.
|
||||
*/
|
||||
public static final String ICON_ROTATION_ALIGNMENT_AUTO = "auto";
|
||||
|
||||
@@ -271,7 +276,7 @@ public final class Property {
|
||||
// TEXT_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text.
|
||||
|
||||
/**
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns text east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns text x-axes with the line.
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns text east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE} or {@link Property#SYMBOL_PLACEMENT_LINE_CENTER}, aligns text x-axes with the line.
|
||||
*/
|
||||
public static final String TEXT_ROTATION_ALIGNMENT_MAP = "map";
|
||||
/**
|
||||
@@ -279,7 +284,7 @@ public final class Property {
|
||||
*/
|
||||
public static final String TEXT_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
|
||||
/**
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_MAP}.
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE} or {@link Property#SYMBOL_PLACEMENT_LINE_CENTER}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_MAP}.
|
||||
*/
|
||||
public static final String TEXT_ROTATION_ALIGNMENT_AUTO = "auto";
|
||||
|
||||
|
||||
@@ -235,10 +235,15 @@ global.propertyValueDoc = function (property, value) {
|
||||
|
||||
// Match references to other property names & values.
|
||||
// Requires the format 'When `foo` is set to `bar`,'.
|
||||
let doc = property.values[value].doc.replace(/When `(.+?)` is set to `(.+?)`,/g, function (m, peerPropertyName, propertyValue, offset, str) {
|
||||
let doc = property.values[value].doc.replace(/When `(.+?)` is set to `(.+?)`(?: or `([^`]+?)`)?,/g, function (m, peerPropertyName, propertyValue, secondPropertyValue, offset, str) {
|
||||
let otherProperty = snakeCaseUpper(peerPropertyName);
|
||||
let otherValue = snakeCaseUpper(peerPropertyName) + '_' + snakeCaseUpper(propertyValue);
|
||||
return 'When {@link ' + `${otherProperty}` + '} is set to {@link Property#' + `${otherValue}` + '},';
|
||||
const firstPropertyValue = 'When {@link ' + `${otherProperty}` + '} is set to {@link Property#' + `${otherValue}` + '}';
|
||||
if (secondPropertyValue) {
|
||||
return firstPropertyValue + ` or {@link Property#${snakeCaseUpper(peerPropertyName) + '_' + snakeCaseUpper(secondPropertyValue)}},`;
|
||||
} else {
|
||||
return firstPropertyValue + ',';
|
||||
}
|
||||
});
|
||||
|
||||
// Match references to our own property values.
|
||||
|
||||
@@ -67,6 +67,9 @@ namespace conversion {
|
||||
case mbgl::style::SymbolPlacementType::Line:
|
||||
return "line";
|
||||
break;
|
||||
case mbgl::style::SymbolPlacementType::LineCenter:
|
||||
return "line-center";
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
@@ -248,13 +248,20 @@ global.testHelperMessage = function (property, layerType, isFunction) {
|
||||
global.propertyDoc = function (propertyName, property, layerType, kind) {
|
||||
// Match references to other property names & values.
|
||||
// Requires the format 'When `foo` is set to `bar`,'.
|
||||
let doc = property.doc.replace(/`([^`]+?)` is set to `([^`]+?)`/g, function (m, peerPropertyName, propertyValue, offset, str) {
|
||||
let doc = property.doc.replace(/`([^`]+?)` is set to `([^`]+?)`(?: or `([^`]+?)`)?/g, function (m, peerPropertyName, propertyValue, secondPropertyValue, offset, str) {
|
||||
let otherProperty = camelizeWithLeadingLowercase(peerPropertyName);
|
||||
let otherValue = objCType(layerType, peerPropertyName) + camelize(propertyValue);
|
||||
if (property.type == 'array' && kind == 'light') {
|
||||
otherValue = propertyValue;
|
||||
}
|
||||
return '`' + `${otherProperty}` + '` is set to `' + `${otherValue}` + '`';
|
||||
const firstPropertyValue = '`' + `${otherProperty}` + '` is set to `' + `${otherValue}` + '`';
|
||||
if (secondPropertyValue) {
|
||||
return firstPropertyValue + ' or `' +
|
||||
objCType(layerType, peerPropertyName) + camelize(secondPropertyValue) +
|
||||
'`';
|
||||
} else {
|
||||
return firstPropertyValue;
|
||||
}
|
||||
});
|
||||
// Match references to our own property values.
|
||||
// Requires the format 'is equivalent to `bar`'.
|
||||
|
||||
@@ -83,8 +83,8 @@ typedef NS_ENUM(NSUInteger, MGLIconPitchAlignment) {
|
||||
typedef NS_ENUM(NSUInteger, MGLIconRotationAlignment) {
|
||||
/**
|
||||
When `symbolPlacement` is set to `MGLSymbolPlacementPoint`, aligns icons
|
||||
east-west. When `symbolPlacement` is set to `MGLSymbolPlacementLine`,
|
||||
aligns icon x-axes with the line.
|
||||
east-west. When `symbolPlacement` is set to `MGLSymbolPlacementLine` or
|
||||
`MGLSymbolPlacementLineCenter`, aligns icon x-axes with the line.
|
||||
*/
|
||||
MGLIconRotationAlignmentMap,
|
||||
/**
|
||||
@@ -95,8 +95,8 @@ typedef NS_ENUM(NSUInteger, MGLIconRotationAlignment) {
|
||||
/**
|
||||
When `symbolPlacement` is set to `MGLSymbolPlacementPoint`, this is
|
||||
equivalent to `MGLIconRotationAlignmentViewport`. When `symbolPlacement` is
|
||||
set to `MGLSymbolPlacementLine`, this is equivalent to
|
||||
`MGLIconRotationAlignmentMap`.
|
||||
set to `MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`, this is
|
||||
equivalent to `MGLIconRotationAlignmentMap`.
|
||||
*/
|
||||
MGLIconRotationAlignmentAuto,
|
||||
};
|
||||
@@ -142,6 +142,12 @@ typedef NS_ENUM(NSUInteger, MGLSymbolPlacement) {
|
||||
`LineString` and `Polygon` geometries.
|
||||
*/
|
||||
MGLSymbolPlacementLine,
|
||||
/**
|
||||
The label is placed at the center of the line of the geometry. Can only be
|
||||
used on `LineString` and `Polygon` geometries. Note that a single feature
|
||||
in a vector tile may contain multiple line geometries.
|
||||
*/
|
||||
MGLSymbolPlacementLineCenter,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -242,8 +248,8 @@ typedef NS_ENUM(NSUInteger, MGLTextPitchAlignment) {
|
||||
typedef NS_ENUM(NSUInteger, MGLTextRotationAlignment) {
|
||||
/**
|
||||
When `symbolPlacement` is set to `MGLSymbolPlacementPoint`, aligns text
|
||||
east-west. When `symbolPlacement` is set to `MGLSymbolPlacementLine`,
|
||||
aligns text x-axes with the line.
|
||||
east-west. When `symbolPlacement` is set to `MGLSymbolPlacementLine` or
|
||||
`MGLSymbolPlacementLineCenter`, aligns text x-axes with the line.
|
||||
*/
|
||||
MGLTextRotationAlignmentMap,
|
||||
/**
|
||||
@@ -254,8 +260,8 @@ typedef NS_ENUM(NSUInteger, MGLTextRotationAlignment) {
|
||||
/**
|
||||
When `symbolPlacement` is set to `MGLSymbolPlacementPoint`, this is
|
||||
equivalent to `MGLTextRotationAlignmentViewport`. When `symbolPlacement` is
|
||||
set to `MGLSymbolPlacementLine`, this is equivalent to
|
||||
`MGLTextRotationAlignmentMap`.
|
||||
set to `MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`, this is
|
||||
equivalent to `MGLTextRotationAlignmentMap`.
|
||||
*/
|
||||
MGLTextRotationAlignmentAuto,
|
||||
};
|
||||
@@ -653,12 +659,13 @@ MGL_EXPORT
|
||||
* Constant `MGLIconRotationAlignment` values
|
||||
* Any of the following constant string values:
|
||||
* `map`: When `symbol-placement` is set to `point`, aligns icons east-west.
|
||||
When `symbol-placement` is set to `line`, aligns icon x-axes with the line.
|
||||
When `symbol-placement` is set to `line` or `line-center`, aligns icon x-axes
|
||||
with the line.
|
||||
* `viewport`: Produces icons whose x-axes are aligned with the x-axis of the
|
||||
viewport, regardless of the value of `symbol-placement`.
|
||||
* `auto`: When `symbol-placement` is set to `point`, this is equivalent to
|
||||
`viewport`. When `symbol-placement` is set to `line`, this is equivalent to
|
||||
`map`.
|
||||
`viewport`. When `symbol-placement` is set to `line` or `line-center`, this is
|
||||
equivalent to `map`.
|
||||
* Predefined functions, including mathematical and string operators
|
||||
* Conditional expressions
|
||||
* Variable assignments and references to assigned variables
|
||||
@@ -795,8 +802,9 @@ MGL_EXPORT
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`, and
|
||||
`iconRotationAlignment` is set to an expression that evaluates to `map`, and
|
||||
`symbolPlacement` is set to an expression that evaluates to `line`. Otherwise,
|
||||
it is ignored.
|
||||
`symbolPlacement` is set to an expression that evaluates to either
|
||||
`MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`. Otherwise, it is
|
||||
ignored.
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-keep-upright"><code>icon-keep-upright</code></a>
|
||||
@@ -828,8 +836,9 @@ MGL_EXPORT
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`, and
|
||||
`textRotationAlignment` is set to an expression that evaluates to `map`, and
|
||||
`symbolPlacement` is set to an expression that evaluates to `line`. Otherwise,
|
||||
it is ignored.
|
||||
`symbolPlacement` is set to an expression that evaluates to either
|
||||
`MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`. Otherwise, it is
|
||||
ignored.
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-keep-upright"><code>text-keep-upright</code></a>
|
||||
@@ -861,8 +870,9 @@ MGL_EXPORT
|
||||
`45`. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`, and
|
||||
`symbolPlacement` is set to an expression that evaluates to `line`. Otherwise,
|
||||
it is ignored.
|
||||
`symbolPlacement` is set to an expression that evaluates to either
|
||||
`MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`. Otherwise, it is
|
||||
ignored.
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-max-angle"><code>text-max-angle</code></a>
|
||||
@@ -956,6 +966,9 @@ MGL_EXPORT
|
||||
* `point`: The label is placed at the point where the geometry is located.
|
||||
* `line`: The label is placed along the line of the geometry. Can only be
|
||||
used on `LineString` and `Polygon` geometries.
|
||||
* `line-center`: The label is placed at the center of the line of the
|
||||
geometry. Can only be used on `LineString` and `Polygon` geometries. Note that
|
||||
a single feature in a vector tile may contain multiple line geometries.
|
||||
* Predefined functions, including mathematical and string operators
|
||||
* Conditional expressions
|
||||
* Variable assignments and references to assigned variables
|
||||
@@ -1427,12 +1440,13 @@ MGL_EXPORT
|
||||
* Constant `MGLTextRotationAlignment` values
|
||||
* Any of the following constant string values:
|
||||
* `map`: When `symbol-placement` is set to `point`, aligns text east-west.
|
||||
When `symbol-placement` is set to `line`, aligns text x-axes with the line.
|
||||
When `symbol-placement` is set to `line` or `line-center`, aligns text x-axes
|
||||
with the line.
|
||||
* `viewport`: Produces glyphs whose x-axes are aligned with the x-axis of the
|
||||
viewport, regardless of the value of `symbol-placement`.
|
||||
* `auto`: When `symbol-placement` is set to `point`, this is equivalent to
|
||||
`viewport`. When `symbol-placement` is set to `line`, this is equivalent to
|
||||
`map`.
|
||||
`viewport`. When `symbol-placement` is set to `line` or `line-center`, this is
|
||||
equivalent to `map`.
|
||||
* Predefined functions, including mathematical and string operators
|
||||
* Conditional expressions
|
||||
* Variable assignments and references to assigned variables
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace mbgl {
|
||||
MBGL_DEFINE_ENUM(MGLSymbolPlacement, {
|
||||
{ MGLSymbolPlacementPoint, "point" },
|
||||
{ MGLSymbolPlacementLine, "line" },
|
||||
{ MGLSymbolPlacementLineCenter, "line-center" },
|
||||
});
|
||||
|
||||
MBGL_DEFINE_ENUM(MGLTextAnchor, {
|
||||
|
||||
@@ -962,22 +962,22 @@
|
||||
@"symbol-placement should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.symbolPlacement;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'line'"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'line-center'"];
|
||||
layer.symbolPlacement = constantExpression;
|
||||
mbgl::style::PropertyValue<mbgl::style::SymbolPlacementType> propertyValue = { mbgl::style::SymbolPlacementType::Line };
|
||||
mbgl::style::PropertyValue<mbgl::style::SymbolPlacementType> propertyValue = { mbgl::style::SymbolPlacementType::LineCenter };
|
||||
XCTAssertEqual(rawLayer->getSymbolPlacement(), propertyValue,
|
||||
@"Setting symbolPlacement to a constant value expression should update symbol-placement.");
|
||||
XCTAssertEqualObjects(layer.symbolPlacement, constantExpression,
|
||||
@"symbolPlacement should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"'line'"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"'line-center'"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.symbolPlacement = functionExpression;
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::PropertyExpression<mbgl::style::SymbolPlacementType>(
|
||||
step(zoom(), literal("line"), 18.0, literal("line"))
|
||||
step(zoom(), literal("line-center"), 18.0, literal("line-center"))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2883,6 +2883,7 @@
|
||||
XCTAssertEqual([NSValue valueWithMGLIconTextFit:MGLIconTextFitBoth].MGLIconTextFitValue, MGLIconTextFitBoth);
|
||||
XCTAssertEqual([NSValue valueWithMGLSymbolPlacement:MGLSymbolPlacementPoint].MGLSymbolPlacementValue, MGLSymbolPlacementPoint);
|
||||
XCTAssertEqual([NSValue valueWithMGLSymbolPlacement:MGLSymbolPlacementLine].MGLSymbolPlacementValue, MGLSymbolPlacementLine);
|
||||
XCTAssertEqual([NSValue valueWithMGLSymbolPlacement:MGLSymbolPlacementLineCenter].MGLSymbolPlacementValue, MGLSymbolPlacementLineCenter);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorCenter].MGLTextAnchorValue, MGLTextAnchorCenter);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorLeft].MGLTextAnchorValue, MGLTextAnchorLeft);
|
||||
XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorRight].MGLTextAnchorValue, MGLTextAnchorRight);
|
||||
|
||||
Reference in New Issue
Block a user