From ddd5550132d8bdc4d7bb37ee462ca4d0377ed1eb Mon Sep 17 00:00:00 2001 From: Ivan Persidsky Date: Fri, 10 Jan 2025 21:52:07 +0200 Subject: [PATCH] Expse new style properties in Annotations, support rich types --- .../Generated/CircleAnnotation.swift | 8 +- .../Generated/CircleAnnotationManager.swift | 8 +- .../Generated/PointAnnotation.swift | 64 +++++------ .../Generated/PointAnnotationManager.swift | 60 ++++++---- .../Generated/PolygonAnnotationManager.swift | 12 +- .../Generated/PolylineAnnotation.swift | 36 ++++-- .../Generated/PolylineAnnotationManager.swift | 49 ++++++-- .../AnnotationGroup+Deprecated.swift | 108 ++++++++++++++++++ .../Generated/CircleAnnotationGroup.swift | 12 +- .../Generated/PointAnnotationGroup.swift | 84 ++++++++------ .../Generated/PolygonAnnotationGroup.swift | 18 ++- .../Generated/PolylineAnnotationGroup.swift | 67 ++++++++--- .../PointAnnotationIntegrationTests.swift | 56 +++++++++ .../PointAnnotationManagerTests.swift | 50 ++++++++ .../PolygonAnnotationIntegrationTests.swift | 26 +++++ .../PolygonAnnotationManagerTests.swift | 25 ++++ .../PolylineAnnotationIntegrationTests.swift | 78 +++++++++++++ .../PolylineAnnotationManagerTests.swift | 75 ++++++++++++ 18 files changed, 698 insertions(+), 138 deletions(-) create mode 100644 Sources/MapboxMaps/SwiftUI/Annotations/AnnotationGroup+Deprecated.swift diff --git a/Sources/MapboxMaps/Annotations/Generated/CircleAnnotation.swift b/Sources/MapboxMaps/Annotations/Generated/CircleAnnotation.swift index 602fdab07ee8..421dc376c600 100644 --- a/Sources/MapboxMaps/Annotations/Generated/CircleAnnotation.swift +++ b/Sources/MapboxMaps/Annotations/Generated/CircleAnnotation.swift @@ -150,7 +150,7 @@ public struct CircleAnnotation: Annotation, Equatable, AnnotationInternal { public var circleOpacity: Double? /// Circle radius. - /// Default value: 5. Minimum value: 0. + /// Default value: 5. Minimum value: 0. The unit of circleRadius is in pixels. public var circleRadius: Double? /// The stroke color of the circle. @@ -162,7 +162,7 @@ public struct CircleAnnotation: Annotation, Equatable, AnnotationInternal { public var circleStrokeOpacity: Double? /// The width of the circle's stroke. Strokes are placed outside of the `circle-radius`. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of circleStrokeWidth is in pixels. public var circleStrokeWidth: Double? } @@ -199,7 +199,7 @@ extension CircleAnnotation { } /// Circle radius. - /// Default value: 5. Minimum value: 0. + /// Default value: 5. Minimum value: 0. The unit of circleRadius is in pixels. public func circleRadius(_ newValue: Double) -> Self { with(self, setter(\.circleRadius, newValue)) } @@ -223,7 +223,7 @@ extension CircleAnnotation { } /// The width of the circle's stroke. Strokes are placed outside of the `circle-radius`. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of circleStrokeWidth is in pixels. public func circleStrokeWidth(_ newValue: Double) -> Self { with(self, setter(\.circleStrokeWidth, newValue)) } diff --git a/Sources/MapboxMaps/Annotations/Generated/CircleAnnotationManager.swift b/Sources/MapboxMaps/Annotations/Generated/CircleAnnotationManager.swift index 271de95714de..cc839af2dffe 100644 --- a/Sources/MapboxMaps/Annotations/Generated/CircleAnnotationManager.swift +++ b/Sources/MapboxMaps/Annotations/Generated/CircleAnnotationManager.swift @@ -78,7 +78,7 @@ public class CircleAnnotationManager: AnnotationManager, AnnotationManagerIntern } /// Controls the intensity of light emitted on the source features. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of circleEmissiveStrength is in intensity. public var circleEmissiveStrength: Double? { get { impl.layerProperties["circle-emissive-strength"] as? Double } set { impl.layerProperties["circle-emissive-strength"] = newValue } @@ -106,7 +106,7 @@ public class CircleAnnotationManager: AnnotationManager, AnnotationManagerIntern } /// Circle radius. - /// Default value: 5. Minimum value: 0. + /// Default value: 5. Minimum value: 0. The unit of circleRadius is in pixels. public var circleRadius: Double? { get { impl.layerProperties["circle-radius"] as? Double } set { impl.layerProperties["circle-radius"] = newValue } @@ -127,14 +127,14 @@ public class CircleAnnotationManager: AnnotationManager, AnnotationManagerIntern } /// The width of the circle's stroke. Strokes are placed outside of the `circle-radius`. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of circleStrokeWidth is in pixels. public var circleStrokeWidth: Double? { get { impl.layerProperties["circle-stroke-width"] as? Double } set { impl.layerProperties["circle-stroke-width"] = newValue } } /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. - /// Default value: [0,0]. + /// Default value: [0,0]. The unit of circleTranslate is in pixels. public var circleTranslate: [Double]? { get { impl.layerProperties["circle-translate"] as? [Double] } set { impl.layerProperties["circle-translate"] = newValue } diff --git a/Sources/MapboxMaps/Annotations/Generated/PointAnnotation.swift b/Sources/MapboxMaps/Annotations/Generated/PointAnnotation.swift index 415a1724d58b..9e102d7dbf14 100644 --- a/Sources/MapboxMaps/Annotations/Generated/PointAnnotation.swift +++ b/Sources/MapboxMaps/Annotations/Generated/PointAnnotation.swift @@ -173,11 +173,11 @@ public struct PointAnnotation: Annotation, Equatable, AnnotationInternal { public var iconOffset: [Double]? /// Rotates the icon clockwise. - /// Default value: 0. + /// Default value: 0. The unit of iconRotate is in degrees. public var iconRotate: Double? /// Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of iconSize is in factor of the original icon size. public var iconSize: Double? /// Scales the icon to fit around the associated text. @@ -185,7 +185,7 @@ public struct PointAnnotation: Annotation, Equatable, AnnotationInternal { public var iconTextFit: IconTextFit? /// Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left. - /// Default value: [0,0,0,0]. + /// Default value: [0,0,0,0]. The unit of iconTextFitPadding is in pixels. public var iconTextFitPadding: [Double]? /// Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When `icon-allow-overlap` or `text-allow-overlap` is `false`, features with a lower sort key will have priority during placement. When `icon-allow-overlap` or `text-allow-overlap` is set to `true`, features with a higher sort key will overlap over features with a lower sort key. @@ -204,31 +204,31 @@ public struct PointAnnotation: Annotation, Equatable, AnnotationInternal { public var textJustify: TextJustify? /// Text tracking amount. - /// Default value: 0. + /// Default value: 0. The unit of textLetterSpacing is in ems. public var textLetterSpacing: Double? /// Text leading value for multi-line text. - /// Default value: 1.2. + /// Default value: 1.2. The unit of textLineHeight is in ems. public var textLineHeight: Double? /// The maximum line width for text wrapping. - /// Default value: 10. Minimum value: 0. + /// Default value: 10. Minimum value: 0. The unit of textMaxWidth is in ems. public var textMaxWidth: Double? /// Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position. - /// Default value: [0,0]. + /// Default value: [0,0]. The unit of textOffset is in ems. public var textOffset: [Double]? /// Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `text-variable-anchor`, which defaults to using the two-dimensional `text-offset` if present. - /// Default value: 0. + /// Default value: 0. The unit of textRadialOffset is in ems. public var textRadialOffset: Double? /// Rotates the text clockwise. - /// Default value: 0. + /// Default value: 0. The unit of textRotate is in degrees. public var textRotate: Double? /// Font size. - /// Default value: 16. Minimum value: 0. + /// Default value: 16. Minimum value: 0. The unit of textSize is in pixels. public var textSize: Double? /// Specifies how to capitalize text, similar to the CSS `text-transform` property. @@ -240,11 +240,11 @@ public struct PointAnnotation: Annotation, Equatable, AnnotationInternal { public var iconColor: StyleColor? /// Controls the intensity of light emitted on the source features. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of iconEmissiveStrength is in intensity. public var iconEmissiveStrength: Double? /// Fade out the halo towards the outside. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of iconHaloBlur is in pixels. public var iconHaloBlur: Double? /// The color of the icon's halo. Icon halos can only be used with [SDF icons](/help/troubleshooting/using-recolorable-images-in-mapbox-maps/). @@ -252,7 +252,7 @@ public struct PointAnnotation: Annotation, Equatable, AnnotationInternal { public var iconHaloColor: StyleColor? /// Distance of halo to the icon outline. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of iconHaloWidth is in pixels. public var iconHaloWidth: Double? /// Controls the transition progress between the image variants of icon-image. Zero means the first variant is used, one is the second, and in between they are blended together. @@ -276,11 +276,11 @@ public struct PointAnnotation: Annotation, Equatable, AnnotationInternal { public var textColor: StyleColor? /// Controls the intensity of light emitted on the source features. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of textEmissiveStrength is in intensity. public var textEmissiveStrength: Double? /// The halo's fadeout distance towards the outside. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of textHaloBlur is in pixels. public var textHaloBlur: Double? /// The color of the text's halo, which helps it stand out from backgrounds. @@ -288,7 +288,7 @@ public struct PointAnnotation: Annotation, Equatable, AnnotationInternal { public var textHaloColor: StyleColor? /// Distance of halo to the font outline. Max text halo width is 1/4 of the font-size. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of textHaloWidth is in pixels. public var textHaloWidth: Double? /// The opacity at which the text will be drawn in case of being depth occluded. Absent value means full occlusion against terrain only. @@ -328,13 +328,13 @@ extension PointAnnotation { } /// Rotates the icon clockwise. - /// Default value: 0. + /// Default value: 0. The unit of iconRotate is in degrees. public func iconRotate(_ newValue: Double) -> Self { with(self, setter(\.iconRotate, newValue)) } /// Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of iconSize is in factor of the original icon size. public func iconSize(_ newValue: Double) -> Self { with(self, setter(\.iconSize, newValue)) } @@ -346,7 +346,7 @@ extension PointAnnotation { } /// Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left. - /// Default value: [0,0,0,0]. + /// Default value: [0,0,0,0]. The unit of iconTextFitPadding is in pixels. public func iconTextFitPadding(_ padding: UIEdgeInsets) -> Self { with(self, setter(\.iconTextFitPadding, [padding.top, padding.right, padding.bottom, padding.left])) } @@ -375,43 +375,43 @@ extension PointAnnotation { } /// Text tracking amount. - /// Default value: 0. + /// Default value: 0. The unit of textLetterSpacing is in ems. public func textLetterSpacing(_ newValue: Double) -> Self { with(self, setter(\.textLetterSpacing, newValue)) } /// Text leading value for multi-line text. - /// Default value: 1.2. + /// Default value: 1.2. The unit of textLineHeight is in ems. public func textLineHeight(_ newValue: Double) -> Self { with(self, setter(\.textLineHeight, newValue)) } /// The maximum line width for text wrapping. - /// Default value: 10. Minimum value: 0. + /// Default value: 10. Minimum value: 0. The unit of textMaxWidth is in ems. public func textMaxWidth(_ newValue: Double) -> Self { with(self, setter(\.textMaxWidth, newValue)) } /// Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position. - /// Default value: [0,0]. + /// Default value: [0,0]. The unit of textOffset is in ems. public func textOffset(x: Double, y: Double) -> Self { with(self, setter(\.textOffset, [x, y])) } /// Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `text-variable-anchor`, which defaults to using the two-dimensional `text-offset` if present. - /// Default value: 0. + /// Default value: 0. The unit of textRadialOffset is in ems. public func textRadialOffset(_ newValue: Double) -> Self { with(self, setter(\.textRadialOffset, newValue)) } /// Rotates the text clockwise. - /// Default value: 0. + /// Default value: 0. The unit of textRotate is in degrees. public func textRotate(_ newValue: Double) -> Self { with(self, setter(\.textRotate, newValue)) } /// Font size. - /// Default value: 16. Minimum value: 0. + /// Default value: 16. Minimum value: 0. The unit of textSize is in pixels. public func textSize(_ newValue: Double) -> Self { with(self, setter(\.textSize, newValue)) } @@ -435,13 +435,13 @@ extension PointAnnotation { } /// Controls the intensity of light emitted on the source features. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of iconEmissiveStrength is in intensity. public func iconEmissiveStrength(_ newValue: Double) -> Self { with(self, setter(\.iconEmissiveStrength, newValue)) } /// Fade out the halo towards the outside. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of iconHaloBlur is in pixels. public func iconHaloBlur(_ newValue: Double) -> Self { with(self, setter(\.iconHaloBlur, newValue)) } @@ -459,7 +459,7 @@ extension PointAnnotation { } /// Distance of halo to the icon outline. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of iconHaloWidth is in pixels. public func iconHaloWidth(_ newValue: Double) -> Self { with(self, setter(\.iconHaloWidth, newValue)) } @@ -501,13 +501,13 @@ extension PointAnnotation { } /// Controls the intensity of light emitted on the source features. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of textEmissiveStrength is in intensity. public func textEmissiveStrength(_ newValue: Double) -> Self { with(self, setter(\.textEmissiveStrength, newValue)) } /// The halo's fadeout distance towards the outside. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of textHaloBlur is in pixels. public func textHaloBlur(_ newValue: Double) -> Self { with(self, setter(\.textHaloBlur, newValue)) } @@ -525,7 +525,7 @@ extension PointAnnotation { } /// Distance of halo to the font outline. Max text halo width is 1/4 of the font-size. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of textHaloWidth is in pixels. public func textHaloWidth(_ newValue: Double) -> Self { with(self, setter(\.textHaloWidth, newValue)) } diff --git a/Sources/MapboxMaps/Annotations/Generated/PointAnnotationManager.swift b/Sources/MapboxMaps/Annotations/Generated/PointAnnotationManager.swift index ec26846613ec..5325b92d9ca0 100644 --- a/Sources/MapboxMaps/Annotations/Generated/PointAnnotationManager.swift +++ b/Sources/MapboxMaps/Annotations/Generated/PointAnnotationManager.swift @@ -151,7 +151,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Size of the additional area around the icon bounding box used for detecting symbol collisions. - /// Default value: 2. Minimum value: 0. + /// Default value: 2. Minimum value: 0. The unit of iconPadding is in pixels. public var iconPadding: Double? { get { impl.layerProperties["icon-padding"] as? Double } set { impl.layerProperties["icon-padding"] = newValue } @@ -165,7 +165,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Rotates the icon clockwise. - /// Default value: 0. + /// Default value: 0. The unit of iconRotate is in degrees. public var iconRotate: Double? { get { impl.layerProperties["icon-rotate"] as? Double } set { impl.layerProperties["icon-rotate"] = newValue } @@ -179,12 +179,20 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of iconSize is in factor of the original icon size. public var iconSize: Double? { get { impl.layerProperties["icon-size"] as? Double } set { impl.layerProperties["icon-size"] = newValue } } + /// Defines the minimum and maximum scaling factors for icon related properties like `icon-size`, `icon-halo-width`, `icon-halo-blur` + /// Default value: [0.8,2]. Value range: [0.1, 10] + @_documentation(visibility: public) + @_spi(Experimental) public var iconSizeScaleRange: [Double]? { + get { impl.layerProperties["icon-size-scale-range"] as? [Double] } + set { impl.layerProperties["icon-size-scale-range"] = newValue } + } + /// Scales the icon to fit around the associated text. /// Default value: "none". public var iconTextFit: IconTextFit? { @@ -193,7 +201,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left. - /// Default value: [0,0,0,0]. + /// Default value: [0,0,0,0]. The unit of iconTextFitPadding is in pixels. public var iconTextFitPadding: [Double]? { get { impl.layerProperties["icon-text-fit-padding"] as? [Double] } set { impl.layerProperties["icon-text-fit-padding"] = newValue } @@ -228,7 +236,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Distance between two symbol anchors. - /// Default value: 250. Minimum value: 1. + /// Default value: 250. Minimum value: 1. The unit of symbolSpacing is in pixels. public var symbolSpacing: Double? { get { impl.layerProperties["symbol-spacing"] as? Double } set { impl.layerProperties["symbol-spacing"] = newValue } @@ -297,35 +305,35 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Text tracking amount. - /// Default value: 0. + /// Default value: 0. The unit of textLetterSpacing is in ems. public var textLetterSpacing: Double? { get { impl.layerProperties["text-letter-spacing"] as? Double } set { impl.layerProperties["text-letter-spacing"] = newValue } } /// Text leading value for multi-line text. - /// Default value: 1.2. + /// Default value: 1.2. The unit of textLineHeight is in ems. public var textLineHeight: Double? { get { impl.layerProperties["text-line-height"] as? Double } set { impl.layerProperties["text-line-height"] = newValue } } /// Maximum angle change between adjacent characters. - /// Default value: 45. + /// Default value: 45. The unit of textMaxAngle is in degrees. public var textMaxAngle: Double? { get { impl.layerProperties["text-max-angle"] as? Double } set { impl.layerProperties["text-max-angle"] = newValue } } /// The maximum line width for text wrapping. - /// Default value: 10. Minimum value: 0. + /// Default value: 10. Minimum value: 0. The unit of textMaxWidth is in ems. public var textMaxWidth: Double? { get { impl.layerProperties["text-max-width"] as? Double } set { impl.layerProperties["text-max-width"] = newValue } } /// Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position. - /// Default value: [0,0]. + /// Default value: [0,0]. The unit of textOffset is in ems. public var textOffset: [Double]? { get { impl.layerProperties["text-offset"] as? [Double] } set { impl.layerProperties["text-offset"] = newValue } @@ -339,7 +347,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Size of the additional area around the text bounding box used for detecting symbol collisions. - /// Default value: 2. Minimum value: 0. + /// Default value: 2. Minimum value: 0. The unit of textPadding is in pixels. public var textPadding: Double? { get { impl.layerProperties["text-padding"] as? Double } set { impl.layerProperties["text-padding"] = newValue } @@ -353,14 +361,14 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `text-variable-anchor`, which defaults to using the two-dimensional `text-offset` if present. - /// Default value: 0. + /// Default value: 0. The unit of textRadialOffset is in ems. public var textRadialOffset: Double? { get { impl.layerProperties["text-radial-offset"] as? Double } set { impl.layerProperties["text-radial-offset"] = newValue } } /// Rotates the text clockwise. - /// Default value: 0. + /// Default value: 0. The unit of textRotate is in degrees. public var textRotate: Double? { get { impl.layerProperties["text-rotate"] as? Double } set { impl.layerProperties["text-rotate"] = newValue } @@ -374,12 +382,20 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Font size. - /// Default value: 16. Minimum value: 0. + /// Default value: 16. Minimum value: 0. The unit of textSize is in pixels. public var textSize: Double? { get { impl.layerProperties["text-size"] as? Double } set { impl.layerProperties["text-size"] = newValue } } + /// Defines the minimum and maximum scaling factors for text related properties like `text-size`, `text-max-width`, `text-halo-width`, `font-size` + /// Default value: [0.8,2]. Value range: [0.1, 10] + @_documentation(visibility: public) + @_spi(Experimental) public var textSizeScaleRange: [Double]? { + get { impl.layerProperties["text-size-scale-range"] as? [Double] } + set { impl.layerProperties["text-size-scale-range"] = newValue } + } + /// Specifies how to capitalize text, similar to the CSS `text-transform` property. /// Default value: "none". public var textTransform: TextTransform? { @@ -414,14 +430,14 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Controls the intensity of light emitted on the source features. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of iconEmissiveStrength is in intensity. public var iconEmissiveStrength: Double? { get { impl.layerProperties["icon-emissive-strength"] as? Double } set { impl.layerProperties["icon-emissive-strength"] = newValue } } /// Fade out the halo towards the outside. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of iconHaloBlur is in pixels. public var iconHaloBlur: Double? { get { impl.layerProperties["icon-halo-blur"] as? Double } set { impl.layerProperties["icon-halo-blur"] = newValue } @@ -435,7 +451,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Distance of halo to the icon outline. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of iconHaloWidth is in pixels. public var iconHaloWidth: Double? { get { impl.layerProperties["icon-halo-width"] as? Double } set { impl.layerProperties["icon-halo-width"] = newValue } @@ -463,7 +479,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. - /// Default value: [0,0]. + /// Default value: [0,0]. The unit of iconTranslate is in pixels. public var iconTranslate: [Double]? { get { impl.layerProperties["icon-translate"] as? [Double] } set { impl.layerProperties["icon-translate"] = newValue } @@ -492,14 +508,14 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Controls the intensity of light emitted on the source features. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of textEmissiveStrength is in intensity. public var textEmissiveStrength: Double? { get { impl.layerProperties["text-emissive-strength"] as? Double } set { impl.layerProperties["text-emissive-strength"] = newValue } } /// The halo's fadeout distance towards the outside. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of textHaloBlur is in pixels. public var textHaloBlur: Double? { get { impl.layerProperties["text-halo-blur"] as? Double } set { impl.layerProperties["text-halo-blur"] = newValue } @@ -513,7 +529,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Distance of halo to the font outline. Max text halo width is 1/4 of the font-size. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of textHaloWidth is in pixels. public var textHaloWidth: Double? { get { impl.layerProperties["text-halo-width"] as? Double } set { impl.layerProperties["text-halo-width"] = newValue } @@ -534,7 +550,7 @@ public class PointAnnotationManager: AnnotationManager, AnnotationManagerInterna } /// Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. - /// Default value: [0,0]. + /// Default value: [0,0]. The unit of textTranslate is in pixels. public var textTranslate: [Double]? { get { impl.layerProperties["text-translate"] as? [Double] } set { impl.layerProperties["text-translate"] = newValue } diff --git a/Sources/MapboxMaps/Annotations/Generated/PolygonAnnotationManager.swift b/Sources/MapboxMaps/Annotations/Generated/PolygonAnnotationManager.swift index af7f887a5a9f..92e116c0a538 100644 --- a/Sources/MapboxMaps/Annotations/Generated/PolygonAnnotationManager.swift +++ b/Sources/MapboxMaps/Annotations/Generated/PolygonAnnotationManager.swift @@ -57,6 +57,14 @@ public class PolygonAnnotationManager: AnnotationManager, AnnotationManagerInter // MARK: - Common layer properties + /// Selects the base of fill-elevation. Some modes might require precomputed elevation data in the tileset. + /// Default value: "none". + @_documentation(visibility: public) + @_spi(Experimental) public var fillElevationReference: FillElevationReference? { + get { impl.layerProperties["fill-elevation-reference"].flatMap { $0 as? String }.flatMap(FillElevationReference.init(rawValue:)) } + set { impl.layerProperties["fill-elevation-reference"] = newValue?.rawValue } + } + /// Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. public var fillSortKey: Double? { get { impl.layerProperties["fill-sort-key"] as? Double } @@ -78,7 +86,7 @@ public class PolygonAnnotationManager: AnnotationManager, AnnotationManagerInter } /// Controls the intensity of light emitted on the source features. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of fillEmissiveStrength is in intensity. public var fillEmissiveStrength: Double? { get { impl.layerProperties["fill-emissive-strength"] as? Double } set { impl.layerProperties["fill-emissive-strength"] = newValue } @@ -104,7 +112,7 @@ public class PolygonAnnotationManager: AnnotationManager, AnnotationManagerInter } /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. - /// Default value: [0,0]. + /// Default value: [0,0]. The unit of fillTranslate is in pixels. public var fillTranslate: [Double]? { get { impl.layerProperties["fill-translate"] as? [Double] } set { impl.layerProperties["fill-translate"] = newValue } diff --git a/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotation.swift b/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotation.swift index 0f0ae3d8a9aa..4c56dc21b8f2 100644 --- a/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotation.swift +++ b/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotation.swift @@ -140,11 +140,19 @@ public struct PolylineAnnotation: Annotation, Equatable, AnnotationInternal { /// Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. public var lineSortKey: Double? - /// Vertical offset from ground, in meters. Defaults to 0. Not supported for globe projection at the moment. + /// Vertical offset from ground, in meters. Defaults to 0. This is an experimental property with some known issues: + /// - Not supported for globe projection at the moment + /// - Elevated line discontinuity is possible on tile borders with terrain enabled + /// - Rendering artifacts can happen near line joins and line caps depending on the line styling + /// - Rendering artifacts relating to `line-opacity` and `line-blur` + /// - Elevated line visibility is determined by layer order + /// - Z-fighting issues can happen with intersecting elevated lines + /// - Elevated lines don't cast shadows + /// Default value: 0. public var lineZOffset: Double? /// Blur applied to the line, in pixels. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of lineBlur is in pixels. public var lineBlur: Double? /// The color of the line border. If line-border-width is greater than zero and the alpha value of this color is 0 (default), the color for the border will be selected automatically based on the line color. @@ -160,11 +168,11 @@ public struct PolylineAnnotation: Annotation, Equatable, AnnotationInternal { public var lineColor: StyleColor? /// Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of lineGapWidth is in pixels. public var lineGapWidth: Double? /// 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. - /// Default value: 0. + /// Default value: 0. The unit of lineOffset is in pixels. public var lineOffset: Double? /// The opacity at which the line will be drawn. @@ -175,7 +183,7 @@ public struct PolylineAnnotation: Annotation, Equatable, AnnotationInternal { public var linePattern: String? /// Stroke thickness. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of lineWidth is in pixels. public var lineWidth: Double? } @@ -193,13 +201,21 @@ extension PolylineAnnotation { with(self, setter(\.lineSortKey, newValue)) } - /// Vertical offset from ground, in meters. Defaults to 0. Not supported for globe projection at the moment. + /// Vertical offset from ground, in meters. Defaults to 0. This is an experimental property with some known issues: + /// - Not supported for globe projection at the moment + /// - Elevated line discontinuity is possible on tile borders with terrain enabled + /// - Rendering artifacts can happen near line joins and line caps depending on the line styling + /// - Rendering artifacts relating to `line-opacity` and `line-blur` + /// - Elevated line visibility is determined by layer order + /// - Z-fighting issues can happen with intersecting elevated lines + /// - Elevated lines don't cast shadows + /// Default value: 0. public func lineZOffset(_ newValue: Double) -> Self { with(self, setter(\.lineZOffset, newValue)) } /// Blur applied to the line, in pixels. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of lineBlur is in pixels. public func lineBlur(_ newValue: Double) -> Self { with(self, setter(\.lineBlur, newValue)) } @@ -235,13 +251,13 @@ extension PolylineAnnotation { } /// Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of lineGapWidth is in pixels. public func lineGapWidth(_ newValue: Double) -> Self { with(self, setter(\.lineGapWidth, newValue)) } /// 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. - /// Default value: 0. + /// Default value: 0. The unit of lineOffset is in pixels. public func lineOffset(_ newValue: Double) -> Self { with(self, setter(\.lineOffset, newValue)) } @@ -258,7 +274,7 @@ extension PolylineAnnotation { } /// Stroke thickness. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of lineWidth is in pixels. public func lineWidth(_ newValue: Double) -> Self { with(self, setter(\.lineWidth, newValue)) } diff --git a/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotationManager.swift b/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotationManager.swift index 226b789a0804..1f531ced9956 100644 --- a/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotationManager.swift +++ b/Sources/MapboxMaps/Annotations/Generated/PolylineAnnotationManager.swift @@ -64,6 +64,23 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte set { impl.layerProperties["line-cap"] = newValue?.rawValue } } + /// Defines the slope of an elevated line. A value of 0 creates a horizontal line. A value of 1 creates a vertical line. Other values are currently not supported. If undefined, the line follows the terrain slope. This is an experimental property with some known issues: + /// - Vertical lines don't support line caps + /// - `line-join: round` is not supported with this property + @_documentation(visibility: public) + @_spi(Experimental) public var lineCrossSlope: Double? { + get { impl.layerProperties["line-cross-slope"] as? Double } + set { impl.layerProperties["line-cross-slope"] = newValue } + } + + /// Selects the base of line-elevation. Some modes might require precomputed elevation data in the tileset. + /// Default value: "none". + @_documentation(visibility: public) + @_spi(Experimental) public var lineElevationReference: LineElevationReference? { + get { impl.layerProperties["line-elevation-reference"].flatMap { $0 as? String }.flatMap(LineElevationReference.init(rawValue:)) } + set { impl.layerProperties["line-elevation-reference"] = newValue?.rawValue } + } + /// The display of lines when joining. /// Default value: "miter". public var lineJoin: LineJoin? { @@ -91,7 +108,23 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte set { impl.layerProperties["line-sort-key"] = newValue } } - /// Vertical offset from ground, in meters. Defaults to 0. Not supported for globe projection at the moment. + /// Selects the unit of line-width. The same unit is automatically used for line-blur and line-offset. Note: This is an experimental property and might be removed in a future release. + /// Default value: "pixels". + @_documentation(visibility: public) + @_spi(Experimental) public var lineWidthUnit: LineWidthUnit? { + get { impl.layerProperties["line-width-unit"].flatMap { $0 as? String }.flatMap(LineWidthUnit.init(rawValue:)) } + set { impl.layerProperties["line-width-unit"] = newValue?.rawValue } + } + + /// Vertical offset from ground, in meters. Defaults to 0. This is an experimental property with some known issues: + /// - Not supported for globe projection at the moment + /// - Elevated line discontinuity is possible on tile borders with terrain enabled + /// - Rendering artifacts can happen near line joins and line caps depending on the line styling + /// - Rendering artifacts relating to `line-opacity` and `line-blur` + /// - Elevated line visibility is determined by layer order + /// - Z-fighting issues can happen with intersecting elevated lines + /// - Elevated lines don't cast shadows + /// Default value: 0. @_documentation(visibility: public) @_spi(Experimental) public var lineZOffset: Double? { get { impl.layerProperties["line-z-offset"] as? Double } @@ -99,7 +132,7 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte } /// Blur applied to the line, in pixels. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of lineBlur is in pixels. public var lineBlur: Double? { get { impl.layerProperties["line-blur"] as? Double } set { impl.layerProperties["line-blur"] = newValue } @@ -127,7 +160,7 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte } /// Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels. - /// Minimum value: 0. + /// Minimum value: 0. The unit of lineDasharray is in line widths. public var lineDasharray: [Double]? { get { impl.layerProperties["line-dasharray"] as? [Double] } set { impl.layerProperties["line-dasharray"] = newValue } @@ -141,14 +174,14 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte } /// Controls the intensity of light emitted on the source features. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of lineEmissiveStrength is in intensity. public var lineEmissiveStrength: Double? { get { impl.layerProperties["line-emissive-strength"] as? Double } set { impl.layerProperties["line-emissive-strength"] = newValue } } /// Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of lineGapWidth is in pixels. public var lineGapWidth: Double? { get { impl.layerProperties["line-gap-width"] as? Double } set { impl.layerProperties["line-gap-width"] = newValue } @@ -162,7 +195,7 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte } /// 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. - /// Default value: 0. + /// Default value: 0. The unit of lineOffset is in pixels. public var lineOffset: Double? { get { impl.layerProperties["line-offset"] as? Double } set { impl.layerProperties["line-offset"] = newValue } @@ -182,7 +215,7 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte } /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. - /// Default value: [0,0]. + /// Default value: [0,0]. The unit of lineTranslate is in pixels. public var lineTranslate: [Double]? { get { impl.layerProperties["line-translate"] as? [Double] } set { impl.layerProperties["line-translate"] = newValue } @@ -219,7 +252,7 @@ public class PolylineAnnotationManager: AnnotationManager, AnnotationManagerInte } /// Stroke thickness. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of lineWidth is in pixels. public var lineWidth: Double? { get { impl.layerProperties["line-width"] as? Double } set { impl.layerProperties["line-width"] = newValue } diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/AnnotationGroup+Deprecated.swift b/Sources/MapboxMaps/SwiftUI/Annotations/AnnotationGroup+Deprecated.swift new file mode 100644 index 000000000000..dd34dc4c0eea --- /dev/null +++ b/Sources/MapboxMaps/SwiftUI/Annotations/AnnotationGroup+Deprecated.swift @@ -0,0 +1,108 @@ +import UIKit + +// This file contains old methods that were public before rich type support. + +@available(iOS 13.0, *) +extension CircleAnnotationGroup { + /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. + @available(*, deprecated, renamed: "circleTranslate(x:y:)") + public func circleTranslate(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return circleTranslate(x: newValue[0], y: newValue[1]) + } + return self + } +} + +@available(iOS 13.0, *) +extension PointAnnotationGroup { + /// Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up. + /// Default value: [0,0]. + @available(*, deprecated, renamed: "iconOffset(x:y:)") + public func iconOffset(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return iconOffset(x: newValue[0], y: newValue[1]) + } + return self + } + + /// Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position. + @available(*, deprecated, renamed: "textOffset(x:y:)") + public func textOffset(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return textOffset(x: newValue[0], y: newValue[1]) + } + return self + } + + /// Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. + @available(*, deprecated, renamed: "iconTranslate(x:y:)") + public func iconTranslate(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return iconTranslate(x: newValue[0], y: newValue[1]) + } + return self + } + + /// Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. + @available(*, deprecated, renamed: "textTranslate(x:y:)") + public func textTranslate(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return textTranslate(x: newValue[0], y: newValue[1]) + } + return self + } + + /// Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left. + /// Default value: [0,0,0,0]. + @available(*, deprecated, message: "Use UIEdgeInsets instead of array") + public func iconTextFitPadding(_ newValue: [Double]) -> Self { + if newValue.count == 4 { + return iconTextFitPadding(UIEdgeInsets(top: newValue[0], left: newValue[3], bottom: newValue[2], right: newValue[1])) + } + return self + } +} + +@available(iOS 13.0, *) +extension PolygonAnnotationGroup { + /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. + @available(*, deprecated, renamed: "fillTranslate(x:y:)") + public func fillTranslate(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return fillTranslate(x: newValue[0], y: newValue[1]) + } + return self + } +} + +@available(iOS 13.0, *) +extension PolylineAnnotationGroup { + /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. + @available(*, deprecated, renamed: "lineTranslate(x:y:)") + public func lineTranslate(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return lineTranslate(x: newValue[0], y: newValue[1]) + } + return self + } + + /// Default value: [0,0]. Minimum value: [0,0]. Maximum value: [1,1]. + @available(*, deprecated, renamed: "lineTrimFadeRange(start:end:)") + public func lineTrimFadeRange(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return lineTrimFadeRange(start: newValue[0], end: newValue[1]) + } + return self + } + + /// The line part between [trim-start, trim-end] will be painted using `line-trim-color,` which is transparent by default to produce a route vanishing effect. The line trim-off offset is based on the whole line range [0.0, 1.0]. + /// Default value: [0,0]. Minimum value: [0,0]. Maximum value: [1,1]. + @available(*, deprecated, renamed: "lineTrimOffset(start:end:)") + public func lineTrimOffset(_ newValue: [Double]) -> Self { + if newValue.count == 2 { + return lineTrimOffset(start: newValue[0], end: newValue[1]) + } + return self + } +} diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/CircleAnnotationGroup.swift b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/CircleAnnotationGroup.swift index c0e09481e9e2..51295783a3b6 100644 --- a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/CircleAnnotationGroup.swift +++ b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/CircleAnnotationGroup.swift @@ -119,7 +119,7 @@ public struct CircleAnnotationGroup private var circleEmissiveStrength: Double? /// Controls the intensity of light emitted on the source features. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of circleEmissiveStrength is in intensity. public func circleEmissiveStrength(_ newValue: Double) -> Self { with(self, setter(\.circleEmissiveStrength, newValue)) } @@ -147,7 +147,7 @@ public struct CircleAnnotationGroup private var circleRadius: Double? /// Circle radius. - /// Default value: 5. Minimum value: 0. + /// Default value: 5. Minimum value: 0. The unit of circleRadius is in pixels. public func circleRadius(_ newValue: Double) -> Self { with(self, setter(\.circleRadius, newValue)) } @@ -168,16 +168,16 @@ public struct CircleAnnotationGroup private var circleStrokeWidth: Double? /// The width of the circle's stroke. Strokes are placed outside of the `circle-radius`. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of circleStrokeWidth is in pixels. public func circleStrokeWidth(_ newValue: Double) -> Self { with(self, setter(\.circleStrokeWidth, newValue)) } private var circleTranslate: [Double]? /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. - /// Default value: [0,0]. - public func circleTranslate(_ newValue: [Double]) -> Self { - with(self, setter(\.circleTranslate, newValue)) + /// Default value: [0,0]. The unit of circleTranslate is in pixels. + public func circleTranslate(x: Double, y: Double) -> Self { + with(self, setter(\.circleTranslate, [x, y])) } private var circleTranslateAnchor: CircleTranslateAnchor? diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PointAnnotationGroup.swift b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PointAnnotationGroup.swift index c693fcde7e70..2a00f07169b2 100644 --- a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PointAnnotationGroup.swift +++ b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PointAnnotationGroup.swift @@ -87,6 +87,7 @@ public struct PointAnnotationGroup { assign(manager, \.iconRotate, value: iconRotate) assign(manager, \.iconRotationAlignment, value: iconRotationAlignment) assign(manager, \.iconSize, value: iconSize) + assign(manager, \.iconSizeScaleRange, value: iconSizeScaleRange) assign(manager, \.iconTextFit, value: iconTextFit) assign(manager, \.iconTextFitPadding, value: iconTextFitPadding) assign(manager, \.symbolAvoidEdges, value: symbolAvoidEdges) @@ -115,6 +116,7 @@ public struct PointAnnotationGroup { assign(manager, \.textRotate, value: textRotate) assign(manager, \.textRotationAlignment, value: textRotationAlignment) assign(manager, \.textSize, value: textSize) + assign(manager, \.textSizeScaleRange, value: textSizeScaleRange) assign(manager, \.textTransform, value: textTransform) assign(manager, \.textVariableAnchor, value: textVariableAnchor) assign(manager, \.textWritingMode, value: textWritingMode) @@ -188,8 +190,8 @@ public struct PointAnnotationGroup { private var iconOffset: [Double]? /// Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up. /// Default value: [0,0]. - public func iconOffset(_ newValue: [Double]) -> Self { - with(self, setter(\.iconOffset, newValue)) + public func iconOffset(x: Double, y: Double) -> Self { + with(self, setter(\.iconOffset, [x, y])) } private var iconOptional: Bool? @@ -201,7 +203,7 @@ public struct PointAnnotationGroup { private var iconPadding: Double? /// Size of the additional area around the icon bounding box used for detecting symbol collisions. - /// Default value: 2. Minimum value: 0. + /// Default value: 2. Minimum value: 0. The unit of iconPadding is in pixels. public func iconPadding(_ newValue: Double) -> Self { with(self, setter(\.iconPadding, newValue)) } @@ -215,7 +217,7 @@ public struct PointAnnotationGroup { private var iconRotate: Double? /// Rotates the icon clockwise. - /// Default value: 0. + /// Default value: 0. The unit of iconRotate is in degrees. public func iconRotate(_ newValue: Double) -> Self { with(self, setter(\.iconRotate, newValue)) } @@ -229,11 +231,20 @@ public struct PointAnnotationGroup { private var iconSize: Double? /// Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of iconSize is in factor of the original icon size. public func iconSize(_ newValue: Double) -> Self { with(self, setter(\.iconSize, newValue)) } + private var iconSizeScaleRange: [Double]? + /// Defines the minimum and maximum scaling factors for icon related properties like `icon-size`, `icon-halo-width`, `icon-halo-blur` + /// Default value: [0.8,2]. Value range: [0.1, 10] + @_documentation(visibility: public) + @_spi(Experimental) + public func iconSizeScaleRange(min: Double, max: Double) -> Self { + with(self, setter(\.iconSizeScaleRange, [min, max])) + } + private var iconTextFit: IconTextFit? /// Scales the icon to fit around the associated text. /// Default value: "none". @@ -243,9 +254,9 @@ public struct PointAnnotationGroup { private var iconTextFitPadding: [Double]? /// Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left. - /// Default value: [0,0,0,0]. - public func iconTextFitPadding(_ newValue: [Double]) -> Self { - with(self, setter(\.iconTextFitPadding, newValue)) + /// Default value: [0,0,0,0]. The unit of iconTextFitPadding is in pixels. + public func iconTextFitPadding(_ padding: UIEdgeInsets) -> Self { + with(self, setter(\.iconTextFitPadding, [padding.top, padding.right, padding.bottom, padding.left])) } private var symbolAvoidEdges: Bool? @@ -279,7 +290,7 @@ public struct PointAnnotationGroup { private var symbolSpacing: Double? /// Distance between two symbol anchors. - /// Default value: 250. Minimum value: 1. + /// Default value: 250. Minimum value: 1. The unit of symbolSpacing is in pixels. public func symbolSpacing(_ newValue: Double) -> Self { with(self, setter(\.symbolSpacing, newValue)) } @@ -348,37 +359,37 @@ public struct PointAnnotationGroup { private var textLetterSpacing: Double? /// Text tracking amount. - /// Default value: 0. + /// Default value: 0. The unit of textLetterSpacing is in ems. public func textLetterSpacing(_ newValue: Double) -> Self { with(self, setter(\.textLetterSpacing, newValue)) } private var textLineHeight: Double? /// Text leading value for multi-line text. - /// Default value: 1.2. + /// Default value: 1.2. The unit of textLineHeight is in ems. public func textLineHeight(_ newValue: Double) -> Self { with(self, setter(\.textLineHeight, newValue)) } private var textMaxAngle: Double? /// Maximum angle change between adjacent characters. - /// Default value: 45. + /// Default value: 45. The unit of textMaxAngle is in degrees. public func textMaxAngle(_ newValue: Double) -> Self { with(self, setter(\.textMaxAngle, newValue)) } private var textMaxWidth: Double? /// The maximum line width for text wrapping. - /// Default value: 10. Minimum value: 0. + /// Default value: 10. Minimum value: 0. The unit of textMaxWidth is in ems. public func textMaxWidth(_ newValue: Double) -> Self { with(self, setter(\.textMaxWidth, newValue)) } private var textOffset: [Double]? /// Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position. - /// Default value: [0,0]. - public func textOffset(_ newValue: [Double]) -> Self { - with(self, setter(\.textOffset, newValue)) + /// Default value: [0,0]. The unit of textOffset is in ems. + public func textOffset(x: Double, y: Double) -> Self { + with(self, setter(\.textOffset, [x, y])) } private var textOptional: Bool? @@ -390,7 +401,7 @@ public struct PointAnnotationGroup { private var textPadding: Double? /// Size of the additional area around the text bounding box used for detecting symbol collisions. - /// Default value: 2. Minimum value: 0. + /// Default value: 2. Minimum value: 0. The unit of textPadding is in pixels. public func textPadding(_ newValue: Double) -> Self { with(self, setter(\.textPadding, newValue)) } @@ -404,14 +415,14 @@ public struct PointAnnotationGroup { private var textRadialOffset: Double? /// Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `text-variable-anchor`, which defaults to using the two-dimensional `text-offset` if present. - /// Default value: 0. + /// Default value: 0. The unit of textRadialOffset is in ems. public func textRadialOffset(_ newValue: Double) -> Self { with(self, setter(\.textRadialOffset, newValue)) } private var textRotate: Double? /// Rotates the text clockwise. - /// Default value: 0. + /// Default value: 0. The unit of textRotate is in degrees. public func textRotate(_ newValue: Double) -> Self { with(self, setter(\.textRotate, newValue)) } @@ -425,11 +436,20 @@ public struct PointAnnotationGroup { private var textSize: Double? /// Font size. - /// Default value: 16. Minimum value: 0. + /// Default value: 16. Minimum value: 0. The unit of textSize is in pixels. public func textSize(_ newValue: Double) -> Self { with(self, setter(\.textSize, newValue)) } + private var textSizeScaleRange: [Double]? + /// Defines the minimum and maximum scaling factors for text related properties like `text-size`, `text-max-width`, `text-halo-width`, `font-size` + /// Default value: [0.8,2]. Value range: [0.1, 10] + @_documentation(visibility: public) + @_spi(Experimental) + public func textSizeScaleRange(min: Double, max: Double) -> Self { + with(self, setter(\.textSizeScaleRange, [min, max])) + } + private var textTransform: TextTransform? /// Specifies how to capitalize text, similar to the CSS `text-transform` property. /// Default value: "none". @@ -465,14 +485,14 @@ public struct PointAnnotationGroup { private var iconEmissiveStrength: Double? /// Controls the intensity of light emitted on the source features. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of iconEmissiveStrength is in intensity. public func iconEmissiveStrength(_ newValue: Double) -> Self { with(self, setter(\.iconEmissiveStrength, newValue)) } private var iconHaloBlur: Double? /// Fade out the halo towards the outside. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of iconHaloBlur is in pixels. public func iconHaloBlur(_ newValue: Double) -> Self { with(self, setter(\.iconHaloBlur, newValue)) } @@ -486,7 +506,7 @@ public struct PointAnnotationGroup { private var iconHaloWidth: Double? /// Distance of halo to the icon outline. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of iconHaloWidth is in pixels. public func iconHaloWidth(_ newValue: Double) -> Self { with(self, setter(\.iconHaloWidth, newValue)) } @@ -514,9 +534,9 @@ public struct PointAnnotationGroup { private var iconTranslate: [Double]? /// Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. - /// Default value: [0,0]. - public func iconTranslate(_ newValue: [Double]) -> Self { - with(self, setter(\.iconTranslate, newValue)) + /// Default value: [0,0]. The unit of iconTranslate is in pixels. + public func iconTranslate(x: Double, y: Double) -> Self { + with(self, setter(\.iconTranslate, [x, y])) } private var iconTranslateAnchor: IconTranslateAnchor? @@ -544,14 +564,14 @@ public struct PointAnnotationGroup { private var textEmissiveStrength: Double? /// Controls the intensity of light emitted on the source features. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of textEmissiveStrength is in intensity. public func textEmissiveStrength(_ newValue: Double) -> Self { with(self, setter(\.textEmissiveStrength, newValue)) } private var textHaloBlur: Double? /// The halo's fadeout distance towards the outside. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of textHaloBlur is in pixels. public func textHaloBlur(_ newValue: Double) -> Self { with(self, setter(\.textHaloBlur, newValue)) } @@ -565,7 +585,7 @@ public struct PointAnnotationGroup { private var textHaloWidth: Double? /// Distance of halo to the font outline. Max text halo width is 1/4 of the font-size. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of textHaloWidth is in pixels. public func textHaloWidth(_ newValue: Double) -> Self { with(self, setter(\.textHaloWidth, newValue)) } @@ -586,9 +606,9 @@ public struct PointAnnotationGroup { private var textTranslate: [Double]? /// Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. - /// Default value: [0,0]. - public func textTranslate(_ newValue: [Double]) -> Self { - with(self, setter(\.textTranslate, newValue)) + /// Default value: [0,0]. The unit of textTranslate is in pixels. + public func textTranslate(x: Double, y: Double) -> Self { + with(self, setter(\.textTranslate, [x, y])) } private var textTranslateAnchor: TextTranslateAnchor? diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolygonAnnotationGroup.swift b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolygonAnnotationGroup.swift index ca72172b73a5..b1f94e03d0a6 100644 --- a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolygonAnnotationGroup.swift +++ b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolygonAnnotationGroup.swift @@ -73,6 +73,7 @@ public struct PolygonAnnotationGroup } private func updateProperties(manager: PolygonAnnotationManager) { + assign(manager, \.fillElevationReference, value: fillElevationReference) assign(manager, \.fillSortKey, value: fillSortKey) assign(manager, \.fillAntialias, value: fillAntialias) assign(manager, \.fillColor, value: fillColor) @@ -90,6 +91,15 @@ public struct PolygonAnnotationGroup // MARK: - Common layer properties + private var fillElevationReference: FillElevationReference? + /// Selects the base of fill-elevation. Some modes might require precomputed elevation data in the tileset. + /// Default value: "none". + @_documentation(visibility: public) + @_spi(Experimental) + public func fillElevationReference(_ newValue: FillElevationReference) -> Self { + with(self, setter(\.fillElevationReference, newValue)) + } + private var fillSortKey: Double? /// Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. public func fillSortKey(_ newValue: Double) -> Self { @@ -112,7 +122,7 @@ public struct PolygonAnnotationGroup private var fillEmissiveStrength: Double? /// Controls the intensity of light emitted on the source features. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of fillEmissiveStrength is in intensity. public func fillEmissiveStrength(_ newValue: Double) -> Self { with(self, setter(\.fillEmissiveStrength, newValue)) } @@ -138,9 +148,9 @@ public struct PolygonAnnotationGroup private var fillTranslate: [Double]? /// The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. - /// Default value: [0,0]. - public func fillTranslate(_ newValue: [Double]) -> Self { - with(self, setter(\.fillTranslate, newValue)) + /// Default value: [0,0]. The unit of fillTranslate is in pixels. + public func fillTranslate(x: Double, y: Double) -> Self { + with(self, setter(\.fillTranslate, [x, y])) } private var fillTranslateAnchor: FillTranslateAnchor? diff --git a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolylineAnnotationGroup.swift b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolylineAnnotationGroup.swift index 05618ffe596e..d19e89cb3303 100644 --- a/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolylineAnnotationGroup.swift +++ b/Sources/MapboxMaps/SwiftUI/Annotations/Generated/PolylineAnnotationGroup.swift @@ -77,10 +77,13 @@ public struct PolylineAnnotationGroup Self { + with(self, setter(\.lineCrossSlope, newValue)) + } + + private var lineElevationReference: LineElevationReference? + /// Selects the base of line-elevation. Some modes might require precomputed elevation data in the tileset. + /// Default value: "none". + @_documentation(visibility: public) + @_spi(Experimental) + public func lineElevationReference(_ newValue: LineElevationReference) -> Self { + with(self, setter(\.lineElevationReference, newValue)) + } + private var lineJoin: LineJoin? /// The display of lines when joining. /// Default value: "miter". @@ -141,8 +163,25 @@ public struct PolylineAnnotationGroup Self { + with(self, setter(\.lineWidthUnit, newValue)) + } + private var lineZOffset: Double? - /// Vertical offset from ground, in meters. Defaults to 0. Not supported for globe projection at the moment. + /// Vertical offset from ground, in meters. Defaults to 0. This is an experimental property with some known issues: + /// - Not supported for globe projection at the moment + /// - Elevated line discontinuity is possible on tile borders with terrain enabled + /// - Rendering artifacts can happen near line joins and line caps depending on the line styling + /// - Rendering artifacts relating to `line-opacity` and `line-blur` + /// - Elevated line visibility is determined by layer order + /// - Z-fighting issues can happen with intersecting elevated lines + /// - Elevated lines don't cast shadows + /// Default value: 0. @_documentation(visibility: public) @_spi(Experimental) public func lineZOffset(_ newValue: Double) -> Self { @@ -151,7 +190,7 @@ public struct PolylineAnnotationGroup Self { with(self, setter(\.lineBlur, newValue)) } @@ -179,7 +218,7 @@ public struct PolylineAnnotationGroup Self { with(self, setter(\.lineDasharray, newValue)) } @@ -193,14 +232,14 @@ public struct PolylineAnnotationGroup Self { with(self, setter(\.lineEmissiveStrength, newValue)) } private var lineGapWidth: Double? /// Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. - /// Default value: 0. Minimum value: 0. + /// Default value: 0. Minimum value: 0. The unit of lineGapWidth is in pixels. public func lineGapWidth(_ newValue: Double) -> Self { with(self, setter(\.lineGapWidth, newValue)) } @@ -214,7 +253,7 @@ public struct PolylineAnnotationGroup Self { with(self, setter(\.lineOffset, newValue)) } @@ -234,9 +273,9 @@ public struct PolylineAnnotationGroup Self { - with(self, setter(\.lineTranslate, newValue)) + /// Default value: [0,0]. The unit of lineTranslate is in pixels. + public func lineTranslate(x: Double, y: Double) -> Self { + with(self, setter(\.lineTranslate, [x, y])) } private var lineTranslateAnchor: LineTranslateAnchor? @@ -260,20 +299,20 @@ public struct PolylineAnnotationGroup Self { - with(self, setter(\.lineTrimFadeRange, newValue)) + public func lineTrimFadeRange(start: Double, end: Double) -> Self { + with(self, setter(\.lineTrimFadeRange, [start, end])) } private var lineTrimOffset: [Double]? /// The line part between [trim-start, trim-end] will be painted using `line-trim-color,` which is transparent by default to produce a route vanishing effect. The line trim-off offset is based on the whole line range [0.0, 1.0]. /// Default value: [0,0]. Minimum value: [0,0]. Maximum value: [1,1]. - public func lineTrimOffset(_ newValue: [Double]) -> Self { - with(self, setter(\.lineTrimOffset, newValue)) + public func lineTrimOffset(start: Double, end: Double) -> Self { + with(self, setter(\.lineTrimOffset, [start, end])) } private var lineWidth: Double? /// Stroke thickness. - /// Default value: 1. Minimum value: 0. + /// Default value: 1. Minimum value: 0. The unit of lineWidth is in pixels. public func lineWidth(_ newValue: Double) -> Self { with(self, setter(\.lineWidth, newValue)) } diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationIntegrationTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationIntegrationTests.swift index 221c2292b904..78b3c75dceac 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationIntegrationTests.swift @@ -241,6 +241,34 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { XCTAssertEqual(layer.iconRotationAlignment, .constant(IconRotationAlignment(rawValue: StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-rotation-alignment").value as! String))) } + func testIconSizeScaleRange() throws { + // Test that the setter and getter work + let value = [0.0, 0.0] + manager.iconSizeScaleRange = value + XCTAssertEqual(manager.iconSizeScaleRange, value) + + // Test that the value is synced to the layer + manager.impl.syncSourceAndLayerIfNeeded() + var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) + if case .constant(let actualValue) = layer.iconSizeScaleRange { + for (actual, expected) in zip(actualValue, value) { + XCTAssertEqual(actual, expected, accuracy: 0.1) + } + } else { + XCTFail("Expected constant") + } + + // Test that the property can be reset to nil + manager.iconSizeScaleRange = nil + XCTAssertNil(manager.iconSizeScaleRange) + + // Verify that when the property is reset to nil, + // the layer is returned to the default value + manager.impl.syncSourceAndLayerIfNeeded() + layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) + XCTAssertEqual(layer.iconSizeScaleRange, .constant(StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-size-scale-range").value as! [Double])) + } + func testSymbolAvoidEdges() throws { // Test that the setter and getter work let value = true @@ -631,6 +659,34 @@ final class PointAnnotationIntegrationTests: MapViewIntegrationTestCase { XCTAssertEqual(layer.textRotationAlignment, .constant(TextRotationAlignment(rawValue: StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-rotation-alignment").value as! String))) } + func testTextSizeScaleRange() throws { + // Test that the setter and getter work + let value = [0.0, 0.0] + manager.textSizeScaleRange = value + XCTAssertEqual(manager.textSizeScaleRange, value) + + // Test that the value is synced to the layer + manager.impl.syncSourceAndLayerIfNeeded() + var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) + if case .constant(let actualValue) = layer.textSizeScaleRange { + for (actual, expected) in zip(actualValue, value) { + XCTAssertEqual(actual, expected, accuracy: 0.1) + } + } else { + XCTFail("Expected constant") + } + + // Test that the property can be reset to nil + manager.textSizeScaleRange = nil + XCTAssertNil(manager.textSizeScaleRange) + + // Verify that when the property is reset to nil, + // the layer is returned to the default value + manager.impl.syncSourceAndLayerIfNeeded() + layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: SymbolLayer.self) + XCTAssertEqual(layer.textSizeScaleRange, .constant(StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-size-scale-range").value as! [Double])) + } + func testTextVariableAnchor() throws { // Test that the setter and getter work let value = Array.testFixture(withLength: .random(in: 0...10), generator: { TextAnchor.testConstantValue() }) diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationManagerTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationManagerTests.swift index a744311dede6..1d8d464cd08c 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationManagerTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PointAnnotationManagerTests.swift @@ -329,6 +329,31 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-size"] as! Double, defaultValue) } + func testInitialIconSizeScaleRange() { + let initialValue = manager.iconSizeScaleRange + XCTAssertNil(initialValue) + } + + func testSetIconSizeScaleRange() { + let value = [0.0, 0.0] + manager.iconSizeScaleRange = value + XCTAssertEqual(manager.iconSizeScaleRange, value) + XCTAssertEqual(manager.impl.layerProperties["icon-size-scale-range"] as! [Double], value) + } + + func testSetToNilIconSizeScaleRange() { + let newIconSizeScaleRangeProperty = [0.0, 0.0] + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "icon-size-scale-range").value as! [Double] + manager.iconSizeScaleRange = newIconSizeScaleRangeProperty + XCTAssertNotNil(manager.impl.layerProperties["icon-size-scale-range"]) + harness.triggerDisplayLink() + + manager.iconSizeScaleRange = nil + XCTAssertNil(manager.iconSizeScaleRange) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["icon-size-scale-range"] as! [Double], defaultValue) + } func testInitialIconTextFit() { let initialValue = manager.iconTextFit XCTAssertNil(initialValue) @@ -1034,6 +1059,31 @@ final class PointAnnotationManagerTests: XCTestCase, AnnotationInteractionDelega XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-size"] as! Double, defaultValue) } + func testInitialTextSizeScaleRange() { + let initialValue = manager.textSizeScaleRange + XCTAssertNil(initialValue) + } + + func testSetTextSizeScaleRange() { + let value = [0.0, 0.0] + manager.textSizeScaleRange = value + XCTAssertEqual(manager.textSizeScaleRange, value) + XCTAssertEqual(manager.impl.layerProperties["text-size-scale-range"] as! [Double], value) + } + + func testSetToNilTextSizeScaleRange() { + let newTextSizeScaleRangeProperty = [0.0, 0.0] + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .symbol, property: "text-size-scale-range").value as! [Double] + manager.textSizeScaleRange = newTextSizeScaleRangeProperty + XCTAssertNotNil(manager.impl.layerProperties["text-size-scale-range"]) + harness.triggerDisplayLink() + + manager.textSizeScaleRange = nil + XCTAssertNil(manager.textSizeScaleRange) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["text-size-scale-range"] as! [Double], defaultValue) + } func testInitialTextTransform() { let initialValue = manager.textTransform XCTAssertNil(initialValue) diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationIntegrationTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationIntegrationTests.swift index d3963d23d271..e976e8b0b01d 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationIntegrationTests.swift @@ -66,6 +66,32 @@ final class PolygonAnnotationIntegrationTests: MapViewIntegrationTestCase { waitForExpectations(timeout: 2, handler: nil) } + func testFillElevationReference() throws { + // Test that the setter and getter work + let value = FillElevationReference.testConstantValue() + manager.fillElevationReference = value + XCTAssertEqual(manager.fillElevationReference, value) + + // Test that the value is synced to the layer + manager.impl.syncSourceAndLayerIfNeeded() + var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: FillLayer.self) + if case .constant(let actualValue) = layer.fillElevationReference { + XCTAssertEqual(actualValue, value) + } else { + XCTFail("Expected constant") + } + + // Test that the property can be reset to nil + manager.fillElevationReference = nil + XCTAssertNil(manager.fillElevationReference) + + // Verify that when the property is reset to nil, + // the layer is returned to the default value + manager.impl.syncSourceAndLayerIfNeeded() + layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: FillLayer.self) + XCTAssertEqual(layer.fillElevationReference, .constant(FillElevationReference(rawValue: StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-elevation-reference").value as! String))) + } + func testFillAntialias() throws { // Test that the setter and getter work let value = true diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationManagerTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationManagerTests.swift index ec3d374fd8f3..51d3140d0b0e 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationManagerTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PolygonAnnotationManagerTests.swift @@ -36,6 +36,31 @@ final class PolygonAnnotationManagerTests: XCTestCase, AnnotationInteractionDele super.tearDown() } + func testInitialFillElevationReference() { + let initialValue = manager.fillElevationReference + XCTAssertNil(initialValue) + } + + func testSetFillElevationReference() { + let value = FillElevationReference.testConstantValue() + manager.fillElevationReference = value + XCTAssertEqual(manager.fillElevationReference, value) + XCTAssertEqual(manager.impl.layerProperties["fill-elevation-reference"] as! String, value.rawValue) + } + + func testSetToNilFillElevationReference() { + let newFillElevationReferenceProperty = FillElevationReference.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .fill, property: "fill-elevation-reference").value as! String + manager.fillElevationReference = newFillElevationReferenceProperty + XCTAssertNotNil(manager.impl.layerProperties["fill-elevation-reference"]) + harness.triggerDisplayLink() + + manager.fillElevationReference = nil + XCTAssertNil(manager.fillElevationReference) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["fill-elevation-reference"] as! String, defaultValue) + } func testInitialFillSortKey() { let initialValue = manager.fillSortKey XCTAssertNil(initialValue) diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationIntegrationTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationIntegrationTests.swift index e4eba2f07640..479903d3c948 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationIntegrationTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationIntegrationTests.swift @@ -86,6 +86,58 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { XCTAssertEqual(layer.lineCap, .constant(LineCap(rawValue: StyleManager.layerPropertyDefaultValue(for: .line, property: "line-cap").value as! String))) } + func testLineCrossSlope() throws { + // Test that the setter and getter work + let value = 0.0 + manager.lineCrossSlope = value + XCTAssertEqual(manager.lineCrossSlope, value) + + // Test that the value is synced to the layer + manager.impl.syncSourceAndLayerIfNeeded() + var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) + if case .constant(let actualValue) = layer.lineCrossSlope { + XCTAssertEqual(actualValue, value, accuracy: 0.1) + } else { + XCTFail("Expected constant") + } + + // Test that the property can be reset to nil + manager.lineCrossSlope = nil + XCTAssertNil(manager.lineCrossSlope) + + // Verify that when the property is reset to nil, + // the layer is returned to the default value + manager.impl.syncSourceAndLayerIfNeeded() + layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) + XCTAssertEqual(layer.lineCrossSlope, .constant((StyleManager.layerPropertyDefaultValue(for: .line, property: "line-cross-slope").value as! NSNumber).doubleValue)) + } + + func testLineElevationReference() throws { + // Test that the setter and getter work + let value = LineElevationReference.testConstantValue() + manager.lineElevationReference = value + XCTAssertEqual(manager.lineElevationReference, value) + + // Test that the value is synced to the layer + manager.impl.syncSourceAndLayerIfNeeded() + var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) + if case .constant(let actualValue) = layer.lineElevationReference { + XCTAssertEqual(actualValue, value) + } else { + XCTFail("Expected constant") + } + + // Test that the property can be reset to nil + manager.lineElevationReference = nil + XCTAssertNil(manager.lineElevationReference) + + // Verify that when the property is reset to nil, + // the layer is returned to the default value + manager.impl.syncSourceAndLayerIfNeeded() + layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) + XCTAssertEqual(layer.lineElevationReference, .constant(LineElevationReference(rawValue: StyleManager.layerPropertyDefaultValue(for: .line, property: "line-elevation-reference").value as! String))) + } + func testLineMiterLimit() throws { // Test that the setter and getter work let value = 0.0 @@ -138,6 +190,32 @@ final class PolylineAnnotationIntegrationTests: MapViewIntegrationTestCase { XCTAssertEqual(layer.lineRoundLimit, .constant((StyleManager.layerPropertyDefaultValue(for: .line, property: "line-round-limit").value as! NSNumber).doubleValue)) } + func testLineWidthUnit() throws { + // Test that the setter and getter work + let value = LineWidthUnit.testConstantValue() + manager.lineWidthUnit = value + XCTAssertEqual(manager.lineWidthUnit, value) + + // Test that the value is synced to the layer + manager.impl.syncSourceAndLayerIfNeeded() + var layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) + if case .constant(let actualValue) = layer.lineWidthUnit { + XCTAssertEqual(actualValue, value) + } else { + XCTFail("Expected constant") + } + + // Test that the property can be reset to nil + manager.lineWidthUnit = nil + XCTAssertNil(manager.lineWidthUnit) + + // Verify that when the property is reset to nil, + // the layer is returned to the default value + manager.impl.syncSourceAndLayerIfNeeded() + layer = try mapView.mapboxMap.layer(withId: self.manager.layerId, type: LineLayer.self) + XCTAssertEqual(layer.lineWidthUnit, .constant(LineWidthUnit(rawValue: StyleManager.layerPropertyDefaultValue(for: .line, property: "line-width-unit").value as! String))) + } + func testLineDasharray() throws { // Test that the setter and getter work let value = Array.testFixture(withLength: .random(in: 0...10), generator: { 0.0 }) diff --git a/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationManagerTests.swift b/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationManagerTests.swift index f7c20c82985a..655bfc8f519b 100644 --- a/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationManagerTests.swift +++ b/Tests/MapboxMapsTests/Annotations/Generated/PolylineAnnotationManagerTests.swift @@ -55,6 +55,56 @@ final class PolylineAnnotationManagerTests: XCTestCase, AnnotationInteractionDel XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-cap"] as! String, defaultValue) } + func testInitialLineCrossSlope() { + let initialValue = manager.lineCrossSlope + XCTAssertNil(initialValue) + } + + func testSetLineCrossSlope() { + let value = 0.0 + manager.lineCrossSlope = value + XCTAssertEqual(manager.lineCrossSlope, value) + XCTAssertEqual(manager.impl.layerProperties["line-cross-slope"] as! Double, value) + } + + func testSetToNilLineCrossSlope() { + let newLineCrossSlopeProperty = 0.0 + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-cross-slope").value as! Double + manager.lineCrossSlope = newLineCrossSlopeProperty + XCTAssertNotNil(manager.impl.layerProperties["line-cross-slope"]) + harness.triggerDisplayLink() + + manager.lineCrossSlope = nil + XCTAssertNil(manager.lineCrossSlope) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-cross-slope"] as! Double, defaultValue) + } + func testInitialLineElevationReference() { + let initialValue = manager.lineElevationReference + XCTAssertNil(initialValue) + } + + func testSetLineElevationReference() { + let value = LineElevationReference.testConstantValue() + manager.lineElevationReference = value + XCTAssertEqual(manager.lineElevationReference, value) + XCTAssertEqual(manager.impl.layerProperties["line-elevation-reference"] as! String, value.rawValue) + } + + func testSetToNilLineElevationReference() { + let newLineElevationReferenceProperty = LineElevationReference.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-elevation-reference").value as! String + manager.lineElevationReference = newLineElevationReferenceProperty + XCTAssertNotNil(manager.impl.layerProperties["line-elevation-reference"]) + harness.triggerDisplayLink() + + manager.lineElevationReference = nil + XCTAssertNil(manager.lineElevationReference) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-elevation-reference"] as! String, defaultValue) + } func testInitialLineJoin() { let initialValue = manager.lineJoin XCTAssertNil(initialValue) @@ -155,6 +205,31 @@ final class PolylineAnnotationManagerTests: XCTestCase, AnnotationInteractionDel XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-sort-key"] as! Double, defaultValue) } + func testInitialLineWidthUnit() { + let initialValue = manager.lineWidthUnit + XCTAssertNil(initialValue) + } + + func testSetLineWidthUnit() { + let value = LineWidthUnit.testConstantValue() + manager.lineWidthUnit = value + XCTAssertEqual(manager.lineWidthUnit, value) + XCTAssertEqual(manager.impl.layerProperties["line-width-unit"] as! String, value.rawValue) + } + + func testSetToNilLineWidthUnit() { + let newLineWidthUnitProperty = LineWidthUnit.testConstantValue() + let defaultValue = StyleManager.layerPropertyDefaultValue(for: .line, property: "line-width-unit").value as! String + manager.lineWidthUnit = newLineWidthUnitProperty + XCTAssertNotNil(manager.impl.layerProperties["line-width-unit"]) + harness.triggerDisplayLink() + + manager.lineWidthUnit = nil + XCTAssertNil(manager.lineWidthUnit) + harness.triggerDisplayLink() + + XCTAssertEqual(harness.style.setLayerPropertiesStub.invocations.last?.parameters.properties["line-width-unit"] as! String, defaultValue) + } func testInitialLineZOffset() { let initialValue = manager.lineZOffset XCTAssertNil(initialValue)