Remove files generated by platform/ios/platform/darwin/scripts/generate-style-code.js (#844)
This commit is contained in:
51
platform/ios/.gitignore
vendored
51
platform/ios/.gitignore
vendored
@@ -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
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
@@ -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 <mbgl/style/layers/background_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
|
||||
@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<mbgl::style::BackgroundLayer>(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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(backgroundColor, false);
|
||||
self.rawLayer->setBackgroundColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)backgroundColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getBackgroundColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultBackgroundColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(backgroundOpacity, false);
|
||||
self.rawLayer->setBackgroundOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)backgroundOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getBackgroundOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultBackgroundOpacity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::style::expression::Image, NSString *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::expression::Image>>(backgroundPattern, false);
|
||||
self.rawLayer->setBackgroundPattern(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)backgroundPattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getBackgroundPattern();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultBackgroundPattern();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::expression::Image, NSString *>().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
|
||||
@@ -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 <mbgl/layermanager/background_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class BackgroundStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::BackgroundLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -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 <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/dds-circle-layer/">Data-driven
|
||||
circles</a>, <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/shape-collection/">Add multiple
|
||||
shapes from a single shape source</a>, and <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/clustering/">Cluster point
|
||||
data</a> 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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-circle-pitch-scale"><code>circle-pitch-scale</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-circle-translate"><code>circle-translate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-circle-translate"><code>circle-translate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-circle-translate-anchor"><code>circle-translate-anchor</code></a>
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/circle_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
|
||||
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<mbgl::style::CircleLayer>(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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleSortKey, true);
|
||||
self.rawLayer->setCircleSortKey(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleSortKey {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleSortKey();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleSortKey();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
// MARK: - Accessing the Paint Attributes
|
||||
|
||||
- (void)setCircleBlur:(NSExpression *)circleBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting circleBlur: %@", circleBlur);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleBlur, true);
|
||||
self.rawLayer->setCircleBlur(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleBlur();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleBlur();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(circleColor, true);
|
||||
self.rawLayer->setCircleColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleOpacity, true);
|
||||
self.rawLayer->setCircleOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleOpacity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLCirclePitchAlignment>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::AlignmentType>>(circlePitchAlignment, false);
|
||||
self.rawLayer->setCirclePitchAlignment(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circlePitchAlignment {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCirclePitchAlignment();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCirclePitchAlignment();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLCirclePitchAlignment>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCircleRadius:(NSExpression *)circleRadius {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting circleRadius: %@", circleRadius);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleRadius, true);
|
||||
self.rawLayer->setCircleRadius(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleRadius {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleRadius();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleRadius();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCircleScaleAlignment>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::CirclePitchScaleType>>(circleScaleAlignment, false);
|
||||
self.rawLayer->setCirclePitchScale(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleScaleAlignment {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCirclePitchScale();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCirclePitchScale();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCircleScaleAlignment>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCirclePitchScale:(NSExpression *)circlePitchScale {
|
||||
}
|
||||
|
||||
- (NSExpression *)circlePitchScale {
|
||||
return self.circleScaleAlignment;
|
||||
}
|
||||
|
||||
- (void)setCircleStrokeColor:(NSExpression *)circleStrokeColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting circleStrokeColor: %@", circleStrokeColor);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(circleStrokeColor, true);
|
||||
self.rawLayer->setCircleStrokeColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleStrokeColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleStrokeColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleStrokeOpacity, true);
|
||||
self.rawLayer->setCircleStrokeOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleStrokeOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleStrokeOpacity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleStrokeWidth, true);
|
||||
self.rawLayer->setCircleStrokeWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleStrokeWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleStrokeWidth();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(circleTranslation, false);
|
||||
self.rawLayer->setCircleTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleTranslate();
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, 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<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(circleTranslationAnchor, false);
|
||||
self.rawLayer->setCircleTranslateAnchor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)circleTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultCircleTranslateAnchor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslationAnchor>().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
|
||||
@@ -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 <mbgl/layermanager/circle_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class CircleStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::CircleLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -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 <a href="https://docs.mapbox.com/ios/maps/examples/extrusions/">Display
|
||||
3D buildings</a> 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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-extrusion-vertical-gradient"><code>fill-extrusion-vertical-gradient</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-extrusion-translate"><code>fill-extrusion-translate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-extrusion-translate"><code>fill-extrusion-translate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-extrusion-translate-anchor"><code>fill-extrusion-translate-anchor</code></a>
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/fill_extrusion_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
|
||||
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<mbgl::style::FillExtrusionLayer>(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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionBase, true);
|
||||
self.rawLayer->setFillExtrusionBase(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionBase {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillExtrusionBase();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillExtrusionBase();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(fillExtrusionColor, true);
|
||||
self.rawLayer->setFillExtrusionColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillExtrusionColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillExtrusionColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(fillExtrusionHasVerticalGradient, false);
|
||||
self.rawLayer->setFillExtrusionVerticalGradient(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionHasVerticalGradient {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillExtrusionVerticalGradient();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillExtrusionVerticalGradient();
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setFillExtrusionVerticalGradient:(NSExpression *)fillExtrusionVerticalGradient {
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionVerticalGradient {
|
||||
return self.fillExtrusionHasVerticalGradient;
|
||||
}
|
||||
|
||||
- (void)setFillExtrusionHeight:(NSExpression *)fillExtrusionHeight {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting fillExtrusionHeight: %@", fillExtrusionHeight);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionHeight, true);
|
||||
self.rawLayer->setFillExtrusionHeight(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionHeight {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillExtrusionHeight();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillExtrusionHeight();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionOpacity, false);
|
||||
self.rawLayer->setFillExtrusionOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillExtrusionOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillExtrusionOpacity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::style::expression::Image, NSString *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::expression::Image>>(fillExtrusionPattern, true);
|
||||
self.rawLayer->setFillExtrusionPattern(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionPattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillExtrusionPattern();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillExtrusionPattern();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::expression::Image, NSString *>().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<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(fillExtrusionTranslation, false);
|
||||
self.rawLayer->setFillExtrusionTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillExtrusionTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillExtrusionTranslate();
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, 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<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillExtrusionTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(fillExtrusionTranslationAnchor, false);
|
||||
self.rawLayer->setFillExtrusionTranslateAnchor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillExtrusionTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillExtrusionTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillExtrusionTranslateAnchor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillExtrusionTranslationAnchor>().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
|
||||
@@ -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 <mbgl/layermanager/fill_extrusion_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class FillExtrusionStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::FillExtrusionLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -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 <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/select-layer/">Select a feature
|
||||
within a layer</a> example to learn how to use a `TERNARY` expression to modify
|
||||
the `fillOpacity` of an `MGLFillStyleLayer` object. See the <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/fill-pattern/">Add a pattern to
|
||||
a polygon</a> 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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-antialias"><code>fill-antialias</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-translate"><code>fill-translate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-translate"><code>fill-translate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-translate-anchor"><code>fill-translate-anchor</code></a>
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/fill_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
|
||||
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<mbgl::style::FillLayer>(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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillSortKey, true);
|
||||
self.rawLayer->setFillSortKey(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillSortKey {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillSortKey();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillSortKey();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
// MARK: - Accessing the Paint Attributes
|
||||
|
||||
- (void)setFillAntialiased:(NSExpression *)fillAntialiased {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting fillAntialiased: %@", fillAntialiased);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(fillAntialiased, false);
|
||||
self.rawLayer->setFillAntialias(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)isFillAntialiased {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillAntialias();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillAntialias();
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setFillAntialias:(NSExpression *)fillAntialias {
|
||||
}
|
||||
|
||||
- (NSExpression *)fillAntialias {
|
||||
return self.isFillAntialiased;
|
||||
}
|
||||
|
||||
- (void)setFillColor:(NSExpression *)fillColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting fillColor: %@", fillColor);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(fillColor, true);
|
||||
self.rawLayer->setFillColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillOpacity, true);
|
||||
self.rawLayer->setFillOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillOpacity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(fillOutlineColor, true);
|
||||
self.rawLayer->setFillOutlineColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillOutlineColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillOutlineColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillOutlineColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<mbgl::style::expression::Image, NSString *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::expression::Image>>(fillPattern, true);
|
||||
self.rawLayer->setFillPattern(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillPattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillPattern();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillPattern();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::expression::Image, NSString *>().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<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(fillTranslation, false);
|
||||
self.rawLayer->setFillTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillTranslate();
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, 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<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(fillTranslationAnchor, false);
|
||||
self.rawLayer->setFillTranslateAnchor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)fillTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultFillTranslateAnchor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslationAnchor>().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
|
||||
@@ -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 <mbgl/layermanager/fill_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class FillStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::FillLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -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 <a
|
||||
href="https://en.wikipedia.org/wiki/Heat_map">heatmap</a>.
|
||||
|
||||
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 <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/heatmap-example/">Create a
|
||||
heatmap layer</a> 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
|
||||
@@ -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 <mbgl/style/layers/heatmap_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
|
||||
@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<mbgl::style::HeatmapLayer>(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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::ColorRampPropertyValue>(heatmapColor);
|
||||
self.rawLayer->setHeatmapColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)heatmapColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHeatmapColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHeatmapColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setHeatmapIntensity:(NSExpression *)heatmapIntensity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting heatmapIntensity: %@", heatmapIntensity);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(heatmapIntensity, false);
|
||||
self.rawLayer->setHeatmapIntensity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)heatmapIntensity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHeatmapIntensity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHeatmapIntensity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(heatmapOpacity, false);
|
||||
self.rawLayer->setHeatmapOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)heatmapOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHeatmapOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHeatmapOpacity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(heatmapRadius, true);
|
||||
self.rawLayer->setHeatmapRadius(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)heatmapRadius {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHeatmapRadius();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHeatmapRadius();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(heatmapWeight, true);
|
||||
self.rawLayer->setHeatmapWeight(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)heatmapWeight {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHeatmapWeight();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHeatmapWeight();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
MGLStyleLayer* HeatmapStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
|
||||
return [[MGLHeatmapStyleLayer alloc] initWithRawLayer:rawLayer];
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -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 <mbgl/layermanager/heatmap_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class HeatmapStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::HeatmapLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -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 <a
|
||||
href="https://en.wikipedia.org/wiki/Digital_elevation_model">digital elevation
|
||||
model</a> (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 <a
|
||||
href="https://docs.mapbox.com/help/troubleshooting/access-elevation-data/#mapbox-terrain-rgb">Mapbox
|
||||
Terrain-RGB</a> data.
|
||||
|
||||
To display posterized hillshading based on vector shapes, as with the <a
|
||||
href="https://www.mapbox.com/vector-tiles/mapbox-terrain/">Mapbox Terrain</a>
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/hillshade_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
|
||||
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<mbgl::style::HillshadeLayer>(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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(hillshadeAccentColor, false);
|
||||
self.rawLayer->setHillshadeAccentColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)hillshadeAccentColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHillshadeAccentColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHillshadeAccentColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(hillshadeExaggeration, false);
|
||||
self.rawLayer->setHillshadeExaggeration(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)hillshadeExaggeration {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHillshadeExaggeration();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHillshadeExaggeration();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(hillshadeHighlightColor, false);
|
||||
self.rawLayer->setHillshadeHighlightColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)hillshadeHighlightColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHillshadeHighlightColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHillshadeHighlightColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<mbgl::style::HillshadeIlluminationAnchorType, NSValue *, mbgl::style::HillshadeIlluminationAnchorType, MGLHillshadeIlluminationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::HillshadeIlluminationAnchorType>>(hillshadeIlluminationAnchor, false);
|
||||
self.rawLayer->setHillshadeIlluminationAnchor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)hillshadeIlluminationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHillshadeIlluminationAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHillshadeIlluminationAnchor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::HillshadeIlluminationAnchorType, NSValue *, mbgl::style::HillshadeIlluminationAnchorType, MGLHillshadeIlluminationAnchor>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setHillshadeIlluminationDirection:(NSExpression *)hillshadeIlluminationDirection {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting hillshadeIlluminationDirection: %@", hillshadeIlluminationDirection);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(hillshadeIlluminationDirection, false);
|
||||
self.rawLayer->setHillshadeIlluminationDirection(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)hillshadeIlluminationDirection {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHillshadeIlluminationDirection();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHillshadeIlluminationDirection();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setHillshadeShadowColor:(NSExpression *)hillshadeShadowColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting hillshadeShadowColor: %@", hillshadeShadowColor);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(hillshadeShadowColor, false);
|
||||
self.rawLayer->setHillshadeShadowColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)hillshadeShadowColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getHillshadeShadowColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultHillshadeShadowColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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
|
||||
@@ -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 <mbgl/layermanager/hillshade_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class HillshadeStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::HillshadeLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,242 +0,0 @@
|
||||
// This file is generated.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
|
||||
#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 <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/light-example/">Adjust light of
|
||||
3D buildings</a> 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 <a
|
||||
href="https://maplibre.org/maplibre-gl-js-docs/style-spec/#light-anchor"><code>anchor</code></a>
|
||||
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 <a
|
||||
href="https://maplibre.org/maplibre-gl-js-docs/style-spec/#light-position"><code>position</code></a>
|
||||
light property in the Mapbox Style Specification.
|
||||
|
||||
#### Related examples
|
||||
See the <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/light-example/">Adjust light of
|
||||
3D buildings</a> 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 <a
|
||||
href="https://maplibre.org/maplibre-gl-js-docs/style-spec/#light-color"><code>color</code></a>
|
||||
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 <a
|
||||
href="https://maplibre.org/maplibre-gl-js-docs/style-spec/#light-color"><code>color</code></a>
|
||||
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 <a
|
||||
href="https://maplibre.org/maplibre-gl-js-docs/style-spec/#light-intensity"><code>intensity</code></a>
|
||||
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
|
||||
@@ -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 <mbgl/style/light.hpp>
|
||||
#import <mbgl/style/types.hpp>
|
||||
|
||||
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<mbgl::style::LightAnchorType> defaultAnchor = mbglLight->getDefaultAnchor();
|
||||
anchorExpression = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::LightAnchorType, MGLLightAnchor>().toExpression(defaultAnchor);
|
||||
} else {
|
||||
anchorExpression = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::LightAnchorType, MGLLightAnchor>().toExpression(anchor);
|
||||
}
|
||||
|
||||
_anchor = anchorExpression;
|
||||
|
||||
auto positionValue = mbglLight->getPosition();
|
||||
if (positionValue.isUndefined()) {
|
||||
_position = MGLStyleValueTransformer<mbgl::style::Position, NSValue *>().toExpression(mbglLight->getDefaultPosition());
|
||||
} else {
|
||||
_position = MGLStyleValueTransformer<mbgl::style::Position, NSValue *>().toExpression(positionValue);
|
||||
}
|
||||
_positionTransition = MGLTransitionFromOptions(mbglLight->getPositionTransition());
|
||||
auto colorValue = mbglLight->getColor();
|
||||
if (colorValue.isUndefined()) {
|
||||
_color = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(mbglLight->getDefaultColor());
|
||||
} else {
|
||||
_color = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(colorValue);
|
||||
}
|
||||
_colorTransition = MGLTransitionFromOptions(mbglLight->getColorTransition());
|
||||
auto intensityValue = mbglLight->getIntensity();
|
||||
if (intensityValue.isUndefined()) {
|
||||
_intensity = MGLStyleValueTransformer<float, NSNumber *>().toExpression(mbglLight->getDefaultIntensity());
|
||||
} else {
|
||||
_intensity = MGLStyleValueTransformer<float, NSNumber *>().toExpression(intensityValue);
|
||||
}
|
||||
_intensityTransition = MGLTransitionFromOptions(mbglLight->getIntensityTransition());
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (mbgl::style::Light)mbglLight
|
||||
{
|
||||
mbgl::style::Light mbglLight;
|
||||
auto anchor = MGLStyleValueTransformer<mbgl::style::LightAnchorType, NSValue *, mbgl::style::LightAnchorType, MGLLightAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::LightAnchorType>>(self.anchor, false);
|
||||
mbglLight.setAnchor(anchor);
|
||||
|
||||
auto position = MGLStyleValueTransformer<mbgl::style::Position, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::Position>>(self.position, false);
|
||||
mbglLight.setPosition(position);
|
||||
|
||||
mbglLight.setPositionTransition(MGLOptionsFromTransition(self.positionTransition));
|
||||
|
||||
auto color = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(self.color, false);
|
||||
mbglLight.setColor(color);
|
||||
|
||||
mbglLight.setColorTransition(MGLOptionsFromTransition(self.colorTransition));
|
||||
|
||||
auto intensity = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(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
|
||||
@@ -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 <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/shape-collection/">Add multiple
|
||||
shapes from a single shape source</a> example to learn how to add a line to
|
||||
your map using this style layer. See the <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/runtime-add-line/">Add a line
|
||||
style layer from GeoJSON</a> 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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-line-dasharray"><code>line-dasharray</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-line-translate"><code>line-translate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-line-translate"><code>line-translate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-line-translate-anchor"><code>line-translate-anchor</code></a>
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/line_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
|
||||
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<mbgl::style::LineLayer>(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<mbgl::style::LineCapType, NSValue *, mbgl::style::LineCapType, MGLLineCap>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::LineCapType>>(lineCap, false);
|
||||
self.rawLayer->setLineCap(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineCap {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineCap();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineCap();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::LineCapType, NSValue *, mbgl::style::LineCapType, MGLLineCap>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineJoin:(NSExpression *)lineJoin {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting lineJoin: %@", lineJoin);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::LineJoinType>>(lineJoin, true);
|
||||
self.rawLayer->setLineJoin(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineJoin {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineJoin();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineJoin();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineMiterLimit:(NSExpression *)lineMiterLimit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting lineMiterLimit: %@", lineMiterLimit);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineMiterLimit, false);
|
||||
self.rawLayer->setLineMiterLimit(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineMiterLimit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineMiterLimit();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineMiterLimit();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineRoundLimit:(NSExpression *)lineRoundLimit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting lineRoundLimit: %@", lineRoundLimit);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineRoundLimit, false);
|
||||
self.rawLayer->setLineRoundLimit(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineRoundLimit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineRoundLimit();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineRoundLimit();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineSortKey:(NSExpression *)lineSortKey {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting lineSortKey: %@", lineSortKey);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineSortKey, true);
|
||||
self.rawLayer->setLineSortKey(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineSortKey {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineSortKey();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineSortKey();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
// MARK: - Accessing the Paint Attributes
|
||||
|
||||
- (void)setLineBlur:(NSExpression *)lineBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting lineBlur: %@", lineBlur);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineBlur, true);
|
||||
self.rawLayer->setLineBlur(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineBlur();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineBlur();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(lineColor, true);
|
||||
self.rawLayer->setLineColor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineColor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().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<std::vector<float>, NSArray<NSNumber *> *, float>().toPropertyValue<mbgl::style::PropertyValue<std::vector<float>>>(lineDashPattern, false);
|
||||
self.rawLayer->setLineDasharray(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineDashPattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineDasharray();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineDasharray();
|
||||
}
|
||||
return MGLStyleValueTransformer<std::vector<float>, NSArray<NSNumber *> *, 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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineGapWidth, true);
|
||||
self.rawLayer->setLineGapWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineGapWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineGapWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineGapWidth();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::ColorRampPropertyValue>(lineGradient);
|
||||
self.rawLayer->setLineGradient(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineGradient {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineGradient();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineGradient();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineOffset:(NSExpression *)lineOffset {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting lineOffset: %@", lineOffset);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineOffset, true);
|
||||
self.rawLayer->setLineOffset(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineOffset {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineOffset();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineOffset();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineOpacity, true);
|
||||
self.rawLayer->setLineOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineOpacity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::style::expression::Image, NSString *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::expression::Image>>(linePattern, true);
|
||||
self.rawLayer->setLinePattern(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)linePattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLinePattern();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLinePattern();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::expression::Image, NSString *>().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<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(lineTranslation, false);
|
||||
self.rawLayer->setLineTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineTranslate();
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, 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<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLLineTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(lineTranslationAnchor, false);
|
||||
self.rawLayer->setLineTranslateAnchor(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineTranslateAnchor();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLLineTranslationAnchor>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineTranslateAnchor:(NSExpression *)lineTranslateAnchor {
|
||||
}
|
||||
|
||||
- (NSExpression *)lineTranslateAnchor {
|
||||
return self.lineTranslationAnchor;
|
||||
}
|
||||
|
||||
- (void)setLineWidth:(NSExpression *)lineWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting lineWidth: %@", lineWidth);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineWidth, true);
|
||||
self.rawLayer->setLineWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)lineWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultLineWidth();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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
|
||||
@@ -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 <mbgl/layermanager/line_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class LineStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::LineLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -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 <a href="https://www.mapbox.com/satellite/">Mapbox Satellite</a>
|
||||
imagery, a <a
|
||||
href="https://docs.mapbox.com/help/glossary/tileset/#raster-tilesets">raster
|
||||
tile set</a> uploaded to Mapbox Studio, or a raster map authored in <a
|
||||
href="https://tilemill-project.github.io/tilemill/">TileMill</a>, 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 <a href="https://docs.mapbox.com/ios/maps/examples/image-source/">Add
|
||||
an image</a> and <a
|
||||
href="https://docs.mapbox.com/ios/maps/examples/source-custom-raster/">Add
|
||||
raster imagery</a> 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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-raster-brightness-max"><code>raster-brightness-max</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-raster-brightness-min"><code>raster-brightness-min</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-raster-hue-rotate"><code>raster-hue-rotate</code></a>
|
||||
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 <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-raster-resampling"><code>raster-resampling</code></a>
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/raster_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
|
||||
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<mbgl::style::RasterLayer>(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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(maximumRasterBrightness, false);
|
||||
self.rawLayer->setRasterBrightnessMax(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)maximumRasterBrightness {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterBrightnessMax();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultRasterBrightnessMax();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(minimumRasterBrightness, false);
|
||||
self.rawLayer->setRasterBrightnessMin(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)minimumRasterBrightness {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterBrightnessMin();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultRasterBrightnessMin();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterContrast, false);
|
||||
self.rawLayer->setRasterContrast(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)rasterContrast {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterContrast();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultRasterContrast();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterFadeDuration, false);
|
||||
self.rawLayer->setRasterFadeDuration(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)rasterFadeDuration {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterFadeDuration();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultRasterFadeDuration();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setRasterHueRotation:(NSExpression *)rasterHueRotation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting rasterHueRotation: %@", rasterHueRotation);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterHueRotation, false);
|
||||
self.rawLayer->setRasterHueRotate(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)rasterHueRotation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterHueRotate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultRasterHueRotate();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterOpacity, false);
|
||||
self.rawLayer->setRasterOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)rasterOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultRasterOpacity();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResamplingMode>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::RasterResamplingType>>(rasterResamplingMode, false);
|
||||
self.rawLayer->setRasterResampling(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)rasterResamplingMode {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterResampling();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultRasterResampling();
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResamplingMode>().toExpression(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setRasterResampling:(NSExpression *)rasterResampling {
|
||||
}
|
||||
|
||||
- (NSExpression *)rasterResampling {
|
||||
return self.rasterResamplingMode;
|
||||
}
|
||||
|
||||
- (void)setRasterSaturation:(NSExpression *)rasterSaturation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
MGLLogDebug(@"Setting rasterSaturation: %@", rasterSaturation);
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterSaturation, false);
|
||||
self.rawLayer->setRasterSaturation(mbglValue);
|
||||
}
|
||||
|
||||
- (NSExpression *)rasterSaturation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterSaturation();
|
||||
if (propertyValue.isUndefined()) {
|
||||
propertyValue = self.rawLayer->getDefaultRasterSaturation();
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().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
|
||||
@@ -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 <mbgl/layermanager/raster_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RasterStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::RasterLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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 <mbgl/layermanager/symbol_layer_factory.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class SymbolStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::SymbolLayerFactory {
|
||||
// LayerPeerFactory overrides.
|
||||
LayerFactory* getCoreLayerFactory() final { return this; }
|
||||
virtual MGLStyleLayer* createPeer(style::Layer*) final;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -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 <mbgl/style/layers/background_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@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<mbgl::style::BackgroundLayer*>(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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<float> 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<float>(
|
||||
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<mbgl::style::expression::Image> 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<mbgl::style::expression::Image>(
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/circle_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@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<mbgl::style::CircleLayer*>(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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<mbgl::style::AlignmentType> 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<mbgl::style::AlignmentType>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<mbgl::style::CirclePitchScaleType> 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<mbgl::style::CirclePitchScaleType>(
|
||||
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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<std::array<float, 2>> 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<std::array<float, 2>>(
|
||||
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<mbgl::style::TranslateAnchorType> 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<mbgl::style::TranslateAnchorType>(
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/fill_extrusion_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@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<mbgl::style::FillExtrusionLayer*>(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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<bool> 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<bool>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<float> 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<float>(
|
||||
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<mbgl::style::expression::Image> 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<mbgl::style::expression::Image>(
|
||||
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<std::array<float, 2>> 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<std::array<float, 2>>(
|
||||
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<mbgl::style::TranslateAnchorType> 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<mbgl::style::TranslateAnchorType>(
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/fill_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@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<mbgl::style::FillLayer*>(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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<bool> 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<bool>(
|
||||
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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<mbgl::style::expression::Image> 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<mbgl::style::expression::Image>(
|
||||
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<std::array<float, 2>> 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<std::array<float, 2>>(
|
||||
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<mbgl::style::TranslateAnchorType> 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<mbgl::style::TranslateAnchorType>(
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/heatmap_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@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<mbgl::style::HeatmapLayer*>(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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/hillshade_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@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<mbgl::style::HillshadeLayer*>(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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<float> 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<float>(
|
||||
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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<mbgl::style::HillshadeIlluminationAnchorType> 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<mbgl::style::HillshadeIlluminationAnchorType>(
|
||||
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<float> 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<float>(
|
||||
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<mbgl::Color> 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<mbgl::Color>(
|
||||
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
|
||||
@@ -1,133 +0,0 @@
|
||||
// This file is generated.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <Mapbox/Mapbox.h>
|
||||
|
||||
#import "MGLLight_Private.h"
|
||||
|
||||
#import "../../darwin/src/NSDate+MGLAdditions.h"
|
||||
|
||||
#import <mbgl/style/light.hpp>
|
||||
#import <mbgl/style/types.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
|
||||
@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<mbgl::style::LightAnchorType> 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<float, 3> positionArray = { { 6, 180, 90 } };
|
||||
mbgl::style::Position position = { positionArray };
|
||||
mbgl::style::PropertyValue<mbgl::style::Position> 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<mbgl::Color> 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<float> 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
|
||||
@@ -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 <mbgl/style/layers/line_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@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<mbgl::style::LineLayer*>(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<mbgl::style::LineCapType> 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<mbgl::style::LineCapType>(
|
||||
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<mbgl::style::LineJoinType> 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<mbgl::style::LineJoinType>(
|
||||
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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<mbgl::Color> 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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<mbgl::Color>(
|
||||
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<std::vector<float>> 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<std::vector<float>>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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<mbgl::style::expression::Image> 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<mbgl::style::expression::Image>(
|
||||
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<std::array<float, 2>> 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<std::array<float, 2>>(
|
||||
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<mbgl::style::TranslateAnchorType> 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<mbgl::style::TranslateAnchorType>(
|
||||
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<float> 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<float>(
|
||||
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<float>(
|
||||
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<float>(
|
||||
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
|
||||
@@ -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 <mbgl/style/layers/raster_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@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<mbgl::style::RasterLayer*>(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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<float> 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<float>(
|
||||
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<mbgl::style::RasterResamplingType> 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<mbgl::style::RasterResamplingType>(
|
||||
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<float> 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<float>(
|
||||
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
|
||||
@@ -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;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,437 +0,0 @@
|
||||
<!--
|
||||
This file is generated.
|
||||
Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
-->
|
||||
# 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<NSNumber>` | `[Float]`
|
||||
Array (`-font`) | `NSArray<NSString>` | `[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.
|
||||
@@ -1,318 +0,0 @@
|
||||
<!--
|
||||
This file is generated.
|
||||
Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
-->
|
||||
|
||||
# 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<UIColor>(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<UIColor>(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<UIColor>(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.
|
||||
|
||||
<img src="img/data-driven-styling/exponential-function.png" height=344/>
|
||||
<img src="img/data-driven-styling/exponential-function-1.png" height=344/>
|
||||
|
||||
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<NSNumber>(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<UIColor>(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<UIColor>(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<UIColor>(rawValue: .orange),
|
||||
"explosion": MGLStyleValue(rawValue: .red),
|
||||
"quarry blast": MGLStyleValue(rawValue: .yellow),
|
||||
]
|
||||
|
||||
layer.circleColor = MGLStyleValue(interpolationMode: .categorical,
|
||||
sourceStops: categoricalStops,
|
||||
attributeName: "type",
|
||||
options: [.defaultValue: MGLStyleValue<UIColor>(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<NSNumber>(rawValue: 0)])
|
||||
```
|
||||
|
||||
Current syntax:
|
||||
```swift
|
||||
layer.circleRadius = NSExpression(forKeyPath: "mag")
|
||||
```
|
||||
|
||||

|
||||
|
||||
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])
|
||||
```
|
||||
|
||||

|
||||
|
||||
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)
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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)
|
||||
@@ -1,99 +0,0 @@
|
||||
<!--
|
||||
This file is generated.
|
||||
Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
-->
|
||||
# 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:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Placeholder string</th><th>Description</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>{x}</code></td>
|
||||
<td>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 2<sup><var>z</var></sup>−1,
|
||||
the tile’s right edge corresponds to the 180th meridian east.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{y}</code></td>
|
||||
<td>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 2<sup><var>z</var></sup>−1, the tile’s bottom edge corresponds to
|
||||
−arctan(sinh(π)), or approximately 85.0511 degrees south. The y axis is
|
||||
inverted if the <code>options</code> parameter contains
|
||||
<code>MGLTileSourceOptionTileCoordinateSystem</code> with a value of
|
||||
<code>MGLTileCoordinateSystemTMS</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{z}</code></td>
|
||||
<td>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,
|
||||
<sup>1</sup>⁄<sub>16</sub> of the world, and so on. For tiles loaded by
|
||||
a <code>MGLRasterTileSource</code> 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
|
||||
<code>MGLTileSourceOptionTileSize</code> key of the <code>options</code>
|
||||
parameter.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{bbox-epsg-3857}</code></td>
|
||||
<td>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
|
||||
<a href="http://www.opengeospatial.org/standards/wms">Web Map Service</a>
|
||||
protocol.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{quadkey}</code></td>
|
||||
<td>A quadkey indicating both the tile’s location and its zoom level. The
|
||||
quadkey is typically used with
|
||||
<a href="https://msdn.microsoft.com/en-us/library/bb259689.aspx">Bing Maps</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{ratio}</code></td>
|
||||
<td>A suffix indicating the resolution of the tile image. The suffix is the
|
||||
empty string for standard resolution displays and <code>@2x</code> for
|
||||
Retina displays, including displays for which <code>UIScreen.scale</code>
|
||||
is 3.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{prefix}</code></td>
|
||||
<td>Two hexadecimal digits chosen such that each visible tile has a
|
||||
different prefix. The prefix is typically used for domain sharding.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
For more information about the `{x}`, `{y}`, and `{z}` placeholder strings,
|
||||
consult the
|
||||
[OpenStreetMap Wiki](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames).
|
||||
@@ -1,430 +0,0 @@
|
||||
<!--
|
||||
This file is generated.
|
||||
Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
-->
|
||||
# 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<NSNumber>` | `[Float]`
|
||||
Array (`-font`) | `NSArray<NSString>` | `[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.
|
||||
@@ -1,317 +0,0 @@
|
||||
<!--
|
||||
This file is generated.
|
||||
Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
-->
|
||||
|
||||
# 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<UIColor>(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<UIColor>(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<UIColor>(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.
|
||||
|
||||
<img src="img/data-driven-styling/exponential-function.png" height=344/>
|
||||
<img src="img/data-driven-styling/exponential-function-1.png" height=344/>
|
||||
|
||||
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<NSNumber>(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<UIColor>(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<UIColor>(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<UIColor>(rawValue: .orange),
|
||||
"explosion": MGLStyleValue(rawValue: .red),
|
||||
"quarry blast": MGLStyleValue(rawValue: .yellow),
|
||||
]
|
||||
|
||||
layer.circleColor = MGLStyleValue(interpolationMode: .categorical,
|
||||
sourceStops: categoricalStops,
|
||||
attributeName: "type",
|
||||
options: [.defaultValue: MGLStyleValue<UIColor>(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<NSNumber>(rawValue: 0)])
|
||||
```
|
||||
|
||||
Current syntax:
|
||||
```swift
|
||||
layer.circleRadius = NSExpression(forKeyPath: "mag")
|
||||
```
|
||||
|
||||

|
||||
|
||||
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])
|
||||
```
|
||||
|
||||

|
||||
|
||||
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)
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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)
|
||||
@@ -1,98 +0,0 @@
|
||||
<!--
|
||||
This file is generated.
|
||||
Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
-->
|
||||
# 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:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Placeholder string</th><th>Description</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>{x}</code></td>
|
||||
<td>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 2<sup><var>z</var></sup>−1,
|
||||
the tile’s right edge corresponds to the 180th meridian east.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{y}</code></td>
|
||||
<td>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 2<sup><var>z</var></sup>−1, the tile’s bottom edge corresponds to
|
||||
−arctan(sinh(π)), or approximately 85.0511 degrees south. The y axis is
|
||||
inverted if the <code>options</code> parameter contains
|
||||
<code>MGLTileSourceOptionTileCoordinateSystem</code> with a value of
|
||||
<code>MGLTileCoordinateSystemTMS</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{z}</code></td>
|
||||
<td>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,
|
||||
<sup>1</sup>⁄<sub>16</sub> of the world, and so on. For tiles loaded by
|
||||
a <code>MGLRasterTileSource</code> 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
|
||||
<code>MGLTileSourceOptionTileSize</code> key of the <code>options</code>
|
||||
parameter.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{bbox-epsg-3857}</code></td>
|
||||
<td>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
|
||||
<a href="http://www.opengeospatial.org/standards/wms">Web Map Service</a>
|
||||
protocol.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{quadkey}</code></td>
|
||||
<td>A quadkey indicating both the tile’s location and its zoom level. The
|
||||
quadkey is typically used with
|
||||
<a href="https://msdn.microsoft.com/en-us/library/bb259689.aspx">Bing Maps</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{ratio}</code></td>
|
||||
<td>A suffix indicating the resolution of the tile image. The suffix is the
|
||||
empty string for standard resolution displays and <code>@2x</code> for
|
||||
Retina displays.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>{prefix}</code></td>
|
||||
<td>Two hexadecimal digits chosen such that each visible tile has a
|
||||
different prefix. The prefix is typically used for domain sharding.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
For more information about the `{x}`, `{y}`, and `{z}` placeholder strings,
|
||||
consult the
|
||||
[OpenStreetMap Wiki](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames).
|
||||
@@ -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}));
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user