diff --git a/platform/ios/.gitignore b/platform/ios/.gitignore index ef0dd0888..d24dbe510 100644 --- a/platform/ios/.gitignore +++ b/platform/ios/.gitignore @@ -47,3 +47,54 @@ mapbox-gl-native.code-workspace /scripts/generate-shaders.list /scripts/generate-style-code.list *.patch + + +# node platform/darwin/scripts/generate-style-code.js +# generated file list will be in: +# platform/ios/platform/darwin/scripts/generate-style-code.list + +platform/darwin/src/MGLLight.h +platform/darwin/src/MGLLight.mm +platform/darwin/test/MGLLightTest.mm +platform/darwin/src/MGLBackgroundStyleLayer.h +platform/darwin/src/MGLBackgroundStyleLayer_Private.h +platform/darwin/src/MGLBackgroundStyleLayer.mm +platform/darwin/test/MGLBackgroundStyleLayerTests.mm +platform/darwin/src/MGLCircleStyleLayer.h +platform/darwin/src/MGLCircleStyleLayer_Private.h +platform/darwin/src/MGLCircleStyleLayer.mm +platform/darwin/test/MGLCircleStyleLayerTests.mm +platform/darwin/src/MGLFillStyleLayer.h +platform/darwin/src/MGLFillStyleLayer_Private.h +platform/darwin/src/MGLFillStyleLayer.mm +platform/darwin/test/MGLFillStyleLayerTests.mm +platform/darwin/src/MGLFillExtrusionStyleLayer.h +platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h +platform/darwin/src/MGLFillExtrusionStyleLayer.mm +platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm +platform/darwin/src/MGLHeatmapStyleLayer.h +platform/darwin/src/MGLHeatmapStyleLayer_Private.h +platform/darwin/src/MGLHeatmapStyleLayer.mm +platform/darwin/test/MGLHeatmapStyleLayerTests.mm +platform/darwin/src/MGLHillshadeStyleLayer.h +platform/darwin/src/MGLHillshadeStyleLayer_Private.h +platform/darwin/src/MGLHillshadeStyleLayer.mm +platform/darwin/test/MGLHillshadeStyleLayerTests.mm +platform/darwin/src/MGLLineStyleLayer.h +platform/darwin/src/MGLLineStyleLayer_Private.h +platform/darwin/src/MGLLineStyleLayer.mm +platform/darwin/test/MGLLineStyleLayerTests.mm +platform/darwin/src/MGLRasterStyleLayer.h +platform/darwin/src/MGLRasterStyleLayer_Private.h +platform/darwin/src/MGLRasterStyleLayer.mm +platform/darwin/test/MGLRasterStyleLayerTests.mm +platform/darwin/src/MGLSymbolStyleLayer.h +platform/darwin/src/MGLSymbolStyleLayer_Private.h +platform/darwin/src/MGLSymbolStyleLayer.mm +platform/darwin/test/MGLSymbolStyleLayerTests.mm +platform/ios/docs/guides/For Style Authors.md +platform/macos/docs/guides/For Style Authors.md +platform/ios/docs/guides/Migrating to Expressions.md +platform/macos/docs/guides/Migrating to Expressions.md +platform/ios/docs/guides/Tile URL Templates.md +platform/macos/docs/guides/Tile URL Templates.md \ No newline at end of file diff --git a/platform/ios/Makefile b/platform/ios/Makefile index 947d6bdca..b70e814a2 100644 --- a/platform/ios/Makefile +++ b/platform/ios/Makefile @@ -3,6 +3,13 @@ export IS_LOCAL_DEVELOPMENT ?= true export TARGET_BRANCH ?= main export CI ?= 0 +# When only the dependencies in the package.json are installed +# Node.js will error when running a script from the root scripts directory +# Getting rid of the duplicate package.json file is an open issue +# https://github.com/maplibre/maplibre-gl-native/issues/657 + +export NODE_PATH = ./node_modules + CMAKE ?= cmake @@ -182,7 +189,7 @@ ios-uitest: $(IOS_PROJ_PATH) echo "You can review uitest results: open $(IOS_OUTPUT_PATH)/Logs/Test" .PHONY: ios-test -ios-test: $(IOS_PROJ_PATH) +ios-test: $(IOS_PROJ_PATH) style-code set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'CI' test $(XCPRETTY) .PHONY: ios-integration-test @@ -289,7 +296,7 @@ xproj: $(MACOS_PROJ_PATH) # make macos-test .PHONY: macos-test -macos-test: $(MACOS_PROJ_PATH) +macos-test: $(MACOS_PROJ_PATH) style-code set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'CI' test $(XCPRETTY) .PHONY: macos-lint @@ -323,8 +330,8 @@ endif .PHONY: style-code style-code: - node scripts/generate-style-code.js - node scripts/generate-shaders.js + node ../../scripts/generate-style-code.js + # node ../../scripts/generate-shaders.js .PHONY: codestyle codestyle: diff --git a/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer.h b/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer.h deleted file mode 100644 index 74fb455be..000000000 --- a/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer.h +++ /dev/null @@ -1,149 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - An `MGLBackgroundStyleLayer` is a style layer that covers the entire map. Use a - background style layer to configure a color or pattern to show below all other - map content. If the style’s other layers use the Mapbox Streets source, the - background style layer is responsible for drawing land, whereas the oceans and - other bodies of water are drawn by `MGLFillStyleLayer` objects. - - A background style layer is typically the bottommost layer in a style, because - it covers the entire map and can occlude any layers below it. You can therefore - access it by getting the last item in the `MGLStyle.layers` array. - - If the background style layer is transparent or omitted from the style, any - portion of the map view that does not show another style layer is transparent. - */ -MGL_EXPORT -@interface MGLBackgroundStyleLayer : MGLStyleLayer - -/** -Returns a background style layer initialized with an identifier. - -After initializing and configuring the style layer, add it to a map view’s -style using the `-[MGLStyle addLayer:]` or -`-[MGLStyle insertLayer:belowLayer:]` method. - -@param identifier A string that uniquely identifies the source in the style to -which it is added. -*/ -- (instancetype)initWithIdentifier:(NSString *)identifier; - -// MARK: - Accessing the Paint Attributes - -#if TARGET_OS_IPHONE -/** - The color with which the background will be drawn. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `backgroundPattern` is set to - `nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *backgroundColor; -#else -/** - The color with which the background will be drawn. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `backgroundPattern` is set to - `nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *backgroundColor; -#endif - -/** - The transition affecting any changes to this layer’s `backgroundColor` property. - - This property corresponds to the `background-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition backgroundColorTransition; - -/** - The opacity at which the background will be drawn. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *backgroundOpacity; - -/** - The transition affecting any changes to this layer’s `backgroundOpacity` property. - - This property corresponds to the `background-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition backgroundOpacityTransition; - -/** - Name of image in style images to use for drawing an image background. For - seamless patterns, image width and height must be a factor of two (2, 4, 8, - ..., 512). - - You can set this property to an expression containing any of the following: - - * Constant string values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *backgroundPattern; - -/** - The transition affecting any changes to this layer’s `backgroundPattern` property. - - This property corresponds to the `background-pattern-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition backgroundPatternTransition; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer.mm deleted file mode 100644 index ad8fd0a78..000000000 --- a/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ /dev/null @@ -1,146 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLBackgroundStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLBackgroundStyleLayer_Private.h" - -#include -#include - - -@interface MGLBackgroundStyleLayer () - -@property (nonatomic, readonly) mbgl::style::BackgroundLayer *rawLayer; - -@end - -@implementation MGLBackgroundStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier -{ - MGLLogDebug(@"Initializing %@ with identifier: %@", NSStringFromClass([self class]), identifier); - auto layer = std::make_unique(identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::BackgroundLayer *)rawLayer -{ - return (mbgl::style::BackgroundLayer *)super.rawLayer; -} - -// MARK: - Accessing the Paint Attributes - -- (void)setBackgroundColor:(NSExpression *)backgroundColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting backgroundColor: %@", backgroundColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundColor, false); - self.rawLayer->setBackgroundColor(mbglValue); -} - -- (NSExpression *)backgroundColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getBackgroundColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultBackgroundColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setBackgroundColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting backgroundColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setBackgroundColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)backgroundColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setBackgroundOpacity:(NSExpression *)backgroundOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting backgroundOpacity: %@", backgroundOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundOpacity, false); - self.rawLayer->setBackgroundOpacity(mbglValue); -} - -- (NSExpression *)backgroundOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getBackgroundOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultBackgroundOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setBackgroundOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting backgroundOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setBackgroundOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)backgroundOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setBackgroundPattern:(NSExpression *)backgroundPattern { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting backgroundPattern: %@", backgroundPattern); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundPattern, false); - self.rawLayer->setBackgroundPattern(mbglValue); -} - -- (NSExpression *)backgroundPattern { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getBackgroundPattern(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultBackgroundPattern(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setBackgroundPatternTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting backgroundPatternTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setBackgroundPatternTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)backgroundPatternTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getBackgroundPatternTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -@end - -namespace mbgl { - -MGLStyleLayer* BackgroundStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLBackgroundStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer_Private.h deleted file mode 100644 index b50a681b4..000000000 --- a/platform/ios/platform/darwin/src/MGLBackgroundStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class BackgroundStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::BackgroundLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLCircleStyleLayer.h b/platform/ios/platform/darwin/src/MGLCircleStyleLayer.h deleted file mode 100644 index 0e9c69f65..000000000 --- a/platform/ios/platform/darwin/src/MGLCircleStyleLayer.h +++ /dev/null @@ -1,562 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLVectorStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - Orientation of circle when map is pitched. - - Values of this type are used in the `MGLCircleStyleLayer.circlePitchAlignment` - property. - */ -typedef NS_ENUM(NSUInteger, MGLCirclePitchAlignment) { - /** - The circle is aligned to the plane of the map. - */ - MGLCirclePitchAlignmentMap, - /** - The circle is aligned to the plane of the viewport. - */ - MGLCirclePitchAlignmentViewport, -}; - -/** - Controls the scaling behavior of the circle when the map is pitched. - - Values of this type are used in the `MGLCircleStyleLayer.circleScaleAlignment` - property. - */ -typedef NS_ENUM(NSUInteger, MGLCircleScaleAlignment) { - /** - Circles are scaled according to their apparent distance to the camera. - */ - MGLCircleScaleAlignmentMap, - /** - Circles are not scaled. - */ - MGLCircleScaleAlignmentViewport, -}; - -/** - Controls the frame of reference for `MGLCircleStyleLayer.circleTranslation`. - - Values of this type are used in the `MGLCircleStyleLayer.circleTranslationAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLCircleTranslationAnchor) { - /** - The circle is translated relative to the map. - */ - MGLCircleTranslationAnchorMap, - /** - The circle is translated relative to the viewport. - */ - MGLCircleTranslationAnchorViewport, -}; - -/** - An `MGLCircleStyleLayer` is a style layer that renders one or more filled - circles on the map. - - Use a circle style layer to configure the visual appearance of point or point - collection features. These features can come from vector tiles loaded by an - `MGLVectorTileSource` object, or they can be `MGLPointAnnotation`, - `MGLPointFeature`, `MGLPointCollection`, or `MGLPointCollectionFeature` - instances in an `MGLShapeSource` or `MGLComputedShapeSource` object. - - A circle style layer renders circles whose radii are measured in screen units. - To display circles on the map whose radii correspond to real-world distances, - use many-sided regular polygons and configure their appearance using an - `MGLFillStyleLayer` object. - - You can access an existing circle style layer using the - `-[MGLStyle layerWithIdentifier:]` method if you know its identifier; - otherwise, find it using the `MGLStyle.layers` property. You can also create a - new circle style layer and add it to the style using a method such as - `-[MGLStyle addLayer:]`. - - #### Related examples - See the Data-driven - circles, Add multiple - shapes from a single shape source, and Cluster point - data examples to learn how to add circles to your map using this style - layer. - - ### Example - - ```swift - let layer = MGLCircleStyleLayer(identifier: "circles", source: population) - layer.sourceLayerIdentifier = "population" - layer.circleColor = NSExpression(forConstantValue: UIColor.green) - - let stops = NSExpression(forConstantValue: [12: 2, - 22: 180]) - layer.circleRadius = NSExpression(forMGLInterpolating: .zoomLevelVariable, - curveType: .exponential, - parameters: NSExpression(forConstantValue: 1.75), - stops: stops) - - layer.circleOpacity = NSExpression(forConstantValue: 0.7) - layer.predicate = NSPredicate(format: "%K == %@", "marital-status", "married") - mapView.style?.addLayer(layer) - ``` - */ -MGL_EXPORT -@interface MGLCircleStyleLayer : MGLVectorStyleLayer - -/** - Returns a circle style layer initialized with an identifier and source. - - After initializing and configuring the style layer, add it to a map view’s - style using the `-[MGLStyle addLayer:]` or - `-[MGLStyle insertLayer:belowLayer:]` method. - - @param identifier A string that uniquely identifies the source in the style to - which it is added. - @param source The source from which to obtain the data to style. If the source - has not yet been added to the current style, the behavior is undefined. - @return An initialized foreground style layer. - */ -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; - -// MARK: - Accessing the Layout Attributes - -/** - Sorts features in ascending order based on this value. Features with a higher - sort key will appear above features with a lower sort key. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleSortKey; - -// MARK: - Accessing the Paint Attributes - -/** - Amount to blur the circle. 1 blurs the circle such that only the centerpoint is - full opacity. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleBlur; - -/** - The transition affecting any changes to this layer’s `circleBlur` property. - - This property corresponds to the `circle-blur-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition circleBlurTransition; - -#if TARGET_OS_IPHONE -/** - The fill color of the circle. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleColor; -#else -/** - The fill color of the circle. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleColor; -#endif - -/** - The transition affecting any changes to this layer’s `circleColor` property. - - This property corresponds to the `circle-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition circleColorTransition; - -/** - The opacity at which the circle will be drawn. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleOpacity; - -/** - The transition affecting any changes to this layer’s `circleOpacity` property. - - This property corresponds to the `circle-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition circleOpacityTransition; - -/** - Orientation of circle when map is pitched. - - The default value of this property is an expression that evaluates to - `viewport`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant `MGLCirclePitchAlignment` values - * Any of the following constant string values: - * `map`: The circle is aligned to the plane of the map. - * `viewport`: The circle is aligned to the plane of the viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *circlePitchAlignment; - -/** - Circle radius. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `5`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleRadius; - -/** - The transition affecting any changes to this layer’s `circleRadius` property. - - This property corresponds to the `circle-radius-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition circleRadiusTransition; - -/** - Controls the scaling behavior of the circle when the map is pitched. - - The default value of this property is an expression that evaluates to `map`. - Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the circle-pitch-scale - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLCircleScaleAlignment` values - * Any of the following constant string values: - * `map`: Circles are scaled according to their apparent distance to the - camera. - * `viewport`: Circles are not scaled. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *circleScaleAlignment; - -@property (nonatomic, null_resettable) NSExpression *circlePitchScale __attribute__((unavailable("Use circleScaleAlignment instead."))); - -#if TARGET_OS_IPHONE -/** - The stroke color of the circle. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleStrokeColor; -#else -/** - The stroke color of the circle. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleStrokeColor; -#endif - -/** - The transition affecting any changes to this layer’s `circleStrokeColor` property. - - This property corresponds to the `circle-stroke-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition circleStrokeColorTransition; - -/** - The opacity of the circle's stroke. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleStrokeOpacity; - -/** - The transition affecting any changes to this layer’s `circleStrokeOpacity` property. - - This property corresponds to the `circle-stroke-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition circleStrokeOpacityTransition; - -/** - The width of the circle's stroke. Strokes are placed outside of the - `circleRadius`. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *circleStrokeWidth; - -/** - The transition affecting any changes to this layer’s `circleStrokeWidth` property. - - This property corresponds to the `circle-stroke-width-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition circleStrokeWidthTransition; - -#if TARGET_OS_IPHONE -/** - The geometry's offset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points downward. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the circle-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *circleTranslation; -#else -/** - The geometry's offset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points upward. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the circle-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *circleTranslation; -#endif - -/** - The transition affecting any changes to this layer’s `circleTranslation` property. - - This property corresponds to the `circle-translate-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition circleTranslationTransition; - -@property (nonatomic, null_resettable) NSExpression *circleTranslate __attribute__((unavailable("Use circleTranslation instead."))); - -/** - Controls the frame of reference for `circleTranslation`. - - The default value of this property is an expression that evaluates to `map`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `circleTranslation` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the circle-translate-anchor - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLCircleTranslationAnchor` values - * Any of the following constant string values: - * `map`: The circle is translated relative to the map. - * `viewport`: The circle is translated relative to the viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *circleTranslationAnchor; - -@property (nonatomic, null_resettable) NSExpression *circleTranslateAnchor __attribute__((unavailable("Use circleTranslationAnchor instead."))); - -@end - -/** - Methods for wrapping an enumeration value for a style layer attribute in an - `MGLCircleStyleLayer` object and unwrapping its raw value. - */ -@interface NSValue (MGLCircleStyleLayerAdditions) - -// MARK: Working with Circle Style Layer Attribute Values - -/** - Creates a new value object containing the given `MGLCirclePitchAlignment` enumeration. - - @param circlePitchAlignment The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLCirclePitchAlignment:(MGLCirclePitchAlignment)circlePitchAlignment; - -/** - The `MGLCirclePitchAlignment` enumeration representation of the value. - */ -@property (readonly) MGLCirclePitchAlignment MGLCirclePitchAlignmentValue; - -/** - Creates a new value object containing the given `MGLCircleScaleAlignment` enumeration. - - @param circleScaleAlignment The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLCircleScaleAlignment:(MGLCircleScaleAlignment)circleScaleAlignment; - -/** - The `MGLCircleScaleAlignment` enumeration representation of the value. - */ -@property (readonly) MGLCircleScaleAlignment MGLCircleScaleAlignmentValue; - -/** - Creates a new value object containing the given `MGLCircleTranslationAnchor` enumeration. - - @param circleTranslationAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLCircleTranslationAnchor:(MGLCircleTranslationAnchor)circleTranslationAnchor; - -/** - The `MGLCircleTranslationAnchor` enumeration representation of the value. - */ -@property (readonly) MGLCircleTranslationAnchor MGLCircleTranslationAnchorValue; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/ios/platform/darwin/src/MGLCircleStyleLayer.mm deleted file mode 100644 index cd9a03f5a..000000000 --- a/platform/ios/platform/darwin/src/MGLCircleStyleLayer.mm +++ /dev/null @@ -1,497 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLCircleStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLCircleStyleLayer_Private.h" - -#include -#include - - -namespace mbgl { - - MBGL_DEFINE_ENUM(MGLCirclePitchAlignment, { - { MGLCirclePitchAlignmentMap, "map" }, - { MGLCirclePitchAlignmentViewport, "viewport" }, - }); - - MBGL_DEFINE_ENUM(MGLCircleScaleAlignment, { - { MGLCircleScaleAlignmentMap, "map" }, - { MGLCircleScaleAlignmentViewport, "viewport" }, - }); - - MBGL_DEFINE_ENUM(MGLCircleTranslationAnchor, { - { MGLCircleTranslationAnchorMap, "map" }, - { MGLCircleTranslationAnchorViewport, "viewport" }, - }); - -} - -@interface MGLCircleStyleLayer () - -@property (nonatomic, readonly) mbgl::style::CircleLayer *rawLayer; - -@end - -@implementation MGLCircleStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source -{ - MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::CircleLayer *)rawLayer -{ - return (mbgl::style::CircleLayer *)super.rawLayer; -} - -- (NSString *)sourceIdentifier -{ - MGLAssertStyleLayerIsValid(); - - return @(self.rawLayer->getSourceID().c_str()); -} - -- (NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - - auto layerID = self.rawLayer->getSourceLayer(); - return layerID.empty() ? nil : @(layerID.c_str()); -} - -- (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); - - self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); -} - -- (void)setPredicate:(NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting predicate: %@", predicate); - - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); -} - -- (NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - - return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; -} - -// MARK: - Accessing the Layout Attributes - -- (void)setCircleSortKey:(NSExpression *)circleSortKey { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleSortKey: %@", circleSortKey); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleSortKey, true); - self.rawLayer->setCircleSortKey(mbglValue); -} - -- (NSExpression *)circleSortKey { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleSortKey(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleSortKey(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -// MARK: - Accessing the Paint Attributes - -- (void)setCircleBlur:(NSExpression *)circleBlur { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleBlur: %@", circleBlur); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleBlur, true); - self.rawLayer->setCircleBlur(mbglValue); -} - -- (NSExpression *)circleBlur { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleBlur(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleBlur(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleBlurTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleBlurTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setCircleBlurTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)circleBlurTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getCircleBlurTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setCircleColor:(NSExpression *)circleColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleColor: %@", circleColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleColor, true); - self.rawLayer->setCircleColor(mbglValue); -} - -- (NSExpression *)circleColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setCircleColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)circleColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getCircleColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setCircleOpacity:(NSExpression *)circleOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleOpacity: %@", circleOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleOpacity, true); - self.rawLayer->setCircleOpacity(mbglValue); -} - -- (NSExpression *)circleOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setCircleOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)circleOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getCircleOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setCirclePitchAlignment:(NSExpression *)circlePitchAlignment { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circlePitchAlignment: %@", circlePitchAlignment); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circlePitchAlignment, false); - self.rawLayer->setCirclePitchAlignment(mbglValue); -} - -- (NSExpression *)circlePitchAlignment { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCirclePitchAlignment(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCirclePitchAlignment(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleRadius:(NSExpression *)circleRadius { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleRadius: %@", circleRadius); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleRadius, true); - self.rawLayer->setCircleRadius(mbglValue); -} - -- (NSExpression *)circleRadius { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleRadius(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleRadius(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleRadiusTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleRadiusTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setCircleRadiusTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)circleRadiusTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getCircleRadiusTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setCircleScaleAlignment:(NSExpression *)circleScaleAlignment { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleScaleAlignment: %@", circleScaleAlignment); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleScaleAlignment, false); - self.rawLayer->setCirclePitchScale(mbglValue); -} - -- (NSExpression *)circleScaleAlignment { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCirclePitchScale(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCirclePitchScale(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCirclePitchScale:(NSExpression *)circlePitchScale { -} - -- (NSExpression *)circlePitchScale { - return self.circleScaleAlignment; -} - -- (void)setCircleStrokeColor:(NSExpression *)circleStrokeColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleStrokeColor: %@", circleStrokeColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeColor, true); - self.rawLayer->setCircleStrokeColor(mbglValue); -} - -- (NSExpression *)circleStrokeColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleStrokeColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleStrokeColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleStrokeColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleStrokeColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setCircleStrokeColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)circleStrokeColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getCircleStrokeColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setCircleStrokeOpacity:(NSExpression *)circleStrokeOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleStrokeOpacity: %@", circleStrokeOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeOpacity, true); - self.rawLayer->setCircleStrokeOpacity(mbglValue); -} - -- (NSExpression *)circleStrokeOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleStrokeOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleStrokeOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleStrokeOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleStrokeOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setCircleStrokeOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)circleStrokeOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getCircleStrokeOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setCircleStrokeWidth:(NSExpression *)circleStrokeWidth { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleStrokeWidth: %@", circleStrokeWidth); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeWidth, true); - self.rawLayer->setCircleStrokeWidth(mbglValue); -} - -- (NSExpression *)circleStrokeWidth { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleStrokeWidth(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleStrokeWidth(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleStrokeWidthTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleStrokeWidthTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setCircleStrokeWidthTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)circleStrokeWidthTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getCircleStrokeWidthTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setCircleTranslation:(NSExpression *)circleTranslation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleTranslation: %@", circleTranslation); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(circleTranslation, false); - self.rawLayer->setCircleTranslate(mbglValue); -} - -- (NSExpression *)circleTranslation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleTranslate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleTranslate(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setCircleTranslationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleTranslationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setCircleTranslateTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)circleTranslationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getCircleTranslateTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setCircleTranslate:(NSExpression *)circleTranslate { -} - -- (NSExpression *)circleTranslate { - return self.circleTranslation; -} - -- (void)setCircleTranslationAnchor:(NSExpression *)circleTranslationAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting circleTranslationAnchor: %@", circleTranslationAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleTranslationAnchor, false); - self.rawLayer->setCircleTranslateAnchor(mbglValue); -} - -- (NSExpression *)circleTranslationAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getCircleTranslateAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultCircleTranslateAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setCircleTranslateAnchor:(NSExpression *)circleTranslateAnchor { -} - -- (NSExpression *)circleTranslateAnchor { - return self.circleTranslationAnchor; -} - -@end - -@implementation NSValue (MGLCircleStyleLayerAdditions) - -+ (NSValue *)valueWithMGLCirclePitchAlignment:(MGLCirclePitchAlignment)circlePitchAlignment { - return [NSValue value:&circlePitchAlignment withObjCType:@encode(MGLCirclePitchAlignment)]; -} - -- (MGLCirclePitchAlignment)MGLCirclePitchAlignmentValue { - MGLCirclePitchAlignment circlePitchAlignment; - [self getValue:&circlePitchAlignment]; - return circlePitchAlignment; -} - -+ (NSValue *)valueWithMGLCircleScaleAlignment:(MGLCircleScaleAlignment)circleScaleAlignment { - return [NSValue value:&circleScaleAlignment withObjCType:@encode(MGLCircleScaleAlignment)]; -} - -- (MGLCircleScaleAlignment)MGLCircleScaleAlignmentValue { - MGLCircleScaleAlignment circleScaleAlignment; - [self getValue:&circleScaleAlignment]; - return circleScaleAlignment; -} - -+ (NSValue *)valueWithMGLCircleTranslationAnchor:(MGLCircleTranslationAnchor)circleTranslationAnchor { - return [NSValue value:&circleTranslationAnchor withObjCType:@encode(MGLCircleTranslationAnchor)]; -} - -- (MGLCircleTranslationAnchor)MGLCircleTranslationAnchorValue { - MGLCircleTranslationAnchor circleTranslationAnchor; - [self getValue:&circleTranslationAnchor]; - return circleTranslationAnchor; -} - -@end - -namespace mbgl { - -MGLStyleLayer* CircleStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLCircleStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLCircleStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLCircleStyleLayer_Private.h deleted file mode 100644 index 788de6274..000000000 --- a/platform/ios/platform/darwin/src/MGLCircleStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class CircleStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::CircleLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer.h b/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer.h deleted file mode 100644 index c1dac0222..000000000 --- a/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer.h +++ /dev/null @@ -1,388 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLVectorStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - Controls the frame of reference for - `MGLFillExtrusionStyleLayer.fillExtrusionTranslation`. - - Values of this type are used in the `MGLFillExtrusionStyleLayer.fillExtrusionTranslationAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLFillExtrusionTranslationAnchor) { - /** - The fill extrusion is translated relative to the map. - */ - MGLFillExtrusionTranslationAnchorMap, - /** - The fill extrusion is translated relative to the viewport. - */ - MGLFillExtrusionTranslationAnchorViewport, -}; - -/** - An `MGLFillExtrusionStyleLayer` is a style layer that renders one or more 3D - extruded polygons on the map. - - Use a fill-extrusion style layer to configure the visual appearance of polygon - or multipolygon features. These features can come from vector tiles loaded by - an `MGLVectorTileSource` object, or they can be `MGLPolygon`, - `MGLPolygonFeature`, `MGLMultiPolygon`, or `MGLMultiPolygonFeature` instances - in an `MGLShapeSource` or `MGLComputedShapeSource` object. - - You can access an existing fill-extrusion style layer using the - `-[MGLStyle layerWithIdentifier:]` method if you know its identifier; - otherwise, find it using the `MGLStyle.layers` property. You can also create a - new fill-extrusion style layer and add it to the style using a method such as - `-[MGLStyle addLayer:]`. - - #### Related examples - See the Display - 3D buildings example to learn how to add and style 3D layers on a map. - - ### Example - - ```swift - let layer = MGLFillExtrusionStyleLayer(identifier: "buildings", source: buildings) - layer.sourceLayerIdentifier = "building" - layer.fillExtrusionHeight = NSExpression(forKeyPath: "height") - layer.fillExtrusionBase = NSExpression(forKeyPath: "min_height") - layer.predicate = NSPredicate(format: "extrude == 'true'") - mapView.style?.addLayer(layer) - ``` - */ -MGL_EXPORT -@interface MGLFillExtrusionStyleLayer : MGLVectorStyleLayer - -/** - Returns a fill-extrusion style layer initialized with an identifier and source. - - After initializing and configuring the style layer, add it to a map view’s - style using the `-[MGLStyle addLayer:]` or - `-[MGLStyle insertLayer:belowLayer:]` method. - - @param identifier A string that uniquely identifies the source in the style to - which it is added. - @param source The source from which to obtain the data to style. If the source - has not yet been added to the current style, the behavior is undefined. - @return An initialized foreground style layer. - */ -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; - -// MARK: - Accessing the Paint Attributes - -/** - The height with which to extrude the base of this layer. Must be less than or - equal to `fillExtrusionHeight`. - - This property is measured in meters. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `fillExtrusionHeight` is - non-`nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionBase; - -/** - The transition affecting any changes to this layer’s `fillExtrusionBase` property. - - This property corresponds to the `fill-extrusion-base-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillExtrusionBaseTransition; - -#if TARGET_OS_IPHONE -/** - The base color of this layer. The extrusion's surfaces will be shaded - differently based on this color in combination with the `light` settings. If - this color is specified with an alpha component, the alpha component will be - ignored; use `fillExtrusionOpacity` to set layer opacityco. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `fillExtrusionPattern` is set to - `nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionColor; -#else -/** - The base color of this layer. The extrusion's surfaces will be shaded - differently based on this color in combination with the `light` settings. If - this color is specified with an alpha component, the alpha component will be - ignored; use `fillExtrusionOpacity` to set layer opacityco. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `fillExtrusionPattern` is set to - `nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionColor; -#endif - -/** - The transition affecting any changes to this layer’s `fillExtrusionColor` property. - - This property corresponds to the `fill-extrusion-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillExtrusionColorTransition; - -/** - Whether to apply a vertical gradient to the sides of a fill-extrusion layer. If - true, sides will be shaded slightly darker farther down. - - The default value of this property is an expression that evaluates to `YES`. - Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the fill-extrusion-vertical-gradient - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionHasVerticalGradient; - -@property (nonatomic, null_resettable) NSExpression *fillExtrusionVerticalGradient __attribute__((unavailable("Use fillExtrusionHasVerticalGradient instead."))); - -/** - The height with which to extrude this layer. - - This property is measured in meters. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionHeight; - -/** - The transition affecting any changes to this layer’s `fillExtrusionHeight` property. - - This property corresponds to the `fill-extrusion-height-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillExtrusionHeightTransition; - -/** - The opacity of the entire fill extrusion layer. This is rendered on a - per-layer, not per-feature, basis, and data-driven styling is not available. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionOpacity; - -/** - The transition affecting any changes to this layer’s `fillExtrusionOpacity` property. - - This property corresponds to the `fill-extrusion-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillExtrusionOpacityTransition; - -/** - Name of image in style images to use for drawing image fill-extrusions. For - seamless patterns, image width and height must be a factor of two (2, 4, 8, - ..., 512). - - You can set this property to an expression containing any of the following: - - * Constant string values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionPattern; - -/** - The transition affecting any changes to this layer’s `fillExtrusionPattern` property. - - This property corresponds to the `fill-extrusion-pattern-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillExtrusionPatternTransition; - -#if TARGET_OS_IPHONE -/** - The geometry's offset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points downward. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the fill-extrusion-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionTranslation; -#else -/** - The geometry's offset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points upward. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the fill-extrusion-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionTranslation; -#endif - -/** - The transition affecting any changes to this layer’s `fillExtrusionTranslation` property. - - This property corresponds to the `fill-extrusion-translate-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillExtrusionTranslationTransition; - -@property (nonatomic, null_resettable) NSExpression *fillExtrusionTranslate __attribute__((unavailable("Use fillExtrusionTranslation instead."))); - -/** - Controls the frame of reference for `fillExtrusionTranslation`. - - The default value of this property is an expression that evaluates to `map`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `fillExtrusionTranslation` is - non-`nil`. Otherwise, it is ignored. - - This attribute corresponds to the fill-extrusion-translate-anchor - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLFillExtrusionTranslationAnchor` values - * Any of the following constant string values: - * `map`: The fill extrusion is translated relative to the map. - * `viewport`: The fill extrusion is translated relative to the viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *fillExtrusionTranslationAnchor; - -@property (nonatomic, null_resettable) NSExpression *fillExtrusionTranslateAnchor __attribute__((unavailable("Use fillExtrusionTranslationAnchor instead."))); - -@end - -/** - Methods for wrapping an enumeration value for a style layer attribute in an - `MGLFillExtrusionStyleLayer` object and unwrapping its raw value. - */ -@interface NSValue (MGLFillExtrusionStyleLayerAdditions) - -// MARK: Working with Fill extrusion Style Layer Attribute Values - -/** - Creates a new value object containing the given `MGLFillExtrusionTranslationAnchor` enumeration. - - @param fillExtrusionTranslationAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLFillExtrusionTranslationAnchor:(MGLFillExtrusionTranslationAnchor)fillExtrusionTranslationAnchor; - -/** - The `MGLFillExtrusionTranslationAnchor` enumeration representation of the value. - */ -@property (readonly) MGLFillExtrusionTranslationAnchor MGLFillExtrusionTranslationAnchorValue; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer.mm b/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer.mm deleted file mode 100644 index 1115f223e..000000000 --- a/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer.mm +++ /dev/null @@ -1,363 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLFillExtrusionStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLFillExtrusionStyleLayer_Private.h" - -#include -#include - - -namespace mbgl { - - MBGL_DEFINE_ENUM(MGLFillExtrusionTranslationAnchor, { - { MGLFillExtrusionTranslationAnchorMap, "map" }, - { MGLFillExtrusionTranslationAnchorViewport, "viewport" }, - }); - -} - -@interface MGLFillExtrusionStyleLayer () - -@property (nonatomic, readonly) mbgl::style::FillExtrusionLayer *rawLayer; - -@end - -@implementation MGLFillExtrusionStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source -{ - MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::FillExtrusionLayer *)rawLayer -{ - return (mbgl::style::FillExtrusionLayer *)super.rawLayer; -} - -- (NSString *)sourceIdentifier -{ - MGLAssertStyleLayerIsValid(); - - return @(self.rawLayer->getSourceID().c_str()); -} - -- (NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - - auto layerID = self.rawLayer->getSourceLayer(); - return layerID.empty() ? nil : @(layerID.c_str()); -} - -- (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); - - self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); -} - -- (void)setPredicate:(NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting predicate: %@", predicate); - - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); -} - -- (NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - - return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; -} - -// MARK: - Accessing the Paint Attributes - -- (void)setFillExtrusionBase:(NSExpression *)fillExtrusionBase { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionBase: %@", fillExtrusionBase); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionBase, true); - self.rawLayer->setFillExtrusionBase(mbglValue); -} - -- (NSExpression *)fillExtrusionBase { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillExtrusionBase(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillExtrusionBase(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillExtrusionBaseTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionBaseTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillExtrusionBaseTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillExtrusionBaseTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionBaseTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillExtrusionColor:(NSExpression *)fillExtrusionColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionColor: %@", fillExtrusionColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionColor, true); - self.rawLayer->setFillExtrusionColor(mbglValue); -} - -- (NSExpression *)fillExtrusionColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillExtrusionColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillExtrusionColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillExtrusionColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillExtrusionColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillExtrusionColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillExtrusionHasVerticalGradient:(NSExpression *)fillExtrusionHasVerticalGradient { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionHasVerticalGradient: %@", fillExtrusionHasVerticalGradient); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionHasVerticalGradient, false); - self.rawLayer->setFillExtrusionVerticalGradient(mbglValue); -} - -- (NSExpression *)fillExtrusionHasVerticalGradient { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillExtrusionVerticalGradient(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillExtrusionVerticalGradient(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillExtrusionVerticalGradient:(NSExpression *)fillExtrusionVerticalGradient { -} - -- (NSExpression *)fillExtrusionVerticalGradient { - return self.fillExtrusionHasVerticalGradient; -} - -- (void)setFillExtrusionHeight:(NSExpression *)fillExtrusionHeight { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionHeight: %@", fillExtrusionHeight); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionHeight, true); - self.rawLayer->setFillExtrusionHeight(mbglValue); -} - -- (NSExpression *)fillExtrusionHeight { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillExtrusionHeight(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillExtrusionHeight(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillExtrusionHeightTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionHeightTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillExtrusionHeightTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillExtrusionHeightTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionHeightTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillExtrusionOpacity:(NSExpression *)fillExtrusionOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionOpacity: %@", fillExtrusionOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionOpacity, false); - self.rawLayer->setFillExtrusionOpacity(mbglValue); -} - -- (NSExpression *)fillExtrusionOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillExtrusionOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillExtrusionOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillExtrusionOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillExtrusionOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillExtrusionOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillExtrusionPattern:(NSExpression *)fillExtrusionPattern { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionPattern: %@", fillExtrusionPattern); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionPattern, true); - self.rawLayer->setFillExtrusionPattern(mbglValue); -} - -- (NSExpression *)fillExtrusionPattern { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillExtrusionPattern(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillExtrusionPattern(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillExtrusionPatternTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionPatternTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillExtrusionPatternTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillExtrusionPatternTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionPatternTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillExtrusionTranslation:(NSExpression *)fillExtrusionTranslation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionTranslation: %@", fillExtrusionTranslation); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(fillExtrusionTranslation, false); - self.rawLayer->setFillExtrusionTranslate(mbglValue); -} - -- (NSExpression *)fillExtrusionTranslation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillExtrusionTranslate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillExtrusionTranslate(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setFillExtrusionTranslationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionTranslationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillExtrusionTranslateTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillExtrusionTranslationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionTranslateTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillExtrusionTranslate:(NSExpression *)fillExtrusionTranslate { -} - -- (NSExpression *)fillExtrusionTranslate { - return self.fillExtrusionTranslation; -} - -- (void)setFillExtrusionTranslationAnchor:(NSExpression *)fillExtrusionTranslationAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillExtrusionTranslationAnchor: %@", fillExtrusionTranslationAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionTranslationAnchor, false); - self.rawLayer->setFillExtrusionTranslateAnchor(mbglValue); -} - -- (NSExpression *)fillExtrusionTranslationAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillExtrusionTranslateAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillExtrusionTranslateAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillExtrusionTranslateAnchor:(NSExpression *)fillExtrusionTranslateAnchor { -} - -- (NSExpression *)fillExtrusionTranslateAnchor { - return self.fillExtrusionTranslationAnchor; -} - -@end - -@implementation NSValue (MGLFillExtrusionStyleLayerAdditions) - -+ (NSValue *)valueWithMGLFillExtrusionTranslationAnchor:(MGLFillExtrusionTranslationAnchor)fillExtrusionTranslationAnchor { - return [NSValue value:&fillExtrusionTranslationAnchor withObjCType:@encode(MGLFillExtrusionTranslationAnchor)]; -} - -- (MGLFillExtrusionTranslationAnchor)MGLFillExtrusionTranslationAnchorValue { - MGLFillExtrusionTranslationAnchor fillExtrusionTranslationAnchor; - [self getValue:&fillExtrusionTranslationAnchor]; - return fillExtrusionTranslationAnchor; -} - -@end - -namespace mbgl { - -MGLStyleLayer* FillExtrusionStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLFillExtrusionStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h deleted file mode 100644 index 2525b044a..000000000 --- a/platform/ios/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class FillExtrusionStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::FillExtrusionLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLFillStyleLayer.h b/platform/ios/platform/darwin/src/MGLFillStyleLayer.h deleted file mode 100644 index 0acc1a518..000000000 --- a/platform/ios/platform/darwin/src/MGLFillStyleLayer.h +++ /dev/null @@ -1,388 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLVectorStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - Controls the frame of reference for `MGLFillStyleLayer.fillTranslation`. - - Values of this type are used in the `MGLFillStyleLayer.fillTranslationAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) { - /** - The fill is translated relative to the map. - */ - MGLFillTranslationAnchorMap, - /** - The fill is translated relative to the viewport. - */ - MGLFillTranslationAnchorViewport, -}; - -/** - An `MGLFillStyleLayer` is a style layer that renders one or more filled (and - optionally stroked) polygons on the map. - - Use a fill style layer to configure the visual appearance of polygon or - multipolygon features. These features can come from vector tiles loaded by an - `MGLVectorTileSource` object, or they can be `MGLPolygon`, `MGLPolygonFeature`, - `MGLMultiPolygon`, or `MGLMultiPolygonFeature` instances in an `MGLShapeSource` - or `MGLComputedShapeSource` object. - - You can access an existing fill style layer using the - `-[MGLStyle layerWithIdentifier:]` method if you know its identifier; - otherwise, find it using the `MGLStyle.layers` property. You can also create a - new fill style layer and add it to the style using a method such as - `-[MGLStyle addLayer:]`. - - #### Related examples - See the Select a feature - within a layer example to learn how to use a `TERNARY` expression to modify - the `fillOpacity` of an `MGLFillStyleLayer` object. See the Add a pattern to - a polygon example to learn how to use an image to add pattern to the - features styled by a `MGLFillStyleLayer`. - - ### Example - - ```swift - let layer = MGLFillStyleLayer(identifier: "parks", source: parks) - layer.sourceLayerIdentifier = "parks" - layer.fillColor = NSExpression(forConstantValue: UIColor.green) - layer.predicate = NSPredicate(format: "type == %@", "national-park") - mapView.style?.addLayer(layer) - ``` - */ -MGL_EXPORT -@interface MGLFillStyleLayer : MGLVectorStyleLayer - -/** - Returns a fill style layer initialized with an identifier and source. - - After initializing and configuring the style layer, add it to a map view’s - style using the `-[MGLStyle addLayer:]` or - `-[MGLStyle insertLayer:belowLayer:]` method. - - @param identifier A string that uniquely identifies the source in the style to - which it is added. - @param source The source from which to obtain the data to style. If the source - has not yet been added to the current style, the behavior is undefined. - @return An initialized foreground style layer. - */ -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; - -// MARK: - Accessing the Layout Attributes - -/** - Sorts features in ascending order based on this value. Features with a higher - sort key will appear above features with a lower sort key. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillSortKey; - -// MARK: - Accessing the Paint Attributes - -/** - Whether or not the fill should be antialiased. - - The default value of this property is an expression that evaluates to `YES`. - Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the fill-antialias - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable, getter=isFillAntialiased) NSExpression *fillAntialiased; - -@property (nonatomic, null_resettable) NSExpression *fillAntialias __attribute__((unavailable("Use fillAntialiased instead."))); - -#if TARGET_OS_IPHONE -/** - The color of the filled part of this layer. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `fillPattern` is set to `nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillColor; -#else -/** - The color of the filled part of this layer. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `fillPattern` is set to `nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillColor; -#endif - -/** - The transition affecting any changes to this layer’s `fillColor` property. - - This property corresponds to the `fill-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillColorTransition; - -/** - The opacity of the entire fill layer. In contrast to the `fillColor`, this - value will also affect the 1pt stroke around the fill, if the stroke is used. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillOpacity; - -/** - The transition affecting any changes to this layer’s `fillOpacity` property. - - This property corresponds to the `fill-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillOpacityTransition; - -#if TARGET_OS_IPHONE -/** - The outline color of the fill. Matches the value of `fillColor` if unspecified. - - This property is only applied to the style if `fillPattern` is set to `nil`, - and `fillAntialiased` is set to an expression that evaluates to `YES`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillOutlineColor; -#else -/** - The outline color of the fill. Matches the value of `fillColor` if unspecified. - - This property is only applied to the style if `fillPattern` is set to `nil`, - and `fillAntialiased` is set to an expression that evaluates to `YES`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillOutlineColor; -#endif - -/** - The transition affecting any changes to this layer’s `fillOutlineColor` property. - - This property corresponds to the `fill-outline-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillOutlineColorTransition; - -/** - Name of image in sprite to use for drawing image fills. For seamless patterns, - image width and height must be a factor of two (2, 4, 8, ..., 512). Note that - zoom-dependent expressions will be evaluated only at integer zoom levels. - - You can set this property to an expression containing any of the following: - - * Constant string values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *fillPattern; - -/** - The transition affecting any changes to this layer’s `fillPattern` property. - - This property corresponds to the `fill-pattern-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillPatternTransition; - -#if TARGET_OS_IPHONE -/** - The geometry's offset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points downward. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the fill-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *fillTranslation; -#else -/** - The geometry's offset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points upward. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the fill-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *fillTranslation; -#endif - -/** - The transition affecting any changes to this layer’s `fillTranslation` property. - - This property corresponds to the `fill-translate-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition fillTranslationTransition; - -@property (nonatomic, null_resettable) NSExpression *fillTranslate __attribute__((unavailable("Use fillTranslation instead."))); - -/** - Controls the frame of reference for `fillTranslation`. - - The default value of this property is an expression that evaluates to `map`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `fillTranslation` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the fill-translate-anchor - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLFillTranslationAnchor` values - * Any of the following constant string values: - * `map`: The fill is translated relative to the map. - * `viewport`: The fill is translated relative to the viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *fillTranslationAnchor; - -@property (nonatomic, null_resettable) NSExpression *fillTranslateAnchor __attribute__((unavailable("Use fillTranslationAnchor instead."))); - -@end - -/** - Methods for wrapping an enumeration value for a style layer attribute in an - `MGLFillStyleLayer` object and unwrapping its raw value. - */ -@interface NSValue (MGLFillStyleLayerAdditions) - -// MARK: Working with Fill Style Layer Attribute Values - -/** - Creates a new value object containing the given `MGLFillTranslationAnchor` enumeration. - - @param fillTranslationAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLFillTranslationAnchor:(MGLFillTranslationAnchor)fillTranslationAnchor; - -/** - The `MGLFillTranslationAnchor` enumeration representation of the value. - */ -@property (readonly) MGLFillTranslationAnchor MGLFillTranslationAnchorValue; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLFillStyleLayer.mm b/platform/ios/platform/darwin/src/MGLFillStyleLayer.mm deleted file mode 100644 index 5c1a9e73d..000000000 --- a/platform/ios/platform/darwin/src/MGLFillStyleLayer.mm +++ /dev/null @@ -1,350 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLFillStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLFillStyleLayer_Private.h" - -#include -#include - - -namespace mbgl { - - MBGL_DEFINE_ENUM(MGLFillTranslationAnchor, { - { MGLFillTranslationAnchorMap, "map" }, - { MGLFillTranslationAnchorViewport, "viewport" }, - }); - -} - -@interface MGLFillStyleLayer () - -@property (nonatomic, readonly) mbgl::style::FillLayer *rawLayer; - -@end - -@implementation MGLFillStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source -{ - MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::FillLayer *)rawLayer -{ - return (mbgl::style::FillLayer *)super.rawLayer; -} - -- (NSString *)sourceIdentifier -{ - MGLAssertStyleLayerIsValid(); - - return @(self.rawLayer->getSourceID().c_str()); -} - -- (NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - - auto layerID = self.rawLayer->getSourceLayer(); - return layerID.empty() ? nil : @(layerID.c_str()); -} - -- (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); - - self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); -} - -- (void)setPredicate:(NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting predicate: %@", predicate); - - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); -} - -- (NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - - return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; -} - -// MARK: - Accessing the Layout Attributes - -- (void)setFillSortKey:(NSExpression *)fillSortKey { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillSortKey: %@", fillSortKey); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillSortKey, true); - self.rawLayer->setFillSortKey(mbglValue); -} - -- (NSExpression *)fillSortKey { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillSortKey(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillSortKey(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -// MARK: - Accessing the Paint Attributes - -- (void)setFillAntialiased:(NSExpression *)fillAntialiased { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillAntialiased: %@", fillAntialiased); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillAntialiased, false); - self.rawLayer->setFillAntialias(mbglValue); -} - -- (NSExpression *)isFillAntialiased { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillAntialias(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillAntialias(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillAntialias:(NSExpression *)fillAntialias { -} - -- (NSExpression *)fillAntialias { - return self.isFillAntialiased; -} - -- (void)setFillColor:(NSExpression *)fillColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillColor: %@", fillColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillColor, true); - self.rawLayer->setFillColor(mbglValue); -} - -- (NSExpression *)fillColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillOpacity:(NSExpression *)fillOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillOpacity: %@", fillOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillOpacity, true); - self.rawLayer->setFillOpacity(mbglValue); -} - -- (NSExpression *)fillOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillOutlineColor:(NSExpression *)fillOutlineColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillOutlineColor: %@", fillOutlineColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillOutlineColor, true); - self.rawLayer->setFillOutlineColor(mbglValue); -} - -- (NSExpression *)fillOutlineColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillOutlineColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillOutlineColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillOutlineColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillOutlineColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillOutlineColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillOutlineColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillOutlineColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillPattern:(NSExpression *)fillPattern { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillPattern: %@", fillPattern); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillPattern, true); - self.rawLayer->setFillPattern(mbglValue); -} - -- (NSExpression *)fillPattern { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillPattern(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillPattern(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillPatternTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillPatternTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillPatternTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillPatternTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillPatternTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillTranslation:(NSExpression *)fillTranslation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillTranslation: %@", fillTranslation); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(fillTranslation, false); - self.rawLayer->setFillTranslate(mbglValue); -} - -- (NSExpression *)fillTranslation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillTranslate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillTranslate(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setFillTranslationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillTranslationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setFillTranslateTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)fillTranslationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillTranslateTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setFillTranslate:(NSExpression *)fillTranslate { -} - -- (NSExpression *)fillTranslate { - return self.fillTranslation; -} - -- (void)setFillTranslationAnchor:(NSExpression *)fillTranslationAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting fillTranslationAnchor: %@", fillTranslationAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillTranslationAnchor, false); - self.rawLayer->setFillTranslateAnchor(mbglValue); -} - -- (NSExpression *)fillTranslationAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getFillTranslateAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultFillTranslateAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setFillTranslateAnchor:(NSExpression *)fillTranslateAnchor { -} - -- (NSExpression *)fillTranslateAnchor { - return self.fillTranslationAnchor; -} - -@end - -@implementation NSValue (MGLFillStyleLayerAdditions) - -+ (NSValue *)valueWithMGLFillTranslationAnchor:(MGLFillTranslationAnchor)fillTranslationAnchor { - return [NSValue value:&fillTranslationAnchor withObjCType:@encode(MGLFillTranslationAnchor)]; -} - -- (MGLFillTranslationAnchor)MGLFillTranslationAnchorValue { - MGLFillTranslationAnchor fillTranslationAnchor; - [self getValue:&fillTranslationAnchor]; - return fillTranslationAnchor; -} - -@end - -namespace mbgl { - -MGLStyleLayer* FillStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLFillStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLFillStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLFillStyleLayer_Private.h deleted file mode 100644 index 01f8b16f3..000000000 --- a/platform/ios/platform/darwin/src/MGLFillStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class FillStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::FillLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer.h b/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer.h deleted file mode 100644 index 5996bd1df..000000000 --- a/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer.h +++ /dev/null @@ -1,227 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLVectorStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - An `MGLHeatmapStyleLayer` is a style layer that renders a heatmap. - - A heatmap visualizes the spatial distribution of a large, dense set of point - data, using color to avoid cluttering the map with individual points at low - zoom levels. The points are weighted by an attribute you specify. Use a heatmap - style layer in conjunction with point or point collection features. These - features can come from vector tiles loaded by an `MGLVectorTileSource` object, - or they can be `MGLPointAnnotation`, `MGLPointFeature`, `MGLPointCollection`, - or `MGLPointCollectionFeature` instances in an `MGLShapeSource` or - `MGLComputedShapeSource` object. - - Consider accompanying a heatmap style layer with an `MGLCircleStyleLayer` or - `MGLSymbolStyleLayer` at high zoom levels. If you are unsure whether the point - data in an `MGLShapeSource` is dense enough to warrant a heatmap, you can - alternatively cluster the source using the `MGLShapeSourceOptionClustered` - option and render the data using an `MGLCircleStyleLayer` or - `MGLSymbolStyleLayer`. - - You can access an existing heatmap style layer using the - `-[MGLStyle layerWithIdentifier:]` method if you know its identifier; - otherwise, find it using the `MGLStyle.layers` property. You can also create a - new heatmap style layer and add it to the style using a method such as - `-[MGLStyle addLayer:]`. - - #### Related examples - See the Create a - heatmap layer example to learn how to add this style layer to your map. - - ### Example - - ```swift - let layer = MGLHeatmapStyleLayer(identifier: "earthquake-heat", source: earthquakes) - - layer.heatmapWeight = NSExpression(forMGLInterpolating: .zoomLevelVariable, - curveType: .linear, - parameters: nil, - stops: NSExpression(forConstantValue: [0: 0, - 6: 1])) - - layer.heatmapIntensity = NSExpression(forMGLInterpolating: .zoomLevelVariable, - curveType: .linear, - parameters: nil, - stops: NSExpression(forConstantValue: [0: 1, - 9: 3])) - - mapView.style?.addLayer(layer) - ``` - */ -MGL_EXPORT -@interface MGLHeatmapStyleLayer : MGLVectorStyleLayer - -/** - Returns a heatmap style layer initialized with an identifier and source. - - After initializing and configuring the style layer, add it to a map view’s - style using the `-[MGLStyle addLayer:]` or - `-[MGLStyle insertLayer:belowLayer:]` method. - - @param identifier A string that uniquely identifies the source in the style to - which it is added. - @param source The source from which to obtain the data to style. If the source - has not yet been added to the current style, the behavior is undefined. - @return An initialized foreground style layer. - */ -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; - -// MARK: - Accessing the Paint Attributes - -#if TARGET_OS_IPHONE -/** - The color of each screen point based on its density value in a heatmap. This - property is normally set to an interpolation or step expression with the - `$heatmapDensity` value as its input. - - The default value of this property is an expression that evaluates to a rainbow - color scale from blue to red. Set this property to `nil` to reset it to the - default value. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$heatmapDensity` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *heatmapColor; -#else -/** - The color of each screen point based on its density value in a heatmap. This - property is normally set to an interpolation or step expression with the - `$heatmapDensity` value as its input. - - The default value of this property is an expression that evaluates to a rainbow - color scale from blue to red. Set this property to `nil` to reset it to the - default value. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$heatmapDensity` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *heatmapColor; -#endif - -/** - Similar to `heatmapWeight` but controls the intensity of the heatmap globally. - Primarily used for adjusting the heatmap based on zoom level. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *heatmapIntensity; - -/** - The transition affecting any changes to this layer’s `heatmapIntensity` property. - - This property corresponds to the `heatmap-intensity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition heatmapIntensityTransition; - -/** - The global opacity at which the heatmap layer will be drawn. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *heatmapOpacity; - -/** - The transition affecting any changes to this layer’s `heatmapOpacity` property. - - This property corresponds to the `heatmap-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition heatmapOpacityTransition; - -/** - Radius of influence of one heatmap point in points. Increasing the value makes - the heatmap smoother, but less detailed. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `30`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 1 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *heatmapRadius; - -/** - The transition affecting any changes to this layer’s `heatmapRadius` property. - - This property corresponds to the `heatmap-radius-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition heatmapRadiusTransition; - -/** - A measure of how much an individual point contributes to the heatmap. A value - of 10 would be equivalent to having 10 points of weight 1 in the same spot. - Especially useful when combined with clustering. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *heatmapWeight; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer.mm b/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer.mm deleted file mode 100644 index 54a065450..000000000 --- a/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer.mm +++ /dev/null @@ -1,220 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLHeatmapStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLHeatmapStyleLayer_Private.h" - -#include -#include - - -@interface MGLHeatmapStyleLayer () - -@property (nonatomic, readonly) mbgl::style::HeatmapLayer *rawLayer; - -@end - -@implementation MGLHeatmapStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source -{ - MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::HeatmapLayer *)rawLayer -{ - return (mbgl::style::HeatmapLayer *)super.rawLayer; -} - -- (NSString *)sourceIdentifier -{ - MGLAssertStyleLayerIsValid(); - - return @(self.rawLayer->getSourceID().c_str()); -} - -- (NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - - auto layerID = self.rawLayer->getSourceLayer(); - return layerID.empty() ? nil : @(layerID.c_str()); -} - -- (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); - - self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); -} - -- (void)setPredicate:(NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting predicate: %@", predicate); - - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); -} - -- (NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - - return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; -} - -// MARK: - Accessing the Paint Attributes - -- (void)setHeatmapColor:(NSExpression *)heatmapColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting heatmapColor: %@", heatmapColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(heatmapColor); - self.rawLayer->setHeatmapColor(mbglValue); -} - -- (NSExpression *)heatmapColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHeatmapColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHeatmapColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHeatmapIntensity:(NSExpression *)heatmapIntensity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting heatmapIntensity: %@", heatmapIntensity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapIntensity, false); - self.rawLayer->setHeatmapIntensity(mbglValue); -} - -- (NSExpression *)heatmapIntensity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHeatmapIntensity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHeatmapIntensity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHeatmapIntensityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting heatmapIntensityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setHeatmapIntensityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)heatmapIntensityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getHeatmapIntensityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setHeatmapOpacity:(NSExpression *)heatmapOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting heatmapOpacity: %@", heatmapOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapOpacity, false); - self.rawLayer->setHeatmapOpacity(mbglValue); -} - -- (NSExpression *)heatmapOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHeatmapOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHeatmapOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHeatmapOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting heatmapOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setHeatmapOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)heatmapOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getHeatmapOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setHeatmapRadius:(NSExpression *)heatmapRadius { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting heatmapRadius: %@", heatmapRadius); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapRadius, true); - self.rawLayer->setHeatmapRadius(mbglValue); -} - -- (NSExpression *)heatmapRadius { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHeatmapRadius(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHeatmapRadius(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHeatmapRadiusTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting heatmapRadiusTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setHeatmapRadiusTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)heatmapRadiusTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getHeatmapRadiusTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setHeatmapWeight:(NSExpression *)heatmapWeight { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting heatmapWeight: %@", heatmapWeight); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapWeight, true); - self.rawLayer->setHeatmapWeight(mbglValue); -} - -- (NSExpression *)heatmapWeight { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHeatmapWeight(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHeatmapWeight(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -@end - -namespace mbgl { - -MGLStyleLayer* HeatmapStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLHeatmapStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer_Private.h deleted file mode 100644 index 407036ced..000000000 --- a/platform/ios/platform/darwin/src/MGLHeatmapStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class HeatmapStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::HeatmapLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer.h b/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer.h deleted file mode 100644 index 5fa2449d1..000000000 --- a/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer.h +++ /dev/null @@ -1,324 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLForegroundStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - Direction of light source when map is rotated. - - Values of this type are used in the `MGLHillshadeStyleLayer.hillshadeIlluminationAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLHillshadeIlluminationAnchor) { - /** - The hillshade illumination is relative to the north direction. - */ - MGLHillshadeIlluminationAnchorMap, - /** - The hillshade illumination is relative to the top of the viewport. - */ - MGLHillshadeIlluminationAnchorViewport, -}; - -/** - An `MGLHillshadeStyleLayer` is a style layer that renders raster digital elevation - model (DEM) tiles on the map. - - Use a hillshade style layer to configure the color parameters of raster tiles - loaded by an `MGLRasterDEMSource` object. For example, you could use a - hillshade style layer to render Mapbox - Terrain-RGB data. - - To display posterized hillshading based on vector shapes, as with the Mapbox Terrain - source, use an `MGLVectorTileSource` object in conjunction with several - `MGLFillStyleLayer` objects. - - You can access an existing hillshade style layer using the - `-[MGLStyle layerWithIdentifier:]` method if you know its identifier; - otherwise, find it using the `MGLStyle.layers` property. You can also create a - new hillshade style layer and add it to the style using a method such as - `-[MGLStyle addLayer:]`. - - ### Example - - ```swift - let layer = MGLHillshadeStyleLayer(identifier: "hills", source: source) - layer.hillshadeExaggeration = NSExpression(forConstantValue: 0.6) - if let canalShadowLayer = mapView.style?.layer(withIdentifier: "waterway-river-canal-shadow") { - mapView.style?.insertLayer(layer, below: canalShadowLayer) - } - ``` - */ -MGL_EXPORT -@interface MGLHillshadeStyleLayer : MGLForegroundStyleLayer - -/** - Returns a hillshade style layer initialized with an identifier and source. - - After initializing and configuring the style layer, add it to a map view’s - style using the `-[MGLStyle addLayer:]` or - `-[MGLStyle insertLayer:belowLayer:]` method. - - @param identifier A string that uniquely identifies the source in the style to - which it is added. - @param source The source from which to obtain the data to style. If the source - has not yet been added to the current style, the behavior is undefined. - @return An initialized foreground style layer. - */ -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; - -// MARK: - Accessing the Paint Attributes - -#if TARGET_OS_IPHONE -/** - The shading color used to accentuate rugged terrain like sharp cliffs and - gorges. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeAccentColor; -#else -/** - The shading color used to accentuate rugged terrain like sharp cliffs and - gorges. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeAccentColor; -#endif - -/** - The transition affecting any changes to this layer’s `hillshadeAccentColor` property. - - This property corresponds to the `hillshade-accent-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition hillshadeAccentColorTransition; - -/** - Intensity of the hillshade - - The default value of this property is an expression that evaluates to the float - `0.5`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeExaggeration; - -/** - The transition affecting any changes to this layer’s `hillshadeExaggeration` property. - - This property corresponds to the `hillshade-exaggeration-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition hillshadeExaggerationTransition; - -#if TARGET_OS_IPHONE -/** - The shading color of areas that faces towards the light source. - - The default value of this property is an expression that evaluates to - `UIColor.whiteColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeHighlightColor; -#else -/** - The shading color of areas that faces towards the light source. - - The default value of this property is an expression that evaluates to - `NSColor.whiteColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeHighlightColor; -#endif - -/** - The transition affecting any changes to this layer’s `hillshadeHighlightColor` property. - - This property corresponds to the `hillshade-highlight-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition hillshadeHighlightColorTransition; - -/** - Direction of light source when map is rotated. - - The default value of this property is an expression that evaluates to - `viewport`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant `MGLHillshadeIlluminationAnchor` values - * Any of the following constant string values: - * `map`: The hillshade illumination is relative to the north direction. - * `viewport`: The hillshade illumination is relative to the top of the - viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeIlluminationAnchor; - -/** - The direction of the light source used to generate the hillshading with 0 as - the top of the viewport if `hillshadeIlluminationAnchor` is set to - `MGLHillshadeIlluminationAnchorViewport` and due north if - `hillshadeIlluminationAnchor` is set to `MGLHillshadeIlluminationAnchorMap`. - - The default value of this property is an expression that evaluates to the float - `335`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 359 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeIlluminationDirection; - -#if TARGET_OS_IPHONE -/** - The shading color of areas that face away from the light source. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeShadowColor; -#else -/** - The shading color of areas that face away from the light source. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *hillshadeShadowColor; -#endif - -/** - The transition affecting any changes to this layer’s `hillshadeShadowColor` property. - - This property corresponds to the `hillshade-shadow-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition hillshadeShadowColorTransition; - -@end - -/** - Methods for wrapping an enumeration value for a style layer attribute in an - `MGLHillshadeStyleLayer` object and unwrapping its raw value. - */ -@interface NSValue (MGLHillshadeStyleLayerAdditions) - -// MARK: Working with Hillshade Style Layer Attribute Values - -/** - Creates a new value object containing the given `MGLHillshadeIlluminationAnchor` enumeration. - - @param hillshadeIlluminationAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLHillshadeIlluminationAnchor:(MGLHillshadeIlluminationAnchor)hillshadeIlluminationAnchor; - -/** - The `MGLHillshadeIlluminationAnchor` enumeration representation of the value. - */ -@property (readonly) MGLHillshadeIlluminationAnchor MGLHillshadeIlluminationAnchorValue; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer.mm b/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer.mm deleted file mode 100644 index bb747f3af..000000000 --- a/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer.mm +++ /dev/null @@ -1,245 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLHillshadeStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLHillshadeStyleLayer_Private.h" - -#include -#include - - -namespace mbgl { - - MBGL_DEFINE_ENUM(MGLHillshadeIlluminationAnchor, { - { MGLHillshadeIlluminationAnchorMap, "map" }, - { MGLHillshadeIlluminationAnchorViewport, "viewport" }, - }); - -} - -@interface MGLHillshadeStyleLayer () - -@property (nonatomic, readonly) mbgl::style::HillshadeLayer *rawLayer; - -@end - -@implementation MGLHillshadeStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source -{ - MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::HillshadeLayer *)rawLayer -{ - return (mbgl::style::HillshadeLayer *)super.rawLayer; -} - -- (NSString *)sourceIdentifier -{ - MGLAssertStyleLayerIsValid(); - - return @(self.rawLayer->getSourceID().c_str()); -} - -// MARK: - Accessing the Paint Attributes - -- (void)setHillshadeAccentColor:(NSExpression *)hillshadeAccentColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeAccentColor: %@", hillshadeAccentColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeAccentColor, false); - self.rawLayer->setHillshadeAccentColor(mbglValue); -} - -- (NSExpression *)hillshadeAccentColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHillshadeAccentColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHillshadeAccentColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHillshadeAccentColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeAccentColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setHillshadeAccentColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)hillshadeAccentColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getHillshadeAccentColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setHillshadeExaggeration:(NSExpression *)hillshadeExaggeration { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeExaggeration: %@", hillshadeExaggeration); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeExaggeration, false); - self.rawLayer->setHillshadeExaggeration(mbglValue); -} - -- (NSExpression *)hillshadeExaggeration { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHillshadeExaggeration(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHillshadeExaggeration(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHillshadeExaggerationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeExaggerationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setHillshadeExaggerationTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)hillshadeExaggerationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getHillshadeExaggerationTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setHillshadeHighlightColor:(NSExpression *)hillshadeHighlightColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeHighlightColor: %@", hillshadeHighlightColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeHighlightColor, false); - self.rawLayer->setHillshadeHighlightColor(mbglValue); -} - -- (NSExpression *)hillshadeHighlightColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHillshadeHighlightColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHillshadeHighlightColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHillshadeHighlightColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeHighlightColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setHillshadeHighlightColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)hillshadeHighlightColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getHillshadeHighlightColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setHillshadeIlluminationAnchor:(NSExpression *)hillshadeIlluminationAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeIlluminationAnchor: %@", hillshadeIlluminationAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeIlluminationAnchor, false); - self.rawLayer->setHillshadeIlluminationAnchor(mbglValue); -} - -- (NSExpression *)hillshadeIlluminationAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHillshadeIlluminationAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHillshadeIlluminationAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHillshadeIlluminationDirection:(NSExpression *)hillshadeIlluminationDirection { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeIlluminationDirection: %@", hillshadeIlluminationDirection); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeIlluminationDirection, false); - self.rawLayer->setHillshadeIlluminationDirection(mbglValue); -} - -- (NSExpression *)hillshadeIlluminationDirection { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHillshadeIlluminationDirection(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHillshadeIlluminationDirection(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHillshadeShadowColor:(NSExpression *)hillshadeShadowColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeShadowColor: %@", hillshadeShadowColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeShadowColor, false); - self.rawLayer->setHillshadeShadowColor(mbglValue); -} - -- (NSExpression *)hillshadeShadowColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getHillshadeShadowColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultHillshadeShadowColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setHillshadeShadowColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting hillshadeShadowColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setHillshadeShadowColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)hillshadeShadowColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getHillshadeShadowColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -@end - -@implementation NSValue (MGLHillshadeStyleLayerAdditions) - -+ (NSValue *)valueWithMGLHillshadeIlluminationAnchor:(MGLHillshadeIlluminationAnchor)hillshadeIlluminationAnchor { - return [NSValue value:&hillshadeIlluminationAnchor withObjCType:@encode(MGLHillshadeIlluminationAnchor)]; -} - -- (MGLHillshadeIlluminationAnchor)MGLHillshadeIlluminationAnchorValue { - MGLHillshadeIlluminationAnchor hillshadeIlluminationAnchor; - [self getValue:&hillshadeIlluminationAnchor]; - return hillshadeIlluminationAnchor; -} - -@end - -namespace mbgl { - -MGLStyleLayer* HillshadeStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLHillshadeStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer_Private.h deleted file mode 100644 index 4c427f213..000000000 --- a/platform/ios/platform/darwin/src/MGLHillshadeStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class HillshadeStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::HillshadeLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLLight.h b/platform/ios/platform/darwin/src/MGLLight.h deleted file mode 100644 index a2bf021f2..000000000 --- a/platform/ios/platform/darwin/src/MGLLight.h +++ /dev/null @@ -1,242 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import - -#import "MGLFoundation.h" -#import "MGLStyleValue.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - Whether extruded geometries are lit relative to the map or viewport. - */ -typedef NS_ENUM(NSUInteger, MGLLightAnchor) { - /** - The position of the light source is aligned to the rotation of the map. - */ - MGLLightAnchorMap, - /** - The position of the light source is aligned to the rotation of the - viewport. - */ - MGLLightAnchorViewport, -}; - -/** - A structure containing information about the position of the light source - relative to lit geometries. - */ -typedef struct __attribute__((objc_boxable)) MGLSphericalPosition { - /** Distance from the center of the base of an object to its light. */ - CGFloat radial; - /** Position of the light relative to 0° (0° when `MGLLight.anchor` is set to viewport corresponds - to the top of the viewport, or 0° when `MGLLight.anchor` is set to map corresponds to due north, - and degrees proceed clockwise). */ - CLLocationDirection azimuthal; - /** Indicates the height of the light (from 0°, directly above, to 180°, directly below). */ - CLLocationDirection polar; -} MGLSphericalPosition; - -/** - Creates a new `MGLSphericalPosition` from the given radial, azimuthal, polar. - - @param radial The radial coordinate. - @param azimuthal The azimuthal angle. - @param polar The polar angle. - - @return Returns a `MGLSphericalPosition` struct containing the position attributes. - */ -NS_INLINE MGLSphericalPosition MGLSphericalPositionMake(CGFloat radial, CLLocationDirection azimuthal, CLLocationDirection polar) { - MGLSphericalPosition position; - position.radial = radial; - position.azimuthal = azimuthal; - position.polar = polar; - - return position; -} - -/** - An `MGLLight` object represents the light source for extruded geometries in - `MGLStyle`. - - ### Example - ```swift - let light = MGLLight() - let position = MGLSphericalPosition(radial: 5, azimuthal: 180, polar: 80) - light.position = NSExpression(forConstantValue: NSValue(mglSphericalPosition: position)) - light.anchor = NSExpression(forConstantValue: "map") - mapView.style?.light = light - ``` - - #### Related examples - See the Adjust light of - 3D buildings to learn how to create and modify the light source for 3D - geometries. - */ -MGL_EXPORT -@interface MGLLight : NSObject - -/** - Whether extruded geometries are lit relative to the map or viewport. - - The default value of this property is an expression that evaluates to - `viewport`. - - You can set this property to an expression containing any of the following: - - * Constant `MGLAnchor` values - * Any of the following constant string values: - * `map`: The position of the light source is aligned to the rotation of the - map. - * `viewport`: The position of the light source is aligned to the rotation of - the viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - - This property corresponds to the anchor - light property in the Mapbox Style Specification. - */ -@property (nonatomic) NSExpression *anchor; - -/** - Position of the `MGLLight` source relative to lit (extruded) geometries, in a - `MGLSphericalPosition` struct [radial coordinate, azimuthal angle, polar angle] - where radial indicates the distance from the center of the base of an object to - its light, azimuthal indicates the position of the light relative to 0° (0° - when `MGLLight.anchor` is set to `MGLLightAnchorViewport` corresponds to the - top of the viewport, or 0° when `MGLLight.anchor` is set to `MGLLightAnchorMap` - corresponds to due north, and degrees proceed clockwise), and polar indicates - the height of the light (from 0°, directly above, to 180°, directly below). - - The default value of this property is an expression that evaluates to an - `MGLSphericalPosition` struct set to 1.15 radial, 210 azimuthal and 30 polar. - - You can set this property to an expression containing any of the following: - - * Constant `MGLSphericalPosition` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - - This property corresponds to the position - light property in the Mapbox Style Specification. - - #### Related examples - See the Adjust light of - 3D buildings example to learn how to create and modify the position of - value of an `MGLLight` object for 3D geometries. - */ -@property (nonatomic) NSExpression *position; - -/** - The transition affecting any changes to this layer’s `position` property. - - This property corresponds to the `position-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition positionTransition; - -#if TARGET_OS_IPHONE -/** - Color tint for lighting extruded geometries. - - The default value of this property is an expression that evaluates to - `UIColor.whiteColor`. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - - This property corresponds to the color - light property in the Mapbox Style Specification. - */ -@property (nonatomic) NSExpression *color; -#else -/** - Color tint for lighting extruded geometries. - - The default value of this property is an expression that evaluates to - `NSColor.whiteColor`. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - - This property corresponds to the color - light property in the Mapbox Style Specification. - */ -@property (nonatomic) NSExpression *color; -#endif - -/** - The transition affecting any changes to this layer’s `color` property. - - This property corresponds to the `color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition colorTransition; - -/** - Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as - more extreme contrast. - - The default value of this property is an expression that evaluates to the float - `0.5`. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - - This property corresponds to the intensity - light property in the Mapbox Style Specification. - */ -@property (nonatomic) NSExpression *intensity; - -/** - The transition affecting any changes to this layer’s `intensity` property. - - This property corresponds to the `intensity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition intensityTransition; - - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLLight.mm b/platform/ios/platform/darwin/src/MGLLight.mm deleted file mode 100644 index b7566d57a..000000000 --- a/platform/ios/platform/darwin/src/MGLLight.mm +++ /dev/null @@ -1,133 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -// test - -#import "MGLLight.h" - -#import "MGLTypes.h" -#import "MGLStyleValue_Private.h" -#import "NSValue+MGLAdditions.h" -#import "MGLLoggingConfiguration_Private.h" - -#import -#import - -namespace mbgl { - - MBGL_DEFINE_ENUM(MGLLightAnchor, { - { MGLLightAnchorMap, "map" }, - { MGLLightAnchorViewport, "viewport" }, - }); - -} - -@interface MGLLight() - -@end - -@implementation MGLLight - -- (instancetype)initWithMBGLLight:(const mbgl::style::Light *)mbglLight -{ - if (self = [super init]) { - MGLLogInfo(@"Initializing %@.", NSStringFromClass([self class])); - auto anchor = mbglLight->getAnchor(); - NSExpression *anchorExpression; - if (anchor.isUndefined()) { - mbgl::style::PropertyValue defaultAnchor = mbglLight->getDefaultAnchor(); - anchorExpression = MGLStyleValueTransformer().toExpression(defaultAnchor); - } else { - anchorExpression = MGLStyleValueTransformer().toExpression(anchor); - } - - _anchor = anchorExpression; - - auto positionValue = mbglLight->getPosition(); - if (positionValue.isUndefined()) { - _position = MGLStyleValueTransformer().toExpression(mbglLight->getDefaultPosition()); - } else { - _position = MGLStyleValueTransformer().toExpression(positionValue); - } - _positionTransition = MGLTransitionFromOptions(mbglLight->getPositionTransition()); - auto colorValue = mbglLight->getColor(); - if (colorValue.isUndefined()) { - _color = MGLStyleValueTransformer().toExpression(mbglLight->getDefaultColor()); - } else { - _color = MGLStyleValueTransformer().toExpression(colorValue); - } - _colorTransition = MGLTransitionFromOptions(mbglLight->getColorTransition()); - auto intensityValue = mbglLight->getIntensity(); - if (intensityValue.isUndefined()) { - _intensity = MGLStyleValueTransformer().toExpression(mbglLight->getDefaultIntensity()); - } else { - _intensity = MGLStyleValueTransformer().toExpression(intensityValue); - } - _intensityTransition = MGLTransitionFromOptions(mbglLight->getIntensityTransition()); - } - - return self; -} - -- (mbgl::style::Light)mbglLight -{ - mbgl::style::Light mbglLight; - auto anchor = MGLStyleValueTransformer().toPropertyValue>(self.anchor, false); - mbglLight.setAnchor(anchor); - - auto position = MGLStyleValueTransformer().toPropertyValue>(self.position, false); - mbglLight.setPosition(position); - - mbglLight.setPositionTransition(MGLOptionsFromTransition(self.positionTransition)); - - auto color = MGLStyleValueTransformer().toPropertyValue>(self.color, false); - mbglLight.setColor(color); - - mbglLight.setColorTransition(MGLOptionsFromTransition(self.colorTransition)); - - auto intensity = MGLStyleValueTransformer().toPropertyValue>(self.intensity, false); - mbglLight.setIntensity(intensity); - - mbglLight.setIntensityTransition(MGLOptionsFromTransition(self.intensityTransition)); - - - return mbglLight; -} - - - -- (void)setAnchor:(NSExpression *)anchor { - MGLLogDebug(@"Setting anchor: %@", anchor); - _anchor = anchor; -} - -- (void)setPosition:(NSExpression *)position { - MGLLogDebug(@"Setting position: %@", position); - _position = position; -} - -- (void)setPositionTransition:(MGLTransition)transition { - MGLLogDebug(@"Setting positionTransition: %@", MGLStringFromMGLTransition(transition)); - _positionTransition = transition; -} - -- (void)setColor:(NSExpression *)color { - MGLLogDebug(@"Setting color: %@", color); - _color = color; -} - -- (void)setColorTransition:(MGLTransition)transition { - MGLLogDebug(@"Setting colorTransition: %@", MGLStringFromMGLTransition(transition)); - _colorTransition = transition; -} - -- (void)setIntensity:(NSExpression *)intensity { - MGLLogDebug(@"Setting intensity: %@", intensity); - _intensity = intensity; -} - -- (void)setIntensityTransition:(MGLTransition)transition { - MGLLogDebug(@"Setting intensityTransition: %@", MGLStringFromMGLTransition(transition)); - _intensityTransition = transition; -} - -@end diff --git a/platform/ios/platform/darwin/src/MGLLineStyleLayer.h b/platform/ios/platform/darwin/src/MGLLineStyleLayer.h deleted file mode 100644 index 8b0e0d667..000000000 --- a/platform/ios/platform/darwin/src/MGLLineStyleLayer.h +++ /dev/null @@ -1,691 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLVectorStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - The display of line endings. - - Values of this type are used in the `MGLLineStyleLayer.lineCap` - property. - */ -typedef NS_ENUM(NSUInteger, MGLLineCap) { - /** - A cap with a squared-off end which is drawn to the exact endpoint of the - line. - */ - MGLLineCapButt, - /** - A cap with a rounded end which is drawn beyond the endpoint of the line at - a radius of one-half of the line's width and centered on the endpoint of - the line. - */ - MGLLineCapRound, - /** - A cap with a squared-off end which is drawn beyond the endpoint of the line - at a distance of one-half of the line's width. - */ - MGLLineCapSquare, -}; - -/** - The display of lines when joining. - - Values of this type are used in the `MGLLineStyleLayer.lineJoin` - property. - */ -typedef NS_ENUM(NSUInteger, MGLLineJoin) { - /** - A join with a squared-off end which is drawn beyond the endpoint of the - line at a distance of one-half of the line's width. - */ - MGLLineJoinBevel, - /** - A join with a rounded end which is drawn beyond the endpoint of the line at - a radius of one-half of the line's width and centered on the endpoint of - the line. - */ - MGLLineJoinRound, - /** - A join with a sharp, angled corner which is drawn with the outer sides - beyond the endpoint of the path until they meet. - */ - MGLLineJoinMiter, -}; - -/** - Controls the frame of reference for `MGLLineStyleLayer.lineTranslation`. - - Values of this type are used in the `MGLLineStyleLayer.lineTranslationAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLLineTranslationAnchor) { - /** - The line is translated relative to the map. - */ - MGLLineTranslationAnchorMap, - /** - The line is translated relative to the viewport. - */ - MGLLineTranslationAnchorViewport, -}; - -/** - An `MGLLineStyleLayer` is a style layer that renders one or more stroked - polylines on the map. - - Use a line style layer to configure the visual appearance of polyline or - multipolyline features. These features can come from vector tiles loaded by an - `MGLVectorTileSource` object, or they can be `MGLPolyline`, - `MGLPolylineFeature`, `MGLMultiPolyline`, or `MGLMultiPolylineFeature` - instances in an `MGLShapeSource` or `MGLComputedShapeSource` object. - - You can access an existing line style layer using the - `-[MGLStyle layerWithIdentifier:]` method if you know its identifier; - otherwise, find it using the `MGLStyle.layers` property. You can also create a - new line style layer and add it to the style using a method such as - `-[MGLStyle addLayer:]`. - - #### Related examples - See the Add multiple - shapes from a single shape source example to learn how to add a line to - your map using this style layer. See the Add a line - style layer from GeoJSON example to learn how to add and style line data to - an `MGLMapView` object at runtime. - - ### Example - - ```swift - let layer = MGLLineStyleLayer(identifier: "trails-path", source: trails) - layer.sourceLayerIdentifier = "trails" - - let stops = NSExpression(forConstantValue: [14: 2, - 18: 20]) - layer.lineWidth = NSExpression(forMGLInterpolating: .zoomLevelVariable, - curveType: .exponential, - parameters: NSExpression(forConstantValue: 1.5), - stops: stops) - - layer.lineColor = NSExpression(forConstantValue: UIColor.brown) - layer.lineCap = NSExpression(forConstantValue: "round") - layer.predicate = NSPredicate(format: "%K == %@", "trail-type", "mountain-biking") - mapView.style?.addLayer(layer) - ``` - */ -MGL_EXPORT -@interface MGLLineStyleLayer : MGLVectorStyleLayer - -/** - Returns a line style layer initialized with an identifier and source. - - After initializing and configuring the style layer, add it to a map view’s - style using the `-[MGLStyle addLayer:]` or - `-[MGLStyle insertLayer:belowLayer:]` method. - - @param identifier A string that uniquely identifies the source in the style to - which it is added. - @param source The source from which to obtain the data to style. If the source - has not yet been added to the current style, the behavior is undefined. - @return An initialized foreground style layer. - */ -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; - -// MARK: - Accessing the Layout Attributes - -/** - The display of line endings. - - The default value of this property is an expression that evaluates to `butt`. - Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant `MGLLineCap` values - * Any of the following constant string values: - * `butt`: A cap with a squared-off end which is drawn to the exact endpoint - of the line. - * `round`: A cap with a rounded end which is drawn beyond the endpoint of the - line at a radius of one-half of the line's width and centered on the endpoint - of the line. - * `square`: A cap with a squared-off end which is drawn beyond the endpoint - of the line at a distance of one-half of the line's width. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineCap; - -/** - The display of lines when joining. - - The default value of this property is an expression that evaluates to `miter`. - Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant `MGLLineJoin` values - * Any of the following constant string values: - * `bevel`: A join with a squared-off end which is drawn beyond the endpoint - of the line at a distance of one-half of the line's width. - * `round`: A join with a rounded end which is drawn beyond the endpoint of - the line at a radius of one-half of the line's width and centered on the - endpoint of the line. - * `miter`: A join with a sharp, angled corner which is drawn with the outer - sides beyond the endpoint of the path until they meet. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineJoin; - -/** - Used to automatically convert miter joins to bevel joins for sharp angles. - - The default value of this property is an expression that evaluates to the float - `2`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `lineJoin` is set to an - expression that evaluates to `miter`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineMiterLimit; - -/** - Used to automatically convert round joins to miter joins for shallow angles. - - The default value of this property is an expression that evaluates to the float - `1.05`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `lineJoin` is set to an - expression that evaluates to `round`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineRoundLimit; - -/** - Sorts features in ascending order based on this value. Features with a higher - sort key will appear above features with a lower sort key. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineSortKey; - -// MARK: - Accessing the Paint Attributes - -/** - Blur applied to the line, in points. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineBlur; - -/** - The transition affecting any changes to this layer’s `lineBlur` property. - - This property corresponds to the `line-blur-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition lineBlurTransition; - -#if TARGET_OS_IPHONE -/** - The color with which the line will be drawn. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `linePattern` is set to `nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineColor; -#else -/** - The color with which the line will be drawn. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `linePattern` is set to `nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineColor; -#endif - -/** - The transition affecting any changes to this layer’s `lineColor` property. - - This property corresponds to the `line-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition lineColorTransition; - -/** - 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 points, 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. - - This property is measured in line widths. - - This property is only applied to the style if `linePattern` is set to `nil`. - Otherwise, it is ignored. - - This attribute corresponds to the line-dasharray - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant array values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineDashPattern; - -/** - The transition affecting any changes to this layer’s `lineDashPattern` property. - - This property corresponds to the `line-dasharray-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition lineDashPatternTransition; - -@property (nonatomic, null_resettable) NSExpression *lineDasharray __attribute__((unavailable("Use lineDashPattern instead."))); - -/** - Draws a line casing outside of a line's actual path. Value indicates the width - of the inner gap. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineGapWidth; - -/** - The transition affecting any changes to this layer’s `lineGapWidth` property. - - This property corresponds to the `line-gap-width-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition lineGapWidthTransition; - -#if TARGET_OS_IPHONE -/** - The color gradient with which the line will be drawn. This property only has an - effect on lines defined by an `MGLShapeSource` whose - `MGLShapeSourceOptionLineDistanceMetrics` option is set to `YES`. - - This property is only applied to the style if `lineDasharray` is set to `nil`, - and `linePattern` is set to `nil`, and the data source requirements are met. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$lineProgress` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineGradient; -#else -/** - The color gradient with which the line will be drawn. This property only has an - effect on lines defined by an `MGLShapeSource` whose - `MGLShapeSourceOptionLineDistanceMetrics` option is set to `YES`. - - This property is only applied to the style if `lineDasharray` is set to `nil`, - and `linePattern` is set to `nil`, and the data source requirements are met. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$lineProgress` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineGradient; -#endif - -/** - The line's offset. For linear features, a positive value offsets the line to - the right, relative to the direction of the line, and a negative value to the - left. For polygon features, a positive value results in an inset, and a - negative value results in an outset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineOffset; - -/** - The transition affecting any changes to this layer’s `lineOffset` property. - - This property corresponds to the `line-offset-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition lineOffsetTransition; - -/** - The opacity at which the line will be drawn. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineOpacity; - -/** - The transition affecting any changes to this layer’s `lineOpacity` property. - - This property corresponds to the `line-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition lineOpacityTransition; - -/** - Name of image in style images to use for drawing image lines. For seamless - patterns, image width must be a factor of two (2, 4, 8, ..., 512). - - You can set this property to an expression containing any of the following: - - * Constant string values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *linePattern; - -/** - The transition affecting any changes to this layer’s `linePattern` property. - - This property corresponds to the `line-pattern-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition linePatternTransition; - -#if TARGET_OS_IPHONE -/** - The geometry's offset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points downward. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the line-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineTranslation; -#else -/** - The geometry's offset. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points upward. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the line-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineTranslation; -#endif - -/** - The transition affecting any changes to this layer’s `lineTranslation` property. - - This property corresponds to the `line-translate-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition lineTranslationTransition; - -@property (nonatomic, null_resettable) NSExpression *lineTranslate __attribute__((unavailable("Use lineTranslation instead."))); - -/** - Controls the frame of reference for `lineTranslation`. - - The default value of this property is an expression that evaluates to `map`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `lineTranslation` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the line-translate-anchor - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLLineTranslationAnchor` values - * Any of the following constant string values: - * `map`: The line is translated relative to the map. - * `viewport`: The line is translated relative to the viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *lineTranslationAnchor; - -@property (nonatomic, null_resettable) NSExpression *lineTranslateAnchor __attribute__((unavailable("Use lineTranslationAnchor instead."))); - -/** - Stroke thickness. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *lineWidth; - -/** - The transition affecting any changes to this layer’s `lineWidth` property. - - This property corresponds to the `line-width-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition lineWidthTransition; - -@end - -/** - Methods for wrapping an enumeration value for a style layer attribute in an - `MGLLineStyleLayer` object and unwrapping its raw value. - */ -@interface NSValue (MGLLineStyleLayerAdditions) - -// MARK: Working with Line Style Layer Attribute Values - -/** - Creates a new value object containing the given `MGLLineCap` enumeration. - - @param lineCap The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLLineCap:(MGLLineCap)lineCap; - -/** - The `MGLLineCap` enumeration representation of the value. - */ -@property (readonly) MGLLineCap MGLLineCapValue; - -/** - Creates a new value object containing the given `MGLLineJoin` enumeration. - - @param lineJoin The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLLineJoin:(MGLLineJoin)lineJoin; - -/** - The `MGLLineJoin` enumeration representation of the value. - */ -@property (readonly) MGLLineJoin MGLLineJoinValue; - -/** - Creates a new value object containing the given `MGLLineTranslationAnchor` enumeration. - - @param lineTranslationAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLLineTranslationAnchor:(MGLLineTranslationAnchor)lineTranslationAnchor; - -/** - The `MGLLineTranslationAnchor` enumeration representation of the value. - */ -@property (readonly) MGLLineTranslationAnchor MGLLineTranslationAnchorValue; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLLineStyleLayer.mm b/platform/ios/platform/darwin/src/MGLLineStyleLayer.mm deleted file mode 100644 index 1e9aebd50..000000000 --- a/platform/ios/platform/darwin/src/MGLLineStyleLayer.mm +++ /dev/null @@ -1,586 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLLineStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLLineStyleLayer_Private.h" - -#include -#include - - -namespace mbgl { - - MBGL_DEFINE_ENUM(MGLLineCap, { - { MGLLineCapButt, "butt" }, - { MGLLineCapRound, "round" }, - { MGLLineCapSquare, "square" }, - }); - - MBGL_DEFINE_ENUM(MGLLineJoin, { - { MGLLineJoinBevel, "bevel" }, - { MGLLineJoinRound, "round" }, - { MGLLineJoinMiter, "miter" }, - }); - - MBGL_DEFINE_ENUM(MGLLineTranslationAnchor, { - { MGLLineTranslationAnchorMap, "map" }, - { MGLLineTranslationAnchorViewport, "viewport" }, - }); - -} - -@interface MGLLineStyleLayer () - -@property (nonatomic, readonly) mbgl::style::LineLayer *rawLayer; - -@end - -@implementation MGLLineStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source -{ - MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::LineLayer *)rawLayer -{ - return (mbgl::style::LineLayer *)super.rawLayer; -} - -- (NSString *)sourceIdentifier -{ - MGLAssertStyleLayerIsValid(); - - return @(self.rawLayer->getSourceID().c_str()); -} - -- (NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - - auto layerID = self.rawLayer->getSourceLayer(); - return layerID.empty() ? nil : @(layerID.c_str()); -} - -- (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); - - self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); -} - -- (void)setPredicate:(NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting predicate: %@", predicate); - - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); -} - -- (NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - - return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; -} - -// MARK: - Accessing the Layout Attributes - -- (void)setLineCap:(NSExpression *)lineCap { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineCap: %@", lineCap); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineCap, false); - self.rawLayer->setLineCap(mbglValue); -} - -- (NSExpression *)lineCap { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineCap(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineCap(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineJoin:(NSExpression *)lineJoin { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineJoin: %@", lineJoin); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineJoin, true); - self.rawLayer->setLineJoin(mbglValue); -} - -- (NSExpression *)lineJoin { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineJoin(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineJoin(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineMiterLimit:(NSExpression *)lineMiterLimit { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineMiterLimit: %@", lineMiterLimit); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineMiterLimit, false); - self.rawLayer->setLineMiterLimit(mbglValue); -} - -- (NSExpression *)lineMiterLimit { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineMiterLimit(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineMiterLimit(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineRoundLimit:(NSExpression *)lineRoundLimit { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineRoundLimit: %@", lineRoundLimit); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineRoundLimit, false); - self.rawLayer->setLineRoundLimit(mbglValue); -} - -- (NSExpression *)lineRoundLimit { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineRoundLimit(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineRoundLimit(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineSortKey:(NSExpression *)lineSortKey { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineSortKey: %@", lineSortKey); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineSortKey, true); - self.rawLayer->setLineSortKey(mbglValue); -} - -- (NSExpression *)lineSortKey { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineSortKey(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineSortKey(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -// MARK: - Accessing the Paint Attributes - -- (void)setLineBlur:(NSExpression *)lineBlur { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineBlur: %@", lineBlur); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineBlur, true); - self.rawLayer->setLineBlur(mbglValue); -} - -- (NSExpression *)lineBlur { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineBlur(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineBlur(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineBlurTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineBlurTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLineBlurTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)lineBlurTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLineBlurTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setLineColor:(NSExpression *)lineColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineColor: %@", lineColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineColor, true); - self.rawLayer->setLineColor(mbglValue); -} - -- (NSExpression *)lineColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLineColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)lineColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLineColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setLineDashPattern:(NSExpression *)lineDashPattern { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineDashPattern: %@", lineDashPattern); - - auto mbglValue = MGLStyleValueTransformer, NSArray *, float>().toPropertyValue>>(lineDashPattern, false); - self.rawLayer->setLineDasharray(mbglValue); -} - -- (NSExpression *)lineDashPattern { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineDasharray(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineDasharray(); - } - return MGLStyleValueTransformer, NSArray *, float>().toExpression(propertyValue); -} - -- (void)setLineDashPatternTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineDashPatternTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLineDasharrayTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)lineDashPatternTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLineDasharrayTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setLineDasharray:(NSExpression *)lineDasharray { -} - -- (NSExpression *)lineDasharray { - return self.lineDashPattern; -} - -- (void)setLineGapWidth:(NSExpression *)lineGapWidth { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineGapWidth: %@", lineGapWidth); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineGapWidth, true); - self.rawLayer->setLineGapWidth(mbglValue); -} - -- (NSExpression *)lineGapWidth { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineGapWidth(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineGapWidth(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineGapWidthTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineGapWidthTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLineGapWidthTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)lineGapWidthTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLineGapWidthTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setLineGradient:(NSExpression *)lineGradient { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineGradient: %@", lineGradient); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineGradient); - self.rawLayer->setLineGradient(mbglValue); -} - -- (NSExpression *)lineGradient { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineGradient(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineGradient(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineOffset:(NSExpression *)lineOffset { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineOffset: %@", lineOffset); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineOffset, true); - self.rawLayer->setLineOffset(mbglValue); -} - -- (NSExpression *)lineOffset { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineOffset(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineOffset(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineOffsetTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineOffsetTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLineOffsetTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)lineOffsetTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLineOffsetTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setLineOpacity:(NSExpression *)lineOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineOpacity: %@", lineOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineOpacity, true); - self.rawLayer->setLineOpacity(mbglValue); -} - -- (NSExpression *)lineOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLineOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)lineOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLineOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setLinePattern:(NSExpression *)linePattern { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting linePattern: %@", linePattern); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(linePattern, true); - self.rawLayer->setLinePattern(mbglValue); -} - -- (NSExpression *)linePattern { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLinePattern(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLinePattern(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLinePatternTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting linePatternTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLinePatternTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)linePatternTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLinePatternTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setLineTranslation:(NSExpression *)lineTranslation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineTranslation: %@", lineTranslation); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(lineTranslation, false); - self.rawLayer->setLineTranslate(mbglValue); -} - -- (NSExpression *)lineTranslation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineTranslate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineTranslate(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setLineTranslationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineTranslationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLineTranslateTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)lineTranslationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLineTranslateTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setLineTranslate:(NSExpression *)lineTranslate { -} - -- (NSExpression *)lineTranslate { - return self.lineTranslation; -} - -- (void)setLineTranslationAnchor:(NSExpression *)lineTranslationAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineTranslationAnchor: %@", lineTranslationAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineTranslationAnchor, false); - self.rawLayer->setLineTranslateAnchor(mbglValue); -} - -- (NSExpression *)lineTranslationAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineTranslateAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineTranslateAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineTranslateAnchor:(NSExpression *)lineTranslateAnchor { -} - -- (NSExpression *)lineTranslateAnchor { - return self.lineTranslationAnchor; -} - -- (void)setLineWidth:(NSExpression *)lineWidth { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineWidth: %@", lineWidth); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineWidth, true); - self.rawLayer->setLineWidth(mbglValue); -} - -- (NSExpression *)lineWidth { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getLineWidth(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultLineWidth(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setLineWidthTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting lineWidthTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setLineWidthTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)lineWidthTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getLineWidthTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -@end - -@implementation NSValue (MGLLineStyleLayerAdditions) - -+ (NSValue *)valueWithMGLLineCap:(MGLLineCap)lineCap { - return [NSValue value:&lineCap withObjCType:@encode(MGLLineCap)]; -} - -- (MGLLineCap)MGLLineCapValue { - MGLLineCap lineCap; - [self getValue:&lineCap]; - return lineCap; -} - -+ (NSValue *)valueWithMGLLineJoin:(MGLLineJoin)lineJoin { - return [NSValue value:&lineJoin withObjCType:@encode(MGLLineJoin)]; -} - -- (MGLLineJoin)MGLLineJoinValue { - MGLLineJoin lineJoin; - [self getValue:&lineJoin]; - return lineJoin; -} - -+ (NSValue *)valueWithMGLLineTranslationAnchor:(MGLLineTranslationAnchor)lineTranslationAnchor { - return [NSValue value:&lineTranslationAnchor withObjCType:@encode(MGLLineTranslationAnchor)]; -} - -- (MGLLineTranslationAnchor)MGLLineTranslationAnchorValue { - MGLLineTranslationAnchor lineTranslationAnchor; - [self getValue:&lineTranslationAnchor]; - return lineTranslationAnchor; -} - -@end - -namespace mbgl { - -MGLStyleLayer* LineStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLLineStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLLineStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLLineStyleLayer_Private.h deleted file mode 100644 index b4c7b3ee7..000000000 --- a/platform/ios/platform/darwin/src/MGLLineStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class LineStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::LineLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLRasterStyleLayer.h b/platform/ios/platform/darwin/src/MGLRasterStyleLayer.h deleted file mode 100644 index e4edff268..000000000 --- a/platform/ios/platform/darwin/src/MGLRasterStyleLayer.h +++ /dev/null @@ -1,347 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLForegroundStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - The resampling/interpolation method to use for overscaling, also known as - texture magnification filter - - Values of this type are used in the `MGLRasterStyleLayer.rasterResamplingMode` - property. - */ -typedef NS_ENUM(NSUInteger, MGLRasterResamplingMode) { - /** - (Bi)linear filtering interpolates point values using the weighted average - of the four closest original source points creating a smooth but blurry - look when overscaled - */ - MGLRasterResamplingModeLinear, - /** - Nearest neighbor filtering interpolates point values using the nearest - original source point creating a sharp but pointated look when overscaled - */ - MGLRasterResamplingModeNearest, -}; - -/** - An `MGLRasterStyleLayer` is a style layer that renders georeferenced raster - imagery on the map, especially raster tiles. - - Use a raster style layer to configure the color parameters of raster tiles - loaded by an `MGLRasterTileSource` object or raster images loaded by an - `MGLImageSource` object. For example, you could use a raster style layer to - render Mapbox Satellite - imagery, a raster - tile set uploaded to Mapbox Studio, or a raster map authored in TileMill, the classic - Mapbox Editor, or Mapbox Studio Classic. - - Raster images may also be used as icons or patterns in a style layer. To - register an image for use as an icon or pattern, use the `-[MGLStyle - setImage:forName:]` method. To configure a point annotation’s image, use the - `MGLAnnotationImage` class. - - You can access an existing raster style layer using the - `-[MGLStyle layerWithIdentifier:]` method if you know its identifier; - otherwise, find it using the `MGLStyle.layers` property. You can also create a - new raster style layer and add it to the style using a method such as - `-[MGLStyle addLayer:]`. - - #### Related examples - See the Add - an image and Add - raster imagery examples to learn how to add imagery with this style layer. - - ### Example - - ```swift - let layer = MGLRasterStyleLayer(identifier: "clouds", source: source) - layer.rasterOpacity = NSExpression(forConstantValue: 0.5) - mapView.style?.addLayer(layer) - ``` - */ -MGL_EXPORT -@interface MGLRasterStyleLayer : MGLForegroundStyleLayer - -/** - Returns a raster style layer initialized with an identifier and source. - - After initializing and configuring the style layer, add it to a map view’s - style using the `-[MGLStyle addLayer:]` or - `-[MGLStyle insertLayer:belowLayer:]` method. - - @param identifier A string that uniquely identifies the source in the style to - which it is added. - @param source The source from which to obtain the data to style. If the source - has not yet been added to the current style, the behavior is undefined. - @return An initialized foreground style layer. - */ -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; - -// MARK: - Accessing the Paint Attributes - -/** - Increase or reduce the brightness of the image. The value is the maximum - brightness. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the raster-brightness-max - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *maximumRasterBrightness; - -/** - The transition affecting any changes to this layer’s `maximumRasterBrightness` property. - - This property corresponds to the `raster-brightness-max-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition maximumRasterBrightnessTransition; - -@property (nonatomic, null_resettable) NSExpression *rasterBrightnessMax __attribute__((unavailable("Use maximumRasterBrightness instead."))); - -/** - Increase or reduce the brightness of the image. The value is the minimum - brightness. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the raster-brightness-min - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *minimumRasterBrightness; - -/** - The transition affecting any changes to this layer’s `minimumRasterBrightness` property. - - This property corresponds to the `raster-brightness-min-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition minimumRasterBrightnessTransition; - -@property (nonatomic, null_resettable) NSExpression *rasterBrightnessMin __attribute__((unavailable("Use minimumRasterBrightness instead."))); - -/** - Increase or reduce the contrast of the image. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between −1 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *rasterContrast; - -/** - The transition affecting any changes to this layer’s `rasterContrast` property. - - This property corresponds to the `raster-contrast-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition rasterContrastTransition; - -/** - Fade duration when a new tile is added. - - This property is measured in milliseconds. - - The default value of this property is an expression that evaluates to the float - `300`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *rasterFadeDuration; - -/** - Rotates hues around the color wheel. - - This property is measured in degrees. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the raster-hue-rotate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *rasterHueRotation; - -/** - The transition affecting any changes to this layer’s `rasterHueRotation` property. - - This property corresponds to the `raster-hue-rotate-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition rasterHueRotationTransition; - -@property (nonatomic, null_resettable) NSExpression *rasterHueRotate __attribute__((unavailable("Use rasterHueRotation instead."))); - -/** - The opacity at which the image will be drawn. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *rasterOpacity; - -/** - The transition affecting any changes to this layer’s `rasterOpacity` property. - - This property corresponds to the `raster-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition rasterOpacityTransition; - -/** - The resampling/interpolation method to use for overscaling, also known as - texture magnification filter - - The default value of this property is an expression that evaluates to `linear`. - Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the raster-resampling - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLRasterResamplingMode` values - * Any of the following constant string values: - * `linear`: (Bi)linear filtering interpolates pixel values using the weighted - average of the four closest original source pixels creating a smooth but blurry - look when overscaled - * `nearest`: Nearest neighbor filtering interpolates pixel values using the - nearest original source pixel creating a sharp but pixelated look when - overscaled - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *rasterResamplingMode; - -@property (nonatomic, null_resettable) NSExpression *rasterResampling __attribute__((unavailable("Use rasterResamplingMode instead."))); - -/** - Increase or reduce the saturation of the image. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between −1 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *rasterSaturation; - -/** - The transition affecting any changes to this layer’s `rasterSaturation` property. - - This property corresponds to the `raster-saturation-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition rasterSaturationTransition; - -@end - -/** - Methods for wrapping an enumeration value for a style layer attribute in an - `MGLRasterStyleLayer` object and unwrapping its raw value. - */ -@interface NSValue (MGLRasterStyleLayerAdditions) - -// MARK: Working with Raster Style Layer Attribute Values - -/** - Creates a new value object containing the given `MGLRasterResamplingMode` enumeration. - - @param rasterResamplingMode The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLRasterResamplingMode:(MGLRasterResamplingMode)rasterResamplingMode; - -/** - The `MGLRasterResamplingMode` enumeration representation of the value. - */ -@property (readonly) MGLRasterResamplingMode MGLRasterResamplingModeValue; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/ios/platform/darwin/src/MGLRasterStyleLayer.mm deleted file mode 100644 index d4d6a4fda..000000000 --- a/platform/ios/platform/darwin/src/MGLRasterStyleLayer.mm +++ /dev/null @@ -1,339 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLRasterStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLRasterStyleLayer_Private.h" - -#include -#include - - -namespace mbgl { - - MBGL_DEFINE_ENUM(MGLRasterResamplingMode, { - { MGLRasterResamplingModeLinear, "linear" }, - { MGLRasterResamplingModeNearest, "nearest" }, - }); - -} - -@interface MGLRasterStyleLayer () - -@property (nonatomic, readonly) mbgl::style::RasterLayer *rawLayer; - -@end - -@implementation MGLRasterStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source -{ - MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::RasterLayer *)rawLayer -{ - return (mbgl::style::RasterLayer *)super.rawLayer; -} - -- (NSString *)sourceIdentifier -{ - MGLAssertStyleLayerIsValid(); - - return @(self.rawLayer->getSourceID().c_str()); -} - -// MARK: - Accessing the Paint Attributes - -- (void)setMaximumRasterBrightness:(NSExpression *)maximumRasterBrightness { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting maximumRasterBrightness: %@", maximumRasterBrightness); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumRasterBrightness, false); - self.rawLayer->setRasterBrightnessMax(mbglValue); -} - -- (NSExpression *)maximumRasterBrightness { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getRasterBrightnessMax(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultRasterBrightnessMax(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setMaximumRasterBrightnessTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting maximumRasterBrightnessTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setRasterBrightnessMaxTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)maximumRasterBrightnessTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getRasterBrightnessMaxTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setRasterBrightnessMax:(NSExpression *)rasterBrightnessMax { -} - -- (NSExpression *)rasterBrightnessMax { - return self.maximumRasterBrightness; -} - -- (void)setMinimumRasterBrightness:(NSExpression *)minimumRasterBrightness { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting minimumRasterBrightness: %@", minimumRasterBrightness); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(minimumRasterBrightness, false); - self.rawLayer->setRasterBrightnessMin(mbglValue); -} - -- (NSExpression *)minimumRasterBrightness { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getRasterBrightnessMin(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultRasterBrightnessMin(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setMinimumRasterBrightnessTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting minimumRasterBrightnessTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setRasterBrightnessMinTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)minimumRasterBrightnessTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getRasterBrightnessMinTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setRasterBrightnessMin:(NSExpression *)rasterBrightnessMin { -} - -- (NSExpression *)rasterBrightnessMin { - return self.minimumRasterBrightness; -} - -- (void)setRasterContrast:(NSExpression *)rasterContrast { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterContrast: %@", rasterContrast); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterContrast, false); - self.rawLayer->setRasterContrast(mbglValue); -} - -- (NSExpression *)rasterContrast { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getRasterContrast(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultRasterContrast(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setRasterContrastTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterContrastTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setRasterContrastTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)rasterContrastTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getRasterContrastTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setRasterFadeDuration:(NSExpression *)rasterFadeDuration { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterFadeDuration: %@", rasterFadeDuration); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterFadeDuration, false); - self.rawLayer->setRasterFadeDuration(mbglValue); -} - -- (NSExpression *)rasterFadeDuration { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getRasterFadeDuration(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultRasterFadeDuration(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setRasterHueRotation:(NSExpression *)rasterHueRotation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterHueRotation: %@", rasterHueRotation); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterHueRotation, false); - self.rawLayer->setRasterHueRotate(mbglValue); -} - -- (NSExpression *)rasterHueRotation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getRasterHueRotate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultRasterHueRotate(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setRasterHueRotationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterHueRotationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setRasterHueRotateTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)rasterHueRotationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getRasterHueRotateTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setRasterHueRotate:(NSExpression *)rasterHueRotate { -} - -- (NSExpression *)rasterHueRotate { - return self.rasterHueRotation; -} - -- (void)setRasterOpacity:(NSExpression *)rasterOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterOpacity: %@", rasterOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterOpacity, false); - self.rawLayer->setRasterOpacity(mbglValue); -} - -- (NSExpression *)rasterOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getRasterOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultRasterOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setRasterOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setRasterOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)rasterOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getRasterOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setRasterResamplingMode:(NSExpression *)rasterResamplingMode { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterResamplingMode: %@", rasterResamplingMode); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterResamplingMode, false); - self.rawLayer->setRasterResampling(mbglValue); -} - -- (NSExpression *)rasterResamplingMode { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getRasterResampling(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultRasterResampling(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setRasterResampling:(NSExpression *)rasterResampling { -} - -- (NSExpression *)rasterResampling { - return self.rasterResamplingMode; -} - -- (void)setRasterSaturation:(NSExpression *)rasterSaturation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterSaturation: %@", rasterSaturation); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterSaturation, false); - self.rawLayer->setRasterSaturation(mbglValue); -} - -- (NSExpression *)rasterSaturation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getRasterSaturation(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultRasterSaturation(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setRasterSaturationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting rasterSaturationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setRasterSaturationTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)rasterSaturationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getRasterSaturationTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -@end - -@implementation NSValue (MGLRasterStyleLayerAdditions) - -+ (NSValue *)valueWithMGLRasterResamplingMode:(MGLRasterResamplingMode)rasterResamplingMode { - return [NSValue value:&rasterResamplingMode withObjCType:@encode(MGLRasterResamplingMode)]; -} - -- (MGLRasterResamplingMode)MGLRasterResamplingModeValue { - MGLRasterResamplingMode rasterResamplingMode; - [self getValue:&rasterResamplingMode]; - return rasterResamplingMode; -} - -@end - -namespace mbgl { - -MGLStyleLayer* RasterStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLRasterStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLRasterStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLRasterStyleLayer_Private.h deleted file mode 100644 index 7b123ed88..000000000 --- a/platform/ios/platform/darwin/src/MGLRasterStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class RasterStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::RasterLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/ios/platform/darwin/src/MGLSymbolStyleLayer.h deleted file mode 100644 index e5d262dc8..000000000 --- a/platform/ios/platform/darwin/src/MGLSymbolStyleLayer.h +++ /dev/null @@ -1,2494 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLFoundation.h" -#import "MGLVectorStyleLayer.h" - -NS_ASSUME_NONNULL_BEGIN - -/** - Part of the icon placed closest to the anchor. - - Values of this type are used in the `MGLSymbolStyleLayer.iconAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLIconAnchor) { - /** - The center of the icon is placed closest to the anchor. - */ - MGLIconAnchorCenter, - /** - The left side of the icon is placed closest to the anchor. - */ - MGLIconAnchorLeft, - /** - The right side of the icon is placed closest to the anchor. - */ - MGLIconAnchorRight, - /** - The top of the icon is placed closest to the anchor. - */ - MGLIconAnchorTop, - /** - The bottom of the icon is placed closest to the anchor. - */ - MGLIconAnchorBottom, - /** - The top left corner of the icon is placed closest to the anchor. - */ - MGLIconAnchorTopLeft, - /** - The top right corner of the icon is placed closest to the anchor. - */ - MGLIconAnchorTopRight, - /** - The bottom left corner of the icon is placed closest to the anchor. - */ - MGLIconAnchorBottomLeft, - /** - The bottom right corner of the icon is placed closest to the anchor. - */ - MGLIconAnchorBottomRight, -}; - -/** - Orientation of icon when map is pitched. - - Values of this type are used in the `MGLSymbolStyleLayer.iconPitchAlignment` - property. - */ -typedef NS_ENUM(NSUInteger, MGLIconPitchAlignment) { - /** - The icon is aligned to the plane of the map. - */ - MGLIconPitchAlignmentMap, - /** - The icon is aligned to the plane of the viewport. - */ - MGLIconPitchAlignmentViewport, - /** - Automatically matches the value of - `MGLSymbolStyleLayer.iconRotationAlignment`. - */ - MGLIconPitchAlignmentAuto, -}; - -/** - In combination with `MGLSymbolStyleLayer.symbolPlacement`, determines the - rotation behavior of icons. - - Values of this type are used in the `MGLSymbolStyleLayer.iconRotationAlignment` - property. - */ -typedef NS_ENUM(NSUInteger, MGLIconRotationAlignment) { - /** - When `symbolPlacement` is set to `MGLSymbolPlacementPoint`, aligns icons - east-west. When `symbolPlacement` is set to `MGLSymbolPlacementLine` or - `MGLSymbolPlacementLineCenter`, aligns icon x-axes with the line. - */ - MGLIconRotationAlignmentMap, - /** - Produces icons whose x-axes are aligned with the x-axis of the viewport, - regardless of the value of `MGLSymbolStyleLayer.symbolPlacement`. - */ - MGLIconRotationAlignmentViewport, - /** - When `symbolPlacement` is set to `MGLSymbolPlacementPoint`, this is - equivalent to `MGLIconRotationAlignmentViewport`. When `symbolPlacement` is - set to `MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`, this is - equivalent to `MGLIconRotationAlignmentMap`. - */ - MGLIconRotationAlignmentAuto, -}; - -/** - The directions in which the icon stretches to fit around the text. If the icon - image is a resizable image, the resizable areas may be stretched, while the cap - insets are always drawn at the original scale. - - Values of this type are used in the `MGLSymbolStyleLayer.iconTextFit` - property. - */ -typedef NS_ENUM(NSUInteger, MGLIconTextFit) { - /** - The icon is displayed at its intrinsic aspect ratio. - */ - MGLIconTextFitNone, - /** - The icon is scaled in the x-dimension to fit the width of the text. - */ - MGLIconTextFitWidth, - /** - The icon is scaled in the y-dimension to fit the height of the text. - */ - MGLIconTextFitHeight, - /** - The icon is scaled in both x- and y-dimensions. - */ - MGLIconTextFitBoth, -}; - -/** - Label placement relative to its geometry. - - Values of this type are used in the `MGLSymbolStyleLayer.symbolPlacement` - property. - */ -typedef NS_ENUM(NSUInteger, MGLSymbolPlacement) { - /** - The label is placed at the point where the geometry is located. - */ - MGLSymbolPlacementPoint, - /** - The label is placed along the line of the geometry. Can only be used on - `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, -}; - -/** - Controls the order in which overlapping symbols in the same layer are rendered - - Values of this type are used in the `MGLSymbolStyleLayer.symbolZOrder` - property. - */ -typedef NS_ENUM(NSUInteger, MGLSymbolZOrder) { - /** - If `MGLSymbolStyleLayer.symbolSortKey` is set, sort based on that. - Otherwise sort symbols by their y-position relative to the viewport. - */ - MGLSymbolZOrderAuto, - /** - Specify this z order if symbols’ appearance relies on lower features - overlapping higher features. For example, symbols with a pin-like - appearance would require this z order. - */ - MGLSymbolZOrderViewportY, - /** - Specify this z order if the order in which features appear in the source is - significant. - */ - MGLSymbolZOrderSource, -}; - -/** - Part of the text placed closest to the anchor. - - Values of this type are used in the `MGLSymbolStyleLayer.textAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLTextAnchor) { - /** - The center of the text is placed closest to the anchor. - */ - MGLTextAnchorCenter, - /** - The left side of the text is placed closest to the anchor. - */ - MGLTextAnchorLeft, - /** - The right side of the text is placed closest to the anchor. - */ - MGLTextAnchorRight, - /** - The top of the text is placed closest to the anchor. - */ - MGLTextAnchorTop, - /** - The bottom of the text is placed closest to the anchor. - */ - MGLTextAnchorBottom, - /** - The top left corner of the text is placed closest to the anchor. - */ - MGLTextAnchorTopLeft, - /** - The top right corner of the text is placed closest to the anchor. - */ - MGLTextAnchorTopRight, - /** - The bottom left corner of the text is placed closest to the anchor. - */ - MGLTextAnchorBottomLeft, - /** - The bottom right corner of the text is placed closest to the anchor. - */ - MGLTextAnchorBottomRight, -}; - -/** - Text justification options. - - Values of this type are used in the `MGLSymbolStyleLayer.textJustification` - property. - */ -typedef NS_ENUM(NSUInteger, MGLTextJustification) { - /** - The text is aligned towards the anchor position. - */ - MGLTextJustificationAuto, - /** - The text is aligned to the left. - */ - MGLTextJustificationLeft, - /** - The text is centered. - */ - MGLTextJustificationCenter, - /** - The text is aligned to the right. - */ - MGLTextJustificationRight, -}; - -/** - Orientation of text when map is pitched. - - Values of this type are used in the `MGLSymbolStyleLayer.textPitchAlignment` - property. - */ -typedef NS_ENUM(NSUInteger, MGLTextPitchAlignment) { - /** - The text is aligned to the plane of the map. - */ - MGLTextPitchAlignmentMap, - /** - The text is aligned to the plane of the viewport. - */ - MGLTextPitchAlignmentViewport, - /** - Automatically matches the value of - `MGLSymbolStyleLayer.textRotationAlignment`. - */ - MGLTextPitchAlignmentAuto, -}; - -/** - In combination with `MGLSymbolStyleLayer.symbolPlacement`, determines the - rotation behavior of the individual glyphs forming the text. - - Values of this type are used in the `MGLSymbolStyleLayer.textRotationAlignment` - property. - */ -typedef NS_ENUM(NSUInteger, MGLTextRotationAlignment) { - /** - When `symbolPlacement` is set to `MGLSymbolPlacementPoint`, aligns text - east-west. When `symbolPlacement` is set to `MGLSymbolPlacementLine` or - `MGLSymbolPlacementLineCenter`, aligns text x-axes with the line. - */ - MGLTextRotationAlignmentMap, - /** - Produces glyphs whose x-axes are aligned with the x-axis of the viewport, - regardless of the value of `MGLSymbolStyleLayer.symbolPlacement`. - */ - MGLTextRotationAlignmentViewport, - /** - When `symbolPlacement` is set to `MGLSymbolPlacementPoint`, this is - equivalent to `MGLTextRotationAlignmentViewport`. When `symbolPlacement` is - set to `MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`, this is - equivalent to `MGLTextRotationAlignmentMap`. - */ - MGLTextRotationAlignmentAuto, -}; - -/** - Specifies how to capitalize text. - - Values of this type are used in the `MGLSymbolStyleLayer.textTransform` - property. - */ -typedef NS_ENUM(NSUInteger, MGLTextTransform) { - /** - The text is not altered. - */ - MGLTextTransformNone, - /** - Forces all letters to be displayed in uppercase. - */ - MGLTextTransformUppercase, - /** - Forces all letters to be displayed in lowercase. - */ - MGLTextTransformLowercase, -}; - -/** - The property allows control over a symbol's orientation. Note that the property - values act as a hint, so that a symbol whose language doesn’t support the - provided orientation will be laid out in its natural orientation. Example: - English point symbol will be rendered horizontally even if array value contains - single 'vertical' enum value. The order of elements in an array define priority - order for the placement of an orientation variant. - - Values of this type are used in the `MGLSymbolStyleLayer.textWritingModes` - property. - */ -typedef NS_ENUM(NSUInteger, MGLTextWritingMode) { - /** - If a text's language supports horizontal writing mode, symbols with point - placement would be laid out horizontally. - */ - MGLTextWritingModeHorizontal, - /** - If a text's language supports vertical writing mode, symbols with point - placement would be laid out vertically. - */ - MGLTextWritingModeVertical, -}; - -/** - Controls the frame of reference for `MGLSymbolStyleLayer.iconTranslation`. - - Values of this type are used in the `MGLSymbolStyleLayer.iconTranslationAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLIconTranslationAnchor) { - /** - Icons are translated relative to the map. - */ - MGLIconTranslationAnchorMap, - /** - Icons are translated relative to the viewport. - */ - MGLIconTranslationAnchorViewport, -}; - -/** - Controls the frame of reference for `MGLSymbolStyleLayer.textTranslation`. - - Values of this type are used in the `MGLSymbolStyleLayer.textTranslationAnchor` - property. - */ -typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) { - /** - The text is translated relative to the map. - */ - MGLTextTranslationAnchorMap, - /** - The text is translated relative to the viewport. - */ - MGLTextTranslationAnchorViewport, -}; - -/** - An `MGLSymbolStyleLayer` is a style layer that renders icon and text labels at - points or along lines on the map. - - Use a symbol style layer to configure the visual appearance of feature labels. - These features can come from vector tiles loaded by an `MGLVectorTileSource` - object, or they can be `MGLShape` or `MGLFeature` instances in an - `MGLShapeSource` or `MGLComputedShapeSource` object. - - You can access an existing symbol style layer using the - `-[MGLStyle layerWithIdentifier:]` method if you know its identifier; - otherwise, find it using the `MGLStyle.layers` property. You can also create a - new symbol style layer and add it to the style using a method such as - `-[MGLStyle addLayer:]`. - - #### Related examples - See the Dynamically - style interactive points and Use - images to cluster point data examples learn how to style data on your map - using this layer. - - ### Example - - ```swift - let layer = MGLSymbolStyleLayer(identifier: "coffeeshops", source: pois) - layer.sourceLayerIdentifier = "pois" - layer.iconImageName = NSExpression(forConstantValue: "coffee") - layer.iconScale = NSExpression(forConstantValue: 0.5) - layer.text = NSExpression(forKeyPath: "name") - layer.textTranslation = NSExpression(forConstantValue: NSValue(cgVector: CGVector(dx: 10, dy: 0))) - layer.textJustification = NSExpression(forConstantValue: "left") - layer.textAnchor = NSExpression(forConstantValue: "left") - layer.predicate = NSPredicate(format: "%K == %@", "venue-type", "coffee") - mapView.style?.addLayer(layer) - ``` - */ -MGL_EXPORT -@interface MGLSymbolStyleLayer : MGLVectorStyleLayer - -/** - Returns a symbol style layer initialized with an identifier and source. - - After initializing and configuring the style layer, add it to a map view’s - style using the `-[MGLStyle addLayer:]` or - `-[MGLStyle insertLayer:belowLayer:]` method. - - @param identifier A string that uniquely identifies the source in the style to - which it is added. - @param source The source from which to obtain the data to style. If the source - has not yet been added to the current style, the behavior is undefined. - @return An initialized foreground style layer. - */ -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source; - -// MARK: - Accessing the Layout Attributes - -/** - If true, the icon will be visible even if it collides with other previously - drawn symbols. - - The default value of this property is an expression that evaluates to `NO`. Set - this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the icon-allow-overlap - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconAllowsOverlap; - - -@property (nonatomic, null_resettable) NSExpression *iconAllowOverlap __attribute__((unavailable("Use iconAllowsOverlap instead."))); - -/** - Part of the icon placed closest to the anchor. - - The default value of this property is an expression that evaluates to `center`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `MGLIconAnchor` values - * Any of the following constant string values: - * `center`: The center of the icon is placed closest to the anchor. - * `left`: The left side of the icon is placed closest to the anchor. - * `right`: The right side of the icon is placed closest to the anchor. - * `top`: The top of the icon is placed closest to the anchor. - * `bottom`: The bottom of the icon is placed closest to the anchor. - * `top-left`: The top left corner of the icon is placed closest to the - anchor. - * `top-right`: The top right corner of the icon is placed closest to the - anchor. - * `bottom-left`: The bottom left corner of the icon is placed closest to the - anchor. - * `bottom-right`: The bottom right corner of the icon is placed closest to - the anchor. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconAnchor; - -/** - If true, other symbols can be visible even if they collide with the icon. - - The default value of this property is an expression that evaluates to `NO`. Set - this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the icon-ignore-placement - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconIgnoresPlacement; - - -@property (nonatomic, null_resettable) NSExpression *iconIgnorePlacement __attribute__((unavailable("Use iconIgnoresPlacement instead."))); - -/** - Name of a style image to use for drawing an image background. - - Use the `+[MGLStyle setImage:forName:]` method to associate an image with a - name that you can set this property to. - - Within a constant string value, a feature attribute name enclosed in curly - braces (e.g., `{token}`) is replaced with the value of the named attribute. - Tokens inside non-constant expressions are ignored; instead, use `mgl_join:` - and key path expressions. - - This attribute corresponds to the icon-image - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant string values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - - #### Related examples - See the Use - images to cluster point data example to learn how to dynamically set your - icons with an expression. - */ -@property (nonatomic, null_resettable) NSExpression *iconImageName; - - -@property (nonatomic, null_resettable) NSExpression *iconImage __attribute__((unavailable("Use iconImageName instead."))); - -#if TARGET_OS_IPHONE -/** - Offset distance of icon from its anchor. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 rightward and 0 - downward. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconOffset; -#else -/** - Offset distance of icon from its anchor. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 rightward and 0 - upward. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconOffset; -#endif - -/** - If true, text will display without their corresponding icons when the icon - collides with other symbols and the text does not. - - The default value of this property is an expression that evaluates to `NO`. Set - this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`, and - `text` is non-`nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable, getter=isIconOptional) NSExpression *iconOptional; - -/** - Size of the additional area around the icon bounding box used for detecting - symbol collisions. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `2`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconPadding; - -/** - Orientation of icon when map is pitched. - - The default value of this property is an expression that evaluates to `auto`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `MGLIconPitchAlignment` values - * Any of the following constant string values: - * `map`: The icon is aligned to the plane of the map. - * `viewport`: The icon is aligned to the plane of the viewport. - * `auto`: Automatically matches the value of `icon-rotation-alignment`. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconPitchAlignment; - -/** - Rotates the icon clockwise. - - This property is measured in degrees. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the icon-rotate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconRotation; - - -@property (nonatomic, null_resettable) NSExpression *iconRotate __attribute__((unavailable("Use iconRotation instead."))); - -/** - In combination with `symbolPlacement`, determines the rotation behavior of - icons. - - The default value of this property is an expression that evaluates to `auto`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * 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` 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` or `line-center`, this is - equivalent to `map`. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconRotationAlignment; - -/** - Scales the original size of the icon by the provided factor. The new point size - of the image will be the original point size multiplied by `iconScale`. 1 is - the original size; 3 triples the size of the image. - - This property is measured in factor of the original icon sizes. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the icon-size - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconScale; - - -@property (nonatomic, null_resettable) NSExpression *iconSize __attribute__((unavailable("Use iconScale instead."))); - -/** - The directions in which the icon stretches to fit around the text. If the icon - image is a resizable image, the resizable areas may be stretched, while the cap - insets are always drawn at the original scale. - - The default value of this property is an expression that evaluates to `none`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`, and - `text` is non-`nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `MGLIconTextFit` values - * Any of the following constant string values: - * `none`: The icon is displayed at its intrinsic aspect ratio. - * `width`: The icon is scaled in the x-dimension to fit the width of the - text. - * `height`: The icon is scaled in the y-dimension to fit the height of the - text. - * `both`: The icon is scaled in both x- and y-dimensions. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconTextFit; - -#if TARGET_OS_IPHONE -/** - Size of the additional area added to dimensions determined by `iconTextFit`. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing `UIEdgeInsetsZero`. Set this property to `nil` to - reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`, and - `text` is non-`nil`, and `iconTextFit` is set to an expression that evaluates - to `MGLIconTextFitBoth`, `MGLIconTextFitWidth`, or `MGLIconTextFitHeight`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIEdgeInsets` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconTextFitPadding; -#else -/** - Size of the additional area added to dimensions determined by `iconTextFit`. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing `NSEdgeInsetsZero`. Set this property to `nil` to - reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`, and - `text` is non-`nil`, and `iconTextFit` is set to an expression that evaluates - to `MGLIconTextFitBoth`, `MGLIconTextFitWidth`, or `MGLIconTextFitHeight`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSEdgeInsets` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconTextFitPadding; -#endif - -/** - If true, the icon may be flipped to prevent it from being rendered upside-down. - - The default value of this property is an expression that evaluates to `NO`. Set - this property to `nil` to reset it to the default value. - - 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 either - `MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`. Otherwise, it is - ignored. - - This attribute corresponds to the icon-keep-upright - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *keepsIconUpright; - - -@property (nonatomic, null_resettable) NSExpression *iconKeepUpright __attribute__((unavailable("Use keepsIconUpright instead."))); - -/** - If true, the text may be flipped vertically to prevent it from being rendered - upside-down. - - The default value of this property is an expression that evaluates to `YES`. - 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 - `textRotationAlignment` is set to an expression that evaluates to `map`, and - `symbolPlacement` is set to an expression that evaluates to either - `MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`. Otherwise, it is - ignored. - - This attribute corresponds to the text-keep-upright - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *keepsTextUpright; - - -@property (nonatomic, null_resettable) NSExpression *textKeepUpright __attribute__((unavailable("Use keepsTextUpright instead."))); - -/** - Maximum angle change between adjacent characters. - - This property is measured in degrees. - - The default value of this property is an expression that evaluates to the float - `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 either - `MGLSymbolPlacementLine` or `MGLSymbolPlacementLineCenter`. Otherwise, it is - ignored. - - This attribute corresponds to the text-max-angle - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *maximumTextAngle; - - -@property (nonatomic, null_resettable) NSExpression *textMaxAngle __attribute__((unavailable("Use maximumTextAngle instead."))); - -/** - The maximum line width for text wrapping. - - This property is measured in ems. - - The default value of this property is an expression that evaluates to the float - `10`. 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-max-width - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *maximumTextWidth; - - -@property (nonatomic, null_resettable) NSExpression *textMaxWidth __attribute__((unavailable("Use maximumTextWidth instead."))); - -/** - Whether symbols in this layer avoid colliding with symbols in adjacent tiles. - - If this property is set to `true`, symbols in this layer avoid crossing the - edge of a tile. You should set this property to `true` if the backing vector - tiles don’t have enough padding to prevent collisions, or if this layer’s - `symbolPlacement` property is set to `MGLSymbolPlacementPoint` but this layer - is above a symbol layer whose `symbolPlacement` property is set to - `MGLSymbolPlacementLine`. You do not need to enable this property to prevent - clipped labels at tile boundaries. - - The default value of this property is an expression that evaluates to `NO`. Set - this property to `nil` to reset it to the default value. - - This attribute corresponds to the symbol-avoid-edges - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *symbolAvoidsEdges; - - -@property (nonatomic, null_resettable) NSExpression *symbolAvoidEdges __attribute__((unavailable("Use symbolAvoidsEdges instead."))); - -/** - Label placement relative to its geometry. - - The default value of this property is an expression that evaluates to `point`. - Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant `MGLSymbolPlacement` values - * Any of the following constant string values: - * `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 - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *symbolPlacement; - -/** - Sorts features in ascending order based on this value. Features with lower sort - keys are drawn and placed first. When `iconAllowsOverlap` or - `textAllowsOverlap` is `false`, features with a lower sort key will have - priority during placement. When `iconAllowsOverlap` or `textAllowsOverlap` is - set to `YES`, features with a higher sort key will overlap over features with a - lower sort key. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *symbolSortKey; - -/** - Distance between two symbol anchors. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `250`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `symbolPlacement` is set to an - expression that evaluates to `line`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 1 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *symbolSpacing; - -/** - Controls the order in which overlapping symbols in the same layer are rendered - - The default value of this property is an expression that evaluates to `auto`. - Set this property to `nil` to reset it to the default value. - - You can set this property to an expression containing any of the following: - - * Constant `MGLSymbolZOrder` values - * Any of the following constant string values: - * `auto`: If `symbol-sort-key` is set, sort based on that. Otherwise sort - symbols by their y-position relative to the viewport. - * `viewport-y`: Specify this z order if symbols’ appearance relies on lower - features overlapping higher features. For example, symbols with a pin-like - appearance would require this z order. - * `source`: Specify this z order if the order in which features appear in the - source is significant. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *symbolZOrder; - -/** - Value to use for a text label. - - Within a constant string value, a feature attribute name enclosed in curly - braces (e.g., `{token}`) is replaced with the value of the named attribute. - Tokens inside non-constant expressions are ignored; instead, use `mgl_join:` - and key path expressions. - - The default value of this property is an expression that evaluates to the empty - string. Set this property to `nil` to reset it to the default value. - - This attribute corresponds to the text-field - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant string values - * Formatted expressions. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - - #### Related examples - See the Cluster - point data and Use - images to cluster point data to learn how to use an expression to set this - attribute to the number of markers within a cluster. - */ -@property (nonatomic, null_resettable) NSExpression *text; - - -@property (nonatomic, null_resettable) NSExpression *textField __attribute__((unavailable("Use text instead."))); - -/** - If true, the text will be visible even if it collides with other previously - drawn symbols. - - The default value of this property is an expression that evaluates to `NO`. 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-allow-overlap - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textAllowsOverlap; - - -@property (nonatomic, null_resettable) NSExpression *textAllowOverlap __attribute__((unavailable("Use textAllowsOverlap instead."))); - -/** - Part of the text placed closest to the anchor. - - The default value of this property is an expression that evaluates to `center`. - 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 - `textVariableAnchor` is set to `nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `MGLTextAnchor` values - * Any of the following constant string values: - * `center`: The center of the text is placed closest to the anchor. - * `left`: The left side of the text is placed closest to the anchor. - * `right`: The right side of the text is placed closest to the anchor. - * `top`: The top of the text is placed closest to the anchor. - * `bottom`: The bottom of the text is placed closest to the anchor. - * `top-left`: The top left corner of the text is placed closest to the - anchor. - * `top-right`: The top right corner of the text is placed closest to the - anchor. - * `bottom-left`: The bottom left corner of the text is placed closest to the - anchor. - * `bottom-right`: The bottom right corner of the text is placed closest to - the anchor. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textAnchor; - -/** - An array of font face names used to display the text. - - The first font named in the array is applied to the text. For each character in - the text, if the first font lacks a glyph for the character, the next font is - applied as a fallback, and so on. - - See the “[Customizing Fonts](../customizing-fonts.html)” guide for details on - how this SDK chooses and renders fonts based on the value of this property. - - The default value of this property is an expression that evaluates to the array - `Open Sans Regular`, `Arial Unicode MS Regular`. 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-font - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant array values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textFontNames; - - -@property (nonatomic, null_resettable) NSExpression *textFont __attribute__((unavailable("Use textFontNames instead."))); - -/** - Font size. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `16`. 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-size - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textFontSize; - - -@property (nonatomic, null_resettable) NSExpression *textSize __attribute__((unavailable("Use textFontSize instead."))); - -/** - If true, other symbols can be visible even if they collide with the text. - - The default value of this property is an expression that evaluates to `NO`. 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-ignore-placement - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textIgnoresPlacement; - - -@property (nonatomic, null_resettable) NSExpression *textIgnorePlacement __attribute__((unavailable("Use textIgnoresPlacement instead."))); - -/** - Text justification options. - - The default value of this property is an expression that evaluates to `center`. - 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-justify - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLTextJustification` values - * Any of the following constant string values: - * `auto`: The text is aligned towards the anchor position. - * `left`: The text is aligned to the left. - * `center`: The text is centered. - * `right`: The text is aligned to the right. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textJustification; - - -@property (nonatomic, null_resettable) NSExpression *textJustify __attribute__((unavailable("Use textJustification instead."))); - -/** - Text tracking amount. - - This property is measured in ems. - - The default value of this property is an expression that evaluates to the float - `0`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textLetterSpacing; - -/** - Text leading value for multi-line text. - - This property is measured in ems. - - The default value of this property is an expression that evaluates to the float - `1.2`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textLineHeight; - -#if TARGET_OS_IPHONE -/** - Offset distance of text from its anchor. - - This property is measured in ems. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 ems rightward and 0 - ems downward. 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 - `textRadialOffset` is set to `nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textOffset; -#else -/** - Offset distance of text from its anchor. - - This property is measured in ems. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 ems rightward and 0 - ems upward. 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 - `textRadialOffset` is set to `nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textOffset; -#endif - -/** - If true, icons will display without their corresponding text when the text - collides with other symbols and the icon does not. - - The default value of this property is an expression that evaluates to `NO`. 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 - `iconImageName` is non-`nil`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant Boolean values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable, getter=isTextOptional) NSExpression *textOptional; - -/** - Size of the additional area around the text bounding box used for detecting - symbol collisions. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `2`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textPadding; - -/** - Orientation of text when map is pitched. - - The default value of this property is an expression that evaluates to `auto`. - 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `MGLTextPitchAlignment` values - * Any of the following constant string values: - * `map`: The text is aligned to the plane of the map. - * `viewport`: The text is aligned to the plane of the viewport. - * `auto`: Automatically matches the value of `text-rotation-alignment`. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textPitchAlignment; - -/** - Radial offset of text, in the direction of the symbol's anchor. Useful in - combination with `textVariableAnchor`, which defaults to using the - two-dimensional `textOffset` if present. - - This property is measured in ems. - - The default value of this property is an expression that evaluates to the float - `0`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textRadialOffset; - -/** - Rotates the text clockwise. - - This property is measured in degrees. - - The default value of this property is an expression that evaluates to the float - `0`. 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-rotate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant numeric values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textRotation; - - -@property (nonatomic, null_resettable) NSExpression *textRotate __attribute__((unavailable("Use textRotation instead."))); - -/** - In combination with `symbolPlacement`, determines the rotation behavior of the - individual glyphs forming the text. - - The default value of this property is an expression that evaluates to `auto`. - 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * 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` 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` or `line-center`, this is - equivalent to `map`. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textRotationAlignment; - -/** - Specifies how to capitalize text. - - The default value of this property is an expression that evaluates to `none`. - 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `MGLTextTransform` values - * Any of the following constant string values: - * `none`: The text is not altered. - * `uppercase`: Forces all letters to be displayed in uppercase. - * `lowercase`: Forces all letters to be displayed in lowercase. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textTransform; - -/** - To increase the chance of placing high-priority labels on the map, you can - provide an array of `textAnchor` locations: the renderer will attempt to place - the label at each location, in order, before moving onto the next label. Use - `textJustify: auto` to choose justification based on anchor position. To apply - an offset, use the `textRadialOffset` or the two-dimensional `textOffset`. - - This property is only applied to the style if `text` is non-`nil`, and - `symbolPlacement` is set to an expression that evaluates to or - `MGLSymbolPlacementPoint`. Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `MGLTextAnchor` array values - * Constant array, in which each element is any of the following constant string - values: - * `center`: The center of the text is placed closest to the anchor. - * `left`: The left side of the text is placed closest to the anchor. - * `right`: The right side of the text is placed closest to the anchor. - * `top`: The top of the text is placed closest to the anchor. - * `bottom`: The bottom of the text is placed closest to the anchor. - * `top-left`: The top left corner of the text is placed closest to the - anchor. - * `top-right`: The top right corner of the text is placed closest to the - anchor. - * `bottom-left`: The bottom left corner of the text is placed closest to the - anchor. - * `bottom-right`: The bottom right corner of the text is placed closest to - the anchor. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textVariableAnchor; - -/** - The property allows control over a symbol's orientation. Note that the property - values act as a hint, so that a symbol whose language doesn’t support the - provided orientation will be laid out in its natural orientation. Example: - English point symbol will be rendered horizontally even if array value contains - single 'vertical' enum value. The order of elements in an array define priority - order for the placement of an orientation variant. - - This property is only applied to the style if `text` is non-`nil`, and - `symbolPlacement` is set to an expression that evaluates to or - `MGLSymbolPlacementPoint`. Otherwise, it is ignored. - - This attribute corresponds to the text-writing-mode - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLTextWritingMode` array values - * Constant array, in which each element is any of the following constant string - values: - * `horizontal`: If a text's language supports horizontal writing mode, - symbols with point placement would be laid out horizontally. - * `vertical`: If a text's language supports vertical writing mode, symbols - with point placement would be laid out vertically. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textWritingModes; - - -@property (nonatomic, null_resettable) NSExpression *textWritingMode __attribute__((unavailable("Use textWritingModes instead."))); - -// MARK: - Accessing the Paint Attributes - -#if TARGET_OS_IPHONE -/** - The tint color to apply to the icon. The `iconImageName` property must be set - to a template image. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconColor; -#else -/** - The tint color to apply to the icon. The `iconImageName` property must be set - to a template image. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconColor; -#endif - -/** - The transition affecting any changes to this layer’s `iconColor` property. - - This property corresponds to the `icon-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition iconColorTransition; - -/** - Fade out the halo towards the outside. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconHaloBlur; - -/** - The transition affecting any changes to this layer’s `iconHaloBlur` property. - - This property corresponds to the `icon-halo-blur-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition iconHaloBlurTransition; - -#if TARGET_OS_IPHONE -/** - The color of the icon’s halo. The `iconImageName` property must be set to a - template image. - - The default value of this property is an expression that evaluates to - `UIColor.clearColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconHaloColor; -#else -/** - The color of the icon’s halo. The `iconImageName` property must be set to a - template image. - - The default value of this property is an expression that evaluates to - `NSColor.clearColor`. Set this property to `nil` to reset it to the default - value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconHaloColor; -#endif - -/** - The transition affecting any changes to this layer’s `iconHaloColor` property. - - This property corresponds to the `icon-halo-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition iconHaloColorTransition; - -/** - Distance of halo to the icon outline. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `0`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconHaloWidth; - -/** - The transition affecting any changes to this layer’s `iconHaloWidth` property. - - This property corresponds to the `icon-halo-width-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition iconHaloWidthTransition; - -/** - The opacity at which the icon will be drawn. - - The default value of this property is an expression that evaluates to the float - `1`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *iconOpacity; - -/** - The transition affecting any changes to this layer’s `iconOpacity` property. - - This property corresponds to the `icon-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition iconOpacityTransition; - -#if TARGET_OS_IPHONE -/** - Distance that the icon's anchor is moved from its original placement. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points downward. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the icon-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconTranslation; -#else -/** - Distance that the icon's anchor is moved from its original placement. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points upward. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`. - Otherwise, it is ignored. - - This attribute corresponds to the icon-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconTranslation; -#endif - -/** - The transition affecting any changes to this layer’s `iconTranslation` property. - - This property corresponds to the `icon-translate-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition iconTranslationTransition; - -@property (nonatomic, null_resettable) NSExpression *iconTranslate __attribute__((unavailable("Use iconTranslation instead."))); - -/** - Controls the frame of reference for `iconTranslation`. - - The default value of this property is an expression that evaluates to `map`. - Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`, and - `iconTranslation` is non-`nil`. Otherwise, it is ignored. - - This attribute corresponds to the icon-translate-anchor - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLIconTranslationAnchor` values - * Any of the following constant string values: - * `map`: Icons are translated relative to the map. - * `viewport`: Icons are translated relative to the viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *iconTranslationAnchor; - -@property (nonatomic, null_resettable) NSExpression *iconTranslateAnchor __attribute__((unavailable("Use iconTranslationAnchor instead."))); - -#if TARGET_OS_IPHONE -/** - The color with which the text will be drawn. - - The default value of this property is an expression that evaluates to - `UIColor.blackColor`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textColor; -#else -/** - The color with which the text will be drawn. - - The default value of this property is an expression that evaluates to - `NSColor.blackColor`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textColor; -#endif - -/** - The transition affecting any changes to this layer’s `textColor` property. - - This property corresponds to the `text-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition textColorTransition; - -/** - The halo's fadeout distance towards the outside. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `0`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textHaloBlur; - -/** - The transition affecting any changes to this layer’s `textHaloBlur` property. - - This property corresponds to the `text-halo-blur-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition textHaloBlurTransition; - -#if TARGET_OS_IPHONE -/** - The color of the text's halo, which helps it stand out from backgrounds. - - The default value of this property is an expression that evaluates to - `UIColor.clearColor`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `UIColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textHaloColor; -#else -/** - The color of the text's halo, which helps it stand out from backgrounds. - - The default value of this property is an expression that evaluates to - `NSColor.clearColor`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant `NSColor` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textHaloColor; -#endif - -/** - The transition affecting any changes to this layer’s `textHaloColor` property. - - This property corresponds to the `text-halo-color-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition textHaloColorTransition; - -/** - Distance of halo to the font outline. Max text halo width is 1/4 of the - font-size. - - This property is measured in points. - - The default value of this property is an expression that evaluates to the float - `0`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values no less than 0 - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textHaloWidth; - -/** - The transition affecting any changes to this layer’s `textHaloWidth` property. - - This property corresponds to the `text-halo-width-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition textHaloWidthTransition; - -/** - The opacity at which the text will be drawn. - - The default value of this property is an expression that evaluates to the float - `1`. 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`. Otherwise, - it is ignored. - - You can set this property to an expression containing any of the following: - - * Constant numeric values between 0 and 1 inclusive - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable and/or - feature attributes - */ -@property (nonatomic, null_resettable) NSExpression *textOpacity; - -/** - The transition affecting any changes to this layer’s `textOpacity` property. - - This property corresponds to the `text-opacity-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition textOpacityTransition; - -#if TARGET_OS_IPHONE -/** - Distance that the text's anchor is moved from its original placement. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points downward. 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textTranslation; -#else -/** - Distance that the text's anchor is moved from its original placement. - - This property is measured in points. - - The default value of this property is an expression that evaluates to an - `NSValue` object containing a `CGVector` struct set to 0 points rightward and 0 - points upward. 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`. Otherwise, - it is ignored. - - This attribute corresponds to the text-translate - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `CGVector` values - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Interpolation and step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation or step functions to - feature attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textTranslation; -#endif - -/** - The transition affecting any changes to this layer’s `textTranslation` property. - - This property corresponds to the `text-translate-transition` property in the style JSON file format. -*/ -@property (nonatomic) MGLTransition textTranslationTransition; - -@property (nonatomic, null_resettable) NSExpression *textTranslate __attribute__((unavailable("Use textTranslation instead."))); - -/** - Controls the frame of reference for `textTranslation`. - - The default value of this property is an expression that evaluates to `map`. - 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 - `textTranslation` is non-`nil`. Otherwise, it is ignored. - - This attribute corresponds to the text-translate-anchor - layout property in the Mapbox Style Specification. - - You can set this property to an expression containing any of the following: - - * Constant `MGLTextTranslationAnchor` values - * Any of the following constant string values: - * `map`: The text is translated relative to the map. - * `viewport`: The text is translated relative to the viewport. - * Predefined functions, including mathematical and string operators - * Conditional expressions - * Variable assignments and references to assigned variables - * Step functions applied to the `$zoomLevel` variable - - This property does not support applying interpolation functions to the - `$zoomLevel` variable or applying interpolation or step functions to feature - attributes. - */ -@property (nonatomic, null_resettable) NSExpression *textTranslationAnchor; - -@property (nonatomic, null_resettable) NSExpression *textTranslateAnchor __attribute__((unavailable("Use textTranslationAnchor instead."))); - -@end - -/** - Methods for wrapping an enumeration value for a style layer attribute in an - `MGLSymbolStyleLayer` object and unwrapping its raw value. - */ -@interface NSValue (MGLSymbolStyleLayerAdditions) - -// MARK: Working with Symbol Style Layer Attribute Values - -/** - Creates a new value object containing the given `MGLIconAnchor` enumeration. - - @param iconAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLIconAnchor:(MGLIconAnchor)iconAnchor; - -/** - The `MGLIconAnchor` enumeration representation of the value. - */ -@property (readonly) MGLIconAnchor MGLIconAnchorValue; - -/** - Creates a new value object containing the given `MGLIconPitchAlignment` enumeration. - - @param iconPitchAlignment The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLIconPitchAlignment:(MGLIconPitchAlignment)iconPitchAlignment; - -/** - The `MGLIconPitchAlignment` enumeration representation of the value. - */ -@property (readonly) MGLIconPitchAlignment MGLIconPitchAlignmentValue; - -/** - Creates a new value object containing the given `MGLIconRotationAlignment` enumeration. - - @param iconRotationAlignment The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLIconRotationAlignment:(MGLIconRotationAlignment)iconRotationAlignment; - -/** - The `MGLIconRotationAlignment` enumeration representation of the value. - */ -@property (readonly) MGLIconRotationAlignment MGLIconRotationAlignmentValue; - -/** - Creates a new value object containing the given `MGLIconTextFit` enumeration. - - @param iconTextFit The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLIconTextFit:(MGLIconTextFit)iconTextFit; - -/** - The `MGLIconTextFit` enumeration representation of the value. - */ -@property (readonly) MGLIconTextFit MGLIconTextFitValue; - -/** - Creates a new value object containing the given `MGLSymbolPlacement` enumeration. - - @param symbolPlacement The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLSymbolPlacement:(MGLSymbolPlacement)symbolPlacement; - -/** - The `MGLSymbolPlacement` enumeration representation of the value. - */ -@property (readonly) MGLSymbolPlacement MGLSymbolPlacementValue; - -/** - Creates a new value object containing the given `MGLSymbolZOrder` enumeration. - - @param symbolZOrder The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLSymbolZOrder:(MGLSymbolZOrder)symbolZOrder; - -/** - The `MGLSymbolZOrder` enumeration representation of the value. - */ -@property (readonly) MGLSymbolZOrder MGLSymbolZOrderValue; - -/** - Creates a new value object containing the given `MGLTextAnchor` enumeration. - - @param textAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLTextAnchor:(MGLTextAnchor)textAnchor; - -/** - The `MGLTextAnchor` enumeration representation of the value. - */ -@property (readonly) MGLTextAnchor MGLTextAnchorValue; - -/** - Creates a new value object containing the given `MGLTextJustification` enumeration. - - @param textJustification The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLTextJustification:(MGLTextJustification)textJustification; - -/** - The `MGLTextJustification` enumeration representation of the value. - */ -@property (readonly) MGLTextJustification MGLTextJustificationValue; - -/** - Creates a new value object containing the given `MGLTextPitchAlignment` enumeration. - - @param textPitchAlignment The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLTextPitchAlignment:(MGLTextPitchAlignment)textPitchAlignment; - -/** - The `MGLTextPitchAlignment` enumeration representation of the value. - */ -@property (readonly) MGLTextPitchAlignment MGLTextPitchAlignmentValue; - -/** - Creates a new value object containing the given `MGLTextRotationAlignment` enumeration. - - @param textRotationAlignment The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLTextRotationAlignment:(MGLTextRotationAlignment)textRotationAlignment; - -/** - The `MGLTextRotationAlignment` enumeration representation of the value. - */ -@property (readonly) MGLTextRotationAlignment MGLTextRotationAlignmentValue; - -/** - Creates a new value object containing the given `MGLTextTransform` enumeration. - - @param textTransform The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLTextTransform:(MGLTextTransform)textTransform; - -/** - The `MGLTextTransform` enumeration representation of the value. - */ -@property (readonly) MGLTextTransform MGLTextTransformValue; - -/** - Creates a new value object containing the given `MGLTextWritingMode` enumeration. - - @param textWritingModes The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLTextWritingMode:(MGLTextWritingMode)textWritingModes; - -/** - The `MGLTextWritingMode` enumeration representation of the value. - */ -@property (readonly) MGLTextWritingMode MGLTextWritingModeValue; - -/** - Creates a new value object containing the given `MGLIconTranslationAnchor` enumeration. - - @param iconTranslationAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLIconTranslationAnchor:(MGLIconTranslationAnchor)iconTranslationAnchor; - -/** - The `MGLIconTranslationAnchor` enumeration representation of the value. - */ -@property (readonly) MGLIconTranslationAnchor MGLIconTranslationAnchorValue; - -/** - Creates a new value object containing the given `MGLTextTranslationAnchor` enumeration. - - @param textTranslationAnchor The value for the new object. - @return A new value object that contains the enumeration value. - */ -+ (instancetype)valueWithMGLTextTranslationAnchor:(MGLTextTranslationAnchor)textTranslationAnchor; - -/** - The `MGLTextTranslationAnchor` enumeration representation of the value. - */ -@property (readonly) MGLTextTranslationAnchor MGLTextTranslationAnchorValue; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/ios/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/ios/platform/darwin/src/MGLSymbolStyleLayer.mm deleted file mode 100644 index 6cd2c5ad1..000000000 --- a/platform/ios/platform/darwin/src/MGLSymbolStyleLayer.mm +++ /dev/null @@ -1,1670 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLSource.h" -#import "NSPredicate+MGLPrivateAdditions.h" -#import "NSDate+MGLAdditions.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleValue_Private.h" -#import "MGLSymbolStyleLayer.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLSymbolStyleLayer_Private.h" - -#include -#include - - -namespace mbgl { - - MBGL_DEFINE_ENUM(MGLIconAnchor, { - { MGLIconAnchorCenter, "center" }, - { MGLIconAnchorLeft, "left" }, - { MGLIconAnchorRight, "right" }, - { MGLIconAnchorTop, "top" }, - { MGLIconAnchorBottom, "bottom" }, - { MGLIconAnchorTopLeft, "top-left" }, - { MGLIconAnchorTopRight, "top-right" }, - { MGLIconAnchorBottomLeft, "bottom-left" }, - { MGLIconAnchorBottomRight, "bottom-right" }, - }); - - MBGL_DEFINE_ENUM(MGLIconPitchAlignment, { - { MGLIconPitchAlignmentMap, "map" }, - { MGLIconPitchAlignmentViewport, "viewport" }, - { MGLIconPitchAlignmentAuto, "auto" }, - }); - - MBGL_DEFINE_ENUM(MGLIconRotationAlignment, { - { MGLIconRotationAlignmentMap, "map" }, - { MGLIconRotationAlignmentViewport, "viewport" }, - { MGLIconRotationAlignmentAuto, "auto" }, - }); - - MBGL_DEFINE_ENUM(MGLIconTextFit, { - { MGLIconTextFitNone, "none" }, - { MGLIconTextFitWidth, "width" }, - { MGLIconTextFitHeight, "height" }, - { MGLIconTextFitBoth, "both" }, - }); - - MBGL_DEFINE_ENUM(MGLSymbolPlacement, { - { MGLSymbolPlacementPoint, "point" }, - { MGLSymbolPlacementLine, "line" }, - { MGLSymbolPlacementLineCenter, "line-center" }, - }); - - MBGL_DEFINE_ENUM(MGLSymbolZOrder, { - { MGLSymbolZOrderAuto, "auto" }, - { MGLSymbolZOrderViewportY, "viewport-y" }, - { MGLSymbolZOrderSource, "source" }, - }); - - MBGL_DEFINE_ENUM(MGLTextAnchor, { - { MGLTextAnchorCenter, "center" }, - { MGLTextAnchorLeft, "left" }, - { MGLTextAnchorRight, "right" }, - { MGLTextAnchorTop, "top" }, - { MGLTextAnchorBottom, "bottom" }, - { MGLTextAnchorTopLeft, "top-left" }, - { MGLTextAnchorTopRight, "top-right" }, - { MGLTextAnchorBottomLeft, "bottom-left" }, - { MGLTextAnchorBottomRight, "bottom-right" }, - }); - - MBGL_DEFINE_ENUM(MGLTextJustification, { - { MGLTextJustificationAuto, "auto" }, - { MGLTextJustificationLeft, "left" }, - { MGLTextJustificationCenter, "center" }, - { MGLTextJustificationRight, "right" }, - }); - - MBGL_DEFINE_ENUM(MGLTextPitchAlignment, { - { MGLTextPitchAlignmentMap, "map" }, - { MGLTextPitchAlignmentViewport, "viewport" }, - { MGLTextPitchAlignmentAuto, "auto" }, - }); - - MBGL_DEFINE_ENUM(MGLTextRotationAlignment, { - { MGLTextRotationAlignmentMap, "map" }, - { MGLTextRotationAlignmentViewport, "viewport" }, - { MGLTextRotationAlignmentAuto, "auto" }, - }); - - MBGL_DEFINE_ENUM(MGLTextTransform, { - { MGLTextTransformNone, "none" }, - { MGLTextTransformUppercase, "uppercase" }, - { MGLTextTransformLowercase, "lowercase" }, - }); - - MBGL_DEFINE_ENUM(MGLTextWritingMode, { - { MGLTextWritingModeHorizontal, "horizontal" }, - { MGLTextWritingModeVertical, "vertical" }, - }); - - MBGL_DEFINE_ENUM(MGLIconTranslationAnchor, { - { MGLIconTranslationAnchorMap, "map" }, - { MGLIconTranslationAnchorViewport, "viewport" }, - }); - - MBGL_DEFINE_ENUM(MGLTextTranslationAnchor, { - { MGLTextTranslationAnchorMap, "map" }, - { MGLTextTranslationAnchorViewport, "viewport" }, - }); - -} - -@interface MGLSymbolStyleLayer () - -@property (nonatomic, readonly) mbgl::style::SymbolLayer *rawLayer; - -@end - -@implementation MGLSymbolStyleLayer - -- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source -{ - MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); - auto layer = std::make_unique(identifier.UTF8String, source.identifier.UTF8String); - return self = [super initWithPendingLayer:std::move(layer)]; -} - -- (mbgl::style::SymbolLayer *)rawLayer -{ - return (mbgl::style::SymbolLayer *)super.rawLayer; -} - -- (NSString *)sourceIdentifier -{ - MGLAssertStyleLayerIsValid(); - - return @(self.rawLayer->getSourceID().c_str()); -} - -- (NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - - auto layerID = self.rawLayer->getSourceLayer(); - return layerID.empty() ? nil : @(layerID.c_str()); -} - -- (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); - - self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); -} - -- (void)setPredicate:(NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting predicate: %@", predicate); - - self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); -} - -- (NSPredicate *)predicate -{ - MGLAssertStyleLayerIsValid(); - - return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; -} - -// MARK: - Accessing the Layout Attributes - -- (void)setIconAllowsOverlap:(NSExpression *)iconAllowsOverlap { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconAllowsOverlap: %@", iconAllowsOverlap); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconAllowsOverlap, false); - self.rawLayer->setIconAllowOverlap(mbglValue); -} - -- (NSExpression *)iconAllowsOverlap { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconAllowOverlap(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconAllowOverlap(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconAllowOverlap:(NSExpression *)iconAllowOverlap { -} - -- (NSExpression *)iconAllowOverlap { - return self.iconAllowsOverlap; -} - -- (void)setIconAnchor:(NSExpression *)iconAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconAnchor: %@", iconAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconAnchor, true); - self.rawLayer->setIconAnchor(mbglValue); -} - -- (NSExpression *)iconAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconIgnoresPlacement:(NSExpression *)iconIgnoresPlacement { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconIgnoresPlacement: %@", iconIgnoresPlacement); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconIgnoresPlacement, false); - self.rawLayer->setIconIgnorePlacement(mbglValue); -} - -- (NSExpression *)iconIgnoresPlacement { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconIgnorePlacement(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconIgnorePlacement(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconIgnorePlacement:(NSExpression *)iconIgnorePlacement { -} - -- (NSExpression *)iconIgnorePlacement { - return self.iconIgnoresPlacement; -} - -- (void)setIconImageName:(NSExpression *)iconImageName { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconImageName: %@", iconImageName); - - if (iconImageName && iconImageName.expressionType == NSConstantValueExpressionType) { - std::string string = ((NSString *)iconImageName.constantValue).UTF8String; - if (mbgl::style::conversion::hasTokens(string)) { - self.rawLayer->setIconImage(mbgl::style::PropertyValue( - mbgl::style::conversion::convertTokenStringToImageExpression(string))); - return; - } - } - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconImageName, true); - self.rawLayer->setIconImage(mbglValue); -} - -- (NSExpression *)iconImageName { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconImage(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconImage(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconImage:(NSExpression *)iconImage { -} - -- (NSExpression *)iconImage { - return self.iconImageName; -} - -- (void)setIconOffset:(NSExpression *)iconOffset { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconOffset: %@", iconOffset); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconOffset, true); - self.rawLayer->setIconOffset(mbglValue); -} - -- (NSExpression *)iconOffset { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconOffset(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconOffset(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setIconOptional:(NSExpression *)iconOptional { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconOptional: %@", iconOptional); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconOptional, false); - self.rawLayer->setIconOptional(mbglValue); -} - -- (NSExpression *)isIconOptional { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconOptional(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconOptional(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconPadding:(NSExpression *)iconPadding { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconPadding: %@", iconPadding); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconPadding, false); - self.rawLayer->setIconPadding(mbglValue); -} - -- (NSExpression *)iconPadding { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconPadding(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconPadding(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconPitchAlignment:(NSExpression *)iconPitchAlignment { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconPitchAlignment: %@", iconPitchAlignment); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconPitchAlignment, false); - self.rawLayer->setIconPitchAlignment(mbglValue); -} - -- (NSExpression *)iconPitchAlignment { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconPitchAlignment(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconPitchAlignment(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconRotation:(NSExpression *)iconRotation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconRotation: %@", iconRotation); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconRotation, true); - self.rawLayer->setIconRotate(mbglValue); -} - -- (NSExpression *)iconRotation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconRotate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconRotate(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconRotate:(NSExpression *)iconRotate { -} - -- (NSExpression *)iconRotate { - return self.iconRotation; -} - -- (void)setIconRotationAlignment:(NSExpression *)iconRotationAlignment { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconRotationAlignment: %@", iconRotationAlignment); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconRotationAlignment, false); - self.rawLayer->setIconRotationAlignment(mbglValue); -} - -- (NSExpression *)iconRotationAlignment { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconRotationAlignment(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconRotationAlignment(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconScale:(NSExpression *)iconScale { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconScale: %@", iconScale); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconScale, true); - self.rawLayer->setIconSize(mbglValue); -} - -- (NSExpression *)iconScale { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconSize(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconSize(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconSize:(NSExpression *)iconSize { -} - -- (NSExpression *)iconSize { - return self.iconScale; -} - -- (void)setIconTextFit:(NSExpression *)iconTextFit { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconTextFit: %@", iconTextFit); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconTextFit, false); - self.rawLayer->setIconTextFit(mbglValue); -} - -- (NSExpression *)iconTextFit { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconTextFit(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconTextFit(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconTextFitPadding:(NSExpression *)iconTextFitPadding { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconTextFitPadding: %@", iconTextFitPadding); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconTextFitPadding, false); - self.rawLayer->setIconTextFitPadding(mbglValue); -} - -- (NSExpression *)iconTextFitPadding { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconTextFitPadding(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconTextFitPadding(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setKeepsIconUpright:(NSExpression *)keepsIconUpright { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting keepsIconUpright: %@", keepsIconUpright); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(keepsIconUpright, false); - self.rawLayer->setIconKeepUpright(mbglValue); -} - -- (NSExpression *)keepsIconUpright { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconKeepUpright(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconKeepUpright(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconKeepUpright:(NSExpression *)iconKeepUpright { -} - -- (NSExpression *)iconKeepUpright { - return self.keepsIconUpright; -} - -- (void)setKeepsTextUpright:(NSExpression *)keepsTextUpright { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting keepsTextUpright: %@", keepsTextUpright); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(keepsTextUpright, false); - self.rawLayer->setTextKeepUpright(mbglValue); -} - -- (NSExpression *)keepsTextUpright { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextKeepUpright(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextKeepUpright(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextKeepUpright:(NSExpression *)textKeepUpright { -} - -- (NSExpression *)textKeepUpright { - return self.keepsTextUpright; -} - -- (void)setMaximumTextAngle:(NSExpression *)maximumTextAngle { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting maximumTextAngle: %@", maximumTextAngle); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumTextAngle, false); - self.rawLayer->setTextMaxAngle(mbglValue); -} - -- (NSExpression *)maximumTextAngle { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextMaxAngle(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextMaxAngle(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextMaxAngle:(NSExpression *)textMaxAngle { -} - -- (NSExpression *)textMaxAngle { - return self.maximumTextAngle; -} - -- (void)setMaximumTextWidth:(NSExpression *)maximumTextWidth { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting maximumTextWidth: %@", maximumTextWidth); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumTextWidth, true); - self.rawLayer->setTextMaxWidth(mbglValue); -} - -- (NSExpression *)maximumTextWidth { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextMaxWidth(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextMaxWidth(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextMaxWidth:(NSExpression *)textMaxWidth { -} - -- (NSExpression *)textMaxWidth { - return self.maximumTextWidth; -} - -- (void)setSymbolAvoidsEdges:(NSExpression *)symbolAvoidsEdges { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting symbolAvoidsEdges: %@", symbolAvoidsEdges); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolAvoidsEdges, false); - self.rawLayer->setSymbolAvoidEdges(mbglValue); -} - -- (NSExpression *)symbolAvoidsEdges { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getSymbolAvoidEdges(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultSymbolAvoidEdges(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setSymbolAvoidEdges:(NSExpression *)symbolAvoidEdges { -} - -- (NSExpression *)symbolAvoidEdges { - return self.symbolAvoidsEdges; -} - -- (void)setSymbolPlacement:(NSExpression *)symbolPlacement { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting symbolPlacement: %@", symbolPlacement); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolPlacement, false); - self.rawLayer->setSymbolPlacement(mbglValue); -} - -- (NSExpression *)symbolPlacement { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getSymbolPlacement(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultSymbolPlacement(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setSymbolSortKey:(NSExpression *)symbolSortKey { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting symbolSortKey: %@", symbolSortKey); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolSortKey, true); - self.rawLayer->setSymbolSortKey(mbglValue); -} - -- (NSExpression *)symbolSortKey { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getSymbolSortKey(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultSymbolSortKey(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setSymbolSpacing:(NSExpression *)symbolSpacing { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting symbolSpacing: %@", symbolSpacing); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolSpacing, false); - self.rawLayer->setSymbolSpacing(mbglValue); -} - -- (NSExpression *)symbolSpacing { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getSymbolSpacing(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultSymbolSpacing(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setSymbolZOrder:(NSExpression *)symbolZOrder { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting symbolZOrder: %@", symbolZOrder); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolZOrder, false); - self.rawLayer->setSymbolZOrder(mbglValue); -} - -- (NSExpression *)symbolZOrder { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getSymbolZOrder(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultSymbolZOrder(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setText:(NSExpression *)text { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting text: %@", text); - - if (text && text.expressionType == NSConstantValueExpressionType) { - std::string string = ((NSString *)text.constantValue).UTF8String; - if (mbgl::style::conversion::hasTokens(string)) { - self.rawLayer->setTextField(mbgl::style::PropertyValue( - mbgl::style::conversion::convertTokenStringToFormatExpression(string))); - return; - } - } - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(text, true); - self.rawLayer->setTextField(mbglValue); -} - -- (NSExpression *)text { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextField(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextField(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextField:(NSExpression *)textField { -} - -- (NSExpression *)textField { - return self.text; -} - -- (void)setTextAllowsOverlap:(NSExpression *)textAllowsOverlap { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textAllowsOverlap: %@", textAllowsOverlap); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textAllowsOverlap, false); - self.rawLayer->setTextAllowOverlap(mbglValue); -} - -- (NSExpression *)textAllowsOverlap { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextAllowOverlap(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextAllowOverlap(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextAllowOverlap:(NSExpression *)textAllowOverlap { -} - -- (NSExpression *)textAllowOverlap { - return self.textAllowsOverlap; -} - -- (void)setTextAnchor:(NSExpression *)textAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textAnchor: %@", textAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textAnchor, true); - self.rawLayer->setTextAnchor(mbglValue); -} - -- (NSExpression *)textAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextFontNames:(NSExpression *)textFontNames { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textFontNames: %@", textFontNames); - - auto mbglValue = MGLStyleValueTransformer, NSArray *, std::string>().toPropertyValue>>(textFontNames, true); - self.rawLayer->setTextFont(mbglValue); -} - -- (NSExpression *)textFontNames { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextFont(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextFont(); - } - return MGLStyleValueTransformer, NSArray *, std::string>().toExpression(propertyValue); -} - -- (void)setTextFont:(NSExpression *)textFont { -} - -- (NSExpression *)textFont { - return self.textFontNames; -} - -- (void)setTextFontSize:(NSExpression *)textFontSize { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textFontSize: %@", textFontSize); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textFontSize, true); - self.rawLayer->setTextSize(mbglValue); -} - -- (NSExpression *)textFontSize { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextSize(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextSize(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextSize:(NSExpression *)textSize { -} - -- (NSExpression *)textSize { - return self.textFontSize; -} - -- (void)setTextIgnoresPlacement:(NSExpression *)textIgnoresPlacement { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textIgnoresPlacement: %@", textIgnoresPlacement); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textIgnoresPlacement, false); - self.rawLayer->setTextIgnorePlacement(mbglValue); -} - -- (NSExpression *)textIgnoresPlacement { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextIgnorePlacement(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextIgnorePlacement(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextIgnorePlacement:(NSExpression *)textIgnorePlacement { -} - -- (NSExpression *)textIgnorePlacement { - return self.textIgnoresPlacement; -} - -- (void)setTextJustification:(NSExpression *)textJustification { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textJustification: %@", textJustification); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textJustification, true); - self.rawLayer->setTextJustify(mbglValue); -} - -- (NSExpression *)textJustification { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextJustify(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextJustify(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextJustify:(NSExpression *)textJustify { -} - -- (NSExpression *)textJustify { - return self.textJustification; -} - -- (void)setTextLetterSpacing:(NSExpression *)textLetterSpacing { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textLetterSpacing: %@", textLetterSpacing); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textLetterSpacing, true); - self.rawLayer->setTextLetterSpacing(mbglValue); -} - -- (NSExpression *)textLetterSpacing { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextLetterSpacing(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextLetterSpacing(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextLineHeight:(NSExpression *)textLineHeight { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textLineHeight: %@", textLineHeight); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textLineHeight, false); - self.rawLayer->setTextLineHeight(mbglValue); -} - -- (NSExpression *)textLineHeight { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextLineHeight(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextLineHeight(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextOffset:(NSExpression *)textOffset { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textOffset: %@", textOffset); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(textOffset, true); - self.rawLayer->setTextOffset(mbglValue); -} - -- (NSExpression *)textOffset { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextOffset(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextOffset(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setTextOptional:(NSExpression *)textOptional { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textOptional: %@", textOptional); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textOptional, false); - self.rawLayer->setTextOptional(mbglValue); -} - -- (NSExpression *)isTextOptional { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextOptional(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextOptional(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextPadding:(NSExpression *)textPadding { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textPadding: %@", textPadding); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textPadding, false); - self.rawLayer->setTextPadding(mbglValue); -} - -- (NSExpression *)textPadding { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextPadding(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextPadding(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextPitchAlignment:(NSExpression *)textPitchAlignment { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textPitchAlignment: %@", textPitchAlignment); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textPitchAlignment, false); - self.rawLayer->setTextPitchAlignment(mbglValue); -} - -- (NSExpression *)textPitchAlignment { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextPitchAlignment(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextPitchAlignment(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextRadialOffset:(NSExpression *)textRadialOffset { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textRadialOffset: %@", textRadialOffset); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textRadialOffset, true); - self.rawLayer->setTextRadialOffset(mbglValue); -} - -- (NSExpression *)textRadialOffset { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextRadialOffset(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextRadialOffset(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextRotation:(NSExpression *)textRotation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textRotation: %@", textRotation); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textRotation, true); - self.rawLayer->setTextRotate(mbglValue); -} - -- (NSExpression *)textRotation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextRotate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextRotate(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextRotate:(NSExpression *)textRotate { -} - -- (NSExpression *)textRotate { - return self.textRotation; -} - -- (void)setTextRotationAlignment:(NSExpression *)textRotationAlignment { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textRotationAlignment: %@", textRotationAlignment); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textRotationAlignment, false); - self.rawLayer->setTextRotationAlignment(mbglValue); -} - -- (NSExpression *)textRotationAlignment { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextRotationAlignment(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextRotationAlignment(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextTransform:(NSExpression *)textTransform { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textTransform: %@", textTransform); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textTransform, true); - self.rawLayer->setTextTransform(mbglValue); -} - -- (NSExpression *)textTransform { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextTransform(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextTransform(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextVariableAnchor:(NSExpression *)textVariableAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textVariableAnchor: %@", textVariableAnchor); - - auto mbglValue = MGLStyleValueTransformer, NSArray *, mbgl::style::SymbolAnchorType, MGLTextAnchor>().toPropertyValue>>(textVariableAnchor, false); - self.rawLayer->setTextVariableAnchor(mbglValue); -} - -- (NSExpression *)textVariableAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextVariableAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextVariableAnchor(); - } - return MGLStyleValueTransformer, NSArray *, mbgl::style::SymbolAnchorType, MGLTextAnchor>().toExpression(propertyValue); -} - -- (void)setTextWritingModes:(NSExpression *)textWritingModes { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textWritingModes: %@", textWritingModes); - - auto mbglValue = MGLStyleValueTransformer, NSArray *, mbgl::style::TextWritingModeType, MGLTextWritingMode>().toPropertyValue>>(textWritingModes, false); - self.rawLayer->setTextWritingMode(mbglValue); -} - -- (NSExpression *)textWritingModes { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextWritingMode(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextWritingMode(); - } - return MGLStyleValueTransformer, NSArray *, mbgl::style::TextWritingModeType, MGLTextWritingMode>().toExpression(propertyValue); -} - -- (void)setTextWritingMode:(NSExpression *)textWritingMode { -} - -- (NSExpression *)textWritingMode { - return self.textWritingModes; -} - -// MARK: - Accessing the Paint Attributes - -- (void)setIconColor:(NSExpression *)iconColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconColor: %@", iconColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconColor, true); - self.rawLayer->setIconColor(mbglValue); -} - -- (NSExpression *)iconColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setIconColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)iconColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getIconColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setIconHaloBlur:(NSExpression *)iconHaloBlur { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconHaloBlur: %@", iconHaloBlur); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloBlur, true); - self.rawLayer->setIconHaloBlur(mbglValue); -} - -- (NSExpression *)iconHaloBlur { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconHaloBlur(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconHaloBlur(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconHaloBlurTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconHaloBlurTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setIconHaloBlurTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)iconHaloBlurTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getIconHaloBlurTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setIconHaloColor:(NSExpression *)iconHaloColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconHaloColor: %@", iconHaloColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloColor, true); - self.rawLayer->setIconHaloColor(mbglValue); -} - -- (NSExpression *)iconHaloColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconHaloColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconHaloColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconHaloColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconHaloColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setIconHaloColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)iconHaloColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getIconHaloColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setIconHaloWidth:(NSExpression *)iconHaloWidth { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconHaloWidth: %@", iconHaloWidth); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloWidth, true); - self.rawLayer->setIconHaloWidth(mbglValue); -} - -- (NSExpression *)iconHaloWidth { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconHaloWidth(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconHaloWidth(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconHaloWidthTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconHaloWidthTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setIconHaloWidthTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)iconHaloWidthTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getIconHaloWidthTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setIconOpacity:(NSExpression *)iconOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconOpacity: %@", iconOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconOpacity, true); - self.rawLayer->setIconOpacity(mbglValue); -} - -- (NSExpression *)iconOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setIconOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)iconOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getIconOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setIconTranslation:(NSExpression *)iconTranslation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconTranslation: %@", iconTranslation); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconTranslation, false); - self.rawLayer->setIconTranslate(mbglValue); -} - -- (NSExpression *)iconTranslation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconTranslate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconTranslate(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setIconTranslationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconTranslationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setIconTranslateTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)iconTranslationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getIconTranslateTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setIconTranslate:(NSExpression *)iconTranslate { -} - -- (NSExpression *)iconTranslate { - return self.iconTranslation; -} - -- (void)setIconTranslationAnchor:(NSExpression *)iconTranslationAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting iconTranslationAnchor: %@", iconTranslationAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconTranslationAnchor, false); - self.rawLayer->setIconTranslateAnchor(mbglValue); -} - -- (NSExpression *)iconTranslationAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconTranslateAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultIconTranslateAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setIconTranslateAnchor:(NSExpression *)iconTranslateAnchor { -} - -- (NSExpression *)iconTranslateAnchor { - return self.iconTranslationAnchor; -} - -- (void)setTextColor:(NSExpression *)textColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textColor: %@", textColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textColor, true); - self.rawLayer->setTextColor(mbglValue); -} - -- (NSExpression *)textColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setTextColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)textColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getTextColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setTextHaloBlur:(NSExpression *)textHaloBlur { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textHaloBlur: %@", textHaloBlur); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloBlur, true); - self.rawLayer->setTextHaloBlur(mbglValue); -} - -- (NSExpression *)textHaloBlur { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextHaloBlur(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextHaloBlur(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextHaloBlurTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textHaloBlurTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setTextHaloBlurTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)textHaloBlurTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getTextHaloBlurTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setTextHaloColor:(NSExpression *)textHaloColor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textHaloColor: %@", textHaloColor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloColor, true); - self.rawLayer->setTextHaloColor(mbglValue); -} - -- (NSExpression *)textHaloColor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextHaloColor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextHaloColor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextHaloColorTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textHaloColorTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setTextHaloColorTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)textHaloColorTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getTextHaloColorTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setTextHaloWidth:(NSExpression *)textHaloWidth { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textHaloWidth: %@", textHaloWidth); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloWidth, true); - self.rawLayer->setTextHaloWidth(mbglValue); -} - -- (NSExpression *)textHaloWidth { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextHaloWidth(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextHaloWidth(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextHaloWidthTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textHaloWidthTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setTextHaloWidthTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)textHaloWidthTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getTextHaloWidthTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setTextOpacity:(NSExpression *)textOpacity { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textOpacity: %@", textOpacity); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textOpacity, true); - self.rawLayer->setTextOpacity(mbglValue); -} - -- (NSExpression *)textOpacity { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextOpacity(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextOpacity(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextOpacityTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textOpacityTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setTextOpacityTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)textOpacityTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getTextOpacityTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setTextTranslation:(NSExpression *)textTranslation { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textTranslation: %@", textTranslation); - - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(textTranslation, false); - self.rawLayer->setTextTranslate(mbglValue); -} - -- (NSExpression *)textTranslation { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextTranslate(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextTranslate(); - } - return MGLStyleValueTransformer, NSValue *>().toExpression(propertyValue); -} - -- (void)setTextTranslationTransition:(MGLTransition )transition { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textTranslationTransition: %@", MGLStringFromMGLTransition(transition)); - - self.rawLayer->setTextTranslateTransition(MGLOptionsFromTransition(transition)); -} - -- (MGLTransition)textTranslationTransition { - MGLAssertStyleLayerIsValid(); - - mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getTextTranslateTransition(); - - return MGLTransitionFromOptions(transitionOptions); -} - -- (void)setTextTranslate:(NSExpression *)textTranslate { -} - -- (NSExpression *)textTranslate { - return self.textTranslation; -} - -- (void)setTextTranslationAnchor:(NSExpression *)textTranslationAnchor { - MGLAssertStyleLayerIsValid(); - MGLLogDebug(@"Setting textTranslationAnchor: %@", textTranslationAnchor); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textTranslationAnchor, false); - self.rawLayer->setTextTranslateAnchor(mbglValue); -} - -- (NSExpression *)textTranslationAnchor { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextTranslateAnchor(); - if (propertyValue.isUndefined()) { - propertyValue = self.rawLayer->getDefaultTextTranslateAnchor(); - } - return MGLStyleValueTransformer().toExpression(propertyValue); -} - -- (void)setTextTranslateAnchor:(NSExpression *)textTranslateAnchor { -} - -- (NSExpression *)textTranslateAnchor { - return self.textTranslationAnchor; -} - -@end - -@implementation NSValue (MGLSymbolStyleLayerAdditions) - -+ (NSValue *)valueWithMGLIconAnchor:(MGLIconAnchor)iconAnchor { - return [NSValue value:&iconAnchor withObjCType:@encode(MGLIconAnchor)]; -} - -- (MGLIconAnchor)MGLIconAnchorValue { - MGLIconAnchor iconAnchor; - [self getValue:&iconAnchor]; - return iconAnchor; -} - -+ (NSValue *)valueWithMGLIconPitchAlignment:(MGLIconPitchAlignment)iconPitchAlignment { - return [NSValue value:&iconPitchAlignment withObjCType:@encode(MGLIconPitchAlignment)]; -} - -- (MGLIconPitchAlignment)MGLIconPitchAlignmentValue { - MGLIconPitchAlignment iconPitchAlignment; - [self getValue:&iconPitchAlignment]; - return iconPitchAlignment; -} - -+ (NSValue *)valueWithMGLIconRotationAlignment:(MGLIconRotationAlignment)iconRotationAlignment { - return [NSValue value:&iconRotationAlignment withObjCType:@encode(MGLIconRotationAlignment)]; -} - -- (MGLIconRotationAlignment)MGLIconRotationAlignmentValue { - MGLIconRotationAlignment iconRotationAlignment; - [self getValue:&iconRotationAlignment]; - return iconRotationAlignment; -} - -+ (NSValue *)valueWithMGLIconTextFit:(MGLIconTextFit)iconTextFit { - return [NSValue value:&iconTextFit withObjCType:@encode(MGLIconTextFit)]; -} - -- (MGLIconTextFit)MGLIconTextFitValue { - MGLIconTextFit iconTextFit; - [self getValue:&iconTextFit]; - return iconTextFit; -} - -+ (NSValue *)valueWithMGLSymbolPlacement:(MGLSymbolPlacement)symbolPlacement { - return [NSValue value:&symbolPlacement withObjCType:@encode(MGLSymbolPlacement)]; -} - -- (MGLSymbolPlacement)MGLSymbolPlacementValue { - MGLSymbolPlacement symbolPlacement; - [self getValue:&symbolPlacement]; - return symbolPlacement; -} - -+ (NSValue *)valueWithMGLSymbolZOrder:(MGLSymbolZOrder)symbolZOrder { - return [NSValue value:&symbolZOrder withObjCType:@encode(MGLSymbolZOrder)]; -} - -- (MGLSymbolZOrder)MGLSymbolZOrderValue { - MGLSymbolZOrder symbolZOrder; - [self getValue:&symbolZOrder]; - return symbolZOrder; -} - -+ (NSValue *)valueWithMGLTextAnchor:(MGLTextAnchor)textAnchor { - return [NSValue value:&textAnchor withObjCType:@encode(MGLTextAnchor)]; -} - -- (MGLTextAnchor)MGLTextAnchorValue { - MGLTextAnchor textAnchor; - [self getValue:&textAnchor]; - return textAnchor; -} - -+ (NSValue *)valueWithMGLTextJustification:(MGLTextJustification)textJustification { - return [NSValue value:&textJustification withObjCType:@encode(MGLTextJustification)]; -} - -- (MGLTextJustification)MGLTextJustificationValue { - MGLTextJustification textJustification; - [self getValue:&textJustification]; - return textJustification; -} - -+ (NSValue *)valueWithMGLTextPitchAlignment:(MGLTextPitchAlignment)textPitchAlignment { - return [NSValue value:&textPitchAlignment withObjCType:@encode(MGLTextPitchAlignment)]; -} - -- (MGLTextPitchAlignment)MGLTextPitchAlignmentValue { - MGLTextPitchAlignment textPitchAlignment; - [self getValue:&textPitchAlignment]; - return textPitchAlignment; -} - -+ (NSValue *)valueWithMGLTextRotationAlignment:(MGLTextRotationAlignment)textRotationAlignment { - return [NSValue value:&textRotationAlignment withObjCType:@encode(MGLTextRotationAlignment)]; -} - -- (MGLTextRotationAlignment)MGLTextRotationAlignmentValue { - MGLTextRotationAlignment textRotationAlignment; - [self getValue:&textRotationAlignment]; - return textRotationAlignment; -} - -+ (NSValue *)valueWithMGLTextTransform:(MGLTextTransform)textTransform { - return [NSValue value:&textTransform withObjCType:@encode(MGLTextTransform)]; -} - -- (MGLTextTransform)MGLTextTransformValue { - MGLTextTransform textTransform; - [self getValue:&textTransform]; - return textTransform; -} - -+ (NSValue *)valueWithMGLTextWritingMode:(MGLTextWritingMode)textWritingModes { - return [NSValue value:&textWritingModes withObjCType:@encode(MGLTextWritingMode)]; -} - -- (MGLTextWritingMode)MGLTextWritingModeValue { - MGLTextWritingMode textWritingModes; - [self getValue:&textWritingModes]; - return textWritingModes; -} - -+ (NSValue *)valueWithMGLIconTranslationAnchor:(MGLIconTranslationAnchor)iconTranslationAnchor { - return [NSValue value:&iconTranslationAnchor withObjCType:@encode(MGLIconTranslationAnchor)]; -} - -- (MGLIconTranslationAnchor)MGLIconTranslationAnchorValue { - MGLIconTranslationAnchor iconTranslationAnchor; - [self getValue:&iconTranslationAnchor]; - return iconTranslationAnchor; -} - -+ (NSValue *)valueWithMGLTextTranslationAnchor:(MGLTextTranslationAnchor)textTranslationAnchor { - return [NSValue value:&textTranslationAnchor withObjCType:@encode(MGLTextTranslationAnchor)]; -} - -- (MGLTextTranslationAnchor)MGLTextTranslationAnchorValue { - MGLTextTranslationAnchor textTranslationAnchor; - [self getValue:&textTranslationAnchor]; - return textTranslationAnchor; -} - -@end - -namespace mbgl { - -MGLStyleLayer* SymbolStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) { - return [[MGLSymbolStyleLayer alloc] initWithRawLayer:rawLayer]; -} - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/src/MGLSymbolStyleLayer_Private.h b/platform/ios/platform/darwin/src/MGLSymbolStyleLayer_Private.h deleted file mode 100644 index 4c3505a9d..000000000 --- a/platform/ios/platform/darwin/src/MGLSymbolStyleLayer_Private.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#pragma once - -#include "MGLStyleLayer_Private.h" - -#include - -namespace mbgl { - -class SymbolStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::SymbolLayerFactory { - // LayerPeerFactory overrides. - LayerFactory* getCoreLayerFactory() final { return this; } - virtual MGLStyleLayer* createPeer(style::Layer*) final; -}; - -} // namespace mbgl diff --git a/platform/ios/platform/darwin/test/MGLBackgroundStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLBackgroundStyleLayerTests.mm deleted file mode 100644 index bf57e1782..000000000 --- a/platform/ios/platform/darwin/test/MGLBackgroundStyleLayerTests.mm +++ /dev/null @@ -1,198 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLBackgroundLayerTests : MGLStyleLayerTests -@end - -@implementation MGLBackgroundLayerTests - -+ (NSString *)layerType { - return @"background"; -} - -- (void)testProperties { - MGLBackgroundStyleLayer *layer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"layerID"]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"background"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // background-color - { - XCTAssertTrue(rawLayer->getBackgroundColor().isUndefined(), - @"background-color should be unset initially."); - NSExpression *defaultExpression = layer.backgroundColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.backgroundColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getBackgroundColor(), propertyValue, - @"Setting backgroundColor to a constant value expression should update background-color."); - XCTAssertEqualObjects(layer.backgroundColor, constantExpression, - @"backgroundColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.backgroundColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getBackgroundColor(), propertyValue, - @"Setting backgroundColor to a camera expression should update background-color."); - XCTAssertEqualObjects(layer.backgroundColor, functionExpression, - @"backgroundColor should round-trip camera expressions."); - - - layer.backgroundColor = nil; - XCTAssertTrue(rawLayer->getBackgroundColor().isUndefined(), - @"Unsetting backgroundColor should return background-color to the default value."); - XCTAssertEqualObjects(layer.backgroundColor, defaultExpression, - @"backgroundColor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.backgroundColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.backgroundColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.backgroundColorTransition = transitionTest; - auto toptions = rawLayer->getBackgroundColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition backgroundColorTransition = layer.backgroundColorTransition; - XCTAssertEqual(backgroundColorTransition.delay, transitionTest.delay); - XCTAssertEqual(backgroundColorTransition.duration, transitionTest.duration); - } - - // background-opacity - { - XCTAssertTrue(rawLayer->getBackgroundOpacity().isUndefined(), - @"background-opacity should be unset initially."); - NSExpression *defaultExpression = layer.backgroundOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.backgroundOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue, - @"Setting backgroundOpacity to a constant value expression should update background-opacity."); - XCTAssertEqualObjects(layer.backgroundOpacity, constantExpression, - @"backgroundOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.backgroundOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue, - @"Setting backgroundOpacity to a camera expression should update background-opacity."); - XCTAssertEqualObjects(layer.backgroundOpacity, functionExpression, - @"backgroundOpacity should round-trip camera expressions."); - - - layer.backgroundOpacity = nil; - XCTAssertTrue(rawLayer->getBackgroundOpacity().isUndefined(), - @"Unsetting backgroundOpacity should return background-opacity to the default value."); - XCTAssertEqualObjects(layer.backgroundOpacity, defaultExpression, - @"backgroundOpacity should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.backgroundOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.backgroundOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.backgroundOpacityTransition = transitionTest; - auto toptions = rawLayer->getBackgroundOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition backgroundOpacityTransition = layer.backgroundOpacityTransition; - XCTAssertEqual(backgroundOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(backgroundOpacityTransition.duration, transitionTest.duration); - } - - // background-pattern - { - XCTAssertTrue(rawLayer->getBackgroundPattern().isUndefined(), - @"background-pattern should be unset initially."); - NSExpression *defaultExpression = layer.backgroundPattern; - - NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Background Pattern"]; - layer.backgroundPattern = constantExpression; - mbgl::style::PropertyValue propertyValue = { "Background Pattern" }; - XCTAssertEqual(rawLayer->getBackgroundPattern(), propertyValue, - @"Setting backgroundPattern to a constant value expression should update background-pattern."); - XCTAssertEqualObjects(layer.backgroundPattern, constantExpression, - @"backgroundPattern should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Background Pattern')"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.backgroundPattern = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), image(literal("Background Pattern")), 18.0, image(literal("Background Pattern"))) - ); - } - - XCTAssertEqual(rawLayer->getBackgroundPattern(), propertyValue, - @"Setting backgroundPattern to a camera expression should update background-pattern."); - XCTAssertEqualObjects(layer.backgroundPattern, functionExpression, - @"backgroundPattern should round-trip camera expressions."); - - - layer.backgroundPattern = nil; - XCTAssertTrue(rawLayer->getBackgroundPattern().isUndefined(), - @"Unsetting backgroundPattern should return background-pattern to the default value."); - XCTAssertEqualObjects(layer.backgroundPattern, defaultExpression, - @"backgroundPattern should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.backgroundPattern = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.backgroundPattern = functionExpression, NSException, NSInvalidArgumentException, @"MGLBackgroundLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.backgroundPatternTransition = transitionTest; - auto toptions = rawLayer->getBackgroundPatternTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition backgroundPatternTransition = layer.backgroundPatternTransition; - XCTAssertEqual(backgroundPatternTransition.delay, transitionTest.delay); - XCTAssertEqual(backgroundPatternTransition.duration, transitionTest.duration); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"background-color" isBoolean:NO]; - [self testPropertyName:@"background-opacity" isBoolean:NO]; - [self testPropertyName:@"background-pattern" isBoolean:NO]; -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLCircleStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLCircleStyleLayerTests.mm deleted file mode 100644 index ecc29d87c..000000000 --- a/platform/ios/platform/darwin/test/MGLCircleStyleLayerTests.mm +++ /dev/null @@ -1,875 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLCircleLayerTests : MGLStyleLayerTests -@end - -@implementation MGLCircleLayerTests - -+ (NSString *)layerType { - return @"circle"; -} - -- (void)testPredicates { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - - XCTAssertNil(layer.sourceLayerIdentifier); - layer.sourceLayerIdentifier = @"layerID"; - XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID"); - layer.sourceLayerIdentifier = nil; - XCTAssertNil(layer.sourceLayerIdentifier); - - XCTAssertNil(layer.predicate); - layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]; - XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]); - layer.predicate = nil; - XCTAssertNil(layer.predicate); -} - -- (void)testProperties { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - - MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"circle"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // circle-sort-key - { - XCTAssertTrue(rawLayer->getCircleSortKey().isUndefined(), - @"circle-sort-key should be unset initially."); - NSExpression *defaultExpression = layer.circleSortKey; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.circleSortKey = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getCircleSortKey(), propertyValue, - @"Setting circleSortKey to a constant value expression should update circle-sort-key."); - XCTAssertEqualObjects(layer.circleSortKey, constantExpression, - @"circleSortKey should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleSortKey(), propertyValue, - @"Setting circleSortKey to a camera expression should update circle-sort-key."); - XCTAssertEqualObjects(layer.circleSortKey, functionExpression, - @"circleSortKey should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.circleSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleSortKey(), propertyValue, - @"Setting circleSortKey to a data expression should update circle-sort-key."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.circleSortKey, pedanticFunctionExpression, - @"circleSortKey should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.circleSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getCircleSortKey(), propertyValue, - @"Setting circleSortKey to a camera-data expression should update circle-sort-key."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.circleSortKey, pedanticFunctionExpression, - @"circleSortKey should round-trip camera-data expressions."); - - layer.circleSortKey = nil; - XCTAssertTrue(rawLayer->getCircleSortKey().isUndefined(), - @"Unsetting circleSortKey should return circle-sort-key to the default value."); - XCTAssertEqualObjects(layer.circleSortKey, defaultExpression, - @"circleSortKey should return the default value after being unset."); - } - - // circle-blur - { - XCTAssertTrue(rawLayer->getCircleBlur().isUndefined(), - @"circle-blur should be unset initially."); - NSExpression *defaultExpression = layer.circleBlur; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.circleBlur = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue, - @"Setting circleBlur to a constant value expression should update circle-blur."); - XCTAssertEqualObjects(layer.circleBlur, constantExpression, - @"circleBlur should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue, - @"Setting circleBlur to a camera expression should update circle-blur."); - XCTAssertEqualObjects(layer.circleBlur, functionExpression, - @"circleBlur should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.circleBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue, - @"Setting circleBlur to a data expression should update circle-blur."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.circleBlur, pedanticFunctionExpression, - @"circleBlur should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.circleBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue, - @"Setting circleBlur to a camera-data expression should update circle-blur."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.circleBlur, pedanticFunctionExpression, - @"circleBlur should round-trip camera-data expressions."); - - layer.circleBlur = nil; - XCTAssertTrue(rawLayer->getCircleBlur().isUndefined(), - @"Unsetting circleBlur should return circle-blur to the default value."); - XCTAssertEqualObjects(layer.circleBlur, defaultExpression, - @"circleBlur should return the default value after being unset."); - // Transition property test - layer.circleBlurTransition = transitionTest; - auto toptions = rawLayer->getCircleBlurTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition circleBlurTransition = layer.circleBlurTransition; - XCTAssertEqual(circleBlurTransition.delay, transitionTest.delay); - XCTAssertEqual(circleBlurTransition.duration, transitionTest.duration); - } - - // circle-color - { - XCTAssertTrue(rawLayer->getCircleColor().isUndefined(), - @"circle-color should be unset initially."); - NSExpression *defaultExpression = layer.circleColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.circleColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getCircleColor(), propertyValue, - @"Setting circleColor to a constant value expression should update circle-color."); - XCTAssertEqualObjects(layer.circleColor, constantExpression, - @"circleColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getCircleColor(), propertyValue, - @"Setting circleColor to a camera expression should update circle-color."); - XCTAssertEqualObjects(layer.circleColor, functionExpression, - @"circleColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.circleColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getCircleColor(), propertyValue, - @"Setting circleColor to a data expression should update circle-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.circleColor, pedanticFunctionExpression, - @"circleColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.circleColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getCircleColor(), propertyValue, - @"Setting circleColor to a camera-data expression should update circle-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.circleColor, pedanticFunctionExpression, - @"circleColor should round-trip camera-data expressions."); - - layer.circleColor = nil; - XCTAssertTrue(rawLayer->getCircleColor().isUndefined(), - @"Unsetting circleColor should return circle-color to the default value."); - XCTAssertEqualObjects(layer.circleColor, defaultExpression, - @"circleColor should return the default value after being unset."); - // Transition property test - layer.circleColorTransition = transitionTest; - auto toptions = rawLayer->getCircleColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition circleColorTransition = layer.circleColorTransition; - XCTAssertEqual(circleColorTransition.delay, transitionTest.delay); - XCTAssertEqual(circleColorTransition.duration, transitionTest.duration); - } - - // circle-opacity - { - XCTAssertTrue(rawLayer->getCircleOpacity().isUndefined(), - @"circle-opacity should be unset initially."); - NSExpression *defaultExpression = layer.circleOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.circleOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue, - @"Setting circleOpacity to a constant value expression should update circle-opacity."); - XCTAssertEqualObjects(layer.circleOpacity, constantExpression, - @"circleOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue, - @"Setting circleOpacity to a camera expression should update circle-opacity."); - XCTAssertEqualObjects(layer.circleOpacity, functionExpression, - @"circleOpacity should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.circleOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue, - @"Setting circleOpacity to a data expression should update circle-opacity."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.circleOpacity, pedanticFunctionExpression, - @"circleOpacity should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.circleOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue, - @"Setting circleOpacity to a camera-data expression should update circle-opacity."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.circleOpacity, pedanticFunctionExpression, - @"circleOpacity should round-trip camera-data expressions."); - - layer.circleOpacity = nil; - XCTAssertTrue(rawLayer->getCircleOpacity().isUndefined(), - @"Unsetting circleOpacity should return circle-opacity to the default value."); - XCTAssertEqualObjects(layer.circleOpacity, defaultExpression, - @"circleOpacity should return the default value after being unset."); - // Transition property test - layer.circleOpacityTransition = transitionTest; - auto toptions = rawLayer->getCircleOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition circleOpacityTransition = layer.circleOpacityTransition; - XCTAssertEqual(circleOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(circleOpacityTransition.duration, transitionTest.duration); - } - - // circle-pitch-alignment - { - XCTAssertTrue(rawLayer->getCirclePitchAlignment().isUndefined(), - @"circle-pitch-alignment should be unset initially."); - NSExpression *defaultExpression = layer.circlePitchAlignment; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.circlePitchAlignment = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::AlignmentType::Viewport }; - XCTAssertEqual(rawLayer->getCirclePitchAlignment(), propertyValue, - @"Setting circlePitchAlignment to a constant value expression should update circle-pitch-alignment."); - XCTAssertEqualObjects(layer.circlePitchAlignment, constantExpression, - @"circlePitchAlignment should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circlePitchAlignment = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getCirclePitchAlignment(), propertyValue, - @"Setting circlePitchAlignment to a camera expression should update circle-pitch-alignment."); - XCTAssertEqualObjects(layer.circlePitchAlignment, functionExpression, - @"circlePitchAlignment should round-trip camera expressions."); - - - layer.circlePitchAlignment = nil; - XCTAssertTrue(rawLayer->getCirclePitchAlignment().isUndefined(), - @"Unsetting circlePitchAlignment should return circle-pitch-alignment to the default value."); - XCTAssertEqualObjects(layer.circlePitchAlignment, defaultExpression, - @"circlePitchAlignment should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.circlePitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.circlePitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // circle-radius - { - XCTAssertTrue(rawLayer->getCircleRadius().isUndefined(), - @"circle-radius should be unset initially."); - NSExpression *defaultExpression = layer.circleRadius; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.circleRadius = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue, - @"Setting circleRadius to a constant value expression should update circle-radius."); - XCTAssertEqualObjects(layer.circleRadius, constantExpression, - @"circleRadius should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleRadius = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue, - @"Setting circleRadius to a camera expression should update circle-radius."); - XCTAssertEqualObjects(layer.circleRadius, functionExpression, - @"circleRadius should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.circleRadius = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue, - @"Setting circleRadius to a data expression should update circle-radius."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.circleRadius, pedanticFunctionExpression, - @"circleRadius should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.circleRadius = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue, - @"Setting circleRadius to a camera-data expression should update circle-radius."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.circleRadius, pedanticFunctionExpression, - @"circleRadius should round-trip camera-data expressions."); - - layer.circleRadius = nil; - XCTAssertTrue(rawLayer->getCircleRadius().isUndefined(), - @"Unsetting circleRadius should return circle-radius to the default value."); - XCTAssertEqualObjects(layer.circleRadius, defaultExpression, - @"circleRadius should return the default value after being unset."); - // Transition property test - layer.circleRadiusTransition = transitionTest; - auto toptions = rawLayer->getCircleRadiusTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition circleRadiusTransition = layer.circleRadiusTransition; - XCTAssertEqual(circleRadiusTransition.delay, transitionTest.delay); - XCTAssertEqual(circleRadiusTransition.duration, transitionTest.duration); - } - - // circle-pitch-scale - { - XCTAssertTrue(rawLayer->getCirclePitchScale().isUndefined(), - @"circle-pitch-scale should be unset initially."); - NSExpression *defaultExpression = layer.circleScaleAlignment; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.circleScaleAlignment = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::CirclePitchScaleType::Viewport }; - XCTAssertEqual(rawLayer->getCirclePitchScale(), propertyValue, - @"Setting circleScaleAlignment to a constant value expression should update circle-pitch-scale."); - XCTAssertEqualObjects(layer.circleScaleAlignment, constantExpression, - @"circleScaleAlignment should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleScaleAlignment = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getCirclePitchScale(), propertyValue, - @"Setting circleScaleAlignment to a camera expression should update circle-pitch-scale."); - XCTAssertEqualObjects(layer.circleScaleAlignment, functionExpression, - @"circleScaleAlignment should round-trip camera expressions."); - - - layer.circleScaleAlignment = nil; - XCTAssertTrue(rawLayer->getCirclePitchScale().isUndefined(), - @"Unsetting circleScaleAlignment should return circle-pitch-scale to the default value."); - XCTAssertEqualObjects(layer.circleScaleAlignment, defaultExpression, - @"circleScaleAlignment should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.circleScaleAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.circleScaleAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // circle-stroke-color - { - XCTAssertTrue(rawLayer->getCircleStrokeColor().isUndefined(), - @"circle-stroke-color should be unset initially."); - NSExpression *defaultExpression = layer.circleStrokeColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.circleStrokeColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue, - @"Setting circleStrokeColor to a constant value expression should update circle-stroke-color."); - XCTAssertEqualObjects(layer.circleStrokeColor, constantExpression, - @"circleStrokeColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleStrokeColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue, - @"Setting circleStrokeColor to a camera expression should update circle-stroke-color."); - XCTAssertEqualObjects(layer.circleStrokeColor, functionExpression, - @"circleStrokeColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.circleStrokeColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue, - @"Setting circleStrokeColor to a data expression should update circle-stroke-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.circleStrokeColor, pedanticFunctionExpression, - @"circleStrokeColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.circleStrokeColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue, - @"Setting circleStrokeColor to a camera-data expression should update circle-stroke-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.circleStrokeColor, pedanticFunctionExpression, - @"circleStrokeColor should round-trip camera-data expressions."); - - layer.circleStrokeColor = nil; - XCTAssertTrue(rawLayer->getCircleStrokeColor().isUndefined(), - @"Unsetting circleStrokeColor should return circle-stroke-color to the default value."); - XCTAssertEqualObjects(layer.circleStrokeColor, defaultExpression, - @"circleStrokeColor should return the default value after being unset."); - // Transition property test - layer.circleStrokeColorTransition = transitionTest; - auto toptions = rawLayer->getCircleStrokeColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition circleStrokeColorTransition = layer.circleStrokeColorTransition; - XCTAssertEqual(circleStrokeColorTransition.delay, transitionTest.delay); - XCTAssertEqual(circleStrokeColorTransition.duration, transitionTest.duration); - } - - // circle-stroke-opacity - { - XCTAssertTrue(rawLayer->getCircleStrokeOpacity().isUndefined(), - @"circle-stroke-opacity should be unset initially."); - NSExpression *defaultExpression = layer.circleStrokeOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.circleStrokeOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue, - @"Setting circleStrokeOpacity to a constant value expression should update circle-stroke-opacity."); - XCTAssertEqualObjects(layer.circleStrokeOpacity, constantExpression, - @"circleStrokeOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleStrokeOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue, - @"Setting circleStrokeOpacity to a camera expression should update circle-stroke-opacity."); - XCTAssertEqualObjects(layer.circleStrokeOpacity, functionExpression, - @"circleStrokeOpacity should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.circleStrokeOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue, - @"Setting circleStrokeOpacity to a data expression should update circle-stroke-opacity."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.circleStrokeOpacity, pedanticFunctionExpression, - @"circleStrokeOpacity should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.circleStrokeOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue, - @"Setting circleStrokeOpacity to a camera-data expression should update circle-stroke-opacity."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.circleStrokeOpacity, pedanticFunctionExpression, - @"circleStrokeOpacity should round-trip camera-data expressions."); - - layer.circleStrokeOpacity = nil; - XCTAssertTrue(rawLayer->getCircleStrokeOpacity().isUndefined(), - @"Unsetting circleStrokeOpacity should return circle-stroke-opacity to the default value."); - XCTAssertEqualObjects(layer.circleStrokeOpacity, defaultExpression, - @"circleStrokeOpacity should return the default value after being unset."); - // Transition property test - layer.circleStrokeOpacityTransition = transitionTest; - auto toptions = rawLayer->getCircleStrokeOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition circleStrokeOpacityTransition = layer.circleStrokeOpacityTransition; - XCTAssertEqual(circleStrokeOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(circleStrokeOpacityTransition.duration, transitionTest.duration); - } - - // circle-stroke-width - { - XCTAssertTrue(rawLayer->getCircleStrokeWidth().isUndefined(), - @"circle-stroke-width should be unset initially."); - NSExpression *defaultExpression = layer.circleStrokeWidth; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.circleStrokeWidth = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue, - @"Setting circleStrokeWidth to a constant value expression should update circle-stroke-width."); - XCTAssertEqualObjects(layer.circleStrokeWidth, constantExpression, - @"circleStrokeWidth should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleStrokeWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue, - @"Setting circleStrokeWidth to a camera expression should update circle-stroke-width."); - XCTAssertEqualObjects(layer.circleStrokeWidth, functionExpression, - @"circleStrokeWidth should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.circleStrokeWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue, - @"Setting circleStrokeWidth to a data expression should update circle-stroke-width."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.circleStrokeWidth, pedanticFunctionExpression, - @"circleStrokeWidth should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.circleStrokeWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue, - @"Setting circleStrokeWidth to a camera-data expression should update circle-stroke-width."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.circleStrokeWidth, pedanticFunctionExpression, - @"circleStrokeWidth should round-trip camera-data expressions."); - - layer.circleStrokeWidth = nil; - XCTAssertTrue(rawLayer->getCircleStrokeWidth().isUndefined(), - @"Unsetting circleStrokeWidth should return circle-stroke-width to the default value."); - XCTAssertEqualObjects(layer.circleStrokeWidth, defaultExpression, - @"circleStrokeWidth should return the default value after being unset."); - // Transition property test - layer.circleStrokeWidthTransition = transitionTest; - auto toptions = rawLayer->getCircleStrokeWidthTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition circleStrokeWidthTransition = layer.circleStrokeWidthTransition; - XCTAssertEqual(circleStrokeWidthTransition.delay, transitionTest.delay); - XCTAssertEqual(circleStrokeWidthTransition.duration, transitionTest.duration); - } - - // circle-translate - { - XCTAssertTrue(rawLayer->getCircleTranslate().isUndefined(), - @"circle-translate should be unset initially."); - NSExpression *defaultExpression = layer.circleTranslation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithCGVector:CGVectorMake(1, 1)] -#else - [NSValue valueWithMGLVector:CGVectorMake(1, -1)] -#endif - ]; - layer.circleTranslation = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; - XCTAssertEqual(rawLayer->getCircleTranslate(), propertyValue, - @"Setting circleTranslation to a constant value expression should update circle-translate."); - XCTAssertEqualObjects(layer.circleTranslation, constantExpression, - @"circleTranslation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleTranslation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getCircleTranslate(), propertyValue, - @"Setting circleTranslation to a camera expression should update circle-translate."); - XCTAssertEqualObjects(layer.circleTranslation, functionExpression, - @"circleTranslation should round-trip camera expressions."); - - - layer.circleTranslation = nil; - XCTAssertTrue(rawLayer->getCircleTranslate().isUndefined(), - @"Unsetting circleTranslation should return circle-translate to the default value."); - XCTAssertEqualObjects(layer.circleTranslation, defaultExpression, - @"circleTranslation should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.circleTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.circleTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // circle-translate-anchor - { - XCTAssertTrue(rawLayer->getCircleTranslateAnchor().isUndefined(), - @"circle-translate-anchor should be unset initially."); - NSExpression *defaultExpression = layer.circleTranslationAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.circleTranslationAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::TranslateAnchorType::Viewport }; - XCTAssertEqual(rawLayer->getCircleTranslateAnchor(), propertyValue, - @"Setting circleTranslationAnchor to a constant value expression should update circle-translate-anchor."); - XCTAssertEqualObjects(layer.circleTranslationAnchor, constantExpression, - @"circleTranslationAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.circleTranslationAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getCircleTranslateAnchor(), propertyValue, - @"Setting circleTranslationAnchor to a camera expression should update circle-translate-anchor."); - XCTAssertEqualObjects(layer.circleTranslationAnchor, functionExpression, - @"circleTranslationAnchor should round-trip camera expressions."); - - - layer.circleTranslationAnchor = nil; - XCTAssertTrue(rawLayer->getCircleTranslateAnchor().isUndefined(), - @"Unsetting circleTranslationAnchor should return circle-translate-anchor to the default value."); - XCTAssertEqualObjects(layer.circleTranslationAnchor, defaultExpression, - @"circleTranslationAnchor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.circleTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.circleTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLCircleLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"circle-sort-key" isBoolean:NO]; - [self testPropertyName:@"circle-blur" isBoolean:NO]; - [self testPropertyName:@"circle-color" isBoolean:NO]; - [self testPropertyName:@"circle-opacity" isBoolean:NO]; - [self testPropertyName:@"circle-pitch-alignment" isBoolean:NO]; - [self testPropertyName:@"circle-radius" isBoolean:NO]; - [self testPropertyName:@"circle-scale-alignment" isBoolean:NO]; - [self testPropertyName:@"circle-stroke-color" isBoolean:NO]; - [self testPropertyName:@"circle-stroke-opacity" isBoolean:NO]; - [self testPropertyName:@"circle-stroke-width" isBoolean:NO]; - [self testPropertyName:@"circle-translation" isBoolean:NO]; - [self testPropertyName:@"circle-translation-anchor" isBoolean:NO]; -} - -- (void)testValueAdditions { - XCTAssertEqual([NSValue valueWithMGLCirclePitchAlignment:MGLCirclePitchAlignmentMap].MGLCirclePitchAlignmentValue, MGLCirclePitchAlignmentMap); - XCTAssertEqual([NSValue valueWithMGLCirclePitchAlignment:MGLCirclePitchAlignmentViewport].MGLCirclePitchAlignmentValue, MGLCirclePitchAlignmentViewport); - XCTAssertEqual([NSValue valueWithMGLCircleScaleAlignment:MGLCircleScaleAlignmentMap].MGLCircleScaleAlignmentValue, MGLCircleScaleAlignmentMap); - XCTAssertEqual([NSValue valueWithMGLCircleScaleAlignment:MGLCircleScaleAlignmentViewport].MGLCircleScaleAlignmentValue, MGLCircleScaleAlignmentViewport); - XCTAssertEqual([NSValue valueWithMGLCircleTranslationAnchor:MGLCircleTranslationAnchorMap].MGLCircleTranslationAnchorValue, MGLCircleTranslationAnchorMap); - XCTAssertEqual([NSValue valueWithMGLCircleTranslationAnchor:MGLCircleTranslationAnchorViewport].MGLCircleTranslationAnchorValue, MGLCircleTranslationAnchorViewport); -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm deleted file mode 100644 index 9cc084916..000000000 --- a/platform/ios/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm +++ /dev/null @@ -1,542 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLFillExtrusionLayerTests : MGLStyleLayerTests -@end - -@implementation MGLFillExtrusionLayerTests - -+ (NSString *)layerType { - return @"fill-extrusion"; -} - -- (void)testPredicates { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - MGLFillExtrusionStyleLayer *layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - - XCTAssertNil(layer.sourceLayerIdentifier); - layer.sourceLayerIdentifier = @"layerID"; - XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID"); - layer.sourceLayerIdentifier = nil; - XCTAssertNil(layer.sourceLayerIdentifier); - - XCTAssertNil(layer.predicate); - layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]; - XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]); - layer.predicate = nil; - XCTAssertNil(layer.predicate); -} - -- (void)testProperties { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - - MGLFillExtrusionStyleLayer *layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"fill-extrusion"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // fill-extrusion-base - { - XCTAssertTrue(rawLayer->getFillExtrusionBase().isUndefined(), - @"fill-extrusion-base should be unset initially."); - NSExpression *defaultExpression = layer.fillExtrusionBase; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.fillExtrusionBase = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue, - @"Setting fillExtrusionBase to a constant value expression should update fill-extrusion-base."); - XCTAssertEqualObjects(layer.fillExtrusionBase, constantExpression, - @"fillExtrusionBase should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillExtrusionBase = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue, - @"Setting fillExtrusionBase to a camera expression should update fill-extrusion-base."); - XCTAssertEqualObjects(layer.fillExtrusionBase, functionExpression, - @"fillExtrusionBase should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.fillExtrusionBase = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue, - @"Setting fillExtrusionBase to a data expression should update fill-extrusion-base."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.fillExtrusionBase, pedanticFunctionExpression, - @"fillExtrusionBase should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.fillExtrusionBase = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue, - @"Setting fillExtrusionBase to a camera-data expression should update fill-extrusion-base."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.fillExtrusionBase, pedanticFunctionExpression, - @"fillExtrusionBase should round-trip camera-data expressions."); - - layer.fillExtrusionBase = nil; - XCTAssertTrue(rawLayer->getFillExtrusionBase().isUndefined(), - @"Unsetting fillExtrusionBase should return fill-extrusion-base to the default value."); - XCTAssertEqualObjects(layer.fillExtrusionBase, defaultExpression, - @"fillExtrusionBase should return the default value after being unset."); - // Transition property test - layer.fillExtrusionBaseTransition = transitionTest; - auto toptions = rawLayer->getFillExtrusionBaseTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillExtrusionBaseTransition = layer.fillExtrusionBaseTransition; - XCTAssertEqual(fillExtrusionBaseTransition.delay, transitionTest.delay); - XCTAssertEqual(fillExtrusionBaseTransition.duration, transitionTest.duration); - } - - // fill-extrusion-color - { - XCTAssertTrue(rawLayer->getFillExtrusionColor().isUndefined(), - @"fill-extrusion-color should be unset initially."); - NSExpression *defaultExpression = layer.fillExtrusionColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.fillExtrusionColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue, - @"Setting fillExtrusionColor to a constant value expression should update fill-extrusion-color."); - XCTAssertEqualObjects(layer.fillExtrusionColor, constantExpression, - @"fillExtrusionColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillExtrusionColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue, - @"Setting fillExtrusionColor to a camera expression should update fill-extrusion-color."); - XCTAssertEqualObjects(layer.fillExtrusionColor, functionExpression, - @"fillExtrusionColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.fillExtrusionColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue, - @"Setting fillExtrusionColor to a data expression should update fill-extrusion-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.fillExtrusionColor, pedanticFunctionExpression, - @"fillExtrusionColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.fillExtrusionColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue, - @"Setting fillExtrusionColor to a camera-data expression should update fill-extrusion-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.fillExtrusionColor, pedanticFunctionExpression, - @"fillExtrusionColor should round-trip camera-data expressions."); - - layer.fillExtrusionColor = nil; - XCTAssertTrue(rawLayer->getFillExtrusionColor().isUndefined(), - @"Unsetting fillExtrusionColor should return fill-extrusion-color to the default value."); - XCTAssertEqualObjects(layer.fillExtrusionColor, defaultExpression, - @"fillExtrusionColor should return the default value after being unset."); - // Transition property test - layer.fillExtrusionColorTransition = transitionTest; - auto toptions = rawLayer->getFillExtrusionColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillExtrusionColorTransition = layer.fillExtrusionColorTransition; - XCTAssertEqual(fillExtrusionColorTransition.delay, transitionTest.delay); - XCTAssertEqual(fillExtrusionColorTransition.duration, transitionTest.duration); - } - - // fill-extrusion-vertical-gradient - { - XCTAssertTrue(rawLayer->getFillExtrusionVerticalGradient().isUndefined(), - @"fill-extrusion-vertical-gradient should be unset initially."); - NSExpression *defaultExpression = layer.fillExtrusionHasVerticalGradient; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"false"]; - layer.fillExtrusionHasVerticalGradient = constantExpression; - mbgl::style::PropertyValue propertyValue = { false }; - XCTAssertEqual(rawLayer->getFillExtrusionVerticalGradient(), propertyValue, - @"Setting fillExtrusionHasVerticalGradient to a constant value expression should update fill-extrusion-vertical-gradient."); - XCTAssertEqualObjects(layer.fillExtrusionHasVerticalGradient, constantExpression, - @"fillExtrusionHasVerticalGradient should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"false"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillExtrusionHasVerticalGradient = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(false), 18.0, literal(false)) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionVerticalGradient(), propertyValue, - @"Setting fillExtrusionHasVerticalGradient to a camera expression should update fill-extrusion-vertical-gradient."); - XCTAssertEqualObjects(layer.fillExtrusionHasVerticalGradient, functionExpression, - @"fillExtrusionHasVerticalGradient should round-trip camera expressions."); - - - layer.fillExtrusionHasVerticalGradient = nil; - XCTAssertTrue(rawLayer->getFillExtrusionVerticalGradient().isUndefined(), - @"Unsetting fillExtrusionHasVerticalGradient should return fill-extrusion-vertical-gradient to the default value."); - XCTAssertEqualObjects(layer.fillExtrusionHasVerticalGradient, defaultExpression, - @"fillExtrusionHasVerticalGradient should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.fillExtrusionHasVerticalGradient = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.fillExtrusionHasVerticalGradient = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // fill-extrusion-height - { - XCTAssertTrue(rawLayer->getFillExtrusionHeight().isUndefined(), - @"fill-extrusion-height should be unset initially."); - NSExpression *defaultExpression = layer.fillExtrusionHeight; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.fillExtrusionHeight = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue, - @"Setting fillExtrusionHeight to a constant value expression should update fill-extrusion-height."); - XCTAssertEqualObjects(layer.fillExtrusionHeight, constantExpression, - @"fillExtrusionHeight should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillExtrusionHeight = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue, - @"Setting fillExtrusionHeight to a camera expression should update fill-extrusion-height."); - XCTAssertEqualObjects(layer.fillExtrusionHeight, functionExpression, - @"fillExtrusionHeight should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.fillExtrusionHeight = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue, - @"Setting fillExtrusionHeight to a data expression should update fill-extrusion-height."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.fillExtrusionHeight, pedanticFunctionExpression, - @"fillExtrusionHeight should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.fillExtrusionHeight = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue, - @"Setting fillExtrusionHeight to a camera-data expression should update fill-extrusion-height."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.fillExtrusionHeight, pedanticFunctionExpression, - @"fillExtrusionHeight should round-trip camera-data expressions."); - - layer.fillExtrusionHeight = nil; - XCTAssertTrue(rawLayer->getFillExtrusionHeight().isUndefined(), - @"Unsetting fillExtrusionHeight should return fill-extrusion-height to the default value."); - XCTAssertEqualObjects(layer.fillExtrusionHeight, defaultExpression, - @"fillExtrusionHeight should return the default value after being unset."); - // Transition property test - layer.fillExtrusionHeightTransition = transitionTest; - auto toptions = rawLayer->getFillExtrusionHeightTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillExtrusionHeightTransition = layer.fillExtrusionHeightTransition; - XCTAssertEqual(fillExtrusionHeightTransition.delay, transitionTest.delay); - XCTAssertEqual(fillExtrusionHeightTransition.duration, transitionTest.duration); - } - - // fill-extrusion-opacity - { - XCTAssertTrue(rawLayer->getFillExtrusionOpacity().isUndefined(), - @"fill-extrusion-opacity should be unset initially."); - NSExpression *defaultExpression = layer.fillExtrusionOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.fillExtrusionOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getFillExtrusionOpacity(), propertyValue, - @"Setting fillExtrusionOpacity to a constant value expression should update fill-extrusion-opacity."); - XCTAssertEqualObjects(layer.fillExtrusionOpacity, constantExpression, - @"fillExtrusionOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillExtrusionOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionOpacity(), propertyValue, - @"Setting fillExtrusionOpacity to a camera expression should update fill-extrusion-opacity."); - XCTAssertEqualObjects(layer.fillExtrusionOpacity, functionExpression, - @"fillExtrusionOpacity should round-trip camera expressions."); - - - layer.fillExtrusionOpacity = nil; - XCTAssertTrue(rawLayer->getFillExtrusionOpacity().isUndefined(), - @"Unsetting fillExtrusionOpacity should return fill-extrusion-opacity to the default value."); - XCTAssertEqualObjects(layer.fillExtrusionOpacity, defaultExpression, - @"fillExtrusionOpacity should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.fillExtrusionOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.fillExtrusionOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.fillExtrusionOpacityTransition = transitionTest; - auto toptions = rawLayer->getFillExtrusionOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillExtrusionOpacityTransition = layer.fillExtrusionOpacityTransition; - XCTAssertEqual(fillExtrusionOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(fillExtrusionOpacityTransition.duration, transitionTest.duration); - } - - // fill-extrusion-pattern - { - XCTAssertTrue(rawLayer->getFillExtrusionPattern().isUndefined(), - @"fill-extrusion-pattern should be unset initially."); - NSExpression *defaultExpression = layer.fillExtrusionPattern; - - NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Fill Extrusion Pattern"]; - layer.fillExtrusionPattern = constantExpression; - mbgl::style::PropertyValue propertyValue = { "Fill Extrusion Pattern" }; - XCTAssertEqual(rawLayer->getFillExtrusionPattern(), propertyValue, - @"Setting fillExtrusionPattern to a constant value expression should update fill-extrusion-pattern."); - XCTAssertEqualObjects(layer.fillExtrusionPattern, constantExpression, - @"fillExtrusionPattern should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Fill Extrusion Pattern')"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillExtrusionPattern = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), image(literal("Fill Extrusion Pattern")), 18.0, image(literal("Fill Extrusion Pattern"))) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionPattern(), propertyValue, - @"Setting fillExtrusionPattern to a camera expression should update fill-extrusion-pattern."); - XCTAssertEqualObjects(layer.fillExtrusionPattern, functionExpression, - @"fillExtrusionPattern should round-trip camera expressions."); - - - layer.fillExtrusionPattern = nil; - XCTAssertTrue(rawLayer->getFillExtrusionPattern().isUndefined(), - @"Unsetting fillExtrusionPattern should return fill-extrusion-pattern to the default value."); - XCTAssertEqualObjects(layer.fillExtrusionPattern, defaultExpression, - @"fillExtrusionPattern should return the default value after being unset."); - // Transition property test - layer.fillExtrusionPatternTransition = transitionTest; - auto toptions = rawLayer->getFillExtrusionPatternTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillExtrusionPatternTransition = layer.fillExtrusionPatternTransition; - XCTAssertEqual(fillExtrusionPatternTransition.delay, transitionTest.delay); - XCTAssertEqual(fillExtrusionPatternTransition.duration, transitionTest.duration); - } - - // fill-extrusion-translate - { - XCTAssertTrue(rawLayer->getFillExtrusionTranslate().isUndefined(), - @"fill-extrusion-translate should be unset initially."); - NSExpression *defaultExpression = layer.fillExtrusionTranslation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithCGVector:CGVectorMake(1, 1)] -#else - [NSValue valueWithMGLVector:CGVectorMake(1, -1)] -#endif - ]; - layer.fillExtrusionTranslation = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; - XCTAssertEqual(rawLayer->getFillExtrusionTranslate(), propertyValue, - @"Setting fillExtrusionTranslation to a constant value expression should update fill-extrusion-translate."); - XCTAssertEqualObjects(layer.fillExtrusionTranslation, constantExpression, - @"fillExtrusionTranslation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillExtrusionTranslation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionTranslate(), propertyValue, - @"Setting fillExtrusionTranslation to a camera expression should update fill-extrusion-translate."); - XCTAssertEqualObjects(layer.fillExtrusionTranslation, functionExpression, - @"fillExtrusionTranslation should round-trip camera expressions."); - - - layer.fillExtrusionTranslation = nil; - XCTAssertTrue(rawLayer->getFillExtrusionTranslate().isUndefined(), - @"Unsetting fillExtrusionTranslation should return fill-extrusion-translate to the default value."); - XCTAssertEqualObjects(layer.fillExtrusionTranslation, defaultExpression, - @"fillExtrusionTranslation should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.fillExtrusionTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.fillExtrusionTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // fill-extrusion-translate-anchor - { - XCTAssertTrue(rawLayer->getFillExtrusionTranslateAnchor().isUndefined(), - @"fill-extrusion-translate-anchor should be unset initially."); - NSExpression *defaultExpression = layer.fillExtrusionTranslationAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.fillExtrusionTranslationAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::TranslateAnchorType::Viewport }; - XCTAssertEqual(rawLayer->getFillExtrusionTranslateAnchor(), propertyValue, - @"Setting fillExtrusionTranslationAnchor to a constant value expression should update fill-extrusion-translate-anchor."); - XCTAssertEqualObjects(layer.fillExtrusionTranslationAnchor, constantExpression, - @"fillExtrusionTranslationAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillExtrusionTranslationAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getFillExtrusionTranslateAnchor(), propertyValue, - @"Setting fillExtrusionTranslationAnchor to a camera expression should update fill-extrusion-translate-anchor."); - XCTAssertEqualObjects(layer.fillExtrusionTranslationAnchor, functionExpression, - @"fillExtrusionTranslationAnchor should round-trip camera expressions."); - - - layer.fillExtrusionTranslationAnchor = nil; - XCTAssertTrue(rawLayer->getFillExtrusionTranslateAnchor().isUndefined(), - @"Unsetting fillExtrusionTranslationAnchor should return fill-extrusion-translate-anchor to the default value."); - XCTAssertEqualObjects(layer.fillExtrusionTranslationAnchor, defaultExpression, - @"fillExtrusionTranslationAnchor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.fillExtrusionTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.fillExtrusionTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillExtrusionLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"fill-extrusion-base" isBoolean:NO]; - [self testPropertyName:@"fill-extrusion-color" isBoolean:NO]; - [self testPropertyName:@"fill-extrusion-has-vertical-gradient" isBoolean:YES]; - [self testPropertyName:@"fill-extrusion-height" isBoolean:NO]; - [self testPropertyName:@"fill-extrusion-opacity" isBoolean:NO]; - [self testPropertyName:@"fill-extrusion-pattern" isBoolean:NO]; - [self testPropertyName:@"fill-extrusion-translation" isBoolean:NO]; - [self testPropertyName:@"fill-extrusion-translation-anchor" isBoolean:NO]; -} - -- (void)testValueAdditions { - XCTAssertEqual([NSValue valueWithMGLFillExtrusionTranslationAnchor:MGLFillExtrusionTranslationAnchorMap].MGLFillExtrusionTranslationAnchorValue, MGLFillExtrusionTranslationAnchorMap); - XCTAssertEqual([NSValue valueWithMGLFillExtrusionTranslationAnchor:MGLFillExtrusionTranslationAnchorViewport].MGLFillExtrusionTranslationAnchorValue, MGLFillExtrusionTranslationAnchorViewport); -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLFillStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLFillStyleLayerTests.mm deleted file mode 100644 index 6ef930c9f..000000000 --- a/platform/ios/platform/darwin/test/MGLFillStyleLayerTests.mm +++ /dev/null @@ -1,561 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLFillLayerTests : MGLStyleLayerTests -@end - -@implementation MGLFillLayerTests - -+ (NSString *)layerType { - return @"fill"; -} - -- (void)testPredicates { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - - XCTAssertNil(layer.sourceLayerIdentifier); - layer.sourceLayerIdentifier = @"layerID"; - XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID"); - layer.sourceLayerIdentifier = nil; - XCTAssertNil(layer.sourceLayerIdentifier); - - XCTAssertNil(layer.predicate); - layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]; - XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]); - layer.predicate = nil; - XCTAssertNil(layer.predicate); -} - -- (void)testProperties { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - - MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"fill"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // fill-sort-key - { - XCTAssertTrue(rawLayer->getFillSortKey().isUndefined(), - @"fill-sort-key should be unset initially."); - NSExpression *defaultExpression = layer.fillSortKey; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.fillSortKey = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getFillSortKey(), propertyValue, - @"Setting fillSortKey to a constant value expression should update fill-sort-key."); - XCTAssertEqualObjects(layer.fillSortKey, constantExpression, - @"fillSortKey should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; -#if TARGET_OS_IPHONE - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); -#endif - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillSortKey(), propertyValue, - @"Setting fillSortKey to a camera expression should update fill-sort-key."); - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - XCTAssertEqualObjects(layer.fillSortKey, functionExpression, - @"fillSortKey should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.fillSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillSortKey(), propertyValue, - @"Setting fillSortKey to a data expression should update fill-sort-key."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.fillSortKey, pedanticFunctionExpression, - @"fillSortKey should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.fillSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getFillSortKey(), propertyValue, - @"Setting fillSortKey to a camera-data expression should update fill-sort-key."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.fillSortKey, pedanticFunctionExpression, - @"fillSortKey should round-trip camera-data expressions."); - - layer.fillSortKey = nil; - XCTAssertTrue(rawLayer->getFillSortKey().isUndefined(), - @"Unsetting fillSortKey should return fill-sort-key to the default value."); - XCTAssertEqualObjects(layer.fillSortKey, defaultExpression, - @"fillSortKey should return the default value after being unset."); - } - - // fill-antialias - { - XCTAssertTrue(rawLayer->getFillAntialias().isUndefined(), - @"fill-antialias should be unset initially."); - NSExpression *defaultExpression = layer.fillAntialiased; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"false"]; - layer.fillAntialiased = constantExpression; - mbgl::style::PropertyValue propertyValue = { false }; - XCTAssertEqual(rawLayer->getFillAntialias(), propertyValue, - @"Setting fillAntialiased to a constant value expression should update fill-antialias."); - XCTAssertEqualObjects(layer.fillAntialiased, constantExpression, - @"fillAntialiased should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"false"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillAntialiased = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(false), 18.0, literal(false)) - ); - } - - XCTAssertEqual(rawLayer->getFillAntialias(), propertyValue, - @"Setting fillAntialiased to a camera expression should update fill-antialias."); - XCTAssertEqualObjects(layer.fillAntialiased, functionExpression, - @"fillAntialiased should round-trip camera expressions."); - - - layer.fillAntialiased = nil; - XCTAssertTrue(rawLayer->getFillAntialias().isUndefined(), - @"Unsetting fillAntialiased should return fill-antialias to the default value."); - XCTAssertEqualObjects(layer.fillAntialiased, defaultExpression, - @"fillAntialiased should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.fillAntialiased = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.fillAntialiased = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // fill-color - { - XCTAssertTrue(rawLayer->getFillColor().isUndefined(), - @"fill-color should be unset initially."); - NSExpression *defaultExpression = layer.fillColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.fillColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getFillColor(), propertyValue, - @"Setting fillColor to a constant value expression should update fill-color."); - XCTAssertEqualObjects(layer.fillColor, constantExpression, - @"fillColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getFillColor(), propertyValue, - @"Setting fillColor to a camera expression should update fill-color."); - XCTAssertEqualObjects(layer.fillColor, functionExpression, - @"fillColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.fillColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getFillColor(), propertyValue, - @"Setting fillColor to a data expression should update fill-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.fillColor, pedanticFunctionExpression, - @"fillColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.fillColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getFillColor(), propertyValue, - @"Setting fillColor to a camera-data expression should update fill-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.fillColor, pedanticFunctionExpression, - @"fillColor should round-trip camera-data expressions."); - - layer.fillColor = nil; - XCTAssertTrue(rawLayer->getFillColor().isUndefined(), - @"Unsetting fillColor should return fill-color to the default value."); - XCTAssertEqualObjects(layer.fillColor, defaultExpression, - @"fillColor should return the default value after being unset."); - // Transition property test - layer.fillColorTransition = transitionTest; - auto toptions = rawLayer->getFillColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillColorTransition = layer.fillColorTransition; - XCTAssertEqual(fillColorTransition.delay, transitionTest.delay); - XCTAssertEqual(fillColorTransition.duration, transitionTest.duration); - } - - // fill-opacity - { - XCTAssertTrue(rawLayer->getFillOpacity().isUndefined(), - @"fill-opacity should be unset initially."); - NSExpression *defaultExpression = layer.fillOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.fillOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue, - @"Setting fillOpacity to a constant value expression should update fill-opacity."); - XCTAssertEqualObjects(layer.fillOpacity, constantExpression, - @"fillOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue, - @"Setting fillOpacity to a camera expression should update fill-opacity."); - XCTAssertEqualObjects(layer.fillOpacity, functionExpression, - @"fillOpacity should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.fillOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue, - @"Setting fillOpacity to a data expression should update fill-opacity."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.fillOpacity, pedanticFunctionExpression, - @"fillOpacity should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.fillOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue, - @"Setting fillOpacity to a camera-data expression should update fill-opacity."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.fillOpacity, pedanticFunctionExpression, - @"fillOpacity should round-trip camera-data expressions."); - - layer.fillOpacity = nil; - XCTAssertTrue(rawLayer->getFillOpacity().isUndefined(), - @"Unsetting fillOpacity should return fill-opacity to the default value."); - XCTAssertEqualObjects(layer.fillOpacity, defaultExpression, - @"fillOpacity should return the default value after being unset."); - // Transition property test - layer.fillOpacityTransition = transitionTest; - auto toptions = rawLayer->getFillOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillOpacityTransition = layer.fillOpacityTransition; - XCTAssertEqual(fillOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(fillOpacityTransition.duration, transitionTest.duration); - } - - // fill-outline-color - { - XCTAssertTrue(rawLayer->getFillOutlineColor().isUndefined(), - @"fill-outline-color should be unset initially."); - NSExpression *defaultExpression = layer.fillOutlineColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.fillOutlineColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue, - @"Setting fillOutlineColor to a constant value expression should update fill-outline-color."); - XCTAssertEqualObjects(layer.fillOutlineColor, constantExpression, - @"fillOutlineColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillOutlineColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue, - @"Setting fillOutlineColor to a camera expression should update fill-outline-color."); - XCTAssertEqualObjects(layer.fillOutlineColor, functionExpression, - @"fillOutlineColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.fillOutlineColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue, - @"Setting fillOutlineColor to a data expression should update fill-outline-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.fillOutlineColor, pedanticFunctionExpression, - @"fillOutlineColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.fillOutlineColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue, - @"Setting fillOutlineColor to a camera-data expression should update fill-outline-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.fillOutlineColor, pedanticFunctionExpression, - @"fillOutlineColor should round-trip camera-data expressions."); - - layer.fillOutlineColor = nil; - XCTAssertTrue(rawLayer->getFillOutlineColor().isUndefined(), - @"Unsetting fillOutlineColor should return fill-outline-color to the default value."); - XCTAssertEqualObjects(layer.fillOutlineColor, defaultExpression, - @"fillOutlineColor should return the default value after being unset."); - // Transition property test - layer.fillOutlineColorTransition = transitionTest; - auto toptions = rawLayer->getFillOutlineColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillOutlineColorTransition = layer.fillOutlineColorTransition; - XCTAssertEqual(fillOutlineColorTransition.delay, transitionTest.delay); - XCTAssertEqual(fillOutlineColorTransition.duration, transitionTest.duration); - } - - // fill-pattern - { - XCTAssertTrue(rawLayer->getFillPattern().isUndefined(), - @"fill-pattern should be unset initially."); - NSExpression *defaultExpression = layer.fillPattern; - - NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Fill Pattern"]; - layer.fillPattern = constantExpression; - mbgl::style::PropertyValue propertyValue = { "Fill Pattern" }; - XCTAssertEqual(rawLayer->getFillPattern(), propertyValue, - @"Setting fillPattern to a constant value expression should update fill-pattern."); - XCTAssertEqualObjects(layer.fillPattern, constantExpression, - @"fillPattern should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Fill Pattern')"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillPattern = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), image(literal("Fill Pattern")), 18.0, image(literal("Fill Pattern"))) - ); - } - - XCTAssertEqual(rawLayer->getFillPattern(), propertyValue, - @"Setting fillPattern to a camera expression should update fill-pattern."); - XCTAssertEqualObjects(layer.fillPattern, functionExpression, - @"fillPattern should round-trip camera expressions."); - - - layer.fillPattern = nil; - XCTAssertTrue(rawLayer->getFillPattern().isUndefined(), - @"Unsetting fillPattern should return fill-pattern to the default value."); - XCTAssertEqualObjects(layer.fillPattern, defaultExpression, - @"fillPattern should return the default value after being unset."); - // Transition property test - layer.fillPatternTransition = transitionTest; - auto toptions = rawLayer->getFillPatternTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition fillPatternTransition = layer.fillPatternTransition; - XCTAssertEqual(fillPatternTransition.delay, transitionTest.delay); - XCTAssertEqual(fillPatternTransition.duration, transitionTest.duration); - } - - // fill-translate - { - XCTAssertTrue(rawLayer->getFillTranslate().isUndefined(), - @"fill-translate should be unset initially."); - NSExpression *defaultExpression = layer.fillTranslation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithCGVector:CGVectorMake(1, 1)] -#else - [NSValue valueWithMGLVector:CGVectorMake(1, -1)] -#endif - ]; - layer.fillTranslation = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; - XCTAssertEqual(rawLayer->getFillTranslate(), propertyValue, - @"Setting fillTranslation to a constant value expression should update fill-translate."); - XCTAssertEqualObjects(layer.fillTranslation, constantExpression, - @"fillTranslation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillTranslation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getFillTranslate(), propertyValue, - @"Setting fillTranslation to a camera expression should update fill-translate."); - XCTAssertEqualObjects(layer.fillTranslation, functionExpression, - @"fillTranslation should round-trip camera expressions."); - - - layer.fillTranslation = nil; - XCTAssertTrue(rawLayer->getFillTranslate().isUndefined(), - @"Unsetting fillTranslation should return fill-translate to the default value."); - XCTAssertEqualObjects(layer.fillTranslation, defaultExpression, - @"fillTranslation should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.fillTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.fillTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // fill-translate-anchor - { - XCTAssertTrue(rawLayer->getFillTranslateAnchor().isUndefined(), - @"fill-translate-anchor should be unset initially."); - NSExpression *defaultExpression = layer.fillTranslationAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.fillTranslationAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::TranslateAnchorType::Viewport }; - XCTAssertEqual(rawLayer->getFillTranslateAnchor(), propertyValue, - @"Setting fillTranslationAnchor to a constant value expression should update fill-translate-anchor."); - XCTAssertEqualObjects(layer.fillTranslationAnchor, constantExpression, - @"fillTranslationAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.fillTranslationAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getFillTranslateAnchor(), propertyValue, - @"Setting fillTranslationAnchor to a camera expression should update fill-translate-anchor."); - XCTAssertEqualObjects(layer.fillTranslationAnchor, functionExpression, - @"fillTranslationAnchor should round-trip camera expressions."); - - - layer.fillTranslationAnchor = nil; - XCTAssertTrue(rawLayer->getFillTranslateAnchor().isUndefined(), - @"Unsetting fillTranslationAnchor should return fill-translate-anchor to the default value."); - XCTAssertEqualObjects(layer.fillTranslationAnchor, defaultExpression, - @"fillTranslationAnchor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.fillTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.fillTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLFillLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"fill-sort-key" isBoolean:NO]; - [self testPropertyName:@"is-fill-antialiased" isBoolean:YES]; - [self testPropertyName:@"fill-color" isBoolean:NO]; - [self testPropertyName:@"fill-opacity" isBoolean:NO]; - [self testPropertyName:@"fill-outline-color" isBoolean:NO]; - [self testPropertyName:@"fill-pattern" isBoolean:NO]; - [self testPropertyName:@"fill-translation" isBoolean:NO]; - [self testPropertyName:@"fill-translation-anchor" isBoolean:NO]; -} - -- (void)testValueAdditions { - XCTAssertEqual([NSValue valueWithMGLFillTranslationAnchor:MGLFillTranslationAnchorMap].MGLFillTranslationAnchorValue, MGLFillTranslationAnchorMap); - XCTAssertEqual([NSValue valueWithMGLFillTranslationAnchor:MGLFillTranslationAnchorViewport].MGLFillTranslationAnchorValue, MGLFillTranslationAnchorViewport); -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLHeatmapStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLHeatmapStyleLayerTests.mm deleted file mode 100644 index 745cfd366..000000000 --- a/platform/ios/platform/darwin/test/MGLHeatmapStyleLayerTests.mm +++ /dev/null @@ -1,317 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLHeatmapLayerTests : MGLStyleLayerTests -@end - -@implementation MGLHeatmapLayerTests - -+ (NSString *)layerType { - return @"heatmap"; -} - -- (void)testPredicates { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - MGLHeatmapStyleLayer *layer = [[MGLHeatmapStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - - XCTAssertNil(layer.sourceLayerIdentifier); - layer.sourceLayerIdentifier = @"layerID"; - XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID"); - layer.sourceLayerIdentifier = nil; - XCTAssertNil(layer.sourceLayerIdentifier); - - XCTAssertNil(layer.predicate); - layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]; - XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]); - layer.predicate = nil; - XCTAssertNil(layer.predicate); -} - -- (void)testProperties { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - - MGLHeatmapStyleLayer *layer = [[MGLHeatmapStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"heatmap"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // heatmap-intensity - { - XCTAssertTrue(rawLayer->getHeatmapIntensity().isUndefined(), - @"heatmap-intensity should be unset initially."); - NSExpression *defaultExpression = layer.heatmapIntensity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.heatmapIntensity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getHeatmapIntensity(), propertyValue, - @"Setting heatmapIntensity to a constant value expression should update heatmap-intensity."); - XCTAssertEqualObjects(layer.heatmapIntensity, constantExpression, - @"heatmapIntensity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; -#if TARGET_OS_IPHONE - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); -#endif - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.heatmapIntensity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getHeatmapIntensity(), propertyValue, - @"Setting heatmapIntensity to a camera expression should update heatmap-intensity."); - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - XCTAssertEqualObjects(layer.heatmapIntensity, functionExpression, - @"heatmapIntensity should round-trip camera expressions."); - - - layer.heatmapIntensity = nil; - XCTAssertTrue(rawLayer->getHeatmapIntensity().isUndefined(), - @"Unsetting heatmapIntensity should return heatmap-intensity to the default value."); - XCTAssertEqualObjects(layer.heatmapIntensity, defaultExpression, - @"heatmapIntensity should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.heatmapIntensity = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.heatmapIntensity = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.heatmapIntensityTransition = transitionTest; - auto toptions = rawLayer->getHeatmapIntensityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition heatmapIntensityTransition = layer.heatmapIntensityTransition; - XCTAssertEqual(heatmapIntensityTransition.delay, transitionTest.delay); - XCTAssertEqual(heatmapIntensityTransition.duration, transitionTest.duration); - } - - // heatmap-opacity - { - XCTAssertTrue(rawLayer->getHeatmapOpacity().isUndefined(), - @"heatmap-opacity should be unset initially."); - NSExpression *defaultExpression = layer.heatmapOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.heatmapOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getHeatmapOpacity(), propertyValue, - @"Setting heatmapOpacity to a constant value expression should update heatmap-opacity."); - XCTAssertEqualObjects(layer.heatmapOpacity, constantExpression, - @"heatmapOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.heatmapOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getHeatmapOpacity(), propertyValue, - @"Setting heatmapOpacity to a camera expression should update heatmap-opacity."); - XCTAssertEqualObjects(layer.heatmapOpacity, functionExpression, - @"heatmapOpacity should round-trip camera expressions."); - - - layer.heatmapOpacity = nil; - XCTAssertTrue(rawLayer->getHeatmapOpacity().isUndefined(), - @"Unsetting heatmapOpacity should return heatmap-opacity to the default value."); - XCTAssertEqualObjects(layer.heatmapOpacity, defaultExpression, - @"heatmapOpacity should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.heatmapOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.heatmapOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLHeatmapLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.heatmapOpacityTransition = transitionTest; - auto toptions = rawLayer->getHeatmapOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition heatmapOpacityTransition = layer.heatmapOpacityTransition; - XCTAssertEqual(heatmapOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(heatmapOpacityTransition.duration, transitionTest.duration); - } - - // heatmap-radius - { - XCTAssertTrue(rawLayer->getHeatmapRadius().isUndefined(), - @"heatmap-radius should be unset initially."); - NSExpression *defaultExpression = layer.heatmapRadius; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.heatmapRadius = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue, - @"Setting heatmapRadius to a constant value expression should update heatmap-radius."); - XCTAssertEqualObjects(layer.heatmapRadius, constantExpression, - @"heatmapRadius should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.heatmapRadius = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue, - @"Setting heatmapRadius to a camera expression should update heatmap-radius."); - XCTAssertEqualObjects(layer.heatmapRadius, functionExpression, - @"heatmapRadius should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.heatmapRadius = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue, - @"Setting heatmapRadius to a data expression should update heatmap-radius."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.heatmapRadius, pedanticFunctionExpression, - @"heatmapRadius should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.heatmapRadius = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue, - @"Setting heatmapRadius to a camera-data expression should update heatmap-radius."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.heatmapRadius, pedanticFunctionExpression, - @"heatmapRadius should round-trip camera-data expressions."); - - layer.heatmapRadius = nil; - XCTAssertTrue(rawLayer->getHeatmapRadius().isUndefined(), - @"Unsetting heatmapRadius should return heatmap-radius to the default value."); - XCTAssertEqualObjects(layer.heatmapRadius, defaultExpression, - @"heatmapRadius should return the default value after being unset."); - // Transition property test - layer.heatmapRadiusTransition = transitionTest; - auto toptions = rawLayer->getHeatmapRadiusTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition heatmapRadiusTransition = layer.heatmapRadiusTransition; - XCTAssertEqual(heatmapRadiusTransition.delay, transitionTest.delay); - XCTAssertEqual(heatmapRadiusTransition.duration, transitionTest.duration); - } - - // heatmap-weight - { - XCTAssertTrue(rawLayer->getHeatmapWeight().isUndefined(), - @"heatmap-weight should be unset initially."); - NSExpression *defaultExpression = layer.heatmapWeight; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.heatmapWeight = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue, - @"Setting heatmapWeight to a constant value expression should update heatmap-weight."); - XCTAssertEqualObjects(layer.heatmapWeight, constantExpression, - @"heatmapWeight should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.heatmapWeight = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue, - @"Setting heatmapWeight to a camera expression should update heatmap-weight."); - XCTAssertEqualObjects(layer.heatmapWeight, functionExpression, - @"heatmapWeight should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.heatmapWeight = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue, - @"Setting heatmapWeight to a data expression should update heatmap-weight."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.heatmapWeight, pedanticFunctionExpression, - @"heatmapWeight should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.heatmapWeight = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue, - @"Setting heatmapWeight to a camera-data expression should update heatmap-weight."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.heatmapWeight, pedanticFunctionExpression, - @"heatmapWeight should round-trip camera-data expressions."); - - layer.heatmapWeight = nil; - XCTAssertTrue(rawLayer->getHeatmapWeight().isUndefined(), - @"Unsetting heatmapWeight should return heatmap-weight to the default value."); - XCTAssertEqualObjects(layer.heatmapWeight, defaultExpression, - @"heatmapWeight should return the default value after being unset."); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"heatmap-intensity" isBoolean:NO]; - [self testPropertyName:@"heatmap-opacity" isBoolean:NO]; - [self testPropertyName:@"heatmap-radius" isBoolean:NO]; - [self testPropertyName:@"heatmap-weight" isBoolean:NO]; -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLHillshadeStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLHillshadeStyleLayerTests.mm deleted file mode 100644 index 751ae589d..000000000 --- a/platform/ios/platform/darwin/test/MGLHillshadeStyleLayerTests.mm +++ /dev/null @@ -1,353 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLHillshadeLayerTests : MGLStyleLayerTests -@end - -@implementation MGLHillshadeLayerTests - -+ (NSString *)layerType { - return @"hillshade"; -} - -- (void)testProperties { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - - MGLHillshadeStyleLayer *layer = [[MGLHillshadeStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"hillshade"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // hillshade-accent-color - { - XCTAssertTrue(rawLayer->getHillshadeAccentColor().isUndefined(), - @"hillshade-accent-color should be unset initially."); - NSExpression *defaultExpression = layer.hillshadeAccentColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.hillshadeAccentColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getHillshadeAccentColor(), propertyValue, - @"Setting hillshadeAccentColor to a constant value expression should update hillshade-accent-color."); - XCTAssertEqualObjects(layer.hillshadeAccentColor, constantExpression, - @"hillshadeAccentColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; -#if TARGET_OS_IPHONE - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); -#endif - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.hillshadeAccentColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getHillshadeAccentColor(), propertyValue, - @"Setting hillshadeAccentColor to a camera expression should update hillshade-accent-color."); - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - XCTAssertEqualObjects(layer.hillshadeAccentColor, functionExpression, - @"hillshadeAccentColor should round-trip camera expressions."); - - - layer.hillshadeAccentColor = nil; - XCTAssertTrue(rawLayer->getHillshadeAccentColor().isUndefined(), - @"Unsetting hillshadeAccentColor should return hillshade-accent-color to the default value."); - XCTAssertEqualObjects(layer.hillshadeAccentColor, defaultExpression, - @"hillshadeAccentColor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.hillshadeAccentColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.hillshadeAccentColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.hillshadeAccentColorTransition = transitionTest; - auto toptions = rawLayer->getHillshadeAccentColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition hillshadeAccentColorTransition = layer.hillshadeAccentColorTransition; - XCTAssertEqual(hillshadeAccentColorTransition.delay, transitionTest.delay); - XCTAssertEqual(hillshadeAccentColorTransition.duration, transitionTest.duration); - } - - // hillshade-exaggeration - { - XCTAssertTrue(rawLayer->getHillshadeExaggeration().isUndefined(), - @"hillshade-exaggeration should be unset initially."); - NSExpression *defaultExpression = layer.hillshadeExaggeration; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.hillshadeExaggeration = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getHillshadeExaggeration(), propertyValue, - @"Setting hillshadeExaggeration to a constant value expression should update hillshade-exaggeration."); - XCTAssertEqualObjects(layer.hillshadeExaggeration, constantExpression, - @"hillshadeExaggeration should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.hillshadeExaggeration = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getHillshadeExaggeration(), propertyValue, - @"Setting hillshadeExaggeration to a camera expression should update hillshade-exaggeration."); - XCTAssertEqualObjects(layer.hillshadeExaggeration, functionExpression, - @"hillshadeExaggeration should round-trip camera expressions."); - - - layer.hillshadeExaggeration = nil; - XCTAssertTrue(rawLayer->getHillshadeExaggeration().isUndefined(), - @"Unsetting hillshadeExaggeration should return hillshade-exaggeration to the default value."); - XCTAssertEqualObjects(layer.hillshadeExaggeration, defaultExpression, - @"hillshadeExaggeration should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.hillshadeExaggeration = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.hillshadeExaggeration = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.hillshadeExaggerationTransition = transitionTest; - auto toptions = rawLayer->getHillshadeExaggerationTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition hillshadeExaggerationTransition = layer.hillshadeExaggerationTransition; - XCTAssertEqual(hillshadeExaggerationTransition.delay, transitionTest.delay); - XCTAssertEqual(hillshadeExaggerationTransition.duration, transitionTest.duration); - } - - // hillshade-highlight-color - { - XCTAssertTrue(rawLayer->getHillshadeHighlightColor().isUndefined(), - @"hillshade-highlight-color should be unset initially."); - NSExpression *defaultExpression = layer.hillshadeHighlightColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.hillshadeHighlightColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getHillshadeHighlightColor(), propertyValue, - @"Setting hillshadeHighlightColor to a constant value expression should update hillshade-highlight-color."); - XCTAssertEqualObjects(layer.hillshadeHighlightColor, constantExpression, - @"hillshadeHighlightColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.hillshadeHighlightColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getHillshadeHighlightColor(), propertyValue, - @"Setting hillshadeHighlightColor to a camera expression should update hillshade-highlight-color."); - XCTAssertEqualObjects(layer.hillshadeHighlightColor, functionExpression, - @"hillshadeHighlightColor should round-trip camera expressions."); - - - layer.hillshadeHighlightColor = nil; - XCTAssertTrue(rawLayer->getHillshadeHighlightColor().isUndefined(), - @"Unsetting hillshadeHighlightColor should return hillshade-highlight-color to the default value."); - XCTAssertEqualObjects(layer.hillshadeHighlightColor, defaultExpression, - @"hillshadeHighlightColor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.hillshadeHighlightColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.hillshadeHighlightColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.hillshadeHighlightColorTransition = transitionTest; - auto toptions = rawLayer->getHillshadeHighlightColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition hillshadeHighlightColorTransition = layer.hillshadeHighlightColorTransition; - XCTAssertEqual(hillshadeHighlightColorTransition.delay, transitionTest.delay); - XCTAssertEqual(hillshadeHighlightColorTransition.duration, transitionTest.duration); - } - - // hillshade-illumination-anchor - { - XCTAssertTrue(rawLayer->getHillshadeIlluminationAnchor().isUndefined(), - @"hillshade-illumination-anchor should be unset initially."); - NSExpression *defaultExpression = layer.hillshadeIlluminationAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.hillshadeIlluminationAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::HillshadeIlluminationAnchorType::Viewport }; - XCTAssertEqual(rawLayer->getHillshadeIlluminationAnchor(), propertyValue, - @"Setting hillshadeIlluminationAnchor to a constant value expression should update hillshade-illumination-anchor."); - XCTAssertEqualObjects(layer.hillshadeIlluminationAnchor, constantExpression, - @"hillshadeIlluminationAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.hillshadeIlluminationAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getHillshadeIlluminationAnchor(), propertyValue, - @"Setting hillshadeIlluminationAnchor to a camera expression should update hillshade-illumination-anchor."); - XCTAssertEqualObjects(layer.hillshadeIlluminationAnchor, functionExpression, - @"hillshadeIlluminationAnchor should round-trip camera expressions."); - - - layer.hillshadeIlluminationAnchor = nil; - XCTAssertTrue(rawLayer->getHillshadeIlluminationAnchor().isUndefined(), - @"Unsetting hillshadeIlluminationAnchor should return hillshade-illumination-anchor to the default value."); - XCTAssertEqualObjects(layer.hillshadeIlluminationAnchor, defaultExpression, - @"hillshadeIlluminationAnchor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.hillshadeIlluminationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.hillshadeIlluminationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // hillshade-illumination-direction - { - XCTAssertTrue(rawLayer->getHillshadeIlluminationDirection().isUndefined(), - @"hillshade-illumination-direction should be unset initially."); - NSExpression *defaultExpression = layer.hillshadeIlluminationDirection; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.hillshadeIlluminationDirection = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getHillshadeIlluminationDirection(), propertyValue, - @"Setting hillshadeIlluminationDirection to a constant value expression should update hillshade-illumination-direction."); - XCTAssertEqualObjects(layer.hillshadeIlluminationDirection, constantExpression, - @"hillshadeIlluminationDirection should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.hillshadeIlluminationDirection = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getHillshadeIlluminationDirection(), propertyValue, - @"Setting hillshadeIlluminationDirection to a camera expression should update hillshade-illumination-direction."); - XCTAssertEqualObjects(layer.hillshadeIlluminationDirection, functionExpression, - @"hillshadeIlluminationDirection should round-trip camera expressions."); - - - layer.hillshadeIlluminationDirection = nil; - XCTAssertTrue(rawLayer->getHillshadeIlluminationDirection().isUndefined(), - @"Unsetting hillshadeIlluminationDirection should return hillshade-illumination-direction to the default value."); - XCTAssertEqualObjects(layer.hillshadeIlluminationDirection, defaultExpression, - @"hillshadeIlluminationDirection should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.hillshadeIlluminationDirection = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.hillshadeIlluminationDirection = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // hillshade-shadow-color - { - XCTAssertTrue(rawLayer->getHillshadeShadowColor().isUndefined(), - @"hillshade-shadow-color should be unset initially."); - NSExpression *defaultExpression = layer.hillshadeShadowColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.hillshadeShadowColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getHillshadeShadowColor(), propertyValue, - @"Setting hillshadeShadowColor to a constant value expression should update hillshade-shadow-color."); - XCTAssertEqualObjects(layer.hillshadeShadowColor, constantExpression, - @"hillshadeShadowColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.hillshadeShadowColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getHillshadeShadowColor(), propertyValue, - @"Setting hillshadeShadowColor to a camera expression should update hillshade-shadow-color."); - XCTAssertEqualObjects(layer.hillshadeShadowColor, functionExpression, - @"hillshadeShadowColor should round-trip camera expressions."); - - - layer.hillshadeShadowColor = nil; - XCTAssertTrue(rawLayer->getHillshadeShadowColor().isUndefined(), - @"Unsetting hillshadeShadowColor should return hillshade-shadow-color to the default value."); - XCTAssertEqualObjects(layer.hillshadeShadowColor, defaultExpression, - @"hillshadeShadowColor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.hillshadeShadowColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.hillshadeShadowColor = functionExpression, NSException, NSInvalidArgumentException, @"MGLHillshadeLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.hillshadeShadowColorTransition = transitionTest; - auto toptions = rawLayer->getHillshadeShadowColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition hillshadeShadowColorTransition = layer.hillshadeShadowColorTransition; - XCTAssertEqual(hillshadeShadowColorTransition.delay, transitionTest.delay); - XCTAssertEqual(hillshadeShadowColorTransition.duration, transitionTest.duration); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"hillshade-accent-color" isBoolean:NO]; - [self testPropertyName:@"hillshade-exaggeration" isBoolean:NO]; - [self testPropertyName:@"hillshade-highlight-color" isBoolean:NO]; - [self testPropertyName:@"hillshade-illumination-anchor" isBoolean:NO]; - [self testPropertyName:@"hillshade-illumination-direction" isBoolean:NO]; - [self testPropertyName:@"hillshade-shadow-color" isBoolean:NO]; -} - -- (void)testValueAdditions { - XCTAssertEqual([NSValue valueWithMGLHillshadeIlluminationAnchor:MGLHillshadeIlluminationAnchorMap].MGLHillshadeIlluminationAnchorValue, MGLHillshadeIlluminationAnchorMap); - XCTAssertEqual([NSValue valueWithMGLHillshadeIlluminationAnchor:MGLHillshadeIlluminationAnchorViewport].MGLHillshadeIlluminationAnchorValue, MGLHillshadeIlluminationAnchorViewport); -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLLightTest.mm b/platform/ios/platform/darwin/test/MGLLightTest.mm deleted file mode 100644 index 0bc7b15af..000000000 --- a/platform/ios/platform/darwin/test/MGLLightTest.mm +++ /dev/null @@ -1,133 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. -#import -#import - -#import "MGLLight_Private.h" - -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import -#import -#include - -@interface MGLLightTest : XCTestCase - -@end - -@implementation MGLLightTest - -- (void)testProperties { - - MGLTransition defaultTransition = MGLTransitionMake(0, 0); - MGLTransition transition = MGLTransitionMake(6, 3); - mbgl::style::TransitionOptions transitionOptions { { MGLDurationFromTimeInterval(6) }, { MGLDurationFromTimeInterval(3) } }; - - // anchor - { - mbgl::style::Light light; - MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - auto lightFromMGLLight = mglLight.mbglLight; - - XCTAssertEqual(light.getDefaultAnchor(), lightFromMGLLight.getAnchor()); - XCTAssertEqual(mglLight.anchor.expressionType, NSConstantValueExpressionType, @"mglLight.anchor isn’t a constant value expression."); - XCTAssertEqualObjects(mglLight.anchor.constantValue, @"viewport"); - - mbgl::style::PropertyValue propertyValue = { mbgl::style::LightAnchorType::Viewport }; - light.setAnchor(propertyValue); - mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - lightFromMGLLight = mglLight.mbglLight; - - XCTAssertEqual(light.getAnchor(), lightFromMGLLight.getAnchor()); - } - - // position - { - mbgl::style::Light light; - MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - auto lightFromMGLLight = mglLight.mbglLight; - - XCTAssertEqual(light.getDefaultPosition(), lightFromMGLLight.getPosition()); - auto positionTransition = lightFromMGLLight.getPositionTransition(); - XCTAssert(positionTransition.delay && MGLTimeIntervalFromDuration(*positionTransition.delay) == defaultTransition.delay); - XCTAssert(positionTransition.duration && MGLTimeIntervalFromDuration(*positionTransition.duration) == defaultTransition.duration); - - std::array positionArray = { { 6, 180, 90 } }; - mbgl::style::Position position = { positionArray }; - mbgl::style::PropertyValue propertyValue = { position }; - light.setPosition(propertyValue); - light.setPositionTransition(transitionOptions); - - mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - lightFromMGLLight = mglLight.mbglLight; - - XCTAssertEqual(light.getPosition(), lightFromMGLLight.getPosition()); - positionTransition = lightFromMGLLight.getPositionTransition(); - XCTAssert(positionTransition.delay && MGLTimeIntervalFromDuration(*positionTransition.delay) == transition.delay); - XCTAssert(positionTransition.duration && MGLTimeIntervalFromDuration(*positionTransition.duration) == transition.duration); - - } - - // color - { - mbgl::style::Light light; - MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - auto lightFromMGLLight = mglLight.mbglLight; - - XCTAssertEqual(light.getDefaultColor(), lightFromMGLLight.getColor()); - auto colorTransition = lightFromMGLLight.getColorTransition(); - XCTAssert(colorTransition.delay && MGLTimeIntervalFromDuration(*colorTransition.delay) == defaultTransition.delay); - XCTAssert(colorTransition.duration && MGLTimeIntervalFromDuration(*colorTransition.duration) == defaultTransition.duration); - - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - light.setColor(propertyValue); - light.setColorTransition(transitionOptions); - - mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - lightFromMGLLight = mglLight.mbglLight; - - XCTAssertEqual(light.getColor(), lightFromMGLLight.getColor()); - colorTransition = lightFromMGLLight.getColorTransition(); - XCTAssert(colorTransition.delay && MGLTimeIntervalFromDuration(*colorTransition.delay) == transition.delay); - XCTAssert(colorTransition.duration && MGLTimeIntervalFromDuration(*colorTransition.duration) == transition.duration); - - } - - // intensity - { - mbgl::style::Light light; - MGLLight *mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - auto lightFromMGLLight = mglLight.mbglLight; - - XCTAssertEqual(light.getDefaultIntensity(), lightFromMGLLight.getIntensity()); - auto intensityTransition = lightFromMGLLight.getIntensityTransition(); - XCTAssert(intensityTransition.delay && MGLTimeIntervalFromDuration(*intensityTransition.delay) == defaultTransition.delay); - XCTAssert(intensityTransition.duration && MGLTimeIntervalFromDuration(*intensityTransition.duration) == defaultTransition.duration); - - mbgl::style::PropertyValue propertyValue = { 1.0 }; - light.setIntensity(propertyValue); - light.setIntensityTransition(transitionOptions); - - mglLight = [[MGLLight alloc] initWithMBGLLight:&light]; - lightFromMGLLight = mglLight.mbglLight; - - XCTAssertEqual(light.getIntensity(), lightFromMGLLight.getIntensity()); - intensityTransition = lightFromMGLLight.getIntensityTransition(); - XCTAssert(intensityTransition.delay && MGLTimeIntervalFromDuration(*intensityTransition.delay) == transition.delay); - XCTAssert(intensityTransition.duration && MGLTimeIntervalFromDuration(*intensityTransition.duration) == transition.duration); - - } - -} - -- (void)testValueAdditions { - MGLSphericalPosition position = MGLSphericalPositionMake(1.15, 210, 30); - - XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.radial, position.radial); - XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.azimuthal, position.azimuthal); - XCTAssertEqual([NSValue valueWithMGLSphericalPosition:position].MGLSphericalPositionValue.polar, position.polar); - XCTAssertEqual([NSValue valueWithMGLLightAnchor:MGLLightAnchorMap].MGLLightAnchorValue, MGLLightAnchorMap); - XCTAssertEqual([NSValue valueWithMGLLightAnchor:MGLLightAnchorViewport].MGLLightAnchorValue, MGLLightAnchorViewport); -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLLineStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLLineStyleLayerTests.mm deleted file mode 100644 index 6fe8e62e9..000000000 --- a/platform/ios/platform/darwin/test/MGLLineStyleLayerTests.mm +++ /dev/null @@ -1,978 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLLineLayerTests : MGLStyleLayerTests -@end - -@implementation MGLLineLayerTests - -+ (NSString *)layerType { - return @"line"; -} - -- (void)testPredicates { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - - XCTAssertNil(layer.sourceLayerIdentifier); - layer.sourceLayerIdentifier = @"layerID"; - XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID"); - layer.sourceLayerIdentifier = nil; - XCTAssertNil(layer.sourceLayerIdentifier); - - XCTAssertNil(layer.predicate); - layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]; - XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]); - layer.predicate = nil; - XCTAssertNil(layer.predicate); -} - -- (void)testProperties { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - - MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"line"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // line-cap - { - XCTAssertTrue(rawLayer->getLineCap().isUndefined(), - @"line-cap should be unset initially."); - NSExpression *defaultExpression = layer.lineCap; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'square'"]; - layer.lineCap = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::LineCapType::Square }; - XCTAssertEqual(rawLayer->getLineCap(), propertyValue, - @"Setting lineCap to a constant value expression should update line-cap."); - XCTAssertEqualObjects(layer.lineCap, constantExpression, - @"lineCap should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'square'"]; -#if TARGET_OS_IPHONE - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); -#endif - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineCap = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("square"), 18.0, literal("square")) - ); - } - - XCTAssertEqual(rawLayer->getLineCap(), propertyValue, - @"Setting lineCap to a camera expression should update line-cap."); - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - XCTAssertEqualObjects(layer.lineCap, functionExpression, - @"lineCap should round-trip camera expressions."); - - - layer.lineCap = nil; - XCTAssertTrue(rawLayer->getLineCap().isUndefined(), - @"Unsetting lineCap should return line-cap to the default value."); - XCTAssertEqualObjects(layer.lineCap, defaultExpression, - @"lineCap should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.lineCap = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.lineCap = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // line-join - { - XCTAssertTrue(rawLayer->getLineJoin().isUndefined(), - @"line-join should be unset initially."); - NSExpression *defaultExpression = layer.lineJoin; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'miter'"]; - layer.lineJoin = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::LineJoinType::Miter }; - XCTAssertEqual(rawLayer->getLineJoin(), propertyValue, - @"Setting lineJoin to a constant value expression should update line-join."); - XCTAssertEqualObjects(layer.lineJoin, constantExpression, - @"lineJoin should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'miter'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineJoin = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("miter"), 18.0, literal("miter")) - ); - } - - XCTAssertEqual(rawLayer->getLineJoin(), propertyValue, - @"Setting lineJoin to a camera expression should update line-join."); - XCTAssertEqualObjects(layer.lineJoin, functionExpression, - @"lineJoin should round-trip camera expressions."); - - - layer.lineJoin = nil; - XCTAssertTrue(rawLayer->getLineJoin().isUndefined(), - @"Unsetting lineJoin should return line-join to the default value."); - XCTAssertEqualObjects(layer.lineJoin, defaultExpression, - @"lineJoin should return the default value after being unset."); - } - - // line-miter-limit - { - XCTAssertTrue(rawLayer->getLineMiterLimit().isUndefined(), - @"line-miter-limit should be unset initially."); - NSExpression *defaultExpression = layer.lineMiterLimit; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.lineMiterLimit = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getLineMiterLimit(), propertyValue, - @"Setting lineMiterLimit to a constant value expression should update line-miter-limit."); - XCTAssertEqualObjects(layer.lineMiterLimit, constantExpression, - @"lineMiterLimit should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineMiterLimit = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineMiterLimit(), propertyValue, - @"Setting lineMiterLimit to a camera expression should update line-miter-limit."); - XCTAssertEqualObjects(layer.lineMiterLimit, functionExpression, - @"lineMiterLimit should round-trip camera expressions."); - - - layer.lineMiterLimit = nil; - XCTAssertTrue(rawLayer->getLineMiterLimit().isUndefined(), - @"Unsetting lineMiterLimit should return line-miter-limit to the default value."); - XCTAssertEqualObjects(layer.lineMiterLimit, defaultExpression, - @"lineMiterLimit should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.lineMiterLimit = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.lineMiterLimit = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // line-round-limit - { - XCTAssertTrue(rawLayer->getLineRoundLimit().isUndefined(), - @"line-round-limit should be unset initially."); - NSExpression *defaultExpression = layer.lineRoundLimit; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.lineRoundLimit = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getLineRoundLimit(), propertyValue, - @"Setting lineRoundLimit to a constant value expression should update line-round-limit."); - XCTAssertEqualObjects(layer.lineRoundLimit, constantExpression, - @"lineRoundLimit should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineRoundLimit = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineRoundLimit(), propertyValue, - @"Setting lineRoundLimit to a camera expression should update line-round-limit."); - XCTAssertEqualObjects(layer.lineRoundLimit, functionExpression, - @"lineRoundLimit should round-trip camera expressions."); - - - layer.lineRoundLimit = nil; - XCTAssertTrue(rawLayer->getLineRoundLimit().isUndefined(), - @"Unsetting lineRoundLimit should return line-round-limit to the default value."); - XCTAssertEqualObjects(layer.lineRoundLimit, defaultExpression, - @"lineRoundLimit should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.lineRoundLimit = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.lineRoundLimit = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // line-sort-key - { - XCTAssertTrue(rawLayer->getLineSortKey().isUndefined(), - @"line-sort-key should be unset initially."); - NSExpression *defaultExpression = layer.lineSortKey; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.lineSortKey = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getLineSortKey(), propertyValue, - @"Setting lineSortKey to a constant value expression should update line-sort-key."); - XCTAssertEqualObjects(layer.lineSortKey, constantExpression, - @"lineSortKey should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineSortKey(), propertyValue, - @"Setting lineSortKey to a camera expression should update line-sort-key."); - XCTAssertEqualObjects(layer.lineSortKey, functionExpression, - @"lineSortKey should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.lineSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineSortKey(), propertyValue, - @"Setting lineSortKey to a data expression should update line-sort-key."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.lineSortKey, pedanticFunctionExpression, - @"lineSortKey should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.lineSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getLineSortKey(), propertyValue, - @"Setting lineSortKey to a camera-data expression should update line-sort-key."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.lineSortKey, pedanticFunctionExpression, - @"lineSortKey should round-trip camera-data expressions."); - - layer.lineSortKey = nil; - XCTAssertTrue(rawLayer->getLineSortKey().isUndefined(), - @"Unsetting lineSortKey should return line-sort-key to the default value."); - XCTAssertEqualObjects(layer.lineSortKey, defaultExpression, - @"lineSortKey should return the default value after being unset."); - } - - // line-blur - { - XCTAssertTrue(rawLayer->getLineBlur().isUndefined(), - @"line-blur should be unset initially."); - NSExpression *defaultExpression = layer.lineBlur; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.lineBlur = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getLineBlur(), propertyValue, - @"Setting lineBlur to a constant value expression should update line-blur."); - XCTAssertEqualObjects(layer.lineBlur, constantExpression, - @"lineBlur should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineBlur(), propertyValue, - @"Setting lineBlur to a camera expression should update line-blur."); - XCTAssertEqualObjects(layer.lineBlur, functionExpression, - @"lineBlur should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.lineBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineBlur(), propertyValue, - @"Setting lineBlur to a data expression should update line-blur."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.lineBlur, pedanticFunctionExpression, - @"lineBlur should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.lineBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getLineBlur(), propertyValue, - @"Setting lineBlur to a camera-data expression should update line-blur."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.lineBlur, pedanticFunctionExpression, - @"lineBlur should round-trip camera-data expressions."); - - layer.lineBlur = nil; - XCTAssertTrue(rawLayer->getLineBlur().isUndefined(), - @"Unsetting lineBlur should return line-blur to the default value."); - XCTAssertEqualObjects(layer.lineBlur, defaultExpression, - @"lineBlur should return the default value after being unset."); - // Transition property test - layer.lineBlurTransition = transitionTest; - auto toptions = rawLayer->getLineBlurTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition lineBlurTransition = layer.lineBlurTransition; - XCTAssertEqual(lineBlurTransition.delay, transitionTest.delay); - XCTAssertEqual(lineBlurTransition.duration, transitionTest.duration); - } - - // line-color - { - XCTAssertTrue(rawLayer->getLineColor().isUndefined(), - @"line-color should be unset initially."); - NSExpression *defaultExpression = layer.lineColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.lineColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getLineColor(), propertyValue, - @"Setting lineColor to a constant value expression should update line-color."); - XCTAssertEqualObjects(layer.lineColor, constantExpression, - @"lineColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getLineColor(), propertyValue, - @"Setting lineColor to a camera expression should update line-color."); - XCTAssertEqualObjects(layer.lineColor, functionExpression, - @"lineColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.lineColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getLineColor(), propertyValue, - @"Setting lineColor to a data expression should update line-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.lineColor, pedanticFunctionExpression, - @"lineColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.lineColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getLineColor(), propertyValue, - @"Setting lineColor to a camera-data expression should update line-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.lineColor, pedanticFunctionExpression, - @"lineColor should round-trip camera-data expressions."); - - layer.lineColor = nil; - XCTAssertTrue(rawLayer->getLineColor().isUndefined(), - @"Unsetting lineColor should return line-color to the default value."); - XCTAssertEqualObjects(layer.lineColor, defaultExpression, - @"lineColor should return the default value after being unset."); - // Transition property test - layer.lineColorTransition = transitionTest; - auto toptions = rawLayer->getLineColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition lineColorTransition = layer.lineColorTransition; - XCTAssertEqual(lineColorTransition.delay, transitionTest.delay); - XCTAssertEqual(lineColorTransition.duration, transitionTest.duration); - } - - // line-dasharray - { - XCTAssertTrue(rawLayer->getLineDasharray().isUndefined(), - @"line-dasharray should be unset initially."); - NSExpression *defaultExpression = layer.lineDashPattern; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{1, 2}"]; - layer.lineDashPattern = constantExpression; - mbgl::style::PropertyValue> propertyValue = { {1, 2} }; - XCTAssertEqual(rawLayer->getLineDasharray(), propertyValue, - @"Setting lineDashPattern to a constant value expression should update line-dasharray."); - XCTAssertEqualObjects(layer.lineDashPattern, constantExpression, - @"lineDashPattern should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 2}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineDashPattern = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({1, 2}), 18.0, literal({1, 2})) - ); - } - - XCTAssertEqual(rawLayer->getLineDasharray(), propertyValue, - @"Setting lineDashPattern to a camera expression should update line-dasharray."); - XCTAssertEqualObjects(layer.lineDashPattern, functionExpression, - @"lineDashPattern should round-trip camera expressions."); - - - layer.lineDashPattern = nil; - XCTAssertTrue(rawLayer->getLineDasharray().isUndefined(), - @"Unsetting lineDashPattern should return line-dasharray to the default value."); - XCTAssertEqualObjects(layer.lineDashPattern, defaultExpression, - @"lineDashPattern should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.lineDashPattern = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.lineDashPattern = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // line-gap-width - { - XCTAssertTrue(rawLayer->getLineGapWidth().isUndefined(), - @"line-gap-width should be unset initially."); - NSExpression *defaultExpression = layer.lineGapWidth; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.lineGapWidth = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue, - @"Setting lineGapWidth to a constant value expression should update line-gap-width."); - XCTAssertEqualObjects(layer.lineGapWidth, constantExpression, - @"lineGapWidth should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineGapWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue, - @"Setting lineGapWidth to a camera expression should update line-gap-width."); - XCTAssertEqualObjects(layer.lineGapWidth, functionExpression, - @"lineGapWidth should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.lineGapWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue, - @"Setting lineGapWidth to a data expression should update line-gap-width."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.lineGapWidth, pedanticFunctionExpression, - @"lineGapWidth should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.lineGapWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue, - @"Setting lineGapWidth to a camera-data expression should update line-gap-width."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.lineGapWidth, pedanticFunctionExpression, - @"lineGapWidth should round-trip camera-data expressions."); - - layer.lineGapWidth = nil; - XCTAssertTrue(rawLayer->getLineGapWidth().isUndefined(), - @"Unsetting lineGapWidth should return line-gap-width to the default value."); - XCTAssertEqualObjects(layer.lineGapWidth, defaultExpression, - @"lineGapWidth should return the default value after being unset."); - // Transition property test - layer.lineGapWidthTransition = transitionTest; - auto toptions = rawLayer->getLineGapWidthTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition lineGapWidthTransition = layer.lineGapWidthTransition; - XCTAssertEqual(lineGapWidthTransition.delay, transitionTest.delay); - XCTAssertEqual(lineGapWidthTransition.duration, transitionTest.duration); - } - - // line-offset - { - XCTAssertTrue(rawLayer->getLineOffset().isUndefined(), - @"line-offset should be unset initially."); - NSExpression *defaultExpression = layer.lineOffset; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.lineOffset = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getLineOffset(), propertyValue, - @"Setting lineOffset to a constant value expression should update line-offset."); - XCTAssertEqualObjects(layer.lineOffset, constantExpression, - @"lineOffset should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineOffset(), propertyValue, - @"Setting lineOffset to a camera expression should update line-offset."); - XCTAssertEqualObjects(layer.lineOffset, functionExpression, - @"lineOffset should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.lineOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineOffset(), propertyValue, - @"Setting lineOffset to a data expression should update line-offset."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.lineOffset, pedanticFunctionExpression, - @"lineOffset should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.lineOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getLineOffset(), propertyValue, - @"Setting lineOffset to a camera-data expression should update line-offset."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.lineOffset, pedanticFunctionExpression, - @"lineOffset should round-trip camera-data expressions."); - - layer.lineOffset = nil; - XCTAssertTrue(rawLayer->getLineOffset().isUndefined(), - @"Unsetting lineOffset should return line-offset to the default value."); - XCTAssertEqualObjects(layer.lineOffset, defaultExpression, - @"lineOffset should return the default value after being unset."); - // Transition property test - layer.lineOffsetTransition = transitionTest; - auto toptions = rawLayer->getLineOffsetTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition lineOffsetTransition = layer.lineOffsetTransition; - XCTAssertEqual(lineOffsetTransition.delay, transitionTest.delay); - XCTAssertEqual(lineOffsetTransition.duration, transitionTest.duration); - } - - // line-opacity - { - XCTAssertTrue(rawLayer->getLineOpacity().isUndefined(), - @"line-opacity should be unset initially."); - NSExpression *defaultExpression = layer.lineOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.lineOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue, - @"Setting lineOpacity to a constant value expression should update line-opacity."); - XCTAssertEqualObjects(layer.lineOpacity, constantExpression, - @"lineOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue, - @"Setting lineOpacity to a camera expression should update line-opacity."); - XCTAssertEqualObjects(layer.lineOpacity, functionExpression, - @"lineOpacity should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.lineOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue, - @"Setting lineOpacity to a data expression should update line-opacity."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.lineOpacity, pedanticFunctionExpression, - @"lineOpacity should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.lineOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue, - @"Setting lineOpacity to a camera-data expression should update line-opacity."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.lineOpacity, pedanticFunctionExpression, - @"lineOpacity should round-trip camera-data expressions."); - - layer.lineOpacity = nil; - XCTAssertTrue(rawLayer->getLineOpacity().isUndefined(), - @"Unsetting lineOpacity should return line-opacity to the default value."); - XCTAssertEqualObjects(layer.lineOpacity, defaultExpression, - @"lineOpacity should return the default value after being unset."); - // Transition property test - layer.lineOpacityTransition = transitionTest; - auto toptions = rawLayer->getLineOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition lineOpacityTransition = layer.lineOpacityTransition; - XCTAssertEqual(lineOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(lineOpacityTransition.duration, transitionTest.duration); - } - - // line-pattern - { - XCTAssertTrue(rawLayer->getLinePattern().isUndefined(), - @"line-pattern should be unset initially."); - NSExpression *defaultExpression = layer.linePattern; - - NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Line Pattern"]; - layer.linePattern = constantExpression; - mbgl::style::PropertyValue propertyValue = { "Line Pattern" }; - XCTAssertEqual(rawLayer->getLinePattern(), propertyValue, - @"Setting linePattern to a constant value expression should update line-pattern."); - XCTAssertEqualObjects(layer.linePattern, constantExpression, - @"linePattern should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Line Pattern')"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.linePattern = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), image(literal("Line Pattern")), 18.0, image(literal("Line Pattern"))) - ); - } - - XCTAssertEqual(rawLayer->getLinePattern(), propertyValue, - @"Setting linePattern to a camera expression should update line-pattern."); - XCTAssertEqualObjects(layer.linePattern, functionExpression, - @"linePattern should round-trip camera expressions."); - - - layer.linePattern = nil; - XCTAssertTrue(rawLayer->getLinePattern().isUndefined(), - @"Unsetting linePattern should return line-pattern to the default value."); - XCTAssertEqualObjects(layer.linePattern, defaultExpression, - @"linePattern should return the default value after being unset."); - // Transition property test - layer.linePatternTransition = transitionTest; - auto toptions = rawLayer->getLinePatternTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition linePatternTransition = layer.linePatternTransition; - XCTAssertEqual(linePatternTransition.delay, transitionTest.delay); - XCTAssertEqual(linePatternTransition.duration, transitionTest.duration); - } - - // line-translate - { - XCTAssertTrue(rawLayer->getLineTranslate().isUndefined(), - @"line-translate should be unset initially."); - NSExpression *defaultExpression = layer.lineTranslation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithCGVector:CGVectorMake(1, 1)] -#else - [NSValue valueWithMGLVector:CGVectorMake(1, -1)] -#endif - ]; - layer.lineTranslation = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; - XCTAssertEqual(rawLayer->getLineTranslate(), propertyValue, - @"Setting lineTranslation to a constant value expression should update line-translate."); - XCTAssertEqualObjects(layer.lineTranslation, constantExpression, - @"lineTranslation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineTranslation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getLineTranslate(), propertyValue, - @"Setting lineTranslation to a camera expression should update line-translate."); - XCTAssertEqualObjects(layer.lineTranslation, functionExpression, - @"lineTranslation should round-trip camera expressions."); - - - layer.lineTranslation = nil; - XCTAssertTrue(rawLayer->getLineTranslate().isUndefined(), - @"Unsetting lineTranslation should return line-translate to the default value."); - XCTAssertEqualObjects(layer.lineTranslation, defaultExpression, - @"lineTranslation should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.lineTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.lineTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // line-translate-anchor - { - XCTAssertTrue(rawLayer->getLineTranslateAnchor().isUndefined(), - @"line-translate-anchor should be unset initially."); - NSExpression *defaultExpression = layer.lineTranslationAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.lineTranslationAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::TranslateAnchorType::Viewport }; - XCTAssertEqual(rawLayer->getLineTranslateAnchor(), propertyValue, - @"Setting lineTranslationAnchor to a constant value expression should update line-translate-anchor."); - XCTAssertEqualObjects(layer.lineTranslationAnchor, constantExpression, - @"lineTranslationAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineTranslationAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getLineTranslateAnchor(), propertyValue, - @"Setting lineTranslationAnchor to a camera expression should update line-translate-anchor."); - XCTAssertEqualObjects(layer.lineTranslationAnchor, functionExpression, - @"lineTranslationAnchor should round-trip camera expressions."); - - - layer.lineTranslationAnchor = nil; - XCTAssertTrue(rawLayer->getLineTranslateAnchor().isUndefined(), - @"Unsetting lineTranslationAnchor should return line-translate-anchor to the default value."); - XCTAssertEqualObjects(layer.lineTranslationAnchor, defaultExpression, - @"lineTranslationAnchor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.lineTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.lineTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLLineLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // line-width - { - XCTAssertTrue(rawLayer->getLineWidth().isUndefined(), - @"line-width should be unset initially."); - NSExpression *defaultExpression = layer.lineWidth; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.lineWidth = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getLineWidth(), propertyValue, - @"Setting lineWidth to a constant value expression should update line-width."); - XCTAssertEqualObjects(layer.lineWidth, constantExpression, - @"lineWidth should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.lineWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineWidth(), propertyValue, - @"Setting lineWidth to a camera expression should update line-width."); - XCTAssertEqualObjects(layer.lineWidth, functionExpression, - @"lineWidth should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.lineWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getLineWidth(), propertyValue, - @"Setting lineWidth to a data expression should update line-width."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.lineWidth, pedanticFunctionExpression, - @"lineWidth should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.lineWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getLineWidth(), propertyValue, - @"Setting lineWidth to a camera-data expression should update line-width."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.lineWidth, pedanticFunctionExpression, - @"lineWidth should round-trip camera-data expressions."); - - layer.lineWidth = nil; - XCTAssertTrue(rawLayer->getLineWidth().isUndefined(), - @"Unsetting lineWidth should return line-width to the default value."); - XCTAssertEqualObjects(layer.lineWidth, defaultExpression, - @"lineWidth should return the default value after being unset."); - // Transition property test - layer.lineWidthTransition = transitionTest; - auto toptions = rawLayer->getLineWidthTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition lineWidthTransition = layer.lineWidthTransition; - XCTAssertEqual(lineWidthTransition.delay, transitionTest.delay); - XCTAssertEqual(lineWidthTransition.duration, transitionTest.duration); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"line-cap" isBoolean:NO]; - [self testPropertyName:@"line-join" isBoolean:NO]; - [self testPropertyName:@"line-miter-limit" isBoolean:NO]; - [self testPropertyName:@"line-round-limit" isBoolean:NO]; - [self testPropertyName:@"line-sort-key" isBoolean:NO]; - [self testPropertyName:@"line-blur" isBoolean:NO]; - [self testPropertyName:@"line-color" isBoolean:NO]; - [self testPropertyName:@"line-dash-pattern" isBoolean:NO]; - [self testPropertyName:@"line-gap-width" isBoolean:NO]; - [self testPropertyName:@"line-offset" isBoolean:NO]; - [self testPropertyName:@"line-opacity" isBoolean:NO]; - [self testPropertyName:@"line-pattern" isBoolean:NO]; - [self testPropertyName:@"line-translation" isBoolean:NO]; - [self testPropertyName:@"line-translation-anchor" isBoolean:NO]; - [self testPropertyName:@"line-width" isBoolean:NO]; -} - -- (void)testValueAdditions { - XCTAssertEqual([NSValue valueWithMGLLineCap:MGLLineCapButt].MGLLineCapValue, MGLLineCapButt); - XCTAssertEqual([NSValue valueWithMGLLineCap:MGLLineCapRound].MGLLineCapValue, MGLLineCapRound); - XCTAssertEqual([NSValue valueWithMGLLineCap:MGLLineCapSquare].MGLLineCapValue, MGLLineCapSquare); - XCTAssertEqual([NSValue valueWithMGLLineJoin:MGLLineJoinBevel].MGLLineJoinValue, MGLLineJoinBevel); - XCTAssertEqual([NSValue valueWithMGLLineJoin:MGLLineJoinRound].MGLLineJoinValue, MGLLineJoinRound); - XCTAssertEqual([NSValue valueWithMGLLineJoin:MGLLineJoinMiter].MGLLineJoinValue, MGLLineJoinMiter); - XCTAssertEqual([NSValue valueWithMGLLineTranslationAnchor:MGLLineTranslationAnchorMap].MGLLineTranslationAnchorValue, MGLLineTranslationAnchorMap); - XCTAssertEqual([NSValue valueWithMGLLineTranslationAnchor:MGLLineTranslationAnchorViewport].MGLLineTranslationAnchorValue, MGLLineTranslationAnchorViewport); -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLRasterStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLRasterStyleLayerTests.mm deleted file mode 100644 index db894e9b4..000000000 --- a/platform/ios/platform/darwin/test/MGLRasterStyleLayerTests.mm +++ /dev/null @@ -1,434 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLRasterLayerTests : MGLStyleLayerTests -@end - -@implementation MGLRasterLayerTests - -+ (NSString *)layerType { - return @"raster"; -} - -- (void)testProperties { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - - MGLRasterStyleLayer *layer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"raster"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // raster-brightness-max - { - XCTAssertTrue(rawLayer->getRasterBrightnessMax().isUndefined(), - @"raster-brightness-max should be unset initially."); - NSExpression *defaultExpression = layer.maximumRasterBrightness; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.maximumRasterBrightness = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getRasterBrightnessMax(), propertyValue, - @"Setting maximumRasterBrightness to a constant value expression should update raster-brightness-max."); - XCTAssertEqualObjects(layer.maximumRasterBrightness, constantExpression, - @"maximumRasterBrightness should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; -#if TARGET_OS_IPHONE - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); -#endif - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.maximumRasterBrightness = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getRasterBrightnessMax(), propertyValue, - @"Setting maximumRasterBrightness to a camera expression should update raster-brightness-max."); - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - XCTAssertEqualObjects(layer.maximumRasterBrightness, functionExpression, - @"maximumRasterBrightness should round-trip camera expressions."); - - - layer.maximumRasterBrightness = nil; - XCTAssertTrue(rawLayer->getRasterBrightnessMax().isUndefined(), - @"Unsetting maximumRasterBrightness should return raster-brightness-max to the default value."); - XCTAssertEqualObjects(layer.maximumRasterBrightness, defaultExpression, - @"maximumRasterBrightness should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.maximumRasterBrightness = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.maximumRasterBrightness = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // raster-brightness-min - { - XCTAssertTrue(rawLayer->getRasterBrightnessMin().isUndefined(), - @"raster-brightness-min should be unset initially."); - NSExpression *defaultExpression = layer.minimumRasterBrightness; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.minimumRasterBrightness = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getRasterBrightnessMin(), propertyValue, - @"Setting minimumRasterBrightness to a constant value expression should update raster-brightness-min."); - XCTAssertEqualObjects(layer.minimumRasterBrightness, constantExpression, - @"minimumRasterBrightness should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.minimumRasterBrightness = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getRasterBrightnessMin(), propertyValue, - @"Setting minimumRasterBrightness to a camera expression should update raster-brightness-min."); - XCTAssertEqualObjects(layer.minimumRasterBrightness, functionExpression, - @"minimumRasterBrightness should round-trip camera expressions."); - - - layer.minimumRasterBrightness = nil; - XCTAssertTrue(rawLayer->getRasterBrightnessMin().isUndefined(), - @"Unsetting minimumRasterBrightness should return raster-brightness-min to the default value."); - XCTAssertEqualObjects(layer.minimumRasterBrightness, defaultExpression, - @"minimumRasterBrightness should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.minimumRasterBrightness = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.minimumRasterBrightness = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // raster-contrast - { - XCTAssertTrue(rawLayer->getRasterContrast().isUndefined(), - @"raster-contrast should be unset initially."); - NSExpression *defaultExpression = layer.rasterContrast; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.rasterContrast = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getRasterContrast(), propertyValue, - @"Setting rasterContrast to a constant value expression should update raster-contrast."); - XCTAssertEqualObjects(layer.rasterContrast, constantExpression, - @"rasterContrast should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.rasterContrast = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getRasterContrast(), propertyValue, - @"Setting rasterContrast to a camera expression should update raster-contrast."); - XCTAssertEqualObjects(layer.rasterContrast, functionExpression, - @"rasterContrast should round-trip camera expressions."); - - - layer.rasterContrast = nil; - XCTAssertTrue(rawLayer->getRasterContrast().isUndefined(), - @"Unsetting rasterContrast should return raster-contrast to the default value."); - XCTAssertEqualObjects(layer.rasterContrast, defaultExpression, - @"rasterContrast should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.rasterContrast = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.rasterContrast = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.rasterContrastTransition = transitionTest; - auto toptions = rawLayer->getRasterContrastTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition rasterContrastTransition = layer.rasterContrastTransition; - XCTAssertEqual(rasterContrastTransition.delay, transitionTest.delay); - XCTAssertEqual(rasterContrastTransition.duration, transitionTest.duration); - } - - // raster-fade-duration - { - XCTAssertTrue(rawLayer->getRasterFadeDuration().isUndefined(), - @"raster-fade-duration should be unset initially."); - NSExpression *defaultExpression = layer.rasterFadeDuration; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.rasterFadeDuration = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getRasterFadeDuration(), propertyValue, - @"Setting rasterFadeDuration to a constant value expression should update raster-fade-duration."); - XCTAssertEqualObjects(layer.rasterFadeDuration, constantExpression, - @"rasterFadeDuration should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.rasterFadeDuration = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getRasterFadeDuration(), propertyValue, - @"Setting rasterFadeDuration to a camera expression should update raster-fade-duration."); - XCTAssertEqualObjects(layer.rasterFadeDuration, functionExpression, - @"rasterFadeDuration should round-trip camera expressions."); - - - layer.rasterFadeDuration = nil; - XCTAssertTrue(rawLayer->getRasterFadeDuration().isUndefined(), - @"Unsetting rasterFadeDuration should return raster-fade-duration to the default value."); - XCTAssertEqualObjects(layer.rasterFadeDuration, defaultExpression, - @"rasterFadeDuration should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.rasterFadeDuration = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.rasterFadeDuration = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // raster-hue-rotate - { - XCTAssertTrue(rawLayer->getRasterHueRotate().isUndefined(), - @"raster-hue-rotate should be unset initially."); - NSExpression *defaultExpression = layer.rasterHueRotation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.rasterHueRotation = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getRasterHueRotate(), propertyValue, - @"Setting rasterHueRotation to a constant value expression should update raster-hue-rotate."); - XCTAssertEqualObjects(layer.rasterHueRotation, constantExpression, - @"rasterHueRotation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.rasterHueRotation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getRasterHueRotate(), propertyValue, - @"Setting rasterHueRotation to a camera expression should update raster-hue-rotate."); - XCTAssertEqualObjects(layer.rasterHueRotation, functionExpression, - @"rasterHueRotation should round-trip camera expressions."); - - - layer.rasterHueRotation = nil; - XCTAssertTrue(rawLayer->getRasterHueRotate().isUndefined(), - @"Unsetting rasterHueRotation should return raster-hue-rotate to the default value."); - XCTAssertEqualObjects(layer.rasterHueRotation, defaultExpression, - @"rasterHueRotation should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.rasterHueRotation = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.rasterHueRotation = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // raster-opacity - { - XCTAssertTrue(rawLayer->getRasterOpacity().isUndefined(), - @"raster-opacity should be unset initially."); - NSExpression *defaultExpression = layer.rasterOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.rasterOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getRasterOpacity(), propertyValue, - @"Setting rasterOpacity to a constant value expression should update raster-opacity."); - XCTAssertEqualObjects(layer.rasterOpacity, constantExpression, - @"rasterOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.rasterOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getRasterOpacity(), propertyValue, - @"Setting rasterOpacity to a camera expression should update raster-opacity."); - XCTAssertEqualObjects(layer.rasterOpacity, functionExpression, - @"rasterOpacity should round-trip camera expressions."); - - - layer.rasterOpacity = nil; - XCTAssertTrue(rawLayer->getRasterOpacity().isUndefined(), - @"Unsetting rasterOpacity should return raster-opacity to the default value."); - XCTAssertEqualObjects(layer.rasterOpacity, defaultExpression, - @"rasterOpacity should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.rasterOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.rasterOpacity = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.rasterOpacityTransition = transitionTest; - auto toptions = rawLayer->getRasterOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition rasterOpacityTransition = layer.rasterOpacityTransition; - XCTAssertEqual(rasterOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(rasterOpacityTransition.duration, transitionTest.duration); - } - - // raster-resampling - { - XCTAssertTrue(rawLayer->getRasterResampling().isUndefined(), - @"raster-resampling should be unset initially."); - NSExpression *defaultExpression = layer.rasterResamplingMode; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'nearest'"]; - layer.rasterResamplingMode = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::RasterResamplingType::Nearest }; - XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue, - @"Setting rasterResamplingMode to a constant value expression should update raster-resampling."); - XCTAssertEqualObjects(layer.rasterResamplingMode, constantExpression, - @"rasterResamplingMode should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'nearest'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.rasterResamplingMode = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("nearest"), 18.0, literal("nearest")) - ); - } - - XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue, - @"Setting rasterResamplingMode to a camera expression should update raster-resampling."); - XCTAssertEqualObjects(layer.rasterResamplingMode, functionExpression, - @"rasterResamplingMode should round-trip camera expressions."); - - - layer.rasterResamplingMode = nil; - XCTAssertTrue(rawLayer->getRasterResampling().isUndefined(), - @"Unsetting rasterResamplingMode should return raster-resampling to the default value."); - XCTAssertEqualObjects(layer.rasterResamplingMode, defaultExpression, - @"rasterResamplingMode should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.rasterResamplingMode = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.rasterResamplingMode = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // raster-saturation - { - XCTAssertTrue(rawLayer->getRasterSaturation().isUndefined(), - @"raster-saturation should be unset initially."); - NSExpression *defaultExpression = layer.rasterSaturation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.rasterSaturation = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getRasterSaturation(), propertyValue, - @"Setting rasterSaturation to a constant value expression should update raster-saturation."); - XCTAssertEqualObjects(layer.rasterSaturation, constantExpression, - @"rasterSaturation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.rasterSaturation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getRasterSaturation(), propertyValue, - @"Setting rasterSaturation to a camera expression should update raster-saturation."); - XCTAssertEqualObjects(layer.rasterSaturation, functionExpression, - @"rasterSaturation should round-trip camera expressions."); - - - layer.rasterSaturation = nil; - XCTAssertTrue(rawLayer->getRasterSaturation().isUndefined(), - @"Unsetting rasterSaturation should return raster-saturation to the default value."); - XCTAssertEqualObjects(layer.rasterSaturation, defaultExpression, - @"rasterSaturation should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.rasterSaturation = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.rasterSaturation = functionExpression, NSException, NSInvalidArgumentException, @"MGLRasterLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - // Transition property test - layer.rasterSaturationTransition = transitionTest; - auto toptions = rawLayer->getRasterSaturationTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition rasterSaturationTransition = layer.rasterSaturationTransition; - XCTAssertEqual(rasterSaturationTransition.delay, transitionTest.delay); - XCTAssertEqual(rasterSaturationTransition.duration, transitionTest.duration); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"maximum-raster-brightness" isBoolean:NO]; - [self testPropertyName:@"minimum-raster-brightness" isBoolean:NO]; - [self testPropertyName:@"raster-contrast" isBoolean:NO]; - [self testPropertyName:@"raster-fade-duration" isBoolean:NO]; - [self testPropertyName:@"raster-hue-rotation" isBoolean:NO]; - [self testPropertyName:@"raster-opacity" isBoolean:NO]; - [self testPropertyName:@"raster-resampling-mode" isBoolean:NO]; - [self testPropertyName:@"raster-saturation" isBoolean:NO]; -} - -- (void)testValueAdditions { - XCTAssertEqual([NSValue valueWithMGLRasterResamplingMode:MGLRasterResamplingModeLinear].MGLRasterResamplingModeValue, MGLRasterResamplingModeLinear); - XCTAssertEqual([NSValue valueWithMGLRasterResamplingMode:MGLRasterResamplingModeNearest].MGLRasterResamplingModeValue, MGLRasterResamplingModeNearest); -} - -@end diff --git a/platform/ios/platform/darwin/test/MGLStyleLayerTests.mm.ejs b/platform/ios/platform/darwin/test/MGLStyleLayerTests.mm.ejs index a764f163b..67cbb96fe 100644 --- a/platform/ios/platform/darwin/test/MGLStyleLayerTests.mm.ejs +++ b/platform/ios/platform/darwin/test/MGLStyleLayerTests.mm.ejs @@ -92,6 +92,7 @@ attributes:@{}]; constantExpression = [NSExpression mgl_expressionForAttributedExpressions:@[[NSExpression expressionForConstantValue:attributedConstantExpression]]]; <% } -%> + XCTExpectFailure(@"Awaiting unit test refactoring https://github.com/maplibre/maplibre-gl-native/issues/421"); NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; layer.<%- objCName(property) %> = functionExpression; diff --git a/platform/ios/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/ios/platform/darwin/test/MGLSymbolStyleLayerTests.mm deleted file mode 100644 index fb1c7e1e0..000000000 --- a/platform/ios/platform/darwin/test/MGLSymbolStyleLayerTests.mm +++ /dev/null @@ -1,3208 +0,0 @@ -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. - -#import "MGLStyleLayerTests.h" -#import "../../darwin/src/NSDate+MGLAdditions.h" -#include "../../darwin/src/MGLAttributedExpression.h" - -#import "MGLStyleLayer_Private.h" - -#include -#include -#include - -@interface MGLSymbolLayerTests : MGLStyleLayerTests -@end - -@implementation MGLSymbolLayerTests - -+ (NSString *)layerType { - return @"symbol"; -} - -- (void)testPredicates { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - - XCTAssertNil(layer.sourceLayerIdentifier); - layer.sourceLayerIdentifier = @"layerID"; - XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID"); - layer.sourceLayerIdentifier = nil; - XCTAssertNil(layer.sourceLayerIdentifier); - - XCTAssertNil(layer.predicate); - layer.predicate = [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]; - XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithFormat:@"$featureIdentifier = 1"]); - layer.predicate = nil; - XCTAssertNil(layer.predicate); -} - -- (void)testProperties { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - - MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - XCTAssertNotEqual(layer.rawLayer, nullptr); - XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"symbol"); - auto rawLayer = static_cast(layer.rawLayer); - - MGLTransition transitionTest = MGLTransitionMake(5, 4); - - - // icon-allow-overlap - { - XCTAssertTrue(rawLayer->getIconAllowOverlap().isUndefined(), - @"icon-allow-overlap should be unset initially."); - NSExpression *defaultExpression = layer.iconAllowsOverlap; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"]; - layer.iconAllowsOverlap = constantExpression; - mbgl::style::PropertyValue propertyValue = { true }; - XCTAssertEqual(rawLayer->getIconAllowOverlap(), propertyValue, - @"Setting iconAllowsOverlap to a constant value expression should update icon-allow-overlap."); - XCTAssertEqualObjects(layer.iconAllowsOverlap, constantExpression, - @"iconAllowsOverlap should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"true"]; - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconAllowsOverlap = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(true), 18.0, literal(true)) - ); - } - - XCTAssertEqual(rawLayer->getIconAllowOverlap(), propertyValue, - @"Setting iconAllowsOverlap to a camera expression should update icon-allow-overlap."); -#if TARGET_OS_IPHONE - XCTExpectFailure(@"Awaiting unit test refactoring for https://github.com/maplibre/maplibre-gl-native/issues/331"); -#endif - XCTAssertEqualObjects(layer.iconAllowsOverlap, functionExpression, - @"iconAllowsOverlap should round-trip camera expressions."); - - - layer.iconAllowsOverlap = nil; - XCTAssertTrue(rawLayer->getIconAllowOverlap().isUndefined(), - @"Unsetting iconAllowsOverlap should return icon-allow-overlap to the default value."); - XCTAssertEqualObjects(layer.iconAllowsOverlap, defaultExpression, - @"iconAllowsOverlap should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconAllowsOverlap = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconAllowsOverlap = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-anchor - { - XCTAssertTrue(rawLayer->getIconAnchor().isUndefined(), - @"icon-anchor should be unset initially."); - NSExpression *defaultExpression = layer.iconAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"]; - layer.iconAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::SymbolAnchorType::BottomRight }; - XCTAssertEqual(rawLayer->getIconAnchor(), propertyValue, - @"Setting iconAnchor to a constant value expression should update icon-anchor."); - XCTAssertEqualObjects(layer.iconAnchor, constantExpression, - @"iconAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("bottom-right"), 18.0, literal("bottom-right")) - ); - } - - XCTAssertEqual(rawLayer->getIconAnchor(), propertyValue, - @"Setting iconAnchor to a camera expression should update icon-anchor."); - XCTAssertEqualObjects(layer.iconAnchor, functionExpression, - @"iconAnchor should round-trip camera expressions."); - - - layer.iconAnchor = nil; - XCTAssertTrue(rawLayer->getIconAnchor().isUndefined(), - @"Unsetting iconAnchor should return icon-anchor to the default value."); - XCTAssertEqualObjects(layer.iconAnchor, defaultExpression, - @"iconAnchor should return the default value after being unset."); - } - - // icon-ignore-placement - { - XCTAssertTrue(rawLayer->getIconIgnorePlacement().isUndefined(), - @"icon-ignore-placement should be unset initially."); - NSExpression *defaultExpression = layer.iconIgnoresPlacement; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"]; - layer.iconIgnoresPlacement = constantExpression; - mbgl::style::PropertyValue propertyValue = { true }; - XCTAssertEqual(rawLayer->getIconIgnorePlacement(), propertyValue, - @"Setting iconIgnoresPlacement to a constant value expression should update icon-ignore-placement."); - XCTAssertEqualObjects(layer.iconIgnoresPlacement, constantExpression, - @"iconIgnoresPlacement should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"true"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconIgnoresPlacement = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(true), 18.0, literal(true)) - ); - } - - XCTAssertEqual(rawLayer->getIconIgnorePlacement(), propertyValue, - @"Setting iconIgnoresPlacement to a camera expression should update icon-ignore-placement."); - XCTAssertEqualObjects(layer.iconIgnoresPlacement, functionExpression, - @"iconIgnoresPlacement should round-trip camera expressions."); - - - layer.iconIgnoresPlacement = nil; - XCTAssertTrue(rawLayer->getIconIgnorePlacement().isUndefined(), - @"Unsetting iconIgnoresPlacement should return icon-ignore-placement to the default value."); - XCTAssertEqualObjects(layer.iconIgnoresPlacement, defaultExpression, - @"iconIgnoresPlacement should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconIgnoresPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconIgnoresPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-image - { - XCTAssertTrue(rawLayer->getIconImage().isUndefined(), - @"icon-image should be unset initially."); - NSExpression *defaultExpression = layer.iconImageName; - - NSExpression *constantExpression = [NSExpression expressionForConstantValue:@"Icon Image"]; - layer.iconImageName = constantExpression; - mbgl::style::PropertyValue propertyValue = { "Icon Image" }; - XCTAssertEqual(rawLayer->getIconImage(), propertyValue, - @"Setting iconImageName to a constant value expression should update icon-image."); - XCTAssertEqualObjects(layer.iconImageName, constantExpression, - @"iconImageName should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', 'Icon Image')"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconImageName = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), image(literal("Icon Image")), 18.0, image(literal("Icon Image"))) - ); - } - - XCTAssertEqual(rawLayer->getIconImage(), propertyValue, - @"Setting iconImageName to a camera expression should update icon-image."); - XCTAssertEqualObjects(layer.iconImageName, functionExpression, - @"iconImageName should round-trip camera expressions."); - - - layer.iconImageName = nil; - XCTAssertTrue(rawLayer->getIconImage().isUndefined(), - @"Unsetting iconImageName should return icon-image to the default value."); - XCTAssertEqualObjects(layer.iconImageName, defaultExpression, - @"iconImageName should return the default value after being unset."); - - // Tokens test - layer.iconImageName = [NSExpression expressionForConstantValue:@"{token}"]; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - image(toString(get(literal("token")))) - ); - } - - XCTAssertEqual(rawLayer->getIconImage(), propertyValue, - @"Setting iconImageName to a constant string with tokens should convert to an expression."); - - NSExpression* tokenExpression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('image', CAST(token, \"NSString\"))"]; - XCTAssertEqualObjects(layer.iconImageName, tokenExpression, - @"Setting iconImageName to a constant string with tokens should convert to an expression."); - } - - // icon-offset - { - XCTAssertTrue(rawLayer->getIconOffset().isUndefined(), - @"icon-offset should be unset initially."); - NSExpression *defaultExpression = layer.iconOffset; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithCGVector:CGVectorMake(1, 1)] -#else - [NSValue valueWithMGLVector:CGVectorMake(1, -1)] -#endif - ]; - layer.iconOffset = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; - XCTAssertEqual(rawLayer->getIconOffset(), propertyValue, - @"Setting iconOffset to a constant value expression should update icon-offset."); - XCTAssertEqualObjects(layer.iconOffset, constantExpression, - @"iconOffset should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getIconOffset(), propertyValue, - @"Setting iconOffset to a camera expression should update icon-offset."); - XCTAssertEqualObjects(layer.iconOffset, functionExpression, - @"iconOffset should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.iconOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getIconOffset(), propertyValue, - @"Setting iconOffset to a data expression should update icon-offset."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.iconOffset, pedanticFunctionExpression, - @"iconOffset should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.iconOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 }))) - ); - } - - XCTAssertEqual(rawLayer->getIconOffset(), propertyValue, - @"Setting iconOffset to a camera-data expression should update icon-offset."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.iconOffset, pedanticFunctionExpression, - @"iconOffset should round-trip camera-data expressions."); - - layer.iconOffset = nil; - XCTAssertTrue(rawLayer->getIconOffset().isUndefined(), - @"Unsetting iconOffset should return icon-offset to the default value."); - XCTAssertEqualObjects(layer.iconOffset, defaultExpression, - @"iconOffset should return the default value after being unset."); - } - - // icon-optional - { - XCTAssertTrue(rawLayer->getIconOptional().isUndefined(), - @"icon-optional should be unset initially."); - NSExpression *defaultExpression = layer.iconOptional; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"]; - layer.iconOptional = constantExpression; - mbgl::style::PropertyValue propertyValue = { true }; - XCTAssertEqual(rawLayer->getIconOptional(), propertyValue, - @"Setting iconOptional to a constant value expression should update icon-optional."); - XCTAssertEqualObjects(layer.iconOptional, constantExpression, - @"iconOptional should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"true"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconOptional = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(true), 18.0, literal(true)) - ); - } - - XCTAssertEqual(rawLayer->getIconOptional(), propertyValue, - @"Setting iconOptional to a camera expression should update icon-optional."); - XCTAssertEqualObjects(layer.iconOptional, functionExpression, - @"iconOptional should round-trip camera expressions."); - - - layer.iconOptional = nil; - XCTAssertTrue(rawLayer->getIconOptional().isUndefined(), - @"Unsetting iconOptional should return icon-optional to the default value."); - XCTAssertEqualObjects(layer.iconOptional, defaultExpression, - @"iconOptional should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconOptional = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconOptional = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-padding - { - XCTAssertTrue(rawLayer->getIconPadding().isUndefined(), - @"icon-padding should be unset initially."); - NSExpression *defaultExpression = layer.iconPadding; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.iconPadding = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getIconPadding(), propertyValue, - @"Setting iconPadding to a constant value expression should update icon-padding."); - XCTAssertEqualObjects(layer.iconPadding, constantExpression, - @"iconPadding should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconPadding = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconPadding(), propertyValue, - @"Setting iconPadding to a camera expression should update icon-padding."); - XCTAssertEqualObjects(layer.iconPadding, functionExpression, - @"iconPadding should round-trip camera expressions."); - - - layer.iconPadding = nil; - XCTAssertTrue(rawLayer->getIconPadding().isUndefined(), - @"Unsetting iconPadding should return icon-padding to the default value."); - XCTAssertEqualObjects(layer.iconPadding, defaultExpression, - @"iconPadding should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-pitch-alignment - { - XCTAssertTrue(rawLayer->getIconPitchAlignment().isUndefined(), - @"icon-pitch-alignment should be unset initially."); - NSExpression *defaultExpression = layer.iconPitchAlignment; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'auto'"]; - layer.iconPitchAlignment = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::AlignmentType::Auto }; - XCTAssertEqual(rawLayer->getIconPitchAlignment(), propertyValue, - @"Setting iconPitchAlignment to a constant value expression should update icon-pitch-alignment."); - XCTAssertEqualObjects(layer.iconPitchAlignment, constantExpression, - @"iconPitchAlignment should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'auto'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconPitchAlignment = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("auto"), 18.0, literal("auto")) - ); - } - - XCTAssertEqual(rawLayer->getIconPitchAlignment(), propertyValue, - @"Setting iconPitchAlignment to a camera expression should update icon-pitch-alignment."); - XCTAssertEqualObjects(layer.iconPitchAlignment, functionExpression, - @"iconPitchAlignment should round-trip camera expressions."); - - - layer.iconPitchAlignment = nil; - XCTAssertTrue(rawLayer->getIconPitchAlignment().isUndefined(), - @"Unsetting iconPitchAlignment should return icon-pitch-alignment to the default value."); - XCTAssertEqualObjects(layer.iconPitchAlignment, defaultExpression, - @"iconPitchAlignment should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconPitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconPitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-rotate - { - XCTAssertTrue(rawLayer->getIconRotate().isUndefined(), - @"icon-rotate should be unset initially."); - NSExpression *defaultExpression = layer.iconRotation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.iconRotation = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getIconRotate(), propertyValue, - @"Setting iconRotation to a constant value expression should update icon-rotate."); - XCTAssertEqualObjects(layer.iconRotation, constantExpression, - @"iconRotation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconRotation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconRotate(), propertyValue, - @"Setting iconRotation to a camera expression should update icon-rotate."); - XCTAssertEqualObjects(layer.iconRotation, functionExpression, - @"iconRotation should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.iconRotation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconRotate(), propertyValue, - @"Setting iconRotation to a data expression should update icon-rotate."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.iconRotation, pedanticFunctionExpression, - @"iconRotation should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.iconRotation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getIconRotate(), propertyValue, - @"Setting iconRotation to a camera-data expression should update icon-rotate."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.iconRotation, pedanticFunctionExpression, - @"iconRotation should round-trip camera-data expressions."); - - layer.iconRotation = nil; - XCTAssertTrue(rawLayer->getIconRotate().isUndefined(), - @"Unsetting iconRotation should return icon-rotate to the default value."); - XCTAssertEqualObjects(layer.iconRotation, defaultExpression, - @"iconRotation should return the default value after being unset."); - } - - // icon-rotation-alignment - { - XCTAssertTrue(rawLayer->getIconRotationAlignment().isUndefined(), - @"icon-rotation-alignment should be unset initially."); - NSExpression *defaultExpression = layer.iconRotationAlignment; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'auto'"]; - layer.iconRotationAlignment = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::AlignmentType::Auto }; - XCTAssertEqual(rawLayer->getIconRotationAlignment(), propertyValue, - @"Setting iconRotationAlignment to a constant value expression should update icon-rotation-alignment."); - XCTAssertEqualObjects(layer.iconRotationAlignment, constantExpression, - @"iconRotationAlignment should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'auto'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconRotationAlignment = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("auto"), 18.0, literal("auto")) - ); - } - - XCTAssertEqual(rawLayer->getIconRotationAlignment(), propertyValue, - @"Setting iconRotationAlignment to a camera expression should update icon-rotation-alignment."); - XCTAssertEqualObjects(layer.iconRotationAlignment, functionExpression, - @"iconRotationAlignment should round-trip camera expressions."); - - - layer.iconRotationAlignment = nil; - XCTAssertTrue(rawLayer->getIconRotationAlignment().isUndefined(), - @"Unsetting iconRotationAlignment should return icon-rotation-alignment to the default value."); - XCTAssertEqualObjects(layer.iconRotationAlignment, defaultExpression, - @"iconRotationAlignment should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconRotationAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconRotationAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-size - { - XCTAssertTrue(rawLayer->getIconSize().isUndefined(), - @"icon-size should be unset initially."); - NSExpression *defaultExpression = layer.iconScale; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.iconScale = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getIconSize(), propertyValue, - @"Setting iconScale to a constant value expression should update icon-size."); - XCTAssertEqualObjects(layer.iconScale, constantExpression, - @"iconScale should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconScale = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconSize(), propertyValue, - @"Setting iconScale to a camera expression should update icon-size."); - XCTAssertEqualObjects(layer.iconScale, functionExpression, - @"iconScale should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.iconScale = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconSize(), propertyValue, - @"Setting iconScale to a data expression should update icon-size."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.iconScale, pedanticFunctionExpression, - @"iconScale should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.iconScale = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getIconSize(), propertyValue, - @"Setting iconScale to a camera-data expression should update icon-size."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.iconScale, pedanticFunctionExpression, - @"iconScale should round-trip camera-data expressions."); - - layer.iconScale = nil; - XCTAssertTrue(rawLayer->getIconSize().isUndefined(), - @"Unsetting iconScale should return icon-size to the default value."); - XCTAssertEqualObjects(layer.iconScale, defaultExpression, - @"iconScale should return the default value after being unset."); - } - - // icon-text-fit - { - XCTAssertTrue(rawLayer->getIconTextFit().isUndefined(), - @"icon-text-fit should be unset initially."); - NSExpression *defaultExpression = layer.iconTextFit; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'both'"]; - layer.iconTextFit = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::IconTextFitType::Both }; - XCTAssertEqual(rawLayer->getIconTextFit(), propertyValue, - @"Setting iconTextFit to a constant value expression should update icon-text-fit."); - XCTAssertEqualObjects(layer.iconTextFit, constantExpression, - @"iconTextFit should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'both'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconTextFit = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("both"), 18.0, literal("both")) - ); - } - - XCTAssertEqual(rawLayer->getIconTextFit(), propertyValue, - @"Setting iconTextFit to a camera expression should update icon-text-fit."); - XCTAssertEqualObjects(layer.iconTextFit, functionExpression, - @"iconTextFit should round-trip camera expressions."); - - - layer.iconTextFit = nil; - XCTAssertTrue(rawLayer->getIconTextFit().isUndefined(), - @"Unsetting iconTextFit should return icon-text-fit to the default value."); - XCTAssertEqualObjects(layer.iconTextFit, defaultExpression, - @"iconTextFit should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconTextFit = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconTextFit = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-text-fit-padding - { - XCTAssertTrue(rawLayer->getIconTextFitPadding().isUndefined(), - @"icon-text-fit-padding should be unset initially."); - NSExpression *defaultExpression = layer.iconTextFitPadding; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(1, 1, 1, 1)] -#else - [NSValue valueWithEdgeInsets:NSEdgeInsetsMake(1, 1, 1, 1)] -#endif - ]; - layer.iconTextFitPadding = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1, 1, 1 } }; - XCTAssertEqual(rawLayer->getIconTextFitPadding(), propertyValue, - @"Setting iconTextFitPadding to a constant value expression should update icon-text-fit-padding."); - XCTAssertEqualObjects(layer.iconTextFitPadding, constantExpression, - @"iconTextFitPadding should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1, 1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconTextFitPadding = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1, 1, 1 }), 18.0, literal({ 1, 1, 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getIconTextFitPadding(), propertyValue, - @"Setting iconTextFitPadding to a camera expression should update icon-text-fit-padding."); - XCTAssertEqualObjects(layer.iconTextFitPadding, functionExpression, - @"iconTextFitPadding should round-trip camera expressions."); - - - layer.iconTextFitPadding = nil; - XCTAssertTrue(rawLayer->getIconTextFitPadding().isUndefined(), - @"Unsetting iconTextFitPadding should return icon-text-fit-padding to the default value."); - XCTAssertEqualObjects(layer.iconTextFitPadding, defaultExpression, - @"iconTextFitPadding should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconTextFitPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconTextFitPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-keep-upright - { - XCTAssertTrue(rawLayer->getIconKeepUpright().isUndefined(), - @"icon-keep-upright should be unset initially."); - NSExpression *defaultExpression = layer.keepsIconUpright; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"]; - layer.keepsIconUpright = constantExpression; - mbgl::style::PropertyValue propertyValue = { true }; - XCTAssertEqual(rawLayer->getIconKeepUpright(), propertyValue, - @"Setting keepsIconUpright to a constant value expression should update icon-keep-upright."); - XCTAssertEqualObjects(layer.keepsIconUpright, constantExpression, - @"keepsIconUpright should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"true"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.keepsIconUpright = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(true), 18.0, literal(true)) - ); - } - - XCTAssertEqual(rawLayer->getIconKeepUpright(), propertyValue, - @"Setting keepsIconUpright to a camera expression should update icon-keep-upright."); - XCTAssertEqualObjects(layer.keepsIconUpright, functionExpression, - @"keepsIconUpright should round-trip camera expressions."); - - - layer.keepsIconUpright = nil; - XCTAssertTrue(rawLayer->getIconKeepUpright().isUndefined(), - @"Unsetting keepsIconUpright should return icon-keep-upright to the default value."); - XCTAssertEqualObjects(layer.keepsIconUpright, defaultExpression, - @"keepsIconUpright should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.keepsIconUpright = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.keepsIconUpright = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-keep-upright - { - XCTAssertTrue(rawLayer->getTextKeepUpright().isUndefined(), - @"text-keep-upright should be unset initially."); - NSExpression *defaultExpression = layer.keepsTextUpright; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"false"]; - layer.keepsTextUpright = constantExpression; - mbgl::style::PropertyValue propertyValue = { false }; - XCTAssertEqual(rawLayer->getTextKeepUpright(), propertyValue, - @"Setting keepsTextUpright to a constant value expression should update text-keep-upright."); - XCTAssertEqualObjects(layer.keepsTextUpright, constantExpression, - @"keepsTextUpright should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"false"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.keepsTextUpright = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(false), 18.0, literal(false)) - ); - } - - XCTAssertEqual(rawLayer->getTextKeepUpright(), propertyValue, - @"Setting keepsTextUpright to a camera expression should update text-keep-upright."); - XCTAssertEqualObjects(layer.keepsTextUpright, functionExpression, - @"keepsTextUpright should round-trip camera expressions."); - - - layer.keepsTextUpright = nil; - XCTAssertTrue(rawLayer->getTextKeepUpright().isUndefined(), - @"Unsetting keepsTextUpright should return text-keep-upright to the default value."); - XCTAssertEqualObjects(layer.keepsTextUpright, defaultExpression, - @"keepsTextUpright should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.keepsTextUpright = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.keepsTextUpright = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-max-angle - { - XCTAssertTrue(rawLayer->getTextMaxAngle().isUndefined(), - @"text-max-angle should be unset initially."); - NSExpression *defaultExpression = layer.maximumTextAngle; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.maximumTextAngle = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextMaxAngle(), propertyValue, - @"Setting maximumTextAngle to a constant value expression should update text-max-angle."); - XCTAssertEqualObjects(layer.maximumTextAngle, constantExpression, - @"maximumTextAngle should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.maximumTextAngle = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextMaxAngle(), propertyValue, - @"Setting maximumTextAngle to a camera expression should update text-max-angle."); - XCTAssertEqualObjects(layer.maximumTextAngle, functionExpression, - @"maximumTextAngle should round-trip camera expressions."); - - - layer.maximumTextAngle = nil; - XCTAssertTrue(rawLayer->getTextMaxAngle().isUndefined(), - @"Unsetting maximumTextAngle should return text-max-angle to the default value."); - XCTAssertEqualObjects(layer.maximumTextAngle, defaultExpression, - @"maximumTextAngle should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.maximumTextAngle = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.maximumTextAngle = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-max-width - { - XCTAssertTrue(rawLayer->getTextMaxWidth().isUndefined(), - @"text-max-width should be unset initially."); - NSExpression *defaultExpression = layer.maximumTextWidth; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.maximumTextWidth = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue, - @"Setting maximumTextWidth to a constant value expression should update text-max-width."); - XCTAssertEqualObjects(layer.maximumTextWidth, constantExpression, - @"maximumTextWidth should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.maximumTextWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue, - @"Setting maximumTextWidth to a camera expression should update text-max-width."); - XCTAssertEqualObjects(layer.maximumTextWidth, functionExpression, - @"maximumTextWidth should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.maximumTextWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue, - @"Setting maximumTextWidth to a data expression should update text-max-width."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.maximumTextWidth, pedanticFunctionExpression, - @"maximumTextWidth should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.maximumTextWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue, - @"Setting maximumTextWidth to a camera-data expression should update text-max-width."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.maximumTextWidth, pedanticFunctionExpression, - @"maximumTextWidth should round-trip camera-data expressions."); - - layer.maximumTextWidth = nil; - XCTAssertTrue(rawLayer->getTextMaxWidth().isUndefined(), - @"Unsetting maximumTextWidth should return text-max-width to the default value."); - XCTAssertEqualObjects(layer.maximumTextWidth, defaultExpression, - @"maximumTextWidth should return the default value after being unset."); - } - - // symbol-avoid-edges - { - XCTAssertTrue(rawLayer->getSymbolAvoidEdges().isUndefined(), - @"symbol-avoid-edges should be unset initially."); - NSExpression *defaultExpression = layer.symbolAvoidsEdges; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"]; - layer.symbolAvoidsEdges = constantExpression; - mbgl::style::PropertyValue propertyValue = { true }; - XCTAssertEqual(rawLayer->getSymbolAvoidEdges(), propertyValue, - @"Setting symbolAvoidsEdges to a constant value expression should update symbol-avoid-edges."); - XCTAssertEqualObjects(layer.symbolAvoidsEdges, constantExpression, - @"symbolAvoidsEdges should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"true"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.symbolAvoidsEdges = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(true), 18.0, literal(true)) - ); - } - - XCTAssertEqual(rawLayer->getSymbolAvoidEdges(), propertyValue, - @"Setting symbolAvoidsEdges to a camera expression should update symbol-avoid-edges."); - XCTAssertEqualObjects(layer.symbolAvoidsEdges, functionExpression, - @"symbolAvoidsEdges should round-trip camera expressions."); - - - layer.symbolAvoidsEdges = nil; - XCTAssertTrue(rawLayer->getSymbolAvoidEdges().isUndefined(), - @"Unsetting symbolAvoidsEdges should return symbol-avoid-edges to the default value."); - XCTAssertEqualObjects(layer.symbolAvoidsEdges, defaultExpression, - @"symbolAvoidsEdges should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.symbolAvoidsEdges = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.symbolAvoidsEdges = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // symbol-placement - { - XCTAssertTrue(rawLayer->getSymbolPlacement().isUndefined(), - @"symbol-placement should be unset initially."); - NSExpression *defaultExpression = layer.symbolPlacement; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'line-center'"]; - layer.symbolPlacement = constantExpression; - mbgl::style::PropertyValue 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-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( - step(zoom(), literal("line-center"), 18.0, literal("line-center")) - ); - } - - XCTAssertEqual(rawLayer->getSymbolPlacement(), propertyValue, - @"Setting symbolPlacement to a camera expression should update symbol-placement."); - XCTAssertEqualObjects(layer.symbolPlacement, functionExpression, - @"symbolPlacement should round-trip camera expressions."); - - - layer.symbolPlacement = nil; - XCTAssertTrue(rawLayer->getSymbolPlacement().isUndefined(), - @"Unsetting symbolPlacement should return symbol-placement to the default value."); - XCTAssertEqualObjects(layer.symbolPlacement, defaultExpression, - @"symbolPlacement should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.symbolPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.symbolPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // symbol-sort-key - { - XCTAssertTrue(rawLayer->getSymbolSortKey().isUndefined(), - @"symbol-sort-key should be unset initially."); - NSExpression *defaultExpression = layer.symbolSortKey; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.symbolSortKey = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getSymbolSortKey(), propertyValue, - @"Setting symbolSortKey to a constant value expression should update symbol-sort-key."); - XCTAssertEqualObjects(layer.symbolSortKey, constantExpression, - @"symbolSortKey should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.symbolSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getSymbolSortKey(), propertyValue, - @"Setting symbolSortKey to a camera expression should update symbol-sort-key."); - XCTAssertEqualObjects(layer.symbolSortKey, functionExpression, - @"symbolSortKey should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.symbolSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getSymbolSortKey(), propertyValue, - @"Setting symbolSortKey to a data expression should update symbol-sort-key."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.symbolSortKey, pedanticFunctionExpression, - @"symbolSortKey should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.symbolSortKey = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getSymbolSortKey(), propertyValue, - @"Setting symbolSortKey to a camera-data expression should update symbol-sort-key."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.symbolSortKey, pedanticFunctionExpression, - @"symbolSortKey should round-trip camera-data expressions."); - - layer.symbolSortKey = nil; - XCTAssertTrue(rawLayer->getSymbolSortKey().isUndefined(), - @"Unsetting symbolSortKey should return symbol-sort-key to the default value."); - XCTAssertEqualObjects(layer.symbolSortKey, defaultExpression, - @"symbolSortKey should return the default value after being unset."); - } - - // symbol-spacing - { - XCTAssertTrue(rawLayer->getSymbolSpacing().isUndefined(), - @"symbol-spacing should be unset initially."); - NSExpression *defaultExpression = layer.symbolSpacing; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.symbolSpacing = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getSymbolSpacing(), propertyValue, - @"Setting symbolSpacing to a constant value expression should update symbol-spacing."); - XCTAssertEqualObjects(layer.symbolSpacing, constantExpression, - @"symbolSpacing should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.symbolSpacing = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getSymbolSpacing(), propertyValue, - @"Setting symbolSpacing to a camera expression should update symbol-spacing."); - XCTAssertEqualObjects(layer.symbolSpacing, functionExpression, - @"symbolSpacing should round-trip camera expressions."); - - - layer.symbolSpacing = nil; - XCTAssertTrue(rawLayer->getSymbolSpacing().isUndefined(), - @"Unsetting symbolSpacing should return symbol-spacing to the default value."); - XCTAssertEqualObjects(layer.symbolSpacing, defaultExpression, - @"symbolSpacing should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.symbolSpacing = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.symbolSpacing = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // symbol-z-order - { - XCTAssertTrue(rawLayer->getSymbolZOrder().isUndefined(), - @"symbol-z-order should be unset initially."); - NSExpression *defaultExpression = layer.symbolZOrder; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'source'"]; - layer.symbolZOrder = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::SymbolZOrderType::Source }; - XCTAssertEqual(rawLayer->getSymbolZOrder(), propertyValue, - @"Setting symbolZOrder to a constant value expression should update symbol-z-order."); - XCTAssertEqualObjects(layer.symbolZOrder, constantExpression, - @"symbolZOrder should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'source'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.symbolZOrder = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("source"), 18.0, literal("source")) - ); - } - - XCTAssertEqual(rawLayer->getSymbolZOrder(), propertyValue, - @"Setting symbolZOrder to a camera expression should update symbol-z-order."); - XCTAssertEqualObjects(layer.symbolZOrder, functionExpression, - @"symbolZOrder should round-trip camera expressions."); - - - layer.symbolZOrder = nil; - XCTAssertTrue(rawLayer->getSymbolZOrder().isUndefined(), - @"Unsetting symbolZOrder should return symbol-z-order to the default value."); - XCTAssertEqualObjects(layer.symbolZOrder, defaultExpression, - @"symbolZOrder should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.symbolZOrder = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.symbolZOrder = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-field - { - XCTAssertTrue(rawLayer->getTextField().isUndefined(), - @"text-field should be unset initially."); - NSExpression *defaultExpression = layer.text; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'Text Field'"]; - layer.text = constantExpression; - mbgl::style::PropertyValue propertyValue = { "Text Field" }; - XCTAssertEqual(rawLayer->getTextField(), propertyValue, - @"Setting text to a constant value expression should update text-field."); - XCTAssertEqualObjects(layer.text, constantExpression, - @"text should round-trip constant value expressions."); - - MGLAttributedExpression *attributedConstantExpression = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionWithFormat:@"'Text Field'"] - attributes:@{}]; - constantExpression = [NSExpression mgl_expressionForAttributedExpressions:@[[NSExpression expressionForConstantValue:attributedConstantExpression]]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.text = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), format("Text Field"), 18.0, format("Text Field")) - ); - } - - XCTAssertEqual(rawLayer->getTextField(), propertyValue, - @"Setting text to a camera expression should update text-field."); - XCTAssertEqualObjects(layer.text, functionExpression, - @"text should round-trip camera expressions."); - - - layer.text = nil; - XCTAssertTrue(rawLayer->getTextField().isUndefined(), - @"Unsetting text should return text-field to the default value."); - XCTAssertEqualObjects(layer.text, defaultExpression, - @"text should return the default value after being unset."); - - // Tokens test - layer.text = [NSExpression expressionForConstantValue:@"{token}"]; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - format(toString(get(literal("token")))) - ); - } - - XCTAssertEqual(rawLayer->getTextField(), propertyValue, - @"Setting text to a constant string with tokens should convert to an expression."); - - MGLAttributedExpression *tokenAttibutedExpression = [[MGLAttributedExpression alloc] initWithExpression:[NSExpression expressionWithFormat:@"CAST(token, 'NSString')"] - attributes:@{}]; - NSExpression* tokenExpression = [NSExpression mgl_expressionForAttributedExpressions:@[[NSExpression expressionForConstantValue:tokenAttibutedExpression]]]; - XCTAssertEqualObjects(layer.text, tokenExpression, - @"Setting text to a constant string with tokens should convert to an expression."); - } - - // text-allow-overlap - { - XCTAssertTrue(rawLayer->getTextAllowOverlap().isUndefined(), - @"text-allow-overlap should be unset initially."); - NSExpression *defaultExpression = layer.textAllowsOverlap; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"]; - layer.textAllowsOverlap = constantExpression; - mbgl::style::PropertyValue propertyValue = { true }; - XCTAssertEqual(rawLayer->getTextAllowOverlap(), propertyValue, - @"Setting textAllowsOverlap to a constant value expression should update text-allow-overlap."); - XCTAssertEqualObjects(layer.textAllowsOverlap, constantExpression, - @"textAllowsOverlap should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"true"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textAllowsOverlap = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(true), 18.0, literal(true)) - ); - } - - XCTAssertEqual(rawLayer->getTextAllowOverlap(), propertyValue, - @"Setting textAllowsOverlap to a camera expression should update text-allow-overlap."); - XCTAssertEqualObjects(layer.textAllowsOverlap, functionExpression, - @"textAllowsOverlap should round-trip camera expressions."); - - - layer.textAllowsOverlap = nil; - XCTAssertTrue(rawLayer->getTextAllowOverlap().isUndefined(), - @"Unsetting textAllowsOverlap should return text-allow-overlap to the default value."); - XCTAssertEqualObjects(layer.textAllowsOverlap, defaultExpression, - @"textAllowsOverlap should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textAllowsOverlap = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textAllowsOverlap = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-anchor - { - XCTAssertTrue(rawLayer->getTextAnchor().isUndefined(), - @"text-anchor should be unset initially."); - NSExpression *defaultExpression = layer.textAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"]; - layer.textAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::SymbolAnchorType::BottomRight }; - XCTAssertEqual(rawLayer->getTextAnchor(), propertyValue, - @"Setting textAnchor to a constant value expression should update text-anchor."); - XCTAssertEqualObjects(layer.textAnchor, constantExpression, - @"textAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("bottom-right"), 18.0, literal("bottom-right")) - ); - } - - XCTAssertEqual(rawLayer->getTextAnchor(), propertyValue, - @"Setting textAnchor to a camera expression should update text-anchor."); - XCTAssertEqualObjects(layer.textAnchor, functionExpression, - @"textAnchor should round-trip camera expressions."); - - - layer.textAnchor = nil; - XCTAssertTrue(rawLayer->getTextAnchor().isUndefined(), - @"Unsetting textAnchor should return text-anchor to the default value."); - XCTAssertEqualObjects(layer.textAnchor, defaultExpression, - @"textAnchor should return the default value after being unset."); - } - - // text-font - { - XCTAssertTrue(rawLayer->getTextFont().isUndefined(), - @"text-font should be unset initially."); - NSExpression *defaultExpression = layer.textFontNames; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{'Text Font', 'Tnof Txet'}"]; - layer.textFontNames = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { "Text Font", "Tnof Txet" } }; - XCTAssertEqual(rawLayer->getTextFont(), propertyValue, - @"Setting textFontNames to a constant value expression should update text-font."); - XCTAssertEqualObjects(layer.textFontNames, constantExpression, - @"textFontNames should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{'Text Font', 'Tnof Txet'}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textFontNames = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ "Text Font", "Tnof Txet" }), 18.0, literal({ "Text Font", "Tnof Txet" })) - ); - } - - XCTAssertEqual(rawLayer->getTextFont(), propertyValue, - @"Setting textFontNames to a camera expression should update text-font."); - XCTAssertEqualObjects(layer.textFontNames, functionExpression, - @"textFontNames should round-trip camera expressions."); - - - layer.textFontNames = nil; - XCTAssertTrue(rawLayer->getTextFont().isUndefined(), - @"Unsetting textFontNames should return text-font to the default value."); - XCTAssertEqualObjects(layer.textFontNames, defaultExpression, - @"textFontNames should return the default value after being unset."); - } - - // text-size - { - XCTAssertTrue(rawLayer->getTextSize().isUndefined(), - @"text-size should be unset initially."); - NSExpression *defaultExpression = layer.textFontSize; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textFontSize = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextSize(), propertyValue, - @"Setting textFontSize to a constant value expression should update text-size."); - XCTAssertEqualObjects(layer.textFontSize, constantExpression, - @"textFontSize should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textFontSize = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextSize(), propertyValue, - @"Setting textFontSize to a camera expression should update text-size."); - XCTAssertEqualObjects(layer.textFontSize, functionExpression, - @"textFontSize should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textFontSize = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextSize(), propertyValue, - @"Setting textFontSize to a data expression should update text-size."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textFontSize, pedanticFunctionExpression, - @"textFontSize should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textFontSize = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getTextSize(), propertyValue, - @"Setting textFontSize to a camera-data expression should update text-size."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textFontSize, pedanticFunctionExpression, - @"textFontSize should round-trip camera-data expressions."); - - layer.textFontSize = nil; - XCTAssertTrue(rawLayer->getTextSize().isUndefined(), - @"Unsetting textFontSize should return text-size to the default value."); - XCTAssertEqualObjects(layer.textFontSize, defaultExpression, - @"textFontSize should return the default value after being unset."); - } - - // text-ignore-placement - { - XCTAssertTrue(rawLayer->getTextIgnorePlacement().isUndefined(), - @"text-ignore-placement should be unset initially."); - NSExpression *defaultExpression = layer.textIgnoresPlacement; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"]; - layer.textIgnoresPlacement = constantExpression; - mbgl::style::PropertyValue propertyValue = { true }; - XCTAssertEqual(rawLayer->getTextIgnorePlacement(), propertyValue, - @"Setting textIgnoresPlacement to a constant value expression should update text-ignore-placement."); - XCTAssertEqualObjects(layer.textIgnoresPlacement, constantExpression, - @"textIgnoresPlacement should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"true"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textIgnoresPlacement = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(true), 18.0, literal(true)) - ); - } - - XCTAssertEqual(rawLayer->getTextIgnorePlacement(), propertyValue, - @"Setting textIgnoresPlacement to a camera expression should update text-ignore-placement."); - XCTAssertEqualObjects(layer.textIgnoresPlacement, functionExpression, - @"textIgnoresPlacement should round-trip camera expressions."); - - - layer.textIgnoresPlacement = nil; - XCTAssertTrue(rawLayer->getTextIgnorePlacement().isUndefined(), - @"Unsetting textIgnoresPlacement should return text-ignore-placement to the default value."); - XCTAssertEqualObjects(layer.textIgnoresPlacement, defaultExpression, - @"textIgnoresPlacement should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textIgnoresPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textIgnoresPlacement = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-justify - { - XCTAssertTrue(rawLayer->getTextJustify().isUndefined(), - @"text-justify should be unset initially."); - NSExpression *defaultExpression = layer.textJustification; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'right'"]; - layer.textJustification = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::TextJustifyType::Right }; - XCTAssertEqual(rawLayer->getTextJustify(), propertyValue, - @"Setting textJustification to a constant value expression should update text-justify."); - XCTAssertEqualObjects(layer.textJustification, constantExpression, - @"textJustification should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'right'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textJustification = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("right"), 18.0, literal("right")) - ); - } - - XCTAssertEqual(rawLayer->getTextJustify(), propertyValue, - @"Setting textJustification to a camera expression should update text-justify."); - XCTAssertEqualObjects(layer.textJustification, functionExpression, - @"textJustification should round-trip camera expressions."); - - - layer.textJustification = nil; - XCTAssertTrue(rawLayer->getTextJustify().isUndefined(), - @"Unsetting textJustification should return text-justify to the default value."); - XCTAssertEqualObjects(layer.textJustification, defaultExpression, - @"textJustification should return the default value after being unset."); - } - - // text-letter-spacing - { - XCTAssertTrue(rawLayer->getTextLetterSpacing().isUndefined(), - @"text-letter-spacing should be unset initially."); - NSExpression *defaultExpression = layer.textLetterSpacing; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textLetterSpacing = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue, - @"Setting textLetterSpacing to a constant value expression should update text-letter-spacing."); - XCTAssertEqualObjects(layer.textLetterSpacing, constantExpression, - @"textLetterSpacing should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textLetterSpacing = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue, - @"Setting textLetterSpacing to a camera expression should update text-letter-spacing."); - XCTAssertEqualObjects(layer.textLetterSpacing, functionExpression, - @"textLetterSpacing should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textLetterSpacing = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue, - @"Setting textLetterSpacing to a data expression should update text-letter-spacing."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textLetterSpacing, pedanticFunctionExpression, - @"textLetterSpacing should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textLetterSpacing = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue, - @"Setting textLetterSpacing to a camera-data expression should update text-letter-spacing."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textLetterSpacing, pedanticFunctionExpression, - @"textLetterSpacing should round-trip camera-data expressions."); - - layer.textLetterSpacing = nil; - XCTAssertTrue(rawLayer->getTextLetterSpacing().isUndefined(), - @"Unsetting textLetterSpacing should return text-letter-spacing to the default value."); - XCTAssertEqualObjects(layer.textLetterSpacing, defaultExpression, - @"textLetterSpacing should return the default value after being unset."); - } - - // text-line-height - { - XCTAssertTrue(rawLayer->getTextLineHeight().isUndefined(), - @"text-line-height should be unset initially."); - NSExpression *defaultExpression = layer.textLineHeight; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textLineHeight = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextLineHeight(), propertyValue, - @"Setting textLineHeight to a constant value expression should update text-line-height."); - XCTAssertEqualObjects(layer.textLineHeight, constantExpression, - @"textLineHeight should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textLineHeight = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextLineHeight(), propertyValue, - @"Setting textLineHeight to a camera expression should update text-line-height."); - XCTAssertEqualObjects(layer.textLineHeight, functionExpression, - @"textLineHeight should round-trip camera expressions."); - - - layer.textLineHeight = nil; - XCTAssertTrue(rawLayer->getTextLineHeight().isUndefined(), - @"Unsetting textLineHeight should return text-line-height to the default value."); - XCTAssertEqualObjects(layer.textLineHeight, defaultExpression, - @"textLineHeight should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textLineHeight = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textLineHeight = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-offset - { - XCTAssertTrue(rawLayer->getTextOffset().isUndefined(), - @"text-offset should be unset initially."); - NSExpression *defaultExpression = layer.textOffset; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithCGVector:CGVectorMake(1, 1)] -#else - [NSValue valueWithMGLVector:CGVectorMake(1, -1)] -#endif - ]; - layer.textOffset = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; - XCTAssertEqual(rawLayer->getTextOffset(), propertyValue, - @"Setting textOffset to a constant value expression should update text-offset."); - XCTAssertEqualObjects(layer.textOffset, constantExpression, - @"textOffset should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getTextOffset(), propertyValue, - @"Setting textOffset to a camera expression should update text-offset."); - XCTAssertEqualObjects(layer.textOffset, functionExpression, - @"textOffset should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getTextOffset(), propertyValue, - @"Setting textOffset to a data expression should update text-offset."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textOffset, pedanticFunctionExpression, - @"textOffset should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 }))) - ); - } - - XCTAssertEqual(rawLayer->getTextOffset(), propertyValue, - @"Setting textOffset to a camera-data expression should update text-offset."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textOffset, pedanticFunctionExpression, - @"textOffset should round-trip camera-data expressions."); - - layer.textOffset = nil; - XCTAssertTrue(rawLayer->getTextOffset().isUndefined(), - @"Unsetting textOffset should return text-offset to the default value."); - XCTAssertEqualObjects(layer.textOffset, defaultExpression, - @"textOffset should return the default value after being unset."); - } - - // text-optional - { - XCTAssertTrue(rawLayer->getTextOptional().isUndefined(), - @"text-optional should be unset initially."); - NSExpression *defaultExpression = layer.textOptional; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"true"]; - layer.textOptional = constantExpression; - mbgl::style::PropertyValue propertyValue = { true }; - XCTAssertEqual(rawLayer->getTextOptional(), propertyValue, - @"Setting textOptional to a constant value expression should update text-optional."); - XCTAssertEqualObjects(layer.textOptional, constantExpression, - @"textOptional should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"true"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textOptional = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(true), 18.0, literal(true)) - ); - } - - XCTAssertEqual(rawLayer->getTextOptional(), propertyValue, - @"Setting textOptional to a camera expression should update text-optional."); - XCTAssertEqualObjects(layer.textOptional, functionExpression, - @"textOptional should round-trip camera expressions."); - - - layer.textOptional = nil; - XCTAssertTrue(rawLayer->getTextOptional().isUndefined(), - @"Unsetting textOptional should return text-optional to the default value."); - XCTAssertEqualObjects(layer.textOptional, defaultExpression, - @"textOptional should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textOptional = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textOptional = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-padding - { - XCTAssertTrue(rawLayer->getTextPadding().isUndefined(), - @"text-padding should be unset initially."); - NSExpression *defaultExpression = layer.textPadding; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textPadding = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextPadding(), propertyValue, - @"Setting textPadding to a constant value expression should update text-padding."); - XCTAssertEqualObjects(layer.textPadding, constantExpression, - @"textPadding should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textPadding = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextPadding(), propertyValue, - @"Setting textPadding to a camera expression should update text-padding."); - XCTAssertEqualObjects(layer.textPadding, functionExpression, - @"textPadding should round-trip camera expressions."); - - - layer.textPadding = nil; - XCTAssertTrue(rawLayer->getTextPadding().isUndefined(), - @"Unsetting textPadding should return text-padding to the default value."); - XCTAssertEqualObjects(layer.textPadding, defaultExpression, - @"textPadding should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textPadding = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-pitch-alignment - { - XCTAssertTrue(rawLayer->getTextPitchAlignment().isUndefined(), - @"text-pitch-alignment should be unset initially."); - NSExpression *defaultExpression = layer.textPitchAlignment; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'auto'"]; - layer.textPitchAlignment = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::AlignmentType::Auto }; - XCTAssertEqual(rawLayer->getTextPitchAlignment(), propertyValue, - @"Setting textPitchAlignment to a constant value expression should update text-pitch-alignment."); - XCTAssertEqualObjects(layer.textPitchAlignment, constantExpression, - @"textPitchAlignment should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'auto'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textPitchAlignment = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("auto"), 18.0, literal("auto")) - ); - } - - XCTAssertEqual(rawLayer->getTextPitchAlignment(), propertyValue, - @"Setting textPitchAlignment to a camera expression should update text-pitch-alignment."); - XCTAssertEqualObjects(layer.textPitchAlignment, functionExpression, - @"textPitchAlignment should round-trip camera expressions."); - - - layer.textPitchAlignment = nil; - XCTAssertTrue(rawLayer->getTextPitchAlignment().isUndefined(), - @"Unsetting textPitchAlignment should return text-pitch-alignment to the default value."); - XCTAssertEqualObjects(layer.textPitchAlignment, defaultExpression, - @"textPitchAlignment should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textPitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textPitchAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-radial-offset - { - XCTAssertTrue(rawLayer->getTextRadialOffset().isUndefined(), - @"text-radial-offset should be unset initially."); - NSExpression *defaultExpression = layer.textRadialOffset; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textRadialOffset = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextRadialOffset(), propertyValue, - @"Setting textRadialOffset to a constant value expression should update text-radial-offset."); - XCTAssertEqualObjects(layer.textRadialOffset, constantExpression, - @"textRadialOffset should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textRadialOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextRadialOffset(), propertyValue, - @"Setting textRadialOffset to a camera expression should update text-radial-offset."); - XCTAssertEqualObjects(layer.textRadialOffset, functionExpression, - @"textRadialOffset should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textRadialOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextRadialOffset(), propertyValue, - @"Setting textRadialOffset to a data expression should update text-radial-offset."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textRadialOffset, pedanticFunctionExpression, - @"textRadialOffset should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textRadialOffset = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getTextRadialOffset(), propertyValue, - @"Setting textRadialOffset to a camera-data expression should update text-radial-offset."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textRadialOffset, pedanticFunctionExpression, - @"textRadialOffset should round-trip camera-data expressions."); - - layer.textRadialOffset = nil; - XCTAssertTrue(rawLayer->getTextRadialOffset().isUndefined(), - @"Unsetting textRadialOffset should return text-radial-offset to the default value."); - XCTAssertEqualObjects(layer.textRadialOffset, defaultExpression, - @"textRadialOffset should return the default value after being unset."); - } - - // text-rotate - { - XCTAssertTrue(rawLayer->getTextRotate().isUndefined(), - @"text-rotate should be unset initially."); - NSExpression *defaultExpression = layer.textRotation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textRotation = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextRotate(), propertyValue, - @"Setting textRotation to a constant value expression should update text-rotate."); - XCTAssertEqualObjects(layer.textRotation, constantExpression, - @"textRotation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textRotation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextRotate(), propertyValue, - @"Setting textRotation to a camera expression should update text-rotate."); - XCTAssertEqualObjects(layer.textRotation, functionExpression, - @"textRotation should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textRotation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextRotate(), propertyValue, - @"Setting textRotation to a data expression should update text-rotate."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textRotation, pedanticFunctionExpression, - @"textRotation should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textRotation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getTextRotate(), propertyValue, - @"Setting textRotation to a camera-data expression should update text-rotate."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textRotation, pedanticFunctionExpression, - @"textRotation should round-trip camera-data expressions."); - - layer.textRotation = nil; - XCTAssertTrue(rawLayer->getTextRotate().isUndefined(), - @"Unsetting textRotation should return text-rotate to the default value."); - XCTAssertEqualObjects(layer.textRotation, defaultExpression, - @"textRotation should return the default value after being unset."); - } - - // text-rotation-alignment - { - XCTAssertTrue(rawLayer->getTextRotationAlignment().isUndefined(), - @"text-rotation-alignment should be unset initially."); - NSExpression *defaultExpression = layer.textRotationAlignment; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'auto'"]; - layer.textRotationAlignment = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::AlignmentType::Auto }; - XCTAssertEqual(rawLayer->getTextRotationAlignment(), propertyValue, - @"Setting textRotationAlignment to a constant value expression should update text-rotation-alignment."); - XCTAssertEqualObjects(layer.textRotationAlignment, constantExpression, - @"textRotationAlignment should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'auto'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textRotationAlignment = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("auto"), 18.0, literal("auto")) - ); - } - - XCTAssertEqual(rawLayer->getTextRotationAlignment(), propertyValue, - @"Setting textRotationAlignment to a camera expression should update text-rotation-alignment."); - XCTAssertEqualObjects(layer.textRotationAlignment, functionExpression, - @"textRotationAlignment should round-trip camera expressions."); - - - layer.textRotationAlignment = nil; - XCTAssertTrue(rawLayer->getTextRotationAlignment().isUndefined(), - @"Unsetting textRotationAlignment should return text-rotation-alignment to the default value."); - XCTAssertEqualObjects(layer.textRotationAlignment, defaultExpression, - @"textRotationAlignment should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textRotationAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textRotationAlignment = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-transform - { - XCTAssertTrue(rawLayer->getTextTransform().isUndefined(), - @"text-transform should be unset initially."); - NSExpression *defaultExpression = layer.textTransform; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'lowercase'"]; - layer.textTransform = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::TextTransformType::Lowercase }; - XCTAssertEqual(rawLayer->getTextTransform(), propertyValue, - @"Setting textTransform to a constant value expression should update text-transform."); - XCTAssertEqualObjects(layer.textTransform, constantExpression, - @"textTransform should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'lowercase'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textTransform = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("lowercase"), 18.0, literal("lowercase")) - ); - } - - XCTAssertEqual(rawLayer->getTextTransform(), propertyValue, - @"Setting textTransform to a camera expression should update text-transform."); - XCTAssertEqualObjects(layer.textTransform, functionExpression, - @"textTransform should round-trip camera expressions."); - - - layer.textTransform = nil; - XCTAssertTrue(rawLayer->getTextTransform().isUndefined(), - @"Unsetting textTransform should return text-transform to the default value."); - XCTAssertEqualObjects(layer.textTransform, defaultExpression, - @"textTransform should return the default value after being unset."); - } - - // text-variable-anchor - { - XCTAssertTrue(rawLayer->getTextVariableAnchor().isUndefined(), - @"text-variable-anchor should be unset initially."); - NSExpression *defaultExpression = layer.textVariableAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{'top','bottom'}"]; - layer.textVariableAnchor = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { mbgl::style::SymbolAnchorType::Top, mbgl::style::SymbolAnchorType::Bottom } }; - XCTAssertEqual(rawLayer->getTextVariableAnchor(), propertyValue, - @"Setting textVariableAnchor to a constant value expression should update text-variable-anchor."); - XCTAssertEqualObjects(layer.textVariableAnchor, constantExpression, - @"textVariableAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{'top','bottom'}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textVariableAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({"top", "bottom"}), 18.0, literal({"top", "bottom"})) - ); - } - - XCTAssertEqual(rawLayer->getTextVariableAnchor(), propertyValue, - @"Setting textVariableAnchor to a camera expression should update text-variable-anchor."); - XCTAssertEqualObjects(layer.textVariableAnchor, functionExpression, - @"textVariableAnchor should round-trip camera expressions."); - - - layer.textVariableAnchor = nil; - XCTAssertTrue(rawLayer->getTextVariableAnchor().isUndefined(), - @"Unsetting textVariableAnchor should return text-variable-anchor to the default value."); - XCTAssertEqualObjects(layer.textVariableAnchor, defaultExpression, - @"textVariableAnchor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textVariableAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textVariableAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-writing-mode - { - XCTAssertTrue(rawLayer->getTextWritingMode().isUndefined(), - @"text-writing-mode should be unset initially."); - NSExpression *defaultExpression = layer.textWritingModes; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{'horizontal','vertical'}"]; - layer.textWritingModes = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { mbgl::style::TextWritingModeType::Horizontal, mbgl::style::TextWritingModeType::Vertical } }; - XCTAssertEqual(rawLayer->getTextWritingMode(), propertyValue, - @"Setting textWritingModes to a constant value expression should update text-writing-mode."); - XCTAssertEqualObjects(layer.textWritingModes, constantExpression, - @"textWritingModes should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{'horizontal','vertical'}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textWritingModes = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({"horizontal", "vertical"}), 18.0, literal({"horizontal", "vertical"})) - ); - } - - XCTAssertEqual(rawLayer->getTextWritingMode(), propertyValue, - @"Setting textWritingModes to a camera expression should update text-writing-mode."); - XCTAssertEqualObjects(layer.textWritingModes, functionExpression, - @"textWritingModes should round-trip camera expressions."); - - - layer.textWritingModes = nil; - XCTAssertTrue(rawLayer->getTextWritingMode().isUndefined(), - @"Unsetting textWritingModes should return text-writing-mode to the default value."); - XCTAssertEqualObjects(layer.textWritingModes, defaultExpression, - @"textWritingModes should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textWritingModes = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textWritingModes = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-color - { - XCTAssertTrue(rawLayer->getIconColor().isUndefined(), - @"icon-color should be unset initially."); - NSExpression *defaultExpression = layer.iconColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.iconColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getIconColor(), propertyValue, - @"Setting iconColor to a constant value expression should update icon-color."); - XCTAssertEqualObjects(layer.iconColor, constantExpression, - @"iconColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getIconColor(), propertyValue, - @"Setting iconColor to a camera expression should update icon-color."); - XCTAssertEqualObjects(layer.iconColor, functionExpression, - @"iconColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.iconColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getIconColor(), propertyValue, - @"Setting iconColor to a data expression should update icon-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.iconColor, pedanticFunctionExpression, - @"iconColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.iconColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getIconColor(), propertyValue, - @"Setting iconColor to a camera-data expression should update icon-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.iconColor, pedanticFunctionExpression, - @"iconColor should round-trip camera-data expressions."); - - layer.iconColor = nil; - XCTAssertTrue(rawLayer->getIconColor().isUndefined(), - @"Unsetting iconColor should return icon-color to the default value."); - XCTAssertEqualObjects(layer.iconColor, defaultExpression, - @"iconColor should return the default value after being unset."); - // Transition property test - layer.iconColorTransition = transitionTest; - auto toptions = rawLayer->getIconColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition iconColorTransition = layer.iconColorTransition; - XCTAssertEqual(iconColorTransition.delay, transitionTest.delay); - XCTAssertEqual(iconColorTransition.duration, transitionTest.duration); - } - - // icon-halo-blur - { - XCTAssertTrue(rawLayer->getIconHaloBlur().isUndefined(), - @"icon-halo-blur should be unset initially."); - NSExpression *defaultExpression = layer.iconHaloBlur; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.iconHaloBlur = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue, - @"Setting iconHaloBlur to a constant value expression should update icon-halo-blur."); - XCTAssertEqualObjects(layer.iconHaloBlur, constantExpression, - @"iconHaloBlur should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconHaloBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue, - @"Setting iconHaloBlur to a camera expression should update icon-halo-blur."); - XCTAssertEqualObjects(layer.iconHaloBlur, functionExpression, - @"iconHaloBlur should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.iconHaloBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue, - @"Setting iconHaloBlur to a data expression should update icon-halo-blur."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.iconHaloBlur, pedanticFunctionExpression, - @"iconHaloBlur should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.iconHaloBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue, - @"Setting iconHaloBlur to a camera-data expression should update icon-halo-blur."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.iconHaloBlur, pedanticFunctionExpression, - @"iconHaloBlur should round-trip camera-data expressions."); - - layer.iconHaloBlur = nil; - XCTAssertTrue(rawLayer->getIconHaloBlur().isUndefined(), - @"Unsetting iconHaloBlur should return icon-halo-blur to the default value."); - XCTAssertEqualObjects(layer.iconHaloBlur, defaultExpression, - @"iconHaloBlur should return the default value after being unset."); - // Transition property test - layer.iconHaloBlurTransition = transitionTest; - auto toptions = rawLayer->getIconHaloBlurTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition iconHaloBlurTransition = layer.iconHaloBlurTransition; - XCTAssertEqual(iconHaloBlurTransition.delay, transitionTest.delay); - XCTAssertEqual(iconHaloBlurTransition.duration, transitionTest.duration); - } - - // icon-halo-color - { - XCTAssertTrue(rawLayer->getIconHaloColor().isUndefined(), - @"icon-halo-color should be unset initially."); - NSExpression *defaultExpression = layer.iconHaloColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.iconHaloColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue, - @"Setting iconHaloColor to a constant value expression should update icon-halo-color."); - XCTAssertEqualObjects(layer.iconHaloColor, constantExpression, - @"iconHaloColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconHaloColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue, - @"Setting iconHaloColor to a camera expression should update icon-halo-color."); - XCTAssertEqualObjects(layer.iconHaloColor, functionExpression, - @"iconHaloColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.iconHaloColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue, - @"Setting iconHaloColor to a data expression should update icon-halo-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.iconHaloColor, pedanticFunctionExpression, - @"iconHaloColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.iconHaloColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue, - @"Setting iconHaloColor to a camera-data expression should update icon-halo-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.iconHaloColor, pedanticFunctionExpression, - @"iconHaloColor should round-trip camera-data expressions."); - - layer.iconHaloColor = nil; - XCTAssertTrue(rawLayer->getIconHaloColor().isUndefined(), - @"Unsetting iconHaloColor should return icon-halo-color to the default value."); - XCTAssertEqualObjects(layer.iconHaloColor, defaultExpression, - @"iconHaloColor should return the default value after being unset."); - // Transition property test - layer.iconHaloColorTransition = transitionTest; - auto toptions = rawLayer->getIconHaloColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition iconHaloColorTransition = layer.iconHaloColorTransition; - XCTAssertEqual(iconHaloColorTransition.delay, transitionTest.delay); - XCTAssertEqual(iconHaloColorTransition.duration, transitionTest.duration); - } - - // icon-halo-width - { - XCTAssertTrue(rawLayer->getIconHaloWidth().isUndefined(), - @"icon-halo-width should be unset initially."); - NSExpression *defaultExpression = layer.iconHaloWidth; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.iconHaloWidth = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue, - @"Setting iconHaloWidth to a constant value expression should update icon-halo-width."); - XCTAssertEqualObjects(layer.iconHaloWidth, constantExpression, - @"iconHaloWidth should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconHaloWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue, - @"Setting iconHaloWidth to a camera expression should update icon-halo-width."); - XCTAssertEqualObjects(layer.iconHaloWidth, functionExpression, - @"iconHaloWidth should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.iconHaloWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue, - @"Setting iconHaloWidth to a data expression should update icon-halo-width."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.iconHaloWidth, pedanticFunctionExpression, - @"iconHaloWidth should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.iconHaloWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue, - @"Setting iconHaloWidth to a camera-data expression should update icon-halo-width."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.iconHaloWidth, pedanticFunctionExpression, - @"iconHaloWidth should round-trip camera-data expressions."); - - layer.iconHaloWidth = nil; - XCTAssertTrue(rawLayer->getIconHaloWidth().isUndefined(), - @"Unsetting iconHaloWidth should return icon-halo-width to the default value."); - XCTAssertEqualObjects(layer.iconHaloWidth, defaultExpression, - @"iconHaloWidth should return the default value after being unset."); - // Transition property test - layer.iconHaloWidthTransition = transitionTest; - auto toptions = rawLayer->getIconHaloWidthTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition iconHaloWidthTransition = layer.iconHaloWidthTransition; - XCTAssertEqual(iconHaloWidthTransition.delay, transitionTest.delay); - XCTAssertEqual(iconHaloWidthTransition.duration, transitionTest.duration); - } - - // icon-opacity - { - XCTAssertTrue(rawLayer->getIconOpacity().isUndefined(), - @"icon-opacity should be unset initially."); - NSExpression *defaultExpression = layer.iconOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.iconOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue, - @"Setting iconOpacity to a constant value expression should update icon-opacity."); - XCTAssertEqualObjects(layer.iconOpacity, constantExpression, - @"iconOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue, - @"Setting iconOpacity to a camera expression should update icon-opacity."); - XCTAssertEqualObjects(layer.iconOpacity, functionExpression, - @"iconOpacity should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.iconOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue, - @"Setting iconOpacity to a data expression should update icon-opacity."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.iconOpacity, pedanticFunctionExpression, - @"iconOpacity should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.iconOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue, - @"Setting iconOpacity to a camera-data expression should update icon-opacity."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.iconOpacity, pedanticFunctionExpression, - @"iconOpacity should round-trip camera-data expressions."); - - layer.iconOpacity = nil; - XCTAssertTrue(rawLayer->getIconOpacity().isUndefined(), - @"Unsetting iconOpacity should return icon-opacity to the default value."); - XCTAssertEqualObjects(layer.iconOpacity, defaultExpression, - @"iconOpacity should return the default value after being unset."); - // Transition property test - layer.iconOpacityTransition = transitionTest; - auto toptions = rawLayer->getIconOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition iconOpacityTransition = layer.iconOpacityTransition; - XCTAssertEqual(iconOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(iconOpacityTransition.duration, transitionTest.duration); - } - - // icon-translate - { - XCTAssertTrue(rawLayer->getIconTranslate().isUndefined(), - @"icon-translate should be unset initially."); - NSExpression *defaultExpression = layer.iconTranslation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithCGVector:CGVectorMake(1, 1)] -#else - [NSValue valueWithMGLVector:CGVectorMake(1, -1)] -#endif - ]; - layer.iconTranslation = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; - XCTAssertEqual(rawLayer->getIconTranslate(), propertyValue, - @"Setting iconTranslation to a constant value expression should update icon-translate."); - XCTAssertEqualObjects(layer.iconTranslation, constantExpression, - @"iconTranslation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconTranslation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getIconTranslate(), propertyValue, - @"Setting iconTranslation to a camera expression should update icon-translate."); - XCTAssertEqualObjects(layer.iconTranslation, functionExpression, - @"iconTranslation should round-trip camera expressions."); - - - layer.iconTranslation = nil; - XCTAssertTrue(rawLayer->getIconTranslate().isUndefined(), - @"Unsetting iconTranslation should return icon-translate to the default value."); - XCTAssertEqualObjects(layer.iconTranslation, defaultExpression, - @"iconTranslation should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // icon-translate-anchor - { - XCTAssertTrue(rawLayer->getIconTranslateAnchor().isUndefined(), - @"icon-translate-anchor should be unset initially."); - NSExpression *defaultExpression = layer.iconTranslationAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.iconTranslationAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::TranslateAnchorType::Viewport }; - XCTAssertEqual(rawLayer->getIconTranslateAnchor(), propertyValue, - @"Setting iconTranslationAnchor to a constant value expression should update icon-translate-anchor."); - XCTAssertEqualObjects(layer.iconTranslationAnchor, constantExpression, - @"iconTranslationAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.iconTranslationAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getIconTranslateAnchor(), propertyValue, - @"Setting iconTranslationAnchor to a camera expression should update icon-translate-anchor."); - XCTAssertEqualObjects(layer.iconTranslationAnchor, functionExpression, - @"iconTranslationAnchor should round-trip camera expressions."); - - - layer.iconTranslationAnchor = nil; - XCTAssertTrue(rawLayer->getIconTranslateAnchor().isUndefined(), - @"Unsetting iconTranslationAnchor should return icon-translate-anchor to the default value."); - XCTAssertEqualObjects(layer.iconTranslationAnchor, defaultExpression, - @"iconTranslationAnchor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.iconTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.iconTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-color - { - XCTAssertTrue(rawLayer->getTextColor().isUndefined(), - @"text-color should be unset initially."); - NSExpression *defaultExpression = layer.textColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.textColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getTextColor(), propertyValue, - @"Setting textColor to a constant value expression should update text-color."); - XCTAssertEqualObjects(layer.textColor, constantExpression, - @"textColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getTextColor(), propertyValue, - @"Setting textColor to a camera expression should update text-color."); - XCTAssertEqualObjects(layer.textColor, functionExpression, - @"textColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getTextColor(), propertyValue, - @"Setting textColor to a data expression should update text-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textColor, pedanticFunctionExpression, - @"textColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getTextColor(), propertyValue, - @"Setting textColor to a camera-data expression should update text-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textColor, pedanticFunctionExpression, - @"textColor should round-trip camera-data expressions."); - - layer.textColor = nil; - XCTAssertTrue(rawLayer->getTextColor().isUndefined(), - @"Unsetting textColor should return text-color to the default value."); - XCTAssertEqualObjects(layer.textColor, defaultExpression, - @"textColor should return the default value after being unset."); - // Transition property test - layer.textColorTransition = transitionTest; - auto toptions = rawLayer->getTextColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition textColorTransition = layer.textColorTransition; - XCTAssertEqual(textColorTransition.delay, transitionTest.delay); - XCTAssertEqual(textColorTransition.duration, transitionTest.duration); - } - - // text-halo-blur - { - XCTAssertTrue(rawLayer->getTextHaloBlur().isUndefined(), - @"text-halo-blur should be unset initially."); - NSExpression *defaultExpression = layer.textHaloBlur; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textHaloBlur = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue, - @"Setting textHaloBlur to a constant value expression should update text-halo-blur."); - XCTAssertEqualObjects(layer.textHaloBlur, constantExpression, - @"textHaloBlur should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textHaloBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue, - @"Setting textHaloBlur to a camera expression should update text-halo-blur."); - XCTAssertEqualObjects(layer.textHaloBlur, functionExpression, - @"textHaloBlur should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textHaloBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue, - @"Setting textHaloBlur to a data expression should update text-halo-blur."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textHaloBlur, pedanticFunctionExpression, - @"textHaloBlur should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textHaloBlur = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue, - @"Setting textHaloBlur to a camera-data expression should update text-halo-blur."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textHaloBlur, pedanticFunctionExpression, - @"textHaloBlur should round-trip camera-data expressions."); - - layer.textHaloBlur = nil; - XCTAssertTrue(rawLayer->getTextHaloBlur().isUndefined(), - @"Unsetting textHaloBlur should return text-halo-blur to the default value."); - XCTAssertEqualObjects(layer.textHaloBlur, defaultExpression, - @"textHaloBlur should return the default value after being unset."); - // Transition property test - layer.textHaloBlurTransition = transitionTest; - auto toptions = rawLayer->getTextHaloBlurTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition textHaloBlurTransition = layer.textHaloBlurTransition; - XCTAssertEqual(textHaloBlurTransition.delay, transitionTest.delay); - XCTAssertEqual(textHaloBlurTransition.duration, transitionTest.duration); - } - - // text-halo-color - { - XCTAssertTrue(rawLayer->getTextHaloColor().isUndefined(), - @"text-halo-color should be unset initially."); - NSExpression *defaultExpression = layer.textHaloColor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - layer.textHaloColor = constantExpression; - mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; - XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue, - @"Setting textHaloColor to a constant value expression should update text-halo-color."); - XCTAssertEqualObjects(layer.textHaloColor, constantExpression, - @"textHaloColor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textHaloColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue, - @"Setting textHaloColor to a camera expression should update text-halo-color."); - XCTAssertEqualObjects(layer.textHaloColor, functionExpression, - @"textHaloColor should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textHaloColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue, - @"Setting textHaloColor to a data expression should update text-halo-color."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textHaloColor, pedanticFunctionExpression, - @"textHaloColor should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textHaloColor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue, - @"Setting textHaloColor to a camera-data expression should update text-halo-color."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textHaloColor, pedanticFunctionExpression, - @"textHaloColor should round-trip camera-data expressions."); - - layer.textHaloColor = nil; - XCTAssertTrue(rawLayer->getTextHaloColor().isUndefined(), - @"Unsetting textHaloColor should return text-halo-color to the default value."); - XCTAssertEqualObjects(layer.textHaloColor, defaultExpression, - @"textHaloColor should return the default value after being unset."); - // Transition property test - layer.textHaloColorTransition = transitionTest; - auto toptions = rawLayer->getTextHaloColorTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition textHaloColorTransition = layer.textHaloColorTransition; - XCTAssertEqual(textHaloColorTransition.delay, transitionTest.delay); - XCTAssertEqual(textHaloColorTransition.duration, transitionTest.duration); - } - - // text-halo-width - { - XCTAssertTrue(rawLayer->getTextHaloWidth().isUndefined(), - @"text-halo-width should be unset initially."); - NSExpression *defaultExpression = layer.textHaloWidth; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textHaloWidth = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue, - @"Setting textHaloWidth to a constant value expression should update text-halo-width."); - XCTAssertEqualObjects(layer.textHaloWidth, constantExpression, - @"textHaloWidth should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textHaloWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue, - @"Setting textHaloWidth to a camera expression should update text-halo-width."); - XCTAssertEqualObjects(layer.textHaloWidth, functionExpression, - @"textHaloWidth should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textHaloWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue, - @"Setting textHaloWidth to a data expression should update text-halo-width."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textHaloWidth, pedanticFunctionExpression, - @"textHaloWidth should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textHaloWidth = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue, - @"Setting textHaloWidth to a camera-data expression should update text-halo-width."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textHaloWidth, pedanticFunctionExpression, - @"textHaloWidth should round-trip camera-data expressions."); - - layer.textHaloWidth = nil; - XCTAssertTrue(rawLayer->getTextHaloWidth().isUndefined(), - @"Unsetting textHaloWidth should return text-halo-width to the default value."); - XCTAssertEqualObjects(layer.textHaloWidth, defaultExpression, - @"textHaloWidth should return the default value after being unset."); - // Transition property test - layer.textHaloWidthTransition = transitionTest; - auto toptions = rawLayer->getTextHaloWidthTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition textHaloWidthTransition = layer.textHaloWidthTransition; - XCTAssertEqual(textHaloWidthTransition.delay, transitionTest.delay); - XCTAssertEqual(textHaloWidthTransition.duration, transitionTest.duration); - } - - // text-opacity - { - XCTAssertTrue(rawLayer->getTextOpacity().isUndefined(), - @"text-opacity should be unset initially."); - NSExpression *defaultExpression = layer.textOpacity; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; - layer.textOpacity = constantExpression; - mbgl::style::PropertyValue propertyValue = { 1.0 }; - XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue, - @"Setting textOpacity to a constant value expression should update text-opacity."); - XCTAssertEqualObjects(layer.textOpacity, constantExpression, - @"textOpacity should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"1"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal(1.0), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue, - @"Setting textOpacity to a camera expression should update text-opacity."); - XCTAssertEqualObjects(layer.textOpacity, functionExpression, - @"textOpacity should round-trip camera expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}]; - layer.textOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)) - ); - } - - XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue, - @"Setting textOpacity to a data expression should update text-opacity."); - NSExpression *pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(CAST(keyName, 'NSNumber'), 'linear', nil, %@)", @{@18: constantExpression}]; - XCTAssertEqualObjects(layer.textOpacity, pedanticFunctionExpression, - @"textOpacity should round-trip data expressions."); - - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - layer.textOpacity = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) - ); - } - - XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue, - @"Setting textOpacity to a camera-data expression should update text-opacity."); - pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; - XCTAssertEqualObjects(layer.textOpacity, pedanticFunctionExpression, - @"textOpacity should round-trip camera-data expressions."); - - layer.textOpacity = nil; - XCTAssertTrue(rawLayer->getTextOpacity().isUndefined(), - @"Unsetting textOpacity should return text-opacity to the default value."); - XCTAssertEqualObjects(layer.textOpacity, defaultExpression, - @"textOpacity should return the default value after being unset."); - // Transition property test - layer.textOpacityTransition = transitionTest; - auto toptions = rawLayer->getTextOpacityTransition(); - XCTAssert(toptions.delay && MGLTimeIntervalFromDuration(*toptions.delay) == transitionTest.delay); - XCTAssert(toptions.duration && MGLTimeIntervalFromDuration(*toptions.duration) == transitionTest.duration); - - MGLTransition textOpacityTransition = layer.textOpacityTransition; - XCTAssertEqual(textOpacityTransition.delay, transitionTest.delay); - XCTAssertEqual(textOpacityTransition.duration, transitionTest.duration); - } - - // text-translate - { - XCTAssertTrue(rawLayer->getTextTranslate().isUndefined(), - @"text-translate should be unset initially."); - NSExpression *defaultExpression = layer.textTranslation; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", -#if TARGET_OS_IPHONE - [NSValue valueWithCGVector:CGVectorMake(1, 1)] -#else - [NSValue valueWithMGLVector:CGVectorMake(1, -1)] -#endif - ]; - layer.textTranslation = constantExpression; - mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; - XCTAssertEqual(rawLayer->getTextTranslate(), propertyValue, - @"Setting textTranslation to a constant value expression should update text-translate."); - XCTAssertEqualObjects(layer.textTranslation, constantExpression, - @"textTranslation should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"{1, 1}"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textTranslation = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression>( - step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 })) - ); - } - - XCTAssertEqual(rawLayer->getTextTranslate(), propertyValue, - @"Setting textTranslation to a camera expression should update text-translate."); - XCTAssertEqualObjects(layer.textTranslation, functionExpression, - @"textTranslation should round-trip camera expressions."); - - - layer.textTranslation = nil; - XCTAssertTrue(rawLayer->getTextTranslate().isUndefined(), - @"Unsetting textTranslation should return text-translate to the default value."); - XCTAssertEqualObjects(layer.textTranslation, defaultExpression, - @"textTranslation should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textTranslation = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } - - // text-translate-anchor - { - XCTAssertTrue(rawLayer->getTextTranslateAnchor().isUndefined(), - @"text-translate-anchor should be unset initially."); - NSExpression *defaultExpression = layer.textTranslationAnchor; - - NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - layer.textTranslationAnchor = constantExpression; - mbgl::style::PropertyValue propertyValue = { mbgl::style::TranslateAnchorType::Viewport }; - XCTAssertEqual(rawLayer->getTextTranslateAnchor(), propertyValue, - @"Setting textTranslationAnchor to a constant value expression should update text-translate-anchor."); - XCTAssertEqualObjects(layer.textTranslationAnchor, constantExpression, - @"textTranslationAnchor should round-trip constant value expressions."); - - constantExpression = [NSExpression expressionWithFormat:@"'viewport'"]; - NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}]; - layer.textTranslationAnchor = functionExpression; - - { - using namespace mbgl::style::expression::dsl; - propertyValue = mbgl::style::PropertyExpression( - step(zoom(), literal("viewport"), 18.0, literal("viewport")) - ); - } - - XCTAssertEqual(rawLayer->getTextTranslateAnchor(), propertyValue, - @"Setting textTranslationAnchor to a camera expression should update text-translate-anchor."); - XCTAssertEqualObjects(layer.textTranslationAnchor, functionExpression, - @"textTranslationAnchor should round-trip camera expressions."); - - - layer.textTranslationAnchor = nil; - XCTAssertTrue(rawLayer->getTextTranslateAnchor().isUndefined(), - @"Unsetting textTranslationAnchor should return text-translate-anchor to the default value."); - XCTAssertEqualObjects(layer.textTranslationAnchor, defaultExpression, - @"textTranslationAnchor should return the default value after being unset."); - - functionExpression = [NSExpression expressionForKeyPath:@"bogus"]; - XCTAssertThrowsSpecificNamed(layer.textTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:(bogus, %@, %@)", constantExpression, @{@18: constantExpression}]; - functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}]; - XCTAssertThrowsSpecificNamed(layer.textTranslationAnchor = functionExpression, NSException, NSInvalidArgumentException, @"MGLSymbolLayer should raise an exception if a camera-data expression is applied to a property that does not support key paths to feature attributes."); - } -} - -- (void)testPropertyNames { - [self testPropertyName:@"icon-allows-overlap" isBoolean:YES]; - [self testPropertyName:@"icon-anchor" isBoolean:NO]; - [self testPropertyName:@"icon-ignores-placement" isBoolean:YES]; - [self testPropertyName:@"icon-image-name" isBoolean:NO]; - [self testPropertyName:@"icon-offset" isBoolean:NO]; - [self testPropertyName:@"is-icon-optional" isBoolean:YES]; - [self testPropertyName:@"icon-padding" isBoolean:NO]; - [self testPropertyName:@"icon-pitch-alignment" isBoolean:NO]; - [self testPropertyName:@"icon-rotation" isBoolean:NO]; - [self testPropertyName:@"icon-rotation-alignment" isBoolean:NO]; - [self testPropertyName:@"icon-scale" isBoolean:NO]; - [self testPropertyName:@"icon-text-fit" isBoolean:NO]; - [self testPropertyName:@"icon-text-fit-padding" isBoolean:NO]; - [self testPropertyName:@"keeps-icon-upright" isBoolean:YES]; - [self testPropertyName:@"keeps-text-upright" isBoolean:YES]; - [self testPropertyName:@"maximum-text-angle" isBoolean:NO]; - [self testPropertyName:@"maximum-text-width" isBoolean:NO]; - [self testPropertyName:@"symbol-avoids-edges" isBoolean:YES]; - [self testPropertyName:@"symbol-placement" isBoolean:NO]; - [self testPropertyName:@"symbol-sort-key" isBoolean:NO]; - [self testPropertyName:@"symbol-spacing" isBoolean:NO]; - [self testPropertyName:@"symbol-z-order" isBoolean:NO]; - [self testPropertyName:@"text" isBoolean:NO]; - [self testPropertyName:@"text-allows-overlap" isBoolean:YES]; - [self testPropertyName:@"text-anchor" isBoolean:NO]; - [self testPropertyName:@"text-font-names" isBoolean:NO]; - [self testPropertyName:@"text-font-size" isBoolean:NO]; - [self testPropertyName:@"text-ignores-placement" isBoolean:YES]; - [self testPropertyName:@"text-justification" isBoolean:NO]; - [self testPropertyName:@"text-letter-spacing" isBoolean:NO]; - [self testPropertyName:@"text-line-height" isBoolean:NO]; - [self testPropertyName:@"text-offset" isBoolean:NO]; - [self testPropertyName:@"is-text-optional" isBoolean:YES]; - [self testPropertyName:@"text-padding" isBoolean:NO]; - [self testPropertyName:@"text-pitch-alignment" isBoolean:NO]; - [self testPropertyName:@"text-radial-offset" isBoolean:NO]; - [self testPropertyName:@"text-rotation" isBoolean:NO]; - [self testPropertyName:@"text-rotation-alignment" isBoolean:NO]; - [self testPropertyName:@"text-transform" isBoolean:NO]; - [self testPropertyName:@"text-variable-anchor" isBoolean:NO]; - [self testPropertyName:@"text-writing-modes" isBoolean:NO]; - [self testPropertyName:@"icon-color" isBoolean:NO]; - [self testPropertyName:@"icon-halo-blur" isBoolean:NO]; - [self testPropertyName:@"icon-halo-color" isBoolean:NO]; - [self testPropertyName:@"icon-halo-width" isBoolean:NO]; - [self testPropertyName:@"icon-opacity" isBoolean:NO]; - [self testPropertyName:@"icon-translation" isBoolean:NO]; - [self testPropertyName:@"icon-translation-anchor" isBoolean:NO]; - [self testPropertyName:@"text-color" isBoolean:NO]; - [self testPropertyName:@"text-halo-blur" isBoolean:NO]; - [self testPropertyName:@"text-halo-color" isBoolean:NO]; - [self testPropertyName:@"text-halo-width" isBoolean:NO]; - [self testPropertyName:@"text-opacity" isBoolean:NO]; - [self testPropertyName:@"text-translation" isBoolean:NO]; - [self testPropertyName:@"text-translation-anchor" isBoolean:NO]; -} - -- (void)testValueAdditions { - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorCenter].MGLIconAnchorValue, MGLIconAnchorCenter); - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorLeft].MGLIconAnchorValue, MGLIconAnchorLeft); - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorRight].MGLIconAnchorValue, MGLIconAnchorRight); - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorTop].MGLIconAnchorValue, MGLIconAnchorTop); - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorBottom].MGLIconAnchorValue, MGLIconAnchorBottom); - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorTopLeft].MGLIconAnchorValue, MGLIconAnchorTopLeft); - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorTopRight].MGLIconAnchorValue, MGLIconAnchorTopRight); - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorBottomLeft].MGLIconAnchorValue, MGLIconAnchorBottomLeft); - XCTAssertEqual([NSValue valueWithMGLIconAnchor:MGLIconAnchorBottomRight].MGLIconAnchorValue, MGLIconAnchorBottomRight); - XCTAssertEqual([NSValue valueWithMGLIconPitchAlignment:MGLIconPitchAlignmentMap].MGLIconPitchAlignmentValue, MGLIconPitchAlignmentMap); - XCTAssertEqual([NSValue valueWithMGLIconPitchAlignment:MGLIconPitchAlignmentViewport].MGLIconPitchAlignmentValue, MGLIconPitchAlignmentViewport); - XCTAssertEqual([NSValue valueWithMGLIconPitchAlignment:MGLIconPitchAlignmentAuto].MGLIconPitchAlignmentValue, MGLIconPitchAlignmentAuto); - XCTAssertEqual([NSValue valueWithMGLIconRotationAlignment:MGLIconRotationAlignmentMap].MGLIconRotationAlignmentValue, MGLIconRotationAlignmentMap); - XCTAssertEqual([NSValue valueWithMGLIconRotationAlignment:MGLIconRotationAlignmentViewport].MGLIconRotationAlignmentValue, MGLIconRotationAlignmentViewport); - XCTAssertEqual([NSValue valueWithMGLIconRotationAlignment:MGLIconRotationAlignmentAuto].MGLIconRotationAlignmentValue, MGLIconRotationAlignmentAuto); - XCTAssertEqual([NSValue valueWithMGLIconTextFit:MGLIconTextFitNone].MGLIconTextFitValue, MGLIconTextFitNone); - XCTAssertEqual([NSValue valueWithMGLIconTextFit:MGLIconTextFitWidth].MGLIconTextFitValue, MGLIconTextFitWidth); - XCTAssertEqual([NSValue valueWithMGLIconTextFit:MGLIconTextFitHeight].MGLIconTextFitValue, MGLIconTextFitHeight); - 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 valueWithMGLSymbolZOrder:MGLSymbolZOrderAuto].MGLSymbolZOrderValue, MGLSymbolZOrderAuto); - XCTAssertEqual([NSValue valueWithMGLSymbolZOrder:MGLSymbolZOrderViewportY].MGLSymbolZOrderValue, MGLSymbolZOrderViewportY); - XCTAssertEqual([NSValue valueWithMGLSymbolZOrder:MGLSymbolZOrderSource].MGLSymbolZOrderValue, MGLSymbolZOrderSource); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorCenter].MGLTextAnchorValue, MGLTextAnchorCenter); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorLeft].MGLTextAnchorValue, MGLTextAnchorLeft); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorRight].MGLTextAnchorValue, MGLTextAnchorRight); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorTop].MGLTextAnchorValue, MGLTextAnchorTop); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorBottom].MGLTextAnchorValue, MGLTextAnchorBottom); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorTopLeft].MGLTextAnchorValue, MGLTextAnchorTopLeft); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorTopRight].MGLTextAnchorValue, MGLTextAnchorTopRight); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorBottomLeft].MGLTextAnchorValue, MGLTextAnchorBottomLeft); - XCTAssertEqual([NSValue valueWithMGLTextAnchor:MGLTextAnchorBottomRight].MGLTextAnchorValue, MGLTextAnchorBottomRight); - XCTAssertEqual([NSValue valueWithMGLTextJustification:MGLTextJustificationAuto].MGLTextJustificationValue, MGLTextJustificationAuto); - XCTAssertEqual([NSValue valueWithMGLTextJustification:MGLTextJustificationLeft].MGLTextJustificationValue, MGLTextJustificationLeft); - XCTAssertEqual([NSValue valueWithMGLTextJustification:MGLTextJustificationCenter].MGLTextJustificationValue, MGLTextJustificationCenter); - XCTAssertEqual([NSValue valueWithMGLTextJustification:MGLTextJustificationRight].MGLTextJustificationValue, MGLTextJustificationRight); - XCTAssertEqual([NSValue valueWithMGLTextPitchAlignment:MGLTextPitchAlignmentMap].MGLTextPitchAlignmentValue, MGLTextPitchAlignmentMap); - XCTAssertEqual([NSValue valueWithMGLTextPitchAlignment:MGLTextPitchAlignmentViewport].MGLTextPitchAlignmentValue, MGLTextPitchAlignmentViewport); - XCTAssertEqual([NSValue valueWithMGLTextPitchAlignment:MGLTextPitchAlignmentAuto].MGLTextPitchAlignmentValue, MGLTextPitchAlignmentAuto); - XCTAssertEqual([NSValue valueWithMGLTextRotationAlignment:MGLTextRotationAlignmentMap].MGLTextRotationAlignmentValue, MGLTextRotationAlignmentMap); - XCTAssertEqual([NSValue valueWithMGLTextRotationAlignment:MGLTextRotationAlignmentViewport].MGLTextRotationAlignmentValue, MGLTextRotationAlignmentViewport); - XCTAssertEqual([NSValue valueWithMGLTextRotationAlignment:MGLTextRotationAlignmentAuto].MGLTextRotationAlignmentValue, MGLTextRotationAlignmentAuto); - XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformNone].MGLTextTransformValue, MGLTextTransformNone); - XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformUppercase].MGLTextTransformValue, MGLTextTransformUppercase); - XCTAssertEqual([NSValue valueWithMGLTextTransform:MGLTextTransformLowercase].MGLTextTransformValue, MGLTextTransformLowercase); - XCTAssertEqual([NSValue valueWithMGLTextWritingMode:MGLTextWritingModeHorizontal].MGLTextWritingModeValue, MGLTextWritingModeHorizontal); - XCTAssertEqual([NSValue valueWithMGLTextWritingMode:MGLTextWritingModeVertical].MGLTextWritingModeValue, MGLTextWritingModeVertical); - XCTAssertEqual([NSValue valueWithMGLIconTranslationAnchor:MGLIconTranslationAnchorMap].MGLIconTranslationAnchorValue, MGLIconTranslationAnchorMap); - XCTAssertEqual([NSValue valueWithMGLIconTranslationAnchor:MGLIconTranslationAnchorViewport].MGLIconTranslationAnchorValue, MGLIconTranslationAnchorViewport); - XCTAssertEqual([NSValue valueWithMGLTextTranslationAnchor:MGLTextTranslationAnchorMap].MGLTextTranslationAnchorValue, MGLTextTranslationAnchorMap); - XCTAssertEqual([NSValue valueWithMGLTextTranslationAnchor:MGLTextTranslationAnchorViewport].MGLTextTranslationAnchorValue, MGLTextTranslationAnchorViewport); -} - -@end diff --git a/platform/ios/platform/ios/docs/guides/For Style Authors.md b/platform/ios/platform/ios/docs/guides/For Style Authors.md deleted file mode 100644 index 1f8928878..000000000 --- a/platform/ios/platform/ios/docs/guides/For Style Authors.md +++ /dev/null @@ -1,437 +0,0 @@ - -# Information for Style Authors - -A _style_ defines a map view’s content and appearance. If you’ve authored a -style using -[Mapbox Studio’s Styles editor](https://www.mapbox.com/studio/styles/) or as -JSON in a text editor, you can use that style in this SDK and manipulate it -afterwards in code. This document provides information you can use to ensure a -seamless transition from Mapbox Studio to your application. - -## Designing for iOS - -When designing your style, consider the context in which your application shows -the style. There are a number of considerations specific to iOS that may -not be obvious when designing your style in Mapbox Studio on the Web. A map view -is essentially a graphical user interface element, so many of same issues in -user interface design also apply when designing a map style. - -### Color - -Ensure sufficient contrast in your application’s user interface when your map -style is present. Standard user interface elements such as toolbars, sidebars, -and sheets often overlap the map view with a translucent, blurred background, so -make sure the contents of these elements remain legible with the map view -underneath. -The user location annotation view, the attribution button, any buttons in -callout views, and any items in the navigation bar are influenced by your -application’s tint color, so choose a tint color that contrasts well with your -map style. -If you intend your style to be used in the dark, consider the impact that Night -Shift may have on your style’s colors. - -### Typography and graphics - -Choose font and icon sizes appropriate to iOS devices. iPhones and iPads have -smaller screens than the typical browser window in which you would use Mapbox -Studio, especially when multitasking is enabled. Your user’s viewing distance -may be shorter than on a desktop computer. Some of your users may use the Larger -Dynamic Type and Accessibility Text features to increase the size of all text on -the device. You can use the -[runtime styling API](#manipulating-the-style-at-runtime) to adjust your style’s - font and icon sizes accordingly. - -Design sprite images and choose font weights that look crisp on both -standard-resolution displays and Retina displays. This SDK supports the same -resolutions as iOS. -Standard-resolution displays are limited to older devices that your application -may or may not support, depending on its minimum deployment target. - -Icon and text labels should be legible regardless of the map’s orientation. -By default, this SDK makes it easy for your users to rotate or tilt the map -using multitouch gestures. -If you do not intend your design to accommodate rotation and tilting, disable -these gestures using the `MGLMapView.rotateEnabled` and -`MGLMapView.pitchEnabled` properties, respectively, or the corresponding -inspectables in Interface Builder. - -### Interactivity - -Pay attention to whether elements of your style appear to be interactive. -A text label may look like a tappable button merely due to matching your -application’s tint color or the default blue tint color. -You can make an icon or text label interactive by installing a gesture -recognizer and performing feature querying (e.g., -`-[MGLMapView visibleFeaturesAtPoint:]`) to get details about the selected -feature. - -Make sure your users can easily distinguish any interactive elements from the -surrounding map, such as pins, the user location annotation view, or a route -line. Avoid relying on hover effects to indicate interactive elements. Leave -enough room between interactive elements to accommodate imprecise tapping -gestures. - -For more information about user interface design, consult Apple’s -[_iOS Human Interface Guidelines_](https://developer.apple.com/ios/human-interface-guidelines/). -To learn more about designing maps for mobile devices, see [Nathaniel Slaughter's blog post](https://www.mapbox.com/blog/designing-maps-for-mobile-devices/) on -the subject. - -## Applying your style - -You set an `MGLMapView` object’s style either in code, by setting the -`MGLMapView.styleURL` property, or in Interface Builder, by setting the “Style -URL” inspectable. The URL must point to a local or remote style JSON file. The -style JSON file format is defined by the -[Mapbox Style Specification](https://www.mapbox.com/mapbox-gl-style-spec/). This -SDK supports the functionality defined by version 8 of the specification unless -otherwise noted in the -[style specification documentation](https://www.mapbox.com/mapbox-gl-style-spec/). - -## Manipulating the style at runtime - -The _runtime styling API_ enables you to modify every aspect of a style -dynamically as a user interacts with your application. The style itself is -represented at runtime by an `MGLStyle` object, which provides access to various -`MGLSource` and `MGLStyleLayer` objects that represent content sources and style -layers, respectively. -For more information about the capabilities exposed by the runtime styling API, -see “[Runtime Styling](https://www.mapbox.com/ios-sdk/maps/overview/runtime-styling/)”. - -The names of runtime styling classes and properties on iOS are generally -consistent with the style specification and Mapbox Studio’s Styles editor. Any -exceptions are listed in this document. - -To avoid conflicts with Objective-C keywords or Cocoa terminology, this SDK uses -the following terms for concepts defined in the style specification: - -In the style specification | In the SDK ----------------------------|--------- -bounds | coordinate bounds -filter | predicate -function type | interpolation mode -id | identifier -image | style image -layer | style layer -property | attribute -SDF icon | template image -source | content source - -## Specifying the map’s content - -Each source defined by a style JSON file is represented at runtime by a content -source object that you can use to initialize new style layers. The content -source object is a member of one of the following subclasses of `MGLSource`: - -In style JSON | In the SDK ---------------|----------- -`vector` | `MGLVectorTileSource` -`raster` | `MGLRasterTileSource` -`raster-dem` | `MGLRasterDEMSource` -`geojson` | `MGLShapeSource` -`image` | `MGLImageSource` - -`canvas` and `video` sources are not supported. - -### Tile sources - -Raster and vector tile sources may be defined in TileJSON configuration files. -This SDK supports the properties defined in the style specification, which are a -subset of the keys defined in version 2.1.0 of the -[TileJSON](https://github.com/mapbox/tilejson-spec/tree/master/2.1.0) -specification. As an alternative to authoring a custom TileJSON file, you may -supply various tile source options when creating a raster or vector tile source. -These options are detailed in the `MGLTileSourceOption` documentation: - -In style JSON | In TileJSON | In the SDK ---------------|---------------|----------- -`url` | — | `configurationURL` parameter in `-[MGLTileSource initWithIdentifier:configurationURL:]` -`tiles` | `tiles` | `tileURLTemplates` parameter in `-[MGLTileSource initWithIdentifier:tileURLTemplates:options:]` -`minzoom` | `minzoom` | `MGLTileSourceOptionMinimumZoomLevel` -`maxzoom` | `maxzoom` | `MGLTileSourceOptionMaximumZoomLevel` -`bounds` | `bounds` | `MGLTileSourceOptionCoordinateBounds` -`tileSize` | — | `MGLTileSourceOptionTileSize` -`attribution` | `attribution` | `MGLTileSourceOptionAttributionHTMLString` (but consider specifying `MGLTileSourceOptionAttributionInfos` instead for improved security) -`scheme` | `scheme` | `MGLTileSourceOptionTileCoordinateSystem` -`encoding` | – | `MGLTileSourceOptionDEMEncoding` - -### Shape sources - -Shape sources also accept various options. These options are detailed in the -`MGLShapeSourceOption` documentation: - -In style JSON | In the SDK ------------------|----------- -`data` | `url` parameter in `-[MGLShapeSource initWithIdentifier:URL:options:]` -`maxzoom` | `MGLShapeSourceOptionMaximumZoomLevel` -`buffer` | `MGLShapeSourceOptionBuffer` -`tolerance` | `MGLShapeSourceOptionSimplificationTolerance` -`cluster` | `MGLShapeSourceOptionClustered` -`clusterRadius` | `MGLShapeSourceOptionClusterRadius` -`clusterMaxZoom` | `MGLShapeSourceOptionMaximumZoomLevelForClustering` -`lineMetrics` | `MGLShapeSourceOptionLineDistanceMetrics` - -To create a shape source from local GeoJSON data, first -[convert the GeoJSON data into a shape](working-with-geojson-data.html#converting-geojson-data-into-shape-objects), -then use the `-[MGLShapeSource initWithIdentifier:shape:options:]` method. - -### Image sources - -Image sources accept a non-axis aligned quadrilateral as their geographic coordinates. -These coordinates, in `MGLCoordinateQuad`, are described in counterclockwise order, -in contrast to the clockwise order defined in the style specification. - -## Configuring the map content’s appearance - -Each layer defined by the style JSON file is represented at runtime by a style -layer object, which you can use to refine the map’s appearance. The style layer -object is a member of one of the following subclasses of `MGLStyleLayer`: - -In style JSON | In the SDK ---------------|----------- -`background` | `MGLBackgroundStyleLayer` -`circle` | `MGLCircleStyleLayer` -`fill` | `MGLFillStyleLayer` -`fill-extrusion` | `MGLFillExtrusionStyleLayer` -`heatmap` | `MGLHeatmapStyleLayer` -`hillshade` | `MGLHillshadeStyleLayer` -`line` | `MGLLineStyleLayer` -`raster` | `MGLRasterStyleLayer` -`symbol` | `MGLSymbolStyleLayer` - -You configure layout and paint attributes by setting properties on these style -layer objects. The property names generally correspond to the style JSON -properties, except for the use of camelCase instead of kebab-case. Properties -whose names differ from the style specification are listed below: - -### Circle style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`circle-pitch-scale` | `MGLCircleStyleLayer.circleScaleAlignment` | `MGLCircleStyleLayer.circleScaleAlignment` -`circle-translate` | `MGLCircleStyleLayer.circleTranslation` | `MGLCircleStyleLayer.circleTranslation` -`circle-translate-anchor` | `MGLCircleStyleLayer.circleTranslationAnchor` | `MGLCircleStyleLayer.circleTranslationAnchor` - -### Fill style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`fill-antialias` | `MGLFillStyleLayer.fillAntialiased` | `MGLFillStyleLayer.isFillAntialiased` -`fill-translate` | `MGLFillStyleLayer.fillTranslation` | `MGLFillStyleLayer.fillTranslation` -`fill-translate-anchor` | `MGLFillStyleLayer.fillTranslationAnchor` | `MGLFillStyleLayer.fillTranslationAnchor` - -### Fill extrusion style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`fill-extrusion-vertical-gradient` | `MGLFillExtrusionStyleLayer.fillExtrusionHasVerticalGradient` | `MGLFillExtrusionStyleLayer.fillExtrusionHasVerticalGradient` -`fill-extrusion-translate` | `MGLFillExtrusionStyleLayer.fillExtrusionTranslation` | `MGLFillExtrusionStyleLayer.fillExtrusionTranslation` -`fill-extrusion-translate-anchor` | `MGLFillExtrusionStyleLayer.fillExtrusionTranslationAnchor` | `MGLFillExtrusionStyleLayer.fillExtrusionTranslationAnchor` - -### Line style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`line-dasharray` | `MGLLineStyleLayer.lineDashPattern` | `MGLLineStyleLayer.lineDashPattern` -`line-translate` | `MGLLineStyleLayer.lineTranslation` | `MGLLineStyleLayer.lineTranslation` -`line-translate-anchor` | `MGLLineStyleLayer.lineTranslationAnchor` | `MGLLineStyleLayer.lineTranslationAnchor` - -### Raster style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`raster-brightness-max` | `MGLRasterStyleLayer.maximumRasterBrightness` | `MGLRasterStyleLayer.maximumRasterBrightness` -`raster-brightness-min` | `MGLRasterStyleLayer.minimumRasterBrightness` | `MGLRasterStyleLayer.minimumRasterBrightness` -`raster-hue-rotate` | `MGLRasterStyleLayer.rasterHueRotation` | `MGLRasterStyleLayer.rasterHueRotation` -`raster-resampling` | `MGLRasterStyleLayer.rasterResamplingMode` | `MGLRasterStyleLayer.rasterResamplingMode` - -### Symbol style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`icon-allow-overlap` | `MGLSymbolStyleLayer.iconAllowsOverlap` | `MGLSymbolStyleLayer.iconAllowsOverlap` -`icon-ignore-placement` | `MGLSymbolStyleLayer.iconIgnoresPlacement` | `MGLSymbolStyleLayer.iconIgnoresPlacement` -`icon-image` | `MGLSymbolStyleLayer.iconImageName` | `MGLSymbolStyleLayer.iconImageName` -`icon-optional` | `MGLSymbolStyleLayer.iconOptional` | `MGLSymbolStyleLayer.isIconOptional` -`icon-rotate` | `MGLSymbolStyleLayer.iconRotation` | `MGLSymbolStyleLayer.iconRotation` -`icon-size` | `MGLSymbolStyleLayer.iconScale` | `MGLSymbolStyleLayer.iconScale` -`icon-keep-upright` | `MGLSymbolStyleLayer.keepsIconUpright` | `MGLSymbolStyleLayer.keepsIconUpright` -`text-keep-upright` | `MGLSymbolStyleLayer.keepsTextUpright` | `MGLSymbolStyleLayer.keepsTextUpright` -`text-max-angle` | `MGLSymbolStyleLayer.maximumTextAngle` | `MGLSymbolStyleLayer.maximumTextAngle` -`text-max-width` | `MGLSymbolStyleLayer.maximumTextWidth` | `MGLSymbolStyleLayer.maximumTextWidth` -`symbol-avoid-edges` | `MGLSymbolStyleLayer.symbolAvoidsEdges` | `MGLSymbolStyleLayer.symbolAvoidsEdges` -`text-field` | `MGLSymbolStyleLayer.text` | `MGLSymbolStyleLayer.text` -`text-allow-overlap` | `MGLSymbolStyleLayer.textAllowsOverlap` | `MGLSymbolStyleLayer.textAllowsOverlap` -`text-font` | `MGLSymbolStyleLayer.textFontNames` | `MGLSymbolStyleLayer.textFontNames` -`text-size` | `MGLSymbolStyleLayer.textFontSize` | `MGLSymbolStyleLayer.textFontSize` -`text-ignore-placement` | `MGLSymbolStyleLayer.textIgnoresPlacement` | `MGLSymbolStyleLayer.textIgnoresPlacement` -`text-justify` | `MGLSymbolStyleLayer.textJustification` | `MGLSymbolStyleLayer.textJustification` -`text-optional` | `MGLSymbolStyleLayer.textOptional` | `MGLSymbolStyleLayer.isTextOptional` -`text-rotate` | `MGLSymbolStyleLayer.textRotation` | `MGLSymbolStyleLayer.textRotation` -`text-writing-mode` | `MGLSymbolStyleLayer.textWritingModes` | `MGLSymbolStyleLayer.textWritingModes` -`icon-translate` | `MGLSymbolStyleLayer.iconTranslation` | `MGLSymbolStyleLayer.iconTranslation` -`icon-translate-anchor` | `MGLSymbolStyleLayer.iconTranslationAnchor` | `MGLSymbolStyleLayer.iconTranslationAnchor` -`text-translate` | `MGLSymbolStyleLayer.textTranslation` | `MGLSymbolStyleLayer.textTranslation` -`text-translate-anchor` | `MGLSymbolStyleLayer.textTranslationAnchor` | `MGLSymbolStyleLayer.textTranslationAnchor` - -## Setting attribute values - -Each property representing a layout or paint attribute is set to an -`NSExpression` object. `NSExpression` objects play the same role as -[expressions in the Mapbox Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/#expressions), -but you create the former using a very different syntax. `NSExpression`’s format -string syntax is reminiscent of a spreadsheet formula or an expression in a -database query. See the -“[Predicates and Expressions](predicates-and-expressions.html)” guide for an -overview of the expression support in this SDK. This SDK no longer supports -style functions; use expressions instead. - -### Constant values in expressions - -In contrast to the JSON type that the style specification defines for each -layout or paint property, the style value object often contains a more specific -Foundation or Cocoa type. General rules for attribute types are listed below. -Pay close attention to the SDK documentation for the attribute you want to get -or set. - -In style JSON | In Objective-C | In Swift ---------------|-----------------------|--------- -Color | `UIColor` | `UIColor` -Enum | `NSString` | `String` -String | `NSString` | `String` -Boolean | `NSNumber.boolValue` | `NSNumber.boolValue` -Number | `NSNumber.floatValue` | `NSNumber.floatValue` -Array (`-dasharray`) | `NSArray` | `[Float]` -Array (`-font`) | `NSArray` | `[String]` -Array (`-offset`, `-translate`) | `NSValue.CGVectorValue` | `NSValue.cgVectorValue` -Array (`-padding`) | `NSValue.UIEdgeInsetsValue` | `NSValue.uiEdgeInsetsValue` - -For padding attributes, note that the arguments to -`UIEdgeInsetsMake()` in Objective-C and `UIEdgeInsets(top:left:bottom:right:)` -in Swift -are specified in counterclockwise order, in contrast to the clockwise order -defined by the style specification. - -### Expression operators - -Many expression operators defined in the style specification have corresponding -symbols to be used with the `+[NSExpression expressionWithFormat:]`, -`+[NSExpression expressionForFunction:arguments:]`, or -`+[NSExpression expressionForFunction:selectorName:arguments:]` method: - -In style specification | Method, function, or predicate type | Format string syntax ------------------------|-------------------------------------|--------------------- -`array` | | -`boolean` | | -`collator` | `NSComparisonPredicateOptions` | `'Québec' =[cd] 'QUEBEC'` -`literal` | `+[NSExpression expressionForConstantValue:]` | `%@` representing `NSArray` or `NSDictionary` -`number` | | -`string` | | -`to-boolean` | `boolValue` | -`to-color` | | `CAST(var, 'UIColor')` -`to-number` | `mgl_numberWithFallbackValues:` | `CAST(zipCode, 'NSNumber')` -`to-string` | `stringValue` | `CAST(ele, 'NSString')` -`typeof` | | -`geometry-type` | `NSExpression.geometryTypeVariableExpression` | `$geometryType` -`id` | `NSExpression.featureIdentifierVariableExpression` | `$featureIdentifier` -`properties` | `NSExpression.featureAttributesVariableExpression` | `$featureAttributes` -`at` | `objectFrom:withIndex:` | `array[n]` -`get` | `+[NSExpression expressionForKeyPath:]` | Key path -`has` | `mgl_does:have:` | `mgl_does:have:(self, 'key')` -`in` | `NSInPredicateOperatorType` | `needle IN haystack` or `haystack CONTAINS needle` or `ANY haystack = needle` -`length` | `count:` | `count({1, 2, 2, 3, 4, 7, 9})` -`!` | `NSNotPredicateType` | `NOT (p0 OR … OR pn)` -`!=` | `NSNotEqualToPredicateOperatorType` | `key != value` -`<` | `NSLessThanPredicateOperatorType` | `key < value` -`<=` | `NSLessThanOrEqualToPredicateOperatorType` | `key <= value` -`==` | `NSEqualToPredicateOperatorType` | `key == value` -`>` | `NSGreaterThanPredicateOperatorType` | `key > value` -`>=` | `NSGreaterThanOrEqualToPredicateOperatorType` | `key >= value` -`all` | `NSAndPredicateType` | `p0 AND … AND pn` -`any` | `NSOrPredicateType` | `p0 OR … OR pn` -`case` | `+[NSExpression expressionForConditional:trueExpression:falseExpression:]` or `MGL_IF` or `+[NSExpression mgl_expressionForConditional:trueExpression:falseExpresssion:]` | `TERNARY(1 = 2, YES, NO)` or `MGL_IF(1 = 2, YES, 2 = 2, YES, NO)` -`coalesce` | `mgl_coalesce:` | `mgl_coalesce({x, y, z})` -`match` | `MGL_MATCH` or `+[NSExpression mgl_expressionForMatchingExpression:inDictionary:defaultExpression:]` | `MGL_MATCH(x, 0, 'zero match', 1, 'one match', 'two match', 'default')` -`within` | `NSInPredicateOperatorType` | `SELF IN %@` or `%@ CONTAINS SELF` where `%@` is an `MGLShape` -`interpolate` | `mgl_interpolate:withCurveType:parameters:stops:` or `+[NSExpression mgl_expressionForInterpolatingExpression:withCurveType:parameters:stops:]` | -`step` | `mgl_step:from:stops:` or `+[NSExpression mgl_expressionForSteppingExpression:fromExpression:stops:]` | -`let` | `mgl_expressionWithContext:` | `MGL_LET('ios', 11, 'macos', 10.13, $ios + $macos)` -`var` | `+[NSExpression expressionForVariable:]` | `$variable` -`concat` | `mgl_join:` or `-[NSExpression mgl_expressionByAppendingExpression:]` | `mgl_join({'Old', ' ', 'MacDonald'})` -`downcase` | `lowercase:` | `lowercase('DOWNTOWN')` -`upcase` | `uppercase:` | `uppercase('Elysian Fields')` -`rgb` | `+[UIColor colorWithRed:green:blue:alpha:]` | -`rgba` | `+[UIColor colorWithRed:green:blue:alpha:]` | -`to-rgba` | | `CAST(noindex(var), 'NSArray')` -`-` | `from:subtract:` | `2 - 1` -`*` | `multiply:by:` | `1 * 2` -`/` | `divide:by:` | `1 / 2` -`%` | `modulus:by:` | -`^` | `raise:toPower:` | `2 ** 2` -`+` | `add:to:` | `1 + 2` -`abs` | `abs:` | `abs(-1)` -`acos` | `mgl_acos:` | `mgl_acos(1)` -`asin` | `mgl_asin:` | `mgl_asin(0)` -`atan` | `mgl_atan:` | `mgl_atan(20)` -`ceil` | `ceiling:` | `ceiling(0.99999)` -`cos` | `mgl_cos:` | `mgl_cos(0)` -`distance` | | `mgl_distanceFrom(%@)` where `%@` is an `MGLShape` -`e` | | `%@` representing `NSNumber` containing `M_E` -`floor` | `floor:` | `floor(-0.99999)` -`ln` | `ln:` | `ln(2)` -`ln2` | | `%@` representing `NSNumber` containing `M_LN2` -`log10` | `log:` | `log(1)` -`log2` | `mgl_log2:` | `mgl_log2(1024)` -`max` | `max:` | `max({1, 2, 2, 3, 4, 7, 9})` -`min` | `min:` | `min({1, 2, 2, 3, 4, 7, 9})` -`pi` | | `%@` representing `NSNumber` containing `M_PI` -`round` | `mgl_round:` | `mgl_round(1.5)` -`sin` | `mgl_sin:` | `mgl_sin(0)` -`sqrt` | `sqrt:` | `sqrt(2)` -`tan` | `mgl_tan:` | `mgl_tan(0)` -`zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoomLevel` -`heatmap-density` | `NSExpression.heatmapDensityVariableExpression` | `$heatmapDensity` -`line-progress` | `NSExpression.lineProgressVariableExpression` | `$lineProgress` -`format` | `+[NSExpression mgl_expressionForAttributedExpressions:]` or `mgl_attributed:` | `mgl_attributed({x, y, z})` - -For operators that have no corresponding `NSExpression` symbol, use the -`MGL_FUNCTION()` format string syntax. - -## Filtering sources - -You can filter a shape or vector tile source by setting the -`MGLVectorStyleLayer.predicate` property to an `NSPredicate` object. Below is a -table of style JSON operators and the corresponding operators used in the -predicate format string: - -In style JSON | In the format string ---------------------------|--------------------- -`["has", key]` | `key != nil` -`["!has", key]` | `key == nil` -`["==", key, value]` | `key == value` -`["!=", key, value]` | `key != value` -`[">", key, value]` | `key > value` -`[">=", key, value]` | `key >= value` -`["<", key, value]` | `key < value` -`["<=", key, value]` | `key <= value` -`["in", key, v0, …, vn]` | `key IN {v0, …, vn}` -`["!in", key, v0, …, vn]` | `NOT key IN {v0, …, vn}` -`["all", f0, …, fn]` | `p0 AND … AND pn` -`["any", f0, …, fn]` | `p0 OR … OR pn` -`["none", f0, …, fn]` | `NOT (p0 OR … OR pn)` - -## Specifying the text format - -The following format attributes are defined as `NSString` constans that you -can use to update the formatting of `MGLSymbolStyleLayer.text` property. - -In style JSON | In Objective-C | In Swift ---------------|-----------------------|--------- -`text-font` | `MGLFontNamesAttribute` | `.fontNamesAttribute` -`font-scale` | `MGLFontScaleAttribute` | `.fontScaleAttribute` -`text-color` | `MGLFontColorAttribute` | `.fontColorAttribute` - -See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for -a full description of the supported operators and operand types. diff --git a/platform/ios/platform/ios/docs/guides/Migrating to Expressions.md b/platform/ios/platform/ios/docs/guides/Migrating to Expressions.md deleted file mode 100644 index 172b3ebf1..000000000 --- a/platform/ios/platform/ios/docs/guides/Migrating to Expressions.md +++ /dev/null @@ -1,318 +0,0 @@ - - -# Migrating from Style Functions to Expressions - -[Runtime Styling](https://www.mapbox.com/ios-sdk/maps/overview/runtime-styling/) enables you to modify every aspect of the map’s appearance dynamically as a user interacts with your application. Developers can specify in advance how a layout or paint attribute will vary as the zoom level changes or how the appearance of individual features vary based on metadata provided by a content source. - -With Mapbox Maps SDK for iOS v4.0.0, style functions have been replaced with expressions. These provide even more tools for developers who want to style their maps dynamically. This guide outlines some tips for migrating from style functions to expressions, and offers an overview of some things that developers can do with expressions. - -An expression is represented at runtime by the `NSExpression` class. Expressions can be used to style paint and layout properties based on zoom level, data attributes, or a combination of the two. - -A constant expression can also be assigned to a style property. For example, the opacity of a fill style layer can be set to a constant value between 0 and 1. - -The documentation for each individual style layer property notes which non-constant expressions are enabled for that property. Style functions supported four interpolation modes: exponential, interval, categorical, and identity. - -This guide uses earthquake data from the [U.S. Geological Survey](https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php). Under each interpolation mode, the style function implementation will be shown, followed by the current syntax. - -For more information about how to work with GeoJSON data in our iOS SDK, please see our [working with GeoJSON data](working-with-geojson-data.html) guide. To learn more about supported expressions, see our ["Predicates and Expressions"](predicates-and-expressions.html) guide. The "Predicates and Expressions" guide also outlines Mapbox custom functions that can be used to dynamically style a map. - -## Stops -Stops are dictionary keys that are associated with layer attribute values. Constant values no longer need to be wrapped as style values when they are values in a stops dictionary. - - -Style function syntax: - -```swift -let stops = [ - 0: MGLStyleValue(rawValue: .yellow), - 2.5: MGLStyleValue(rawValue: .orange), - 5: MGLStyleValue(rawValue: .red), - 7.5: MGLStyleValue(rawValue: .blue), - 10: MGLStyleValue(rawValue: .white), -] -``` - -Current syntax: -```swift -// Swift sample on how to populate a stepping expression with multiple stops. -// Create a color ramp. -let stops: [NSNumber: UIColor] = [ - 0: .yellow, - 2.5: .orange, - 5: .red, - 7.5: .blue, - 10: .white, -] - -// Based on the zoom and `stops`, change the color. -var functionExpression = NSExpression(forMGLStepping: .zoomLevelVariable, - from: NSExpression(forConstantValue: stops[0]), - stops: NSExpression(forConstantValue: stops)) - -// Based on zoom and `stopsLineWidth`, set the Line width. -let initialValue = 4.0 -let stopsLineWidth = [ - 11.0: initialValue, - 14.0: 6.0, - 20.0: 18.0] - -functionExpression = NSExpression( - forMGLStepping: .zoomLevelVariable, - from: NSExpression(forConstantValue: initialValue), - stops: NSExpression(forConstantValue: stopsLineWidth) -) -``` - - -## Interpolation mode - -Style functions supported four interpolation modes: exponential/linear, interval, categorical, and identity. For more information about supported custom expressions, please see the "Predicates and Expressions" guide. - -### Linear - -`+[NSExpression(MGLAdditions) mgl_expressionForInterpolatingExpression:withCurveType:parameters:stops:]` takes the interpolation type as a parameter. If you previously used the default interpolation base, use the curve type `MGLExpressionInterpolationMode.linear`. See the [`mgl_interpolate:withCurveType:parameters:stops:`](predicates-and-expressions.html#code-mgl_interpolate-withcurvetype-parameters-stops-code) documentation for more details. - -The stops dictionary below, shows colors that continuously shift from yellow to orange to red to blue to white based on the attribute value. - -Style function syntax: - -```swift -let url = URL(string: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson")! -let symbolSource = MGLSource(identifier: "source") -let symbolLayer = MGLSymbolStyleLayer(identifier: "place-city-sm", source: symbolSource) - -let source = MGLShapeSource(identifier: "earthquakes", url: url, options: nil) -mapView.style?.addSource(source) - -let stops = [ - 0: MGLStyleValue(rawValue: .yellow), - 2.5: MGLStyleValue(rawValue: .orange), - 5: MGLStyleValue(rawValue: .red), - 7.5: MGLStyleValue(rawValue: .blue), - 10: MGLStyleValue(rawValue: .white), -] - -let layer = MGLCircleStyleLayer(identifier: "circles", source: source) -layer.circleColor = MGLStyleValue(interpolationMode: .exponential, - sourceStops: stops, - attributeName: "mag", - options: [.defaultValue: MGLStyleValue(rawValue: .green)]) -layer.circleRadius = MGLStyleValue(rawValue: 10) -mapView.style?.insertLayer(layer, below: symbolLayer) -``` - -Current syntax: - -```swift -let url = URL(string: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson")! -let symbolSource = MGLSource(identifier: "source") -let symbolLayer = MGLSymbolStyleLayer(identifier: "place-city-sm", source: symbolSource) - -let source = MGLShapeSource(identifier: "earthquakes", url: url, options: nil) -let mag = 1.0 // Update based on earthquake GeoJSON data -mapView.style?.addSource(source) - -let stops: [NSNumber: UIColor] = [ - 0: .yellow, - 2.5: .orange, - 5: .red, - 7.5: .blue, - 10: .white, -] - -let layer = MGLCircleStyleLayer(identifier: "circles", source: source) - -let circleExpression : NSExpression -if #available(iOS 15, *) { - circleExpression = NSExpression( - forMGLInterpolating: NSExpression(forConstantValue: mag), - curveType: .linear, - parameters: nil, - stops: NSExpression(forConstantValue: stops)) -} else { - // This works up to iOS 14.5 - circleExpression = NSExpression( - format: "mgl_interpolate:withCurveType:parameters:stops:(mag, 'linear', nil, %@)", - stops) -} - -layer.circleColor = circleExpression -layer.circleRadius = NSExpression(forConstantValue: 10) -mapView.style?.insertLayer(layer, below: symbolLayer) -``` - -### Exponential - -If you previously used an interpolation base greater than `0` (other than `1`), you can use `MGLExpressionInterpolationMode.exponential` as the curve type for `+[NSExpression(MGLAdditions) mgl_expressionForInterpolatingExpression:withCurveType:parameters:stops:]` or `'exponential'` as the curve type for [`mgl_interpolate:withCurveType:parameters:stops:`](predicates-and-expressions.html#code-mgl_interpolate-withcurvetype-parameters-stops-code). The `parameters` argument takes that interpolation base. This interpolates between values exponentially, creating an accelerated ramp effect. - -Here’s a visualization from Mapbox Studio (see [Mapbox Studio and iOS](https://www.mapbox.com/ios-sdk/maps/overview/mapbox-studio/)) comparing interpolation base values of `1.5` and `0.5` based on zoom. In order to convert camera style functions, use `$zoomLevel` or `MGL_FUNCTION('zoomLevel')` as the attribute key. - - - - -The example below increases a layer’s `circleRadius` exponentially based on a map’s zoom level. The interpolation base is `1.5`. - -Style function syntax: - -```swift -let stops = [ - 12: MGLStyleValue(rawValue: 0.5), - 14: MGLStyleValue(rawValue: 2), - 18: MGLStyleValue(rawValue: 18), -] - -layer.circleRadius = MGLStyleValue(interpolationMode: .exponential, - cameraStops: stops, - options: [.interpolationBase: 1.5]) -``` - -Current syntax: - -```swift -let stops = [ - 12: 0.5, - 14: 2, - 18: 18, -] - -layer.circleRadius = NSExpression(forMGLInterpolating: .zoomLevelVariable, - curveType: .exponential, - parameters: NSExpression(forConstantValue: 1.5), - stops: NSExpression(forConstantValue: stops)) -``` - -### Interval - -Steps, or intervals, create a range using the keys from the stops dictionary. The range is from the given key to just less than the next key. The attribute values that fall into that range are then styled using the layout or paint value assigned to that key. You can use the `+[NSExpression(MGLAdditions) mgl_expressionForSteppingExpression:fromExpression:stops:]` method or the custom function [`mgl_step:from:stops:`](predicates-and-expressions.html#code-mgl_step-from-stops-code) for cases where you previously used interval interpolation mode. The first parameter takes the feature attribute name and the second parameter (`from:`) optionally takes the default or fallback value for that function. The final parameter takes a stops dictionary as an argument. - -When we use the stops dictionary given above with an `'mgl_step:from:stops:'`, we create ranges where earthquakes with a magnitude of 0 to just less than 2.5 would be yellow, 2.5 to just less than 5 would be orange, and so on. - -Style function syntax: - -```swift -let stops = [ - 0: MGLStyleValue(rawValue: .yellow), - 2.5: MGLStyleValue(rawValue: .orange), - 5: MGLStyleValue(rawValue: .red), - 7.5: MGLStyleValue(rawValue: .blue), - 10: MGLStyleValue(rawValue: .white), -] - -layer.circleColor = MGLStyleValue(interpolationMode: .interval, - sourceStops: stops, - attributeName: "mag", - options: [.defaultValue: MGLStyleValue(rawValue: .green)]) -```` - -Current syntax: - -```swift -let stops: [NSNumber: UIColor] = [ - 0: .yellow, - 2.5: .orange, - 5: .red, - 7.5: .blue, - 10: .white, -] - -layer.circleColor = NSExpression(forMGLStepping: .zoomLevelVariable, - from: NSExpression(forConstantValue: UIColor.green), - stops: NSExpression(forConstantValue: stops)) -``` - -### Categorical - -Categorical interpolation mode took a stops dictionary. If the value for a specified feature attribute name matched one in that stops dictionary, the style value for that attribute value would be used. Categorical style functions can now be replaced with `MGL_MATCH`. - -`MGL_MATCH` takes an initial condition, which in this case is an attribute key. This is followed by possible matches for that key and the value to assign to the layer property if there is a match. The final argument can be a default style value that is to be used if none of the specified values match. - -There are three main types of events in the USGS dataset: earthquakes, explosions, and quarry blasts. In this case, the color of the circle layer will be determined by the type of event, with a default value of blue to catch any events that do not fall into any of those categories. - -Style function syntax: - -```swift -let categoricalStops = [ - "earthquake": MGLStyleValue(rawValue: .orange), - "explosion": MGLStyleValue(rawValue: .red), - "quarry blast": MGLStyleValue(rawValue: .yellow), -] - -layer.circleColor = MGLStyleValue(interpolationMode: .categorical, - sourceStops: categoricalStops, - attributeName: "type", - options: [.defaultValue: MGLStyleValue(rawValue: .blue)]) -``` - -Current syntax: -```swift -// Category type -let type = NSExpression(forConstantValue: "type") - -// Categories -let earthquake = NSExpression(forConstantValue: "earthquake") -let explosion = NSExpression(forConstantValue: "explosion") -let quarryBlast = NSExpression(forConstantValue: "quarry blast") - -let defaultColor = NSExpression(forConstantValue: UIColor.blue) -let orange = NSExpression(forConstantValue: UIColor.orange) -let red = NSExpression(forConstantValue: UIColor.red) -let yellow = NSExpression(forConstantValue: UIColor.yellow) - -XCTExpectFailure("#331") -layer.circleColor = NSExpression(forMGLMatchingKey: type, - in: [earthquake:orange, explosion:red, quarryBlast:yellow], - default: defaultColor) -``` - -If your use case does not require a default value, you can either apply a predicate to your layer prior to styling it, or use the format string `"valueForKeyPath:"`. - -### Identity - -Identity interpolation mode used the attribute’s value as the style layer property value. In this example, you might set the `circleRadius` to the earthquake’s magnitude. In order to use a feature attribute value to style a layer property, set the property value to `[NSExpression expressionForKeyPath:]`, which take the feature attribute name as an argument. - -Style function syntax: - -```swift -layer.circleRadius = MGLStyleValue(interpolationMode: .identity, - sourceStops: nil, - attributeName: "mag", - options: [.defaultValue: MGLStyleValue(rawValue: 0)]) -``` - -Current syntax: -```swift -layer.circleRadius = NSExpression(forKeyPath: "mag") -``` - -![identity mode](img/data-driven-styling/identity.png) - -Some built-in functions can be applied to attribute values to style layer property values. To set the circle radius to three times the earthquake’s magnitude, create a `multiply:by:` function that takes the attribute value and the multiplier as arguments, or use a format string. - -```swift -layer.circleRadius = NSExpression(forFunction: "multiply:by:", arguments: [NSExpression(forKeyPath: "mag"), 3]) -``` - -![multiply magnitude](img/data-driven-styling/multiply.png) - -You can also cast attribute values in order to use them. One example is to cast an integer as an `NSString` and use it as a text value. - -```swift -let magnitudeLayer = MGLSymbolStyleLayer(identifier: "mag-layer", source: source) -magnitudeLayer.text = NSExpression(format: "CAST(mag, 'NSString')") -mapView.style?.addLayer(magnitudeLayer) -``` - -![cast a value](img/data-driven-styling/cast.png) - -### Constant Values - -For constant values that do not necessarily change based on camera or attribute values, use `[NSExpression expressionForConstantValue:]` (previously `[MGLStyleValue valueWithRawValue:]`). - -## Resources - -* [USGS Earthquake Feed](https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php) -* [For Style Authors](for-style-authors.html) -* [Predicates and Expressions](predicates-and-expressions.html) diff --git a/platform/ios/platform/ios/docs/guides/Tile URL Templates.md b/platform/ios/platform/ios/docs/guides/Tile URL Templates.md deleted file mode 100644 index 17fe5926f..000000000 --- a/platform/ios/platform/ios/docs/guides/Tile URL Templates.md +++ /dev/null @@ -1,99 +0,0 @@ - -# Tile URL Templates - -`MGLTileSource` objects, specifically `MGLRasterTileSource` and -`MGLVectorTileSource` objects, can be created using an initializer that accepts -an array of tile URL templates. Tile URL templates are strings that specify the -URLs of the vector tiles or raster tile images to load. A template resembles an -absolute URL, but with any number of placeholder strings that the source -evaluates based on the tile it needs to load. For example: - -* `http://www.example.com/tiles/{z}/{x}/{y}.pbf` could be - evaluated as `http://www.example.com/tiles/14/6/9.pbf`. -* `http://www.example.com/tiles/{z}/{x}/{y}{ratio}.png` could be - evaluated as `http://www.example.com/tiles/14/6/9@2x.png`. - -Tile URL templates are also used to define tilesets in TileJSON manifests or -[`raster`](https://maplibre.org/maplibre-gl-js-docs/style-spec/#sources-raster-tiles) -and -[`vector`](https://maplibre.org/maplibre-gl-js-docs/style-spec/#sources-vector-tiles) -sources in style JSON files. See the -[TileJSON specification](https://github.com/mapbox/tilejson-spec/tree/master/2.2.0) -for information about tile URL templates in the context of a TileJSON or style -JSON file. - -Tile sources support the following placeholder strings in tile URL templates, -all of which are optional: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Placeholder stringDescription
{x}The index of the tile along the map’s x axis according to Spherical - Mercator projection. If the value is 0, the tile’s left edge corresponds - to the 180th meridian west. If the value is 2z−1, - the tile’s right edge corresponds to the 180th meridian east.
{y}The index of the tile along the map’s y axis according to Spherical - Mercator projection. If the value is 0, the tile’s tile edge corresponds - to arctan(sinh(π)), or approximately 85.0511 degrees north. If the value - is 2z−1, the tile’s bottom edge corresponds to - −arctan(sinh(π)), or approximately 85.0511 degrees south. The y axis is - inverted if the options parameter contains - MGLTileSourceOptionTileCoordinateSystem with a value of - MGLTileCoordinateSystemTMS.
{z}The tile’s zoom level. At zoom level 0, each tile covers the entire - world map; at zoom level 1, it covers ¼ of the world; at zoom level 2, - 1⁄16 of the world, and so on. For tiles loaded by - a MGLRasterTileSource object, whether the tile zoom level - matches the map’s current zoom level depends on the value of the - source’s tile size as specified in the - MGLTileSourceOptionTileSize key of the options - parameter.
{bbox-epsg-3857}The tile’s bounding box, expressed as a comma-separated list of the - tile’s western, southern, eastern, and northern extents according to - Spherical Mercator (EPSG:3857) projection. The bounding box is typically - used with map services conforming to the - Web Map Service - protocol.
{quadkey}A quadkey indicating both the tile’s location and its zoom level. The - quadkey is typically used with - Bing Maps. -
{ratio}A suffix indicating the resolution of the tile image. The suffix is the - empty string for standard resolution displays and @2x for - Retina displays, including displays for which UIScreen.scale - is 3. -
{prefix}Two hexadecimal digits chosen such that each visible tile has a - different prefix. The prefix is typically used for domain sharding.
- -For more information about the `{x}`, `{y}`, and `{z}` placeholder strings, -consult the -[OpenStreetMap Wiki](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames). diff --git a/platform/ios/platform/macos/docs/guides/For Style Authors.md b/platform/ios/platform/macos/docs/guides/For Style Authors.md deleted file mode 100644 index 2c32bb50f..000000000 --- a/platform/ios/platform/macos/docs/guides/For Style Authors.md +++ /dev/null @@ -1,430 +0,0 @@ - -# Information for Style Authors - -A _style_ defines a map view’s content and appearance. If you’ve authored a -style using -[Mapbox Studio’s Styles editor](https://www.mapbox.com/studio/styles/) or as -JSON in a text editor, you can use that style in this SDK and manipulate it -afterwards in code. This document provides information you can use to ensure a -seamless transition from Mapbox Studio to your application. - -## Designing for macOS - -When designing your style, consider the context in which your application shows -the style. There are a number of considerations specific to macOS that may -not be obvious when designing your style in Mapbox Studio on the Web. A map view -is essentially a graphical user interface element, so many of same issues in -user interface design also apply when designing a map style. - -### Color - -Ensure sufficient contrast in your application’s user interface when your map -style is present. Standard user interface elements such as toolbars, sidebars, -and sheets often overlap the map view with a translucent, blurred background, so -make sure the contents of these elements remain legible with the map view -underneath. -If you intend your style to be used in the dark, consider the impact that Night -Shift may have on your style’s colors. - -### Typography and graphics - - -Design sprite images and choose font weights that look crisp on both -standard-resolution displays and Retina displays. This SDK supports the same -resolutions as macOS. -Standard-resolution displays are often found on external monitors. Even with -built-in screens, some of your users may use the Larger Text option in Display -Preferences, which is essentially standard resolution, to make text easier to -read. - -Icon and text labels should be legible regardless of the map’s orientation. -By default, this SDK makes it easy for your users to rotate or tilt the map -using multitouch trackpad gestures or keyboard shortcuts. -If you do not intend your design to accommodate rotation and tilting, disable -these gestures using the `MGLMapView.rotateEnabled` and -`MGLMapView.pitchEnabled` properties, respectively, or the corresponding -inspectables in Interface Builder. - -### Interactivity - -Pay attention to whether elements of your style appear to be interactive. -An icon with a shadow or shading effect may appear to be clickable. -You can make an icon or text label interactive by installing a gesture -recognizer and performing feature querying (e.g., -`-[MGLMapView visibleFeaturesAtPoint:]`) to get details about the selected -feature. -You can install cursor or tooltip tracking rectangles to indicate interactive -features as an alternative to prominent hover effects. - -Make sure your users can easily distinguish any interactive elements from the -surrounding map, such as pins or a route line. If your application supports -printing, consider using the -[runtime styling API](#manipulating-the-style-at-runtime) to optimize your style -for ink economy before printing the map view. - -For more information about user interface design, consult Apple’s -[_macOS Human Interface Guidelines_](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/OSXHIGuidelines/). - -## Applying your style - -You set an `MGLMapView` object’s style either in code, by setting the -`MGLMapView.styleURL` property, or in Interface Builder, by setting the “Style -URL” inspectable. The URL must point to a local or remote style JSON file. The -style JSON file format is defined by the -[Mapbox Style Specification](https://www.mapbox.com/mapbox-gl-style-spec/). This -SDK supports the functionality defined by version 8 of the specification unless -otherwise noted in the -[style specification documentation](https://www.mapbox.com/mapbox-gl-style-spec/). - -## Manipulating the style at runtime - -The _runtime styling API_ enables you to modify every aspect of a style -dynamically as a user interacts with your application. The style itself is -represented at runtime by an `MGLStyle` object, which provides access to various -`MGLSource` and `MGLStyleLayer` objects that represent content sources and style -layers, respectively. - -The names of runtime styling classes and properties on macOS are generally -consistent with the style specification and Mapbox Studio’s Styles editor. Any -exceptions are listed in this document. - -To avoid conflicts with Objective-C keywords or Cocoa terminology, this SDK uses -the following terms for concepts defined in the style specification: - -In the style specification | In the SDK ----------------------------|--------- -bounds | coordinate bounds -filter | predicate -function type | interpolation mode -id | identifier -image | style image -layer | style layer -property | attribute -SDF icon | template image -source | content source - -## Specifying the map’s content - -Each source defined by a style JSON file is represented at runtime by a content -source object that you can use to initialize new style layers. The content -source object is a member of one of the following subclasses of `MGLSource`: - -In style JSON | In the SDK ---------------|----------- -`vector` | `MGLVectorTileSource` -`raster` | `MGLRasterTileSource` -`raster-dem` | `MGLRasterDEMSource` -`geojson` | `MGLShapeSource` -`image` | `MGLImageSource` - -`canvas` and `video` sources are not supported. - -### Tile sources - -Raster and vector tile sources may be defined in TileJSON configuration files. -This SDK supports the properties defined in the style specification, which are a -subset of the keys defined in version 2.1.0 of the -[TileJSON](https://github.com/mapbox/tilejson-spec/tree/master/2.1.0) -specification. As an alternative to authoring a custom TileJSON file, you may -supply various tile source options when creating a raster or vector tile source. -These options are detailed in the `MGLTileSourceOption` documentation: - -In style JSON | In TileJSON | In the SDK ---------------|---------------|----------- -`url` | — | `configurationURL` parameter in `-[MGLTileSource initWithIdentifier:configurationURL:]` -`tiles` | `tiles` | `tileURLTemplates` parameter in `-[MGLTileSource initWithIdentifier:tileURLTemplates:options:]` -`minzoom` | `minzoom` | `MGLTileSourceOptionMinimumZoomLevel` -`maxzoom` | `maxzoom` | `MGLTileSourceOptionMaximumZoomLevel` -`bounds` | `bounds` | `MGLTileSourceOptionCoordinateBounds` -`tileSize` | — | `MGLTileSourceOptionTileSize` -`attribution` | `attribution` | `MGLTileSourceOptionAttributionHTMLString` (but consider specifying `MGLTileSourceOptionAttributionInfos` instead for improved security) -`scheme` | `scheme` | `MGLTileSourceOptionTileCoordinateSystem` -`encoding` | – | `MGLTileSourceOptionDEMEncoding` - -### Shape sources - -Shape sources also accept various options. These options are detailed in the -`MGLShapeSourceOption` documentation: - -In style JSON | In the SDK ------------------|----------- -`data` | `url` parameter in `-[MGLShapeSource initWithIdentifier:URL:options:]` -`maxzoom` | `MGLShapeSourceOptionMaximumZoomLevel` -`buffer` | `MGLShapeSourceOptionBuffer` -`tolerance` | `MGLShapeSourceOptionSimplificationTolerance` -`cluster` | `MGLShapeSourceOptionClustered` -`clusterRadius` | `MGLShapeSourceOptionClusterRadius` -`clusterMaxZoom` | `MGLShapeSourceOptionMaximumZoomLevelForClustering` -`lineMetrics` | `MGLShapeSourceOptionLineDistanceMetrics` - -To create a shape source from local GeoJSON data, first -[convert the GeoJSON data into a shape](working-with-geojson-data.html#converting-geojson-data-into-shape-objects), -then use the `-[MGLShapeSource initWithIdentifier:shape:options:]` method. - -### Image sources - -Image sources accept a non-axis aligned quadrilateral as their geographic coordinates. -These coordinates, in `MGLCoordinateQuad`, are described in counterclockwise order, -in contrast to the clockwise order defined in the style specification. - -## Configuring the map content’s appearance - -Each layer defined by the style JSON file is represented at runtime by a style -layer object, which you can use to refine the map’s appearance. The style layer -object is a member of one of the following subclasses of `MGLStyleLayer`: - -In style JSON | In the SDK ---------------|----------- -`background` | `MGLBackgroundStyleLayer` -`circle` | `MGLCircleStyleLayer` -`fill` | `MGLFillStyleLayer` -`fill-extrusion` | `MGLFillExtrusionStyleLayer` -`heatmap` | `MGLHeatmapStyleLayer` -`hillshade` | `MGLHillshadeStyleLayer` -`line` | `MGLLineStyleLayer` -`raster` | `MGLRasterStyleLayer` -`symbol` | `MGLSymbolStyleLayer` - -You configure layout and paint attributes by setting properties on these style -layer objects. The property names generally correspond to the style JSON -properties, except for the use of camelCase instead of kebab-case. Properties -whose names differ from the style specification are listed below: - -### Circle style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`circle-pitch-scale` | `MGLCircleStyleLayer.circleScaleAlignment` | `MGLCircleStyleLayer.circleScaleAlignment` -`circle-translate` | `MGLCircleStyleLayer.circleTranslation` | `MGLCircleStyleLayer.circleTranslation` -`circle-translate-anchor` | `MGLCircleStyleLayer.circleTranslationAnchor` | `MGLCircleStyleLayer.circleTranslationAnchor` - -### Fill style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`fill-antialias` | `MGLFillStyleLayer.fillAntialiased` | `MGLFillStyleLayer.isFillAntialiased` -`fill-translate` | `MGLFillStyleLayer.fillTranslation` | `MGLFillStyleLayer.fillTranslation` -`fill-translate-anchor` | `MGLFillStyleLayer.fillTranslationAnchor` | `MGLFillStyleLayer.fillTranslationAnchor` - -### Fill extrusion style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`fill-extrusion-vertical-gradient` | `MGLFillExtrusionStyleLayer.fillExtrusionHasVerticalGradient` | `MGLFillExtrusionStyleLayer.fillExtrusionHasVerticalGradient` -`fill-extrusion-translate` | `MGLFillExtrusionStyleLayer.fillExtrusionTranslation` | `MGLFillExtrusionStyleLayer.fillExtrusionTranslation` -`fill-extrusion-translate-anchor` | `MGLFillExtrusionStyleLayer.fillExtrusionTranslationAnchor` | `MGLFillExtrusionStyleLayer.fillExtrusionTranslationAnchor` - -### Line style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`line-dasharray` | `MGLLineStyleLayer.lineDashPattern` | `MGLLineStyleLayer.lineDashPattern` -`line-translate` | `MGLLineStyleLayer.lineTranslation` | `MGLLineStyleLayer.lineTranslation` -`line-translate-anchor` | `MGLLineStyleLayer.lineTranslationAnchor` | `MGLLineStyleLayer.lineTranslationAnchor` - -### Raster style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`raster-brightness-max` | `MGLRasterStyleLayer.maximumRasterBrightness` | `MGLRasterStyleLayer.maximumRasterBrightness` -`raster-brightness-min` | `MGLRasterStyleLayer.minimumRasterBrightness` | `MGLRasterStyleLayer.minimumRasterBrightness` -`raster-hue-rotate` | `MGLRasterStyleLayer.rasterHueRotation` | `MGLRasterStyleLayer.rasterHueRotation` -`raster-resampling` | `MGLRasterStyleLayer.rasterResamplingMode` | `MGLRasterStyleLayer.rasterResamplingMode` - -### Symbol style layers - -In style JSON | In Objective-C | In Swift ---------------|----------------|--------- -`icon-allow-overlap` | `MGLSymbolStyleLayer.iconAllowsOverlap` | `MGLSymbolStyleLayer.iconAllowsOverlap` -`icon-ignore-placement` | `MGLSymbolStyleLayer.iconIgnoresPlacement` | `MGLSymbolStyleLayer.iconIgnoresPlacement` -`icon-image` | `MGLSymbolStyleLayer.iconImageName` | `MGLSymbolStyleLayer.iconImageName` -`icon-optional` | `MGLSymbolStyleLayer.iconOptional` | `MGLSymbolStyleLayer.isIconOptional` -`icon-rotate` | `MGLSymbolStyleLayer.iconRotation` | `MGLSymbolStyleLayer.iconRotation` -`icon-size` | `MGLSymbolStyleLayer.iconScale` | `MGLSymbolStyleLayer.iconScale` -`icon-keep-upright` | `MGLSymbolStyleLayer.keepsIconUpright` | `MGLSymbolStyleLayer.keepsIconUpright` -`text-keep-upright` | `MGLSymbolStyleLayer.keepsTextUpright` | `MGLSymbolStyleLayer.keepsTextUpright` -`text-max-angle` | `MGLSymbolStyleLayer.maximumTextAngle` | `MGLSymbolStyleLayer.maximumTextAngle` -`text-max-width` | `MGLSymbolStyleLayer.maximumTextWidth` | `MGLSymbolStyleLayer.maximumTextWidth` -`symbol-avoid-edges` | `MGLSymbolStyleLayer.symbolAvoidsEdges` | `MGLSymbolStyleLayer.symbolAvoidsEdges` -`text-field` | `MGLSymbolStyleLayer.text` | `MGLSymbolStyleLayer.text` -`text-allow-overlap` | `MGLSymbolStyleLayer.textAllowsOverlap` | `MGLSymbolStyleLayer.textAllowsOverlap` -`text-font` | `MGLSymbolStyleLayer.textFontNames` | `MGLSymbolStyleLayer.textFontNames` -`text-size` | `MGLSymbolStyleLayer.textFontSize` | `MGLSymbolStyleLayer.textFontSize` -`text-ignore-placement` | `MGLSymbolStyleLayer.textIgnoresPlacement` | `MGLSymbolStyleLayer.textIgnoresPlacement` -`text-justify` | `MGLSymbolStyleLayer.textJustification` | `MGLSymbolStyleLayer.textJustification` -`text-optional` | `MGLSymbolStyleLayer.textOptional` | `MGLSymbolStyleLayer.isTextOptional` -`text-rotate` | `MGLSymbolStyleLayer.textRotation` | `MGLSymbolStyleLayer.textRotation` -`text-writing-mode` | `MGLSymbolStyleLayer.textWritingModes` | `MGLSymbolStyleLayer.textWritingModes` -`icon-translate` | `MGLSymbolStyleLayer.iconTranslation` | `MGLSymbolStyleLayer.iconTranslation` -`icon-translate-anchor` | `MGLSymbolStyleLayer.iconTranslationAnchor` | `MGLSymbolStyleLayer.iconTranslationAnchor` -`text-translate` | `MGLSymbolStyleLayer.textTranslation` | `MGLSymbolStyleLayer.textTranslation` -`text-translate-anchor` | `MGLSymbolStyleLayer.textTranslationAnchor` | `MGLSymbolStyleLayer.textTranslationAnchor` - -## Setting attribute values - -Each property representing a layout or paint attribute is set to an -`NSExpression` object. `NSExpression` objects play the same role as -[expressions in the Mapbox Style Specification](https://maplibre.org/maplibre-gl-js-docs/style-spec/#expressions), -but you create the former using a very different syntax. `NSExpression`’s format -string syntax is reminiscent of a spreadsheet formula or an expression in a -database query. See the -“[Predicates and Expressions](predicates-and-expressions.html)” guide for an -overview of the expression support in this SDK. This SDK no longer supports -style functions; use expressions instead. - -### Constant values in expressions - -In contrast to the JSON type that the style specification defines for each -layout or paint property, the style value object often contains a more specific -Foundation or Cocoa type. General rules for attribute types are listed below. -Pay close attention to the SDK documentation for the attribute you want to get -or set. - -In style JSON | In Objective-C | In Swift ---------------|-----------------------|--------- -Color | `NSColor` | `NSColor` -Enum | `NSString` | `String` -String | `NSString` | `String` -Boolean | `NSNumber.boolValue` | `NSNumber.boolValue` -Number | `NSNumber.floatValue` | `NSNumber.floatValue` -Array (`-dasharray`) | `NSArray` | `[Float]` -Array (`-font`) | `NSArray` | `[String]` -Array (`-offset`, `-translate`) | `NSValue` containing `CGVector` | `NSValue` containing `CGVector` -Array (`-padding`) | `NSValue.edgeInsetsValue` | `NSValue.edgeInsetsValue` - -For padding attributes, note that the arguments to -`NSEdgeInsetsMake()` in Objective-C and `EdgeInsets(top:left:bottom:right:)` in -Swift -are specified in counterclockwise order, in contrast to the clockwise order -defined by the style specification. - -Additionally, on macOS, a screen coordinate of (0, 0) is located at the -lower-left corner of the screen. Therefore, a positive `CGVector.dy` means an -offset or translation upward, while a negative `CGVector.dy` means an offset or -translation downward. This is the reverse of how `CGVector` is interpreted on -iOS. - -### Expression operators - -Many expression operators defined in the style specification have corresponding -symbols to be used with the `+[NSExpression expressionWithFormat:]`, -`+[NSExpression expressionForFunction:arguments:]`, or -`+[NSExpression expressionForFunction:selectorName:arguments:]` method: - -In style specification | Method, function, or predicate type | Format string syntax ------------------------|-------------------------------------|--------------------- -`array` | | -`boolean` | | -`collator` | `NSComparisonPredicateOptions` | `'Québec' =[cd] 'QUEBEC'` -`literal` | `+[NSExpression expressionForConstantValue:]` | `%@` representing `NSArray` or `NSDictionary` -`number` | | -`string` | | -`to-boolean` | `boolValue` | -`to-color` | | `CAST(var, 'NSColor')` -`to-number` | `mgl_numberWithFallbackValues:` | `CAST(zipCode, 'NSNumber')` -`to-string` | `stringValue` | `CAST(ele, 'NSString')` -`typeof` | | -`geometry-type` | `NSExpression.geometryTypeVariableExpression` | `$geometryType` -`id` | `NSExpression.featureIdentifierVariableExpression` | `$featureIdentifier` -`properties` | `NSExpression.featureAttributesVariableExpression` | `$featureAttributes` -`at` | `objectFrom:withIndex:` | `array[n]` -`get` | `+[NSExpression expressionForKeyPath:]` | Key path -`has` | `mgl_does:have:` | `mgl_does:have:(self, 'key')` -`in` | `NSInPredicateOperatorType` | `needle IN haystack` or `haystack CONTAINS needle` or `ANY haystack = needle` -`length` | `count:` | `count({1, 2, 2, 3, 4, 7, 9})` -`!` | `NSNotPredicateType` | `NOT (p0 OR … OR pn)` -`!=` | `NSNotEqualToPredicateOperatorType` | `key != value` -`<` | `NSLessThanPredicateOperatorType` | `key < value` -`<=` | `NSLessThanOrEqualToPredicateOperatorType` | `key <= value` -`==` | `NSEqualToPredicateOperatorType` | `key == value` -`>` | `NSGreaterThanPredicateOperatorType` | `key > value` -`>=` | `NSGreaterThanOrEqualToPredicateOperatorType` | `key >= value` -`all` | `NSAndPredicateType` | `p0 AND … AND pn` -`any` | `NSOrPredicateType` | `p0 OR … OR pn` -`case` | `+[NSExpression expressionForConditional:trueExpression:falseExpression:]` or `MGL_IF` or `+[NSExpression mgl_expressionForConditional:trueExpression:falseExpresssion:]` | `TERNARY(1 = 2, YES, NO)` or `MGL_IF(1 = 2, YES, 2 = 2, YES, NO)` -`coalesce` | `mgl_coalesce:` | `mgl_coalesce({x, y, z})` -`match` | `MGL_MATCH` or `+[NSExpression mgl_expressionForMatchingExpression:inDictionary:defaultExpression:]` | `MGL_MATCH(x, 0, 'zero match', 1, 'one match', 'two match', 'default')` -`within` | `NSInPredicateOperatorType` | `SELF IN %@` or `%@ CONTAINS SELF` where `%@` is an `MGLShape` -`interpolate` | `mgl_interpolate:withCurveType:parameters:stops:` or `+[NSExpression mgl_expressionForInterpolatingExpression:withCurveType:parameters:stops:]` | -`step` | `mgl_step:from:stops:` or `+[NSExpression mgl_expressionForSteppingExpression:fromExpression:stops:]` | -`let` | `mgl_expressionWithContext:` | `MGL_LET('ios', 11, 'macos', 10.13, $ios + $macos)` -`var` | `+[NSExpression expressionForVariable:]` | `$variable` -`concat` | `mgl_join:` or `-[NSExpression mgl_expressionByAppendingExpression:]` | `mgl_join({'Old', ' ', 'MacDonald'})` -`downcase` | `lowercase:` | `lowercase('DOWNTOWN')` -`upcase` | `uppercase:` | `uppercase('Elysian Fields')` -`rgb` | `+[NSColor colorWithCalibratedRed:green:blue:alpha:]` | -`rgba` | `+[NSColor colorWithCalibratedRed:green:blue:alpha:]` | -`to-rgba` | | `CAST(noindex(var), 'NSArray')` -`-` | `from:subtract:` | `2 - 1` -`*` | `multiply:by:` | `1 * 2` -`/` | `divide:by:` | `1 / 2` -`%` | `modulus:by:` | -`^` | `raise:toPower:` | `2 ** 2` -`+` | `add:to:` | `1 + 2` -`abs` | `abs:` | `abs(-1)` -`acos` | `mgl_acos:` | `mgl_acos(1)` -`asin` | `mgl_asin:` | `mgl_asin(0)` -`atan` | `mgl_atan:` | `mgl_atan(20)` -`ceil` | `ceiling:` | `ceiling(0.99999)` -`cos` | `mgl_cos:` | `mgl_cos(0)` -`distance` | | `mgl_distanceFrom(%@)` where `%@` is an `MGLShape` -`e` | | `%@` representing `NSNumber` containing `M_E` -`floor` | `floor:` | `floor(-0.99999)` -`ln` | `ln:` | `ln(2)` -`ln2` | | `%@` representing `NSNumber` containing `M_LN2` -`log10` | `log:` | `log(1)` -`log2` | `mgl_log2:` | `mgl_log2(1024)` -`max` | `max:` | `max({1, 2, 2, 3, 4, 7, 9})` -`min` | `min:` | `min({1, 2, 2, 3, 4, 7, 9})` -`pi` | | `%@` representing `NSNumber` containing `M_PI` -`round` | `mgl_round:` | `mgl_round(1.5)` -`sin` | `mgl_sin:` | `mgl_sin(0)` -`sqrt` | `sqrt:` | `sqrt(2)` -`tan` | `mgl_tan:` | `mgl_tan(0)` -`zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoomLevel` -`heatmap-density` | `NSExpression.heatmapDensityVariableExpression` | `$heatmapDensity` -`line-progress` | `NSExpression.lineProgressVariableExpression` | `$lineProgress` -`format` | `+[NSExpression mgl_expressionForAttributedExpressions:]` or `mgl_attributed:` | `mgl_attributed({x, y, z})` - -For operators that have no corresponding `NSExpression` symbol, use the -`MGL_FUNCTION()` format string syntax. - -## Filtering sources - -You can filter a shape or vector tile source by setting the -`MGLVectorStyleLayer.predicate` property to an `NSPredicate` object. Below is a -table of style JSON operators and the corresponding operators used in the -predicate format string: - -In style JSON | In the format string ---------------------------|--------------------- -`["has", key]` | `key != nil` -`["!has", key]` | `key == nil` -`["==", key, value]` | `key == value` -`["!=", key, value]` | `key != value` -`[">", key, value]` | `key > value` -`[">=", key, value]` | `key >= value` -`["<", key, value]` | `key < value` -`["<=", key, value]` | `key <= value` -`["in", key, v0, …, vn]` | `key IN {v0, …, vn}` -`["!in", key, v0, …, vn]` | `NOT key IN {v0, …, vn}` -`["all", f0, …, fn]` | `p0 AND … AND pn` -`["any", f0, …, fn]` | `p0 OR … OR pn` -`["none", f0, …, fn]` | `NOT (p0 OR … OR pn)` - -## Specifying the text format - -The following format attributes are defined as `NSString` constans that you -can use to update the formatting of `MGLSymbolStyleLayer.text` property. - -In style JSON | In Objective-C | In Swift ---------------|-----------------------|--------- -`text-font` | `MGLFontNamesAttribute` | `.fontNamesAttribute` -`font-scale` | `MGLFontScaleAttribute` | `.fontScaleAttribute` -`text-color` | `MGLFontColorAttribute` | `.fontColorAttribute` - -See the “[Predicates and Expressions](predicates-and-expressions.html)” guide for -a full description of the supported operators and operand types. diff --git a/platform/ios/platform/macos/docs/guides/Migrating to Expressions.md b/platform/ios/platform/macos/docs/guides/Migrating to Expressions.md deleted file mode 100644 index eb60457c5..000000000 --- a/platform/ios/platform/macos/docs/guides/Migrating to Expressions.md +++ /dev/null @@ -1,317 +0,0 @@ - - -# Migrating from Style Functions to Expressions - -[Runtime Styling](https://www.mapbox.com/ios-sdk/maps/overview/runtime-styling/) enables you to modify every aspect of the map’s appearance dynamically as a user interacts with your application. Developers can specify in advance how a layout or paint attribute will vary as the zoom level changes or how the appearance of individual features vary based on metadata provided by a content source. - -With Mapbox Maps SDK for macOS v0.7.0, style functions have been replaced with expressions. These provide even more tools for developers who want to style their maps dynamically. This guide outlines some tips for migrating from style functions to expressions, and offers an overview of some things that developers can do with expressions. - -An expression is represented at runtime by the `NSExpression` class. Expressions can be used to style paint and layout properties based on zoom level, data attributes, or a combination of the two. - -A constant expression can also be assigned to a style property. For example, the opacity of a fill style layer can be set to a constant value between 0 and 1. - -The documentation for each individual style layer property notes which non-constant expressions are enabled for that property. Style functions supported four interpolation modes: exponential, interval, categorical, and identity. - -This guide uses earthquake data from the [U.S. Geological Survey](https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php). Under each interpolation mode, the style function implementation will be shown, followed by the current syntax. - -For more information about how to work with GeoJSON data in our macOS SDK, please see our [working with GeoJSON data](working-with-geojson-data.html) guide. To learn more about supported expressions, see our ["Predicates and Expressions"](predicates-and-expressions.html) guide. The "Predicates and Expressions" guide also outlines Mapbox custom functions that can be used to dynamically style a map. - -## Stops -Stops are dictionary keys that are associated with layer attribute values. Constant values no longer need to be wrapped as style values when they are values in a stops dictionary. - - -Style function syntax: - -```swift -let stops = [ - 0: MGLStyleValue(rawValue: .yellow), - 2.5: MGLStyleValue(rawValue: .orange), - 5: MGLStyleValue(rawValue: .red), - 7.5: MGLStyleValue(rawValue: .blue), - 10: MGLStyleValue(rawValue: .white), -] -``` - -Current syntax: -```swift -// Swift sample on how to populate a stepping expression with multiple stops. -// Create a color ramp. -let stops: [NSNumber: NSColor] = [ - 0: .yellow, - 2.5: .orange, - 5: .red, - 7.5: .blue, - 10: .white, -] - -// Based on the zoom and `stops`, change the color. -var functionExpression = NSExpression(forMGLStepping: .zoomLevelVariable, - from: NSExpression(forConstantValue: stops[0]), - stops: NSExpression(forConstantValue: stops)) - -// Based on zoom and `stopsLineWidth`, set the Line width. -let initialValue = 4.0 -let stopsLineWidth = [ - 11.0: initialValue, - 14.0: 6.0, - 20.0: 18.0] - -functionExpression = NSExpression( - forMGLStepping: .zoomLevelVariable, - from: NSExpression(forConstantValue: initialValue), - stops: NSExpression(forConstantValue: stopsLineWidth) -) -``` - - -## Interpolation mode - -Style functions supported four interpolation modes: exponential/linear, interval, categorical, and identity. For more information about supported custom expressions, please see the "Predicates and Expressions" guide. - -### Linear - -`+[NSExpression(MGLAdditions) mgl_expressionForInterpolatingExpression:withCurveType:parameters:stops:]` takes the interpolation type as a parameter. If you previously used the default interpolation base, use the curve type `MGLExpressionInterpolationMode.linear`. See the [`mgl_interpolate:withCurveType:parameters:stops:`](predicates-and-expressions.html#code-mgl_interpolate-withcurvetype-parameters-stops-code) documentation for more details. - -The stops dictionary below, shows colors that continuously shift from yellow to orange to red to blue to white based on the attribute value. - -Style function syntax: - -```swift -let url = URL(string: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson")! -let symbolSource = MGLSource(identifier: "source") -let symbolLayer = MGLSymbolStyleLayer(identifier: "place-city-sm", source: symbolSource) - -let source = MGLShapeSource(identifier: "earthquakes", url: url, options: nil) -mapView.style?.addSource(source) - -let stops = [ - 0: MGLStyleValue(rawValue: .yellow), - 2.5: MGLStyleValue(rawValue: .orange), - 5: MGLStyleValue(rawValue: .red), - 7.5: MGLStyleValue(rawValue: .blue), - 10: MGLStyleValue(rawValue: .white), -] - -let layer = MGLCircleStyleLayer(identifier: "circles", source: source) -layer.circleColor = MGLStyleValue(interpolationMode: .exponential, - sourceStops: stops, - attributeName: "mag", - options: [.defaultValue: MGLStyleValue(rawValue: .green)]) -layer.circleRadius = MGLStyleValue(rawValue: 10) -mapView.style?.insertLayer(layer, below: symbolLayer) -``` - -Current syntax: - -```swift -let url = URL(string: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson")! -let symbolSource = MGLSource(identifier: "source") -let symbolLayer = MGLSymbolStyleLayer(identifier: "place-city-sm", source: symbolSource) - -let source = MGLShapeSource(identifier: "earthquakes", url: url, options: nil) -let mag = 1.0 // Update based on earthquake GeoJSON data -mapView.style?.addSource(source) - -let stops: [NSNumber: NSColor] = [ - 0: .yellow, - 2.5: .orange, - 5: .red, - 7.5: .blue, - 10: .white, -] - -let layer = MGLCircleStyleLayer(identifier: "circles", source: source) - -let circleExpression : NSExpression -if #available(iOS 15, *) { - circleExpression = NSExpression( - forMGLInterpolating: NSExpression(forConstantValue: mag), - curveType: .linear, - parameters: nil, - stops: NSExpression(forConstantValue: stops)) -} else { - // This works up to iOS 14.5 - circleExpression = NSExpression( - format: "mgl_interpolate:withCurveType:parameters:stops:(mag, 'linear', nil, %@)", - stops) -} - -layer.circleColor = circleExpression -layer.circleRadius = NSExpression(forConstantValue: 10) -mapView.style?.insertLayer(layer, below: symbolLayer) -``` - -### Exponential - -If you previously used an interpolation base greater than `0` (other than `1`), you can use `MGLExpressionInterpolationMode.exponential` as the curve type for `+[NSExpression(MGLAdditions) mgl_expressionForInterpolatingExpression:withCurveType:parameters:stops:]` or `'exponential'` as the curve type for [`mgl_interpolate:withCurveType:parameters:stops:`](predicates-and-expressions.html#code-mgl_interpolate-withcurvetype-parameters-stops-code). The `parameters` argument takes that interpolation base. This interpolates between values exponentially, creating an accelerated ramp effect. - -Here’s a visualization from Mapbox Studio (see [Mapbox Studio and iOS](https://www.mapbox.com/ios-sdk/maps/overview/mapbox-studio/)) comparing interpolation base values of `1.5` and `0.5` based on zoom. In order to convert camera style functions, use `$zoomLevel` or `MGL_FUNCTION('zoomLevel')` as the attribute key. - - - - -The example below increases a layer’s `circleRadius` exponentially based on a map’s zoom level. The interpolation base is `1.5`. - -Style function syntax: - -```swift -let stops = [ - 12: MGLStyleValue(rawValue: 0.5), - 14: MGLStyleValue(rawValue: 2), - 18: MGLStyleValue(rawValue: 18), -] - -layer.circleRadius = MGLStyleValue(interpolationMode: .exponential, - cameraStops: stops, - options: [.interpolationBase: 1.5]) -``` - -Current syntax: - -```swift -let stops = [ - 12: 0.5, - 14: 2, - 18: 18, -] - -layer.circleRadius = NSExpression(forMGLInterpolating: .zoomLevelVariable, - curveType: .exponential, - parameters: NSExpression(forConstantValue: 1.5), - stops: NSExpression(forConstantValue: stops)) -``` - -### Interval - -Steps, or intervals, create a range using the keys from the stops dictionary. The range is from the given key to just less than the next key. The attribute values that fall into that range are then styled using the layout or paint value assigned to that key. You can use the `+[NSExpression(MGLAdditions) mgl_expressionForSteppingExpression:fromExpression:stops:]` method or the custom function [`mgl_step:from:stops:`](predicates-and-expressions.html#code-mgl_step-from-stops-code) for cases where you previously used interval interpolation mode. The first parameter takes the feature attribute name and the second parameter (`from:`) optionally takes the default or fallback value for that function. The final parameter takes a stops dictionary as an argument. - -When we use the stops dictionary given above with an `'mgl_step:from:stops:'`, we create ranges where earthquakes with a magnitude of 0 to just less than 2.5 would be yellow, 2.5 to just less than 5 would be orange, and so on. - -Style function syntax: - -```swift -let stops = [ - 0: MGLStyleValue(rawValue: .yellow), - 2.5: MGLStyleValue(rawValue: .orange), - 5: MGLStyleValue(rawValue: .red), - 7.5: MGLStyleValue(rawValue: .blue), - 10: MGLStyleValue(rawValue: .white), -] - -layer.circleColor = MGLStyleValue(interpolationMode: .interval, - sourceStops: stops, - attributeName: "mag", - options: [.defaultValue: MGLStyleValue(rawValue: .green)]) -```` - -Current syntax: - -```swift -let stops: [NSNumber: NSColor] = [ - 0: .yellow, - 2.5: .orange, - 5: .red, - 7.5: .blue, - 10: .white, -] - -layer.circleColor = NSExpression(forMGLStepping: .zoomLevelVariable, - from: NSExpression(forConstantValue: NSColor.green), - stops: NSExpression(forConstantValue: stops)) -``` - -### Categorical - -Categorical interpolation mode took a stops dictionary. If the value for a specified feature attribute name matched one in that stops dictionary, the style value for that attribute value would be used. Categorical style functions can now be replaced with `MGL_MATCH`. - -`MGL_MATCH` takes an initial condition, which in this case is an attribute key. This is followed by possible matches for that key and the value to assign to the layer property if there is a match. The final argument can be a default style value that is to be used if none of the specified values match. - -There are three main types of events in the USGS dataset: earthquakes, explosions, and quarry blasts. In this case, the color of the circle layer will be determined by the type of event, with a default value of blue to catch any events that do not fall into any of those categories. - -Style function syntax: - -```swift -let categoricalStops = [ - "earthquake": MGLStyleValue(rawValue: .orange), - "explosion": MGLStyleValue(rawValue: .red), - "quarry blast": MGLStyleValue(rawValue: .yellow), -] - -layer.circleColor = MGLStyleValue(interpolationMode: .categorical, - sourceStops: categoricalStops, - attributeName: "type", - options: [.defaultValue: MGLStyleValue(rawValue: .blue)]) -``` - -Current syntax: -```swift -// Category type -let type = NSExpression(forConstantValue: "type") - -// Categories -let earthquake = NSExpression(forConstantValue: "earthquake") -let explosion = NSExpression(forConstantValue: "explosion") -let quarryBlast = NSExpression(forConstantValue: "quarry blast") - -let defaultColor = NSExpression(forConstantValue: NSColor.blue) -let orange = NSExpression(forConstantValue: NSColor.orange) -let red = NSExpression(forConstantValue: NSColor.red) -let yellow = NSExpression(forConstantValue: NSColor.yellow) - -layer.circleColor = NSExpression(forMGLMatchingKey: type, - in: [earthquake:orange, explosion:red, quarryBlast:yellow], - default: defaultColor) -``` - -If your use case does not require a default value, you can either apply a predicate to your layer prior to styling it, or use the format string `"valueForKeyPath:"`. - -### Identity - -Identity interpolation mode used the attribute’s value as the style layer property value. In this example, you might set the `circleRadius` to the earthquake’s magnitude. In order to use a feature attribute value to style a layer property, set the property value to `[NSExpression expressionForKeyPath:]`, which take the feature attribute name as an argument. - -Style function syntax: - -```swift -layer.circleRadius = MGLStyleValue(interpolationMode: .identity, - sourceStops: nil, - attributeName: "mag", - options: [.defaultValue: MGLStyleValue(rawValue: 0)]) -``` - -Current syntax: -```swift -layer.circleRadius = NSExpression(forKeyPath: "mag") -``` - -![identity mode](img/data-driven-styling/identity.png) - -Some built-in functions can be applied to attribute values to style layer property values. To set the circle radius to three times the earthquake’s magnitude, create a `multiply:by:` function that takes the attribute value and the multiplier as arguments, or use a format string. - -```swift -layer.circleRadius = NSExpression(forFunction: "multiply:by:", arguments: [NSExpression(forKeyPath: "mag"), 3]) -``` - -![multiply magnitude](img/data-driven-styling/multiply.png) - -You can also cast attribute values in order to use them. One example is to cast an integer as an `NSString` and use it as a text value. - -```swift -let magnitudeLayer = MGLSymbolStyleLayer(identifier: "mag-layer", source: source) -magnitudeLayer.text = NSExpression(format: "CAST(mag, 'NSString')") -mapView.style?.addLayer(magnitudeLayer) -``` - -![cast a value](img/data-driven-styling/cast.png) - -### Constant Values - -For constant values that do not necessarily change based on camera or attribute values, use `[NSExpression expressionForConstantValue:]` (previously `[MGLStyleValue valueWithRawValue:]`). - -## Resources - -* [USGS Earthquake Feed](https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php) -* [For Style Authors](for-style-authors.html) -* [Predicates and Expressions](predicates-and-expressions.html) diff --git a/platform/ios/platform/macos/docs/guides/Tile URL Templates.md b/platform/ios/platform/macos/docs/guides/Tile URL Templates.md deleted file mode 100644 index 6e6a208cf..000000000 --- a/platform/ios/platform/macos/docs/guides/Tile URL Templates.md +++ /dev/null @@ -1,98 +0,0 @@ - -# Tile URL Templates - -`MGLTileSource` objects, specifically `MGLRasterTileSource` and -`MGLVectorTileSource` objects, can be created using an initializer that accepts -an array of tile URL templates. Tile URL templates are strings that specify the -URLs of the vector tiles or raster tile images to load. A template resembles an -absolute URL, but with any number of placeholder strings that the source -evaluates based on the tile it needs to load. For example: - -* `http://www.example.com/tiles/{z}/{x}/{y}.pbf` could be - evaluated as `http://www.example.com/tiles/14/6/9.pbf`. -* `http://www.example.com/tiles/{z}/{x}/{y}{ratio}.png` could be - evaluated as `http://www.example.com/tiles/14/6/9@2x.png`. - -Tile URL templates are also used to define tilesets in TileJSON manifests or -[`raster`](https://maplibre.org/maplibre-gl-js-docs/style-spec/#sources-raster-tiles) -and -[`vector`](https://maplibre.org/maplibre-gl-js-docs/style-spec/#sources-vector-tiles) -sources in style JSON files. See the -[TileJSON specification](https://github.com/mapbox/tilejson-spec/tree/master/2.2.0) -for information about tile URL templates in the context of a TileJSON or style -JSON file. - -Tile sources support the following placeholder strings in tile URL templates, -all of which are optional: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Placeholder stringDescription
{x}The index of the tile along the map’s x axis according to Spherical - Mercator projection. If the value is 0, the tile’s left edge corresponds - to the 180th meridian west. If the value is 2z−1, - the tile’s right edge corresponds to the 180th meridian east.
{y}The index of the tile along the map’s y axis according to Spherical - Mercator projection. If the value is 0, the tile’s tile edge corresponds - to arctan(sinh(π)), or approximately 85.0511 degrees north. If the value - is 2z−1, the tile’s bottom edge corresponds to - −arctan(sinh(π)), or approximately 85.0511 degrees south. The y axis is - inverted if the options parameter contains - MGLTileSourceOptionTileCoordinateSystem with a value of - MGLTileCoordinateSystemTMS.
{z}The tile’s zoom level. At zoom level 0, each tile covers the entire - world map; at zoom level 1, it covers ¼ of the world; at zoom level 2, - 1⁄16 of the world, and so on. For tiles loaded by - a MGLRasterTileSource object, whether the tile zoom level - matches the map’s current zoom level depends on the value of the - source’s tile size as specified in the - MGLTileSourceOptionTileSize key of the options - parameter.
{bbox-epsg-3857}The tile’s bounding box, expressed as a comma-separated list of the - tile’s western, southern, eastern, and northern extents according to - Spherical Mercator (EPSG:3857) projection. The bounding box is typically - used with map services conforming to the - Web Map Service - protocol.
{quadkey}A quadkey indicating both the tile’s location and its zoom level. The - quadkey is typically used with - Bing Maps. -
{ratio}A suffix indicating the resolution of the tile image. The suffix is the - empty string for standard resolution displays and @2x for - Retina displays. -
{prefix}Two hexadecimal digits chosen such that each visible tile has a - different prefix. The prefix is typically used for domain sharding.
- -For more information about the `{x}`, `{y}`, and `{z}` placeholder strings, -consult the -[OpenStreetMap Wiki](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames). diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index de70fdcbe..83cddabb8 100755 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -204,10 +204,10 @@ global.defaultValue = function (property) { } }; -const layerHpp = ejs.compile(fs.readFileSync('include/mbgl/style/layers/layer.hpp.ejs', 'utf8'), {strict: true}); -const layerCpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer.cpp.ejs', 'utf8'), {strict: true}); -const propertiesHpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer_properties.hpp.ejs', 'utf8'), {strict: true}); -const propertiesCpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer_properties.cpp.ejs', 'utf8'), {strict: true}); +const layerHpp = ejs.compile(fs.readFileSync(`${__dirname}/../include/mbgl/style/layers/layer.hpp.ejs`, 'utf8'), {strict: true}); +const layerCpp = ejs.compile(fs.readFileSync(`${__dirname}/../src/mbgl/style/layers/layer.cpp.ejs`, 'utf8'), {strict: true}); +const propertiesHpp = ejs.compile(fs.readFileSync(`${__dirname}/../src/mbgl/style/layers/layer_properties.hpp.ejs`, 'utf8'), {strict: true}); +const propertiesCpp = ejs.compile(fs.readFileSync(`${__dirname}/../src/mbgl/style/layers/layer_properties.cpp.ejs`, 'utf8'), {strict: true}); const collator = new Intl.Collator("en-US"); @@ -255,16 +255,16 @@ const layers = Object.keys(spec.layer.type.values).map((type) => { for (const layer of layers) { const layerFileName = layer.type.replace('-', '_'); - writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.hpp`, propertiesHpp(layer)); - writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.cpp`, propertiesCpp(layer)); + writeIfModified(`${__dirname}/../src/mbgl/style/layers/${layerFileName}_layer_properties.hpp`, propertiesHpp(layer)); + writeIfModified(`${__dirname}/../src/mbgl/style/layers/${layerFileName}_layer_properties.cpp`, propertiesCpp(layer)); // Remove our fake property for the external interace. if (layer.type === 'line') { layer.paintProperties = layer.paintProperties.filter(property => property.name !== 'line-floor-width'); } - writeIfModified(`include/mbgl/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer)); - writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer)); + writeIfModified(`${__dirname}/../include/mbgl/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer)); + writeIfModified(`${__dirname}/../src/mbgl/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer)); } // Light @@ -280,7 +280,7 @@ const lightProperties = Object.keys(spec[`light`]).reduce((memo, name) => { // to get a deterministic order. lightProperties.sort((a, b) => collator.compare(a.name, b.name)); -const lightHpp = ejs.compile(fs.readFileSync('include/mbgl/style/light.hpp.ejs', 'utf8'), {strict: true}); -const lightCpp = ejs.compile(fs.readFileSync('src/mbgl/style/light.cpp.ejs', 'utf8'), {strict: true}); -writeIfModified(`include/mbgl/style/light.hpp`, lightHpp({properties: lightProperties})); -writeIfModified(`src/mbgl/style/light.cpp`, lightCpp({properties: lightProperties})); +const lightHpp = ejs.compile(fs.readFileSync(`${__dirname}/../include/mbgl/style/light.hpp.ejs`, 'utf8'), {strict: true}); +const lightCpp = ejs.compile(fs.readFileSync(`${__dirname}/../src/mbgl/style/light.cpp.ejs`, 'utf8'), {strict: true}); +writeIfModified(`${__dirname}/../include/mbgl/style/light.hpp`, lightHpp({properties: lightProperties})); +writeIfModified(`${__dirname}/../src/mbgl/style/light.cpp`, lightCpp({properties: lightProperties})); diff --git a/scripts/style-code.js b/scripts/style-code.js index 7a93b13a7..3f0d0c874 100644 --- a/scripts/style-code.js +++ b/scripts/style-code.js @@ -31,7 +31,8 @@ global.unhyphenate = function (str) { var files = []; process.on('exit', function() { const list = path.join(path.dirname(process.argv[1]), path.basename(process.argv[1], '.js') + '.list'); - fs.writeFileSync(list, files.join('\n')); + console.log(`Writing files that this script modifies to: ${list}`); + fs.writeFileSync(list, files.join("\n")); }); global.writeIfModified = function(filename, newContent) {