[ios, macos] Add support for data-driven property functions
This commit is contained in:
committed by
John Firebaugh
parent
f562ecdfc3
commit
22b3834caa
@@ -26,6 +26,11 @@ private:
|
||||
return lhs.value == rhs.value;
|
||||
}
|
||||
|
||||
friend bool operator!=(const DataDrivenPropertyValue& lhs,
|
||||
const DataDrivenPropertyValue& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
public:
|
||||
DataDrivenPropertyValue() = default;
|
||||
DataDrivenPropertyValue( T v) : value(std::move(v)) {}
|
||||
|
||||
@@ -13,11 +13,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
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.
|
||||
*/
|
||||
@@ -31,11 +31,11 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The color with which the background will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`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.
|
||||
*/
|
||||
@@ -43,11 +43,11 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The color with which the background will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`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.
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The opacity at which the background will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
@@ -86,28 +86,34 @@
|
||||
- (void)setBackgroundColor:(MGLStyleValue<MGLColor *> *)backgroundColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(backgroundColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toInterpolatablePropertyValue(backgroundColor);
|
||||
self.rawLayer->setBackgroundColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)backgroundColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getBackgroundColor() ?: self.rawLayer->getDefaultBackgroundColor();
|
||||
auto propertyValue = self.rawLayer->getBackgroundColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(self.rawLayer->getDefaultBackgroundColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setBackgroundOpacity:(MGLStyleValue<NSNumber *> *)backgroundOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(backgroundOpacity);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(backgroundOpacity);
|
||||
self.rawLayer->setBackgroundOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)backgroundOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getBackgroundOpacity() ?: self.rawLayer->getDefaultBackgroundOpacity();
|
||||
auto propertyValue = self.rawLayer->getBackgroundOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultBackgroundOpacity());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -121,7 +127,10 @@
|
||||
- (MGLStyleValue<NSString *> *)backgroundPattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getBackgroundPattern() ?: self.rawLayer->getDefaultBackgroundPattern();
|
||||
auto propertyValue = self.rawLayer->getBackgroundPattern();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(self.rawLayer->getDefaultBackgroundPattern());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ typedef NS_ENUM(NSUInteger, MGLCircleTranslationAnchor) {
|
||||
/**
|
||||
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 in vector tiles loaded by an `MGLVectorSource` object or
|
||||
`MGLPointAnnotation`, `MGLPointFeature`, `MGLPointCollection`, or
|
||||
`MGLPointCollectionFeature` instances in an `MGLShapeSource` 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
|
||||
@@ -84,7 +84,7 @@ MGL_EXPORT
|
||||
/**
|
||||
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 `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -94,7 +94,7 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The fill color of the circle.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`UIColor.blackColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
@@ -103,7 +103,7 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The fill color of the circle.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`NSColor.blackColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
@@ -113,7 +113,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The opacity at which the circle will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -122,9 +122,9 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Circle radius.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `5`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -133,11 +133,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Controls the scaling behavior of the circle when the map is pitched.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLCircleScaleAlignmentMap`. 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.
|
||||
@@ -149,7 +149,7 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The stroke color of the circle.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`UIColor.blackColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
@@ -158,7 +158,7 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The stroke color of the circle.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`NSColor.blackColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
@@ -168,7 +168,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The opacity of the circle's stroke.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -177,10 +177,10 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The width of the circle's stroke. Strokes are placed outside of the
|
||||
"circle-radius".
|
||||
|
||||
`circleRadius`.
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -190,13 +190,13 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The geometry's offset.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing 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.
|
||||
@@ -205,13 +205,13 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The geometry's offset.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing 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.
|
||||
@@ -223,14 +223,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Controls the translation reference point.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLCircleTranslationAnchorMap`. 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.
|
||||
|
||||
@@ -136,57 +136,69 @@ namespace mbgl {
|
||||
- (void)setCircleBlur:(MGLStyleValue<NSNumber *> *)circleBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleBlur);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(circleBlur);
|
||||
self.rawLayer->setCircleBlur(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)circleBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleBlur() ?: self.rawLayer->getDefaultCircleBlur();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getCircleBlur();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleBlur());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCircleColor:(MGLStyleValue<MGLColor *> *)circleColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(circleColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenPropertyValue(circleColor);
|
||||
self.rawLayer->setCircleColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)circleColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleColor() ?: self.rawLayer->getDefaultCircleColor();
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getCircleColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCircleOpacity:(MGLStyleValue<NSNumber *> *)circleOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleOpacity);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(circleOpacity);
|
||||
self.rawLayer->setCircleOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)circleOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleOpacity() ?: self.rawLayer->getDefaultCircleOpacity();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getCircleOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleOpacity());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCircleRadius:(MGLStyleValue<NSNumber *> *)circleRadius {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleRadius);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(circleRadius);
|
||||
self.rawLayer->setCircleRadius(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)circleRadius {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleRadius() ?: self.rawLayer->getDefaultCircleRadius();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getCircleRadius();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleRadius());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCircleScaleAlignment:(MGLStyleValue<NSValue *> *)circleScaleAlignment {
|
||||
@@ -199,7 +211,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)circleScaleAlignment {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCirclePitchScale() ?: self.rawLayer->getDefaultCirclePitchScale();
|
||||
auto propertyValue = self.rawLayer->getCirclePitchScale();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCircleScaleAlignment>().toEnumStyleValue(self.rawLayer->getDefaultCirclePitchScale());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCircleScaleAlignment>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -213,56 +228,68 @@ namespace mbgl {
|
||||
- (void)setCircleStrokeColor:(MGLStyleValue<MGLColor *> *)circleStrokeColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(circleStrokeColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenPropertyValue(circleStrokeColor);
|
||||
self.rawLayer->setCircleStrokeColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)circleStrokeColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeColor() ?: self.rawLayer->getDefaultCircleStrokeColor();
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleStrokeColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCircleStrokeOpacity:(MGLStyleValue<NSNumber *> *)circleStrokeOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleStrokeOpacity);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(circleStrokeOpacity);
|
||||
self.rawLayer->setCircleStrokeOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)circleStrokeOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeOpacity() ?: self.rawLayer->getDefaultCircleStrokeOpacity();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleStrokeOpacity());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCircleStrokeWidth:(MGLStyleValue<NSNumber *> *)circleStrokeWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(circleStrokeWidth);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(circleStrokeWidth);
|
||||
self.rawLayer->setCircleStrokeWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)circleStrokeWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeWidth() ?: self.rawLayer->getDefaultCircleStrokeWidth();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getCircleStrokeWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleStrokeWidth());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setCircleTranslation:(MGLStyleValue<NSValue *> *)circleTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(circleTranslation);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toInterpolatablePropertyValue(circleTranslation);
|
||||
self.rawLayer->setCircleTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSValue *> *)circleTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleTranslate() ?: self.rawLayer->getDefaultCircleTranslate();
|
||||
auto propertyValue = self.rawLayer->getCircleTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(self.rawLayer->getDefaultCircleTranslate());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -283,7 +310,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)circleTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getCircleTranslateAnchor() ?: self.rawLayer->getDefaultCircleTranslateAnchor();
|
||||
auto propertyValue = self.rawLayer->getCircleTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslationAnchor>().toEnumStyleValue(self.rawLayer->getDefaultCircleTranslateAnchor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslationAnchor>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslationAnchor) {
|
||||
/**
|
||||
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 in vector tiles loaded by an `MGLVectorSource` object or
|
||||
`MGLPolygon`, `MGLPolygonFeature`, `MGLMultiPolygon`, or
|
||||
@@ -56,11 +56,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Whether or not the fill should be antialiased.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `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.
|
||||
@@ -72,11 +72,11 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The color of the filled part of this layer.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`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.
|
||||
*/
|
||||
@@ -84,11 +84,11 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The color of the filled part of this layer.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`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.
|
||||
*/
|
||||
@@ -98,7 +98,7 @@ MGL_EXPORT
|
||||
/**
|
||||
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 `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -108,7 +108,7 @@ MGL_EXPORT
|
||||
#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 `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `YES`. Otherwise, it is ignored.
|
||||
@@ -117,7 +117,7 @@ MGL_EXPORT
|
||||
#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 `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `YES`. Otherwise, it is ignored.
|
||||
@@ -134,13 +134,13 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The geometry's offset.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing 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.
|
||||
@@ -149,13 +149,13 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The geometry's offset.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing 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.
|
||||
@@ -167,14 +167,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Controls the translation reference point.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLFillTranslationAnchorMap`. 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.
|
||||
|
||||
@@ -138,7 +138,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)isFillAntialiased {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillAntialias() ?: self.rawLayer->getDefaultFillAntialias();
|
||||
auto propertyValue = self.rawLayer->getFillAntialias();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultFillAntialias());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -152,43 +155,52 @@ namespace mbgl {
|
||||
- (void)setFillColor:(MGLStyleValue<MGLColor *> *)fillColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(fillColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenPropertyValue(fillColor);
|
||||
self.rawLayer->setFillColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)fillColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillColor() ?: self.rawLayer->getDefaultFillColor();
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getFillColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(self.rawLayer->getDefaultFillColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setFillOpacity:(MGLStyleValue<NSNumber *> *)fillOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(fillOpacity);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(fillOpacity);
|
||||
self.rawLayer->setFillOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)fillOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillOpacity() ?: self.rawLayer->getDefaultFillOpacity();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getFillOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultFillOpacity());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setFillOutlineColor:(MGLStyleValue<MGLColor *> *)fillOutlineColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(fillOutlineColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenPropertyValue(fillOutlineColor);
|
||||
self.rawLayer->setFillOutlineColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)fillOutlineColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillOutlineColor() ?: self.rawLayer->getDefaultFillOutlineColor();
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getFillOutlineColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(self.rawLayer->getDefaultFillOutlineColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setFillPattern:(MGLStyleValue<NSString *> *)fillPattern {
|
||||
@@ -201,21 +213,27 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSString *> *)fillPattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillPattern() ?: self.rawLayer->getDefaultFillPattern();
|
||||
auto propertyValue = self.rawLayer->getFillPattern();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(self.rawLayer->getDefaultFillPattern());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setFillTranslation:(MGLStyleValue<NSValue *> *)fillTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(fillTranslation);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toInterpolatablePropertyValue(fillTranslation);
|
||||
self.rawLayer->setFillTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSValue *> *)fillTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillTranslate() ?: self.rawLayer->getDefaultFillTranslate();
|
||||
auto propertyValue = self.rawLayer->getFillTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(self.rawLayer->getDefaultFillTranslate());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -236,7 +254,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)fillTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getFillTranslateAnchor() ?: self.rawLayer->getDefaultFillTranslateAnchor();
|
||||
auto propertyValue = self.rawLayer->getFillTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslationAnchor>().toEnumStyleValue(self.rawLayer->getDefaultFillTranslateAnchor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslationAnchor>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslationAnchor) {
|
||||
/**
|
||||
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 in vector tiles loaded by an `MGLVectorSource` object or
|
||||
`MGLPolyline`, `MGLPolylineFeature`, `MGLMultiPolyline`, or
|
||||
@@ -111,7 +111,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The display of line endings.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLLineCapButt`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
@@ -120,7 +120,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The display of lines when joining.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLLineJoinMiter`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
@@ -129,11 +129,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Used to automatically convert miter joins to bevel joins for sharp angles.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing 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
|
||||
`MGLStyleValue` object containing an `NSValue` object containing
|
||||
`MGLLineJoinMiter`. Otherwise, it is ignored.
|
||||
@@ -142,11 +142,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Used to automatically convert round joins to miter joins for shallow angles.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing 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
|
||||
`MGLStyleValue` object containing an `NSValue` object containing
|
||||
`MGLLineJoinRound`. Otherwise, it is ignored.
|
||||
@@ -157,9 +157,9 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Blur applied to the line, in points.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -169,11 +169,11 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The color with which the line will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`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.
|
||||
*/
|
||||
@@ -181,11 +181,11 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The color with which the line will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`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.
|
||||
*/
|
||||
@@ -196,12 +196,12 @@ MGL_EXPORT
|
||||
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.
|
||||
|
||||
|
||||
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.
|
||||
@@ -213,9 +213,9 @@ MGL_EXPORT
|
||||
/**
|
||||
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 `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -227,9 +227,9 @@ MGL_EXPORT
|
||||
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 `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -238,7 +238,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The opacity at which the line will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -254,13 +254,13 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The geometry's offset.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing 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.
|
||||
@@ -269,13 +269,13 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The geometry's offset.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing 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.
|
||||
@@ -287,14 +287,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Controls the translation reference point.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLLineTranslationAnchorMap`. 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.
|
||||
@@ -305,9 +305,9 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Stroke thickness.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
@@ -150,7 +150,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)lineCap {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineCap() ?: self.rawLayer->getDefaultLineCap();
|
||||
auto propertyValue = self.rawLayer->getLineCap();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::LineCapType, NSValue *, mbgl::style::LineCapType, MGLLineCap>().toEnumStyleValue(self.rawLayer->getDefaultLineCap());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::LineCapType, NSValue *, mbgl::style::LineCapType, MGLLineCap>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -164,35 +167,44 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)lineJoin {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineJoin() ?: self.rawLayer->getDefaultLineJoin();
|
||||
auto propertyValue = self.rawLayer->getLineJoin();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toEnumStyleValue(self.rawLayer->getDefaultLineJoin());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineMiterLimit:(MGLStyleValue<NSNumber *> *)lineMiterLimit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineMiterLimit);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(lineMiterLimit);
|
||||
self.rawLayer->setLineMiterLimit(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)lineMiterLimit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineMiterLimit() ?: self.rawLayer->getDefaultLineMiterLimit();
|
||||
auto propertyValue = self.rawLayer->getLineMiterLimit();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultLineMiterLimit());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineRoundLimit:(MGLStyleValue<NSNumber *> *)lineRoundLimit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineRoundLimit);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(lineRoundLimit);
|
||||
self.rawLayer->setLineRoundLimit(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)lineRoundLimit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineRoundLimit() ?: self.rawLayer->getDefaultLineRoundLimit();
|
||||
auto propertyValue = self.rawLayer->getLineRoundLimit();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultLineRoundLimit());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -201,29 +213,35 @@ namespace mbgl {
|
||||
- (void)setLineBlur:(MGLStyleValue<NSNumber *> *)lineBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineBlur);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(lineBlur);
|
||||
self.rawLayer->setLineBlur(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)lineBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineBlur() ?: self.rawLayer->getDefaultLineBlur();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getLineBlur();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultLineBlur());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineColor:(MGLStyleValue<MGLColor *> *)lineColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(lineColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenPropertyValue(lineColor);
|
||||
self.rawLayer->setLineColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)lineColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineColor() ?: self.rawLayer->getDefaultLineColor();
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getLineColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(self.rawLayer->getDefaultLineColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineDashPattern:(MGLStyleValue<NSArray<NSNumber *> *> *)lineDashPattern {
|
||||
@@ -236,7 +254,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSArray<NSNumber *> *> *)lineDashPattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineDasharray() ?: self.rawLayer->getDefaultLineDasharray();
|
||||
auto propertyValue = self.rawLayer->getLineDasharray();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::vector<float>, NSArray<NSNumber *> *, float>().toStyleValue(self.rawLayer->getDefaultLineDasharray());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::vector<float>, NSArray<NSNumber *> *, float>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -250,43 +271,52 @@ namespace mbgl {
|
||||
- (void)setLineGapWidth:(MGLStyleValue<NSNumber *> *)lineGapWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineGapWidth);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(lineGapWidth);
|
||||
self.rawLayer->setLineGapWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)lineGapWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineGapWidth() ?: self.rawLayer->getDefaultLineGapWidth();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getLineGapWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultLineGapWidth());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineOffset:(MGLStyleValue<NSNumber *> *)lineOffset {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineOffset);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(lineOffset);
|
||||
self.rawLayer->setLineOffset(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)lineOffset {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineOffset() ?: self.rawLayer->getDefaultLineOffset();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getLineOffset();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultLineOffset());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineOpacity:(MGLStyleValue<NSNumber *> *)lineOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineOpacity);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(lineOpacity);
|
||||
self.rawLayer->setLineOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)lineOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineOpacity() ?: self.rawLayer->getDefaultLineOpacity();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getLineOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultLineOpacity());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLinePattern:(MGLStyleValue<NSString *> *)linePattern {
|
||||
@@ -299,21 +329,27 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSString *> *)linePattern {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLinePattern() ?: self.rawLayer->getDefaultLinePattern();
|
||||
auto propertyValue = self.rawLayer->getLinePattern();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(self.rawLayer->getDefaultLinePattern());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineTranslation:(MGLStyleValue<NSValue *> *)lineTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(lineTranslation);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toInterpolatablePropertyValue(lineTranslation);
|
||||
self.rawLayer->setLineTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSValue *> *)lineTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineTranslate() ?: self.rawLayer->getDefaultLineTranslate();
|
||||
auto propertyValue = self.rawLayer->getLineTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(self.rawLayer->getDefaultLineTranslate());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -334,7 +370,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)lineTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineTranslateAnchor() ?: self.rawLayer->getDefaultLineTranslateAnchor();
|
||||
auto propertyValue = self.rawLayer->getLineTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLLineTranslationAnchor>().toEnumStyleValue(self.rawLayer->getDefaultLineTranslateAnchor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLLineTranslationAnchor>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -348,14 +387,17 @@ namespace mbgl {
|
||||
- (void)setLineWidth:(MGLStyleValue<NSNumber *> *)lineWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(lineWidth);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(lineWidth);
|
||||
self.rawLayer->setLineWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)lineWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineWidth() ?: self.rawLayer->getDefaultLineWidth();
|
||||
auto propertyValue = self.rawLayer->getLineWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultLineWidth());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
An `MGLRasterStyleLayer` is a style layer that renders raster tiles on the map.
|
||||
|
||||
|
||||
Use a raster style layer to configure the color parameters of raster tiles
|
||||
loaded by an `MGLRasterSource` object. For example, you could use a raster
|
||||
style layer to render <a href="https://www.mapbox.com/satellite/">Mapbox
|
||||
@@ -41,11 +41,11 @@ MGL_EXPORT
|
||||
/**
|
||||
Increase or reduce the brightness of the image. The value is the maximum
|
||||
brightness.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing 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.
|
||||
@@ -57,11 +57,11 @@ MGL_EXPORT
|
||||
/**
|
||||
Increase or reduce the brightness of the image. The value is the minimum
|
||||
brightness.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing 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.
|
||||
@@ -72,7 +72,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Increase or reduce the contrast of the image.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -81,9 +81,9 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Fade duration when a new tile is added.
|
||||
|
||||
|
||||
This property is measured in milliseconds.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `300`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
@@ -92,13 +92,13 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Rotates hues around the color wheel.
|
||||
|
||||
|
||||
This property is measured in degrees.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing 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.
|
||||
@@ -109,7 +109,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The opacity at which the image will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
@@ -118,7 +118,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Increase or reduce the saturation of the image.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
@@ -93,14 +93,17 @@
|
||||
- (void)setMaximumRasterBrightness:(MGLStyleValue<NSNumber *> *)maximumRasterBrightness {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(maximumRasterBrightness);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(maximumRasterBrightness);
|
||||
self.rawLayer->setRasterBrightnessMax(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)maximumRasterBrightness {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterBrightnessMax() ?: self.rawLayer->getDefaultRasterBrightnessMax();
|
||||
auto propertyValue = self.rawLayer->getRasterBrightnessMax();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultRasterBrightnessMax());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -114,14 +117,17 @@
|
||||
- (void)setMinimumRasterBrightness:(MGLStyleValue<NSNumber *> *)minimumRasterBrightness {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(minimumRasterBrightness);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(minimumRasterBrightness);
|
||||
self.rawLayer->setRasterBrightnessMin(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)minimumRasterBrightness {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterBrightnessMin() ?: self.rawLayer->getDefaultRasterBrightnessMin();
|
||||
auto propertyValue = self.rawLayer->getRasterBrightnessMin();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultRasterBrightnessMin());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -135,42 +141,51 @@
|
||||
- (void)setRasterContrast:(MGLStyleValue<NSNumber *> *)rasterContrast {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterContrast);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(rasterContrast);
|
||||
self.rawLayer->setRasterContrast(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)rasterContrast {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterContrast() ?: self.rawLayer->getDefaultRasterContrast();
|
||||
auto propertyValue = self.rawLayer->getRasterContrast();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultRasterContrast());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setRasterFadeDuration:(MGLStyleValue<NSNumber *> *)rasterFadeDuration {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterFadeDuration);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(rasterFadeDuration);
|
||||
self.rawLayer->setRasterFadeDuration(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)rasterFadeDuration {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterFadeDuration() ?: self.rawLayer->getDefaultRasterFadeDuration();
|
||||
auto propertyValue = self.rawLayer->getRasterFadeDuration();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultRasterFadeDuration());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setRasterHueRotation:(MGLStyleValue<NSNumber *> *)rasterHueRotation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterHueRotation);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(rasterHueRotation);
|
||||
self.rawLayer->setRasterHueRotate(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)rasterHueRotation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterHueRotate() ?: self.rawLayer->getDefaultRasterHueRotate();
|
||||
auto propertyValue = self.rawLayer->getRasterHueRotate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultRasterHueRotate());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -184,28 +199,34 @@
|
||||
- (void)setRasterOpacity:(MGLStyleValue<NSNumber *> *)rasterOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterOpacity);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(rasterOpacity);
|
||||
self.rawLayer->setRasterOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)rasterOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterOpacity() ?: self.rawLayer->getDefaultRasterOpacity();
|
||||
auto propertyValue = self.rawLayer->getRasterOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultRasterOpacity());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setRasterSaturation:(MGLStyleValue<NSNumber *> *)rasterSaturation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(rasterSaturation);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(rasterSaturation);
|
||||
self.rawLayer->setRasterSaturation(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)rasterSaturation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getRasterSaturation() ?: self.rawLayer->getDefaultRasterSaturation();
|
||||
auto propertyValue = self.rawLayer->getRasterSaturation();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultRasterSaturation());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -176,24 +176,42 @@ namespace mbgl {
|
||||
- (void)set<%- camelize(property.name) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
<% if (property["property-function"]) { -%>
|
||||
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenPropertyValue(<%- objCName(property) %>);
|
||||
<% } else { -%>
|
||||
<% if (property.type == "enum") { -%>
|
||||
auto mbglValue = MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>);
|
||||
self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
|
||||
<% } else { -%>
|
||||
<% } else if (property.function == "piecewise-constant") { -%>
|
||||
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>);
|
||||
self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
|
||||
<% } else { -%>
|
||||
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toInterpolatablePropertyValue(<%- objCName(property) %>);
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCGetter(property) %> {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>();
|
||||
auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>();
|
||||
<% if (property["property-function"]) { -%>
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>());
|
||||
}
|
||||
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenStyleValue(propertyValue);
|
||||
<% } else { -%>
|
||||
<% if (property.type == "enum") { -%>
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>());
|
||||
}
|
||||
return MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue);
|
||||
<% } else { -%>
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>());
|
||||
}
|
||||
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue);
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
}
|
||||
|
||||
<% if (property.original) { -%>
|
||||
@@ -214,24 +232,42 @@ namespace mbgl {
|
||||
- (void)set<%- camelize(property.name) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
<% if (property["property-function"]) { -%>
|
||||
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenPropertyValue(<%- objCName(property) %>);
|
||||
<% } else { -%>
|
||||
<% if (property.type == "enum") { -%>
|
||||
auto mbglValue = MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>);
|
||||
self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
|
||||
<% } else { -%>
|
||||
<% } else if (property.function == "piecewise-constant") { -%>
|
||||
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>);
|
||||
self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
|
||||
<% } else { -%>
|
||||
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toInterpolatablePropertyValue(<%- objCName(property) %>);
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCGetter(property) %> {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>();
|
||||
auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>();
|
||||
<% if (property["property-function"]) { -%>
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>());
|
||||
}
|
||||
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenStyleValue(propertyValue);
|
||||
<% } else { -%>
|
||||
<% if (property.type == "enum") { -%>
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>());
|
||||
}
|
||||
return MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue);
|
||||
<% } else { -%>
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>());
|
||||
}
|
||||
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue);
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
}
|
||||
|
||||
<% if (property.original) { -%>
|
||||
|
||||
@@ -2,9 +2,27 @@
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
#import "MGLFoundation.h"
|
||||
#import "MGLTypes.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// TODO: API docs
|
||||
typedef NSString *MGLStyleFunctionOption NS_STRING_ENUM;
|
||||
|
||||
// TODO: API docs
|
||||
extern MGL_EXPORT const MGLStyleFunctionOption MGLStyleFunctionOptionInterpolationBase;
|
||||
|
||||
// TODO: API docs
|
||||
extern MGL_EXPORT const MGLStyleFunctionOption MGLStyleFunctionOptionDefaultValue;
|
||||
|
||||
// TODO: API docs
|
||||
typedef NS_ENUM(NSUInteger, MGLInterpolationMode) {
|
||||
MGLInterpolationModeExponential = 0,
|
||||
MGLInterpolationModeInterval,
|
||||
MGLInterpolationModeCategorical,
|
||||
MGLInterpolationModeIdentity
|
||||
};
|
||||
|
||||
/**
|
||||
An `MGLStyleValue` object is a generic container for a style attribute value.
|
||||
The layout and paint attribute properties of `MGLStyleLayer` can be set to
|
||||
@@ -41,6 +59,8 @@ MGL_EXPORT
|
||||
*/
|
||||
+ (instancetype)valueWithRawValue:(T)rawValue;
|
||||
|
||||
#pragma mark Function values
|
||||
|
||||
/**
|
||||
Creates and returns an `MGLStyleFunction` object representing a linear zoom
|
||||
level function with any number of stops.
|
||||
@@ -48,7 +68,7 @@ MGL_EXPORT
|
||||
@param stops A dictionary associating zoom levels with style values.
|
||||
@return An `MGLStyleFunction` object with the given stops.
|
||||
*/
|
||||
+ (instancetype)valueWithStops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;
|
||||
+ (instancetype)valueWithStops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops __attribute__((deprecated("Use +[MGLStyleValue valueWithInterpolationMode:cameraStops:options:]")));
|
||||
|
||||
/**
|
||||
Creates and returns an `MGLStyleFunction` object representing a zoom level
|
||||
@@ -58,7 +78,16 @@ MGL_EXPORT
|
||||
@param stops A dictionary associating zoom levels with style values.
|
||||
@return An `MGLStyleFunction` object with the given interpolation base and stops.
|
||||
*/
|
||||
+ (instancetype)valueWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;
|
||||
+ (instancetype)valueWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops __attribute__((deprecated("Use +[MGLStyleValue valueWithInterpolationMode:cameraStops:options:]")));
|
||||
|
||||
// TODO: API docs
|
||||
+ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode cameraStops:(NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options;
|
||||
|
||||
// TODO: API docs
|
||||
+ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode sourceStops:(nullable NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options;
|
||||
|
||||
// TODO: API docs
|
||||
+ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode compositeStops:(NS_DICTIONARY_OF(id, NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options;
|
||||
|
||||
@end
|
||||
|
||||
@@ -106,75 +135,76 @@ MGL_EXPORT
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
An `MGLStyleFunction` is a value function defining a style value that changes
|
||||
as the zoom level changes. The layout and paint attribute properties of an
|
||||
`MGLStyleLayer` object can be set to `MGLStyleFunction` objects. Use a zoom
|
||||
level function to create the illusion of depth and control data density.
|
||||
|
||||
The `MGLStyleFunction` class takes a generic parameter `T` that indicates the
|
||||
Foundation class being wrapped by this class.
|
||||
*/
|
||||
MGL_EXPORT
|
||||
@interface MGLStyleFunction<T> : MGLStyleValue<T>
|
||||
@interface MGLCameraStyleFunction<T> : MGLStyleValue<T>
|
||||
|
||||
#pragma mark Creating a Style Function
|
||||
// TODO: API docs
|
||||
+ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options;
|
||||
|
||||
/**
|
||||
Creates and returns an `MGLStyleFunction` object representing a linear zoom
|
||||
level function with any number of stops.
|
||||
// TODO: API docs
|
||||
- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@param stops A dictionary associating zoom levels with style values.
|
||||
@return An `MGLStyleFunction` object with the given stops.
|
||||
*/
|
||||
+ (instancetype)functionWithStops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;
|
||||
// TODO: API docs
|
||||
@property (nonatomic) MGLInterpolationMode interpolationMode;
|
||||
|
||||
/**
|
||||
Creates and returns an `MGLStyleFunction` object representing a zoom level
|
||||
function with an exponential interpolation base and any number of stops.
|
||||
// TODO: API docs
|
||||
@property (nonatomic, copy) NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *stops;
|
||||
|
||||
@param interpolationBase The exponential base of the interpolation curve.
|
||||
@param stops A dictionary associating zoom levels with style values.
|
||||
@return An `MGLStyleFunction` object with the given interpolation base and stops.
|
||||
*/
|
||||
+ (instancetype)functionWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;
|
||||
|
||||
#pragma mark Initializing a Style Function
|
||||
|
||||
/**
|
||||
Returns an `MGLStyleFunction` object representing a zoom level function with an
|
||||
exponential interpolation base and any number of stops.
|
||||
|
||||
@param interpolationBase The exponential base of the interpolation curve.
|
||||
@param stops A dictionary associating zoom levels with style values.
|
||||
@return An `MGLStyleFunction` object with the given interpolation base and stops.
|
||||
*/
|
||||
- (instancetype)initWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
#pragma mark Accessing the Parameters of a Function
|
||||
|
||||
/**
|
||||
The exponential interpolation base of the function’s interpolation curve.
|
||||
|
||||
The exponential interpolation base controls the rate at which the function’s output values
|
||||
increase. A value of 1 causes the function to increase linearly by zoom level.
|
||||
A higher exponential interpolation base causes the function’s output values to vary
|
||||
exponentially, increasing more rapidly towards the high end of the function’s
|
||||
range. The default value of this property is 1, for a linear curve.
|
||||
*/
|
||||
// TODO: API docs
|
||||
@property (nonatomic) CGFloat interpolationBase;
|
||||
|
||||
/**
|
||||
A dictionary associating zoom levels with style values.
|
||||
@end
|
||||
|
||||
Each of the function’s stops is represented by one key-value pair in the
|
||||
dictionary. Each key in the dictionary is an `NSNumber` object containing a
|
||||
floating-point zoom level. Each value in the dictionary is an `MGLStyleValue`
|
||||
object containing the value of the style attribute when the map is at the
|
||||
associated zoom level. An `MGLStyleFunction` object may not be used recursively
|
||||
as a stop value.
|
||||
*/
|
||||
@property (nonatomic, copy) NSDictionary<NSNumber *, MGLStyleValue<T> *> *stops;
|
||||
@compatibility_alias MGLStyleFunction MGLCameraStyleFunction;
|
||||
|
||||
MGL_EXPORT
|
||||
@interface MGLSourceStyleFunction<T> : MGLStyleValue<T>
|
||||
|
||||
// TODO: API docs
|
||||
+ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(nullable NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options;
|
||||
|
||||
// TODO: API docs
|
||||
- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(nullable NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic) MGLInterpolationMode interpolationMode;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic, copy) NSString *attributeName;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic, copy, nullable) NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *stops;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic, nullable) MGLStyleValue<T> *defaultValue;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic) CGFloat interpolationBase;
|
||||
|
||||
@end
|
||||
|
||||
MGL_EXPORT
|
||||
@interface MGLCompositeStyleFunction<T> : MGLStyleValue<T>
|
||||
|
||||
// TODO: API docs
|
||||
+ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NS_DICTIONARY_OF(id, NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options;
|
||||
|
||||
- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NS_DICTIONARY_OF(id, NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *) *)stops attributeName:(NSString *)attributeName options:(nullable NS_DICTIONARY_OF(MGLStyleFunctionOption, id) *)options NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic) MGLInterpolationMode interpolationMode;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic, copy) NSString *attributeName;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic, copy) NS_DICTIONARY_OF(id, NS_DICTIONARY_OF(id, MGLStyleValue<T> *) *) *stops;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic, nullable) MGLStyleValue<T> *defaultValue;
|
||||
|
||||
// TODO: API docs
|
||||
@property (nonatomic) CGFloat interpolationBase;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#import "MGLStyleValue_Private.h"
|
||||
|
||||
const MGLStyleFunctionOption MGLStyleFunctionOptionInterpolationBase = @"MGLStyleFunctionOptionInterpolationBase";
|
||||
const MGLStyleFunctionOption MGLStyleFunctionOptionDefaultValue = @"MGLStyleFunctionOptionDefaultValue";
|
||||
|
||||
@implementation MGLStyleValue
|
||||
|
||||
+ (instancetype)valueWithRawValue:(id)rawValue {
|
||||
@@ -7,11 +10,23 @@
|
||||
}
|
||||
|
||||
+ (instancetype)valueWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary *)stops {
|
||||
return [MGLStyleFunction functionWithInterpolationBase:interpolationBase stops:stops];
|
||||
return [MGLCameraStyleFunction functionWithInterpolationMode:MGLInterpolationModeExponential stops:stops options:@{MGLStyleFunctionOptionInterpolationBase: @(interpolationBase)}];
|
||||
}
|
||||
|
||||
+ (instancetype)valueWithStops:(NSDictionary *)stops {
|
||||
return [MGLStyleFunction functionWithStops:stops];
|
||||
return [MGLCameraStyleFunction functionWithInterpolationMode:MGLInterpolationModeExponential stops:stops options:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode cameraStops:(NSDictionary *)stops options:(NSDictionary *)options {
|
||||
return [MGLCameraStyleFunction functionWithInterpolationMode:interpolationMode stops:stops options:options];
|
||||
}
|
||||
|
||||
+ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode sourceStops:(NSDictionary *)stops attributeName:(NSString *)attributeName options:(NSDictionary *)options {
|
||||
return [MGLSourceStyleFunction functionWithInterpolationMode:interpolationMode stops:stops attributeName:attributeName options:options];
|
||||
}
|
||||
|
||||
+ (instancetype)valueWithInterpolationMode:(MGLInterpolationMode)interpolationMode compositeStops:(NSDictionary *)stops attributeName:(NSString *)attributeName options:(NSDictionary *)options {
|
||||
return [MGLCompositeStyleFunction functionWithInterpolationMode:interpolationMode stops:stops attributeName:attributeName options:options];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -47,46 +62,203 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation MGLStyleFunction
|
||||
@implementation MGLCameraStyleFunction
|
||||
|
||||
+ (instancetype)functionWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary *)stops {
|
||||
return [[self alloc] initWithInterpolationBase:interpolationBase stops:stops];
|
||||
}
|
||||
@synthesize interpolationMode = _interpolationMode;
|
||||
|
||||
+ (instancetype)functionWithStops:(NSDictionary *)stops {
|
||||
return [[self alloc] initWithInterpolationBase:1 stops:stops];
|
||||
+ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NSDictionary *)stops options:(NSDictionary *)options {
|
||||
return [[self alloc] initWithInterpolationMode:interpolationMode stops:stops options:options];
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
return [self initWithInterpolationBase:1 stops:@{}];
|
||||
return [self initWithInterpolationMode:MGLInterpolationModeExponential stops:@{} options:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary *)stops {
|
||||
if (self = [super init]) {
|
||||
if (!stops.count)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException format:@"%@ requires at least one stop.", self];
|
||||
}
|
||||
_interpolationBase = interpolationBase;
|
||||
- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NSDictionary *)stops options:(NSDictionary *)options {
|
||||
if (![stops count]) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Camera functions must have at least one stop."];
|
||||
return {};
|
||||
}
|
||||
|
||||
if (self == [super init]) {
|
||||
_interpolationMode = interpolationMode;
|
||||
_stops = stops;
|
||||
_interpolationBase = 1.0;
|
||||
|
||||
if ([options.allKeys containsObject:MGLStyleFunctionOptionInterpolationBase]) {
|
||||
if ([options[MGLStyleFunctionOptionInterpolationBase] isKindOfClass:[NSNumber class]]) {
|
||||
NSNumber *value = (NSNumber *)options[MGLStyleFunctionOptionInterpolationBase];
|
||||
_interpolationBase = [value floatValue];
|
||||
} else {
|
||||
[NSException raise:NSInvalidArgumentException format:@"Interpolation base must be an NSNumber that represents a CGFloat."];
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"<%@: %p, interpolationBase = %f; stops = %@>",
|
||||
return [NSString stringWithFormat:@"<%@: %p, \
|
||||
interpolationMode = %lu, \
|
||||
stops = %@, \
|
||||
interpolationBase = %f>",
|
||||
NSStringFromClass([self class]), (void *)self,
|
||||
self.interpolationBase,
|
||||
self.stops];
|
||||
(unsigned long)self.interpolationMode,
|
||||
self.stops,
|
||||
self.interpolationBase];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(MGLStyleFunction *)other {
|
||||
return ([other isKindOfClass:[self class]] && other.interpolationBase == self.interpolationBase
|
||||
&& [other.stops isEqualToDictionary:self.stops]);
|
||||
- (BOOL)isEqual:(MGLCameraStyleFunction *)other {
|
||||
return ([other isKindOfClass:[self class]]
|
||||
&& other.interpolationMode == self.interpolationMode
|
||||
&& [other.stops isEqualToDictionary:self.stops]
|
||||
&& other.interpolationBase == self.interpolationBase);
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
return self.interpolationBase + self.stops.hash;
|
||||
return self.interpolationMode + self.stops.hash + self.interpolationBase;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MGLSourceStyleFunction
|
||||
|
||||
@synthesize interpolationMode = _interpolationMode;
|
||||
|
||||
+ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NSDictionary *)stops attributeName:(NSString *)attributeName options:(NSDictionary *)options {
|
||||
return [[self alloc] initWithInterpolationMode:interpolationMode stops:stops attributeName:attributeName options:options];
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
return [self initWithInterpolationMode:MGLInterpolationModeExponential stops:nil attributeName:@"" options:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NSDictionary *)stops attributeName:(NSString *)attributeName options:(NSDictionary *)options {
|
||||
if (self == [super init]) {
|
||||
_interpolationMode = interpolationMode;
|
||||
_stops = stops;
|
||||
_attributeName = attributeName;
|
||||
_interpolationBase = 1.0;
|
||||
|
||||
if ([options.allKeys containsObject:MGLStyleFunctionOptionDefaultValue]) {
|
||||
if ([options[MGLStyleFunctionOptionDefaultValue] isKindOfClass:[MGLStyleValue class]]) {
|
||||
MGLStyleValue *value = (MGLStyleValue *)options[MGLStyleFunctionOptionDefaultValue];
|
||||
_defaultValue = value;
|
||||
} else {
|
||||
[NSException raise:NSInvalidArgumentException format:@"Default value must be an MGLStyleValue"];
|
||||
}
|
||||
}
|
||||
|
||||
if ([options.allKeys containsObject:MGLStyleFunctionOptionInterpolationBase]) {
|
||||
if ([options[MGLStyleFunctionOptionInterpolationBase] isKindOfClass:[NSNumber class]]) {
|
||||
NSNumber *value = (NSNumber *)options[MGLStyleFunctionOptionInterpolationBase];
|
||||
_interpolationBase = [value floatValue];
|
||||
} else {
|
||||
[NSException raise:NSInvalidArgumentException format:@"Interpolation base must be an NSNumber that represents a CGFloat."];
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"<%@: %p, \
|
||||
interpolationMode = %lu, \
|
||||
stops = %@, \
|
||||
attributeName = %@, \
|
||||
defaultValue = %@, \
|
||||
interpolationBase = %f>",
|
||||
NSStringFromClass([self class]),
|
||||
(void *)self,
|
||||
(unsigned long)self.interpolationMode,
|
||||
self.stops,
|
||||
self.attributeName,
|
||||
self.defaultValue,
|
||||
self.interpolationBase];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(MGLSourceStyleFunction *)other {
|
||||
return ([other isKindOfClass:[self class]]
|
||||
&& other.interpolationMode == self.interpolationMode
|
||||
&& ((self.stops && [other.stops isEqualToDictionary:self.stops]) || (!self.stops && !other.stops))
|
||||
&& [other.attributeName isEqual:self.attributeName]
|
||||
&& ((self.defaultValue && [other.defaultValue isEqual:self.defaultValue]) || (!self.defaultValue && !other.defaultValue))
|
||||
&& other.interpolationBase == self.interpolationBase);
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
return self.interpolationMode + self.stops.hash + self.attributeName.hash + self.defaultValue.hash + self.interpolationBase;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MGLCompositeStyleFunction
|
||||
|
||||
@synthesize interpolationMode = _interpolationMode;
|
||||
|
||||
+ (instancetype)functionWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NSDictionary *)stops attributeName:(NSString *)attributeName options:(NSDictionary *)options {
|
||||
return [[self alloc] initWithInterpolationMode:interpolationMode stops:stops attributeName:attributeName options:options];
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
return [self initWithInterpolationMode:MGLInterpolationModeExponential stops:@{} attributeName:@"" options:nil];
|
||||
}
|
||||
|
||||
- (instancetype)initWithInterpolationMode:(MGLInterpolationMode)interpolationMode stops:(NSDictionary *)stops attributeName:(NSString *)attributeName options:(NSDictionary *)options {
|
||||
if (self == [super init]) {
|
||||
_interpolationMode = interpolationMode;
|
||||
_stops = stops;
|
||||
_attributeName = attributeName;
|
||||
_interpolationBase = 1.0;
|
||||
|
||||
if ([options.allKeys containsObject:MGLStyleFunctionOptionDefaultValue]) {
|
||||
if ([options[MGLStyleFunctionOptionDefaultValue] isKindOfClass:[MGLStyleValue class]]) {
|
||||
MGLStyleValue *value = (MGLStyleValue *)options[MGLStyleFunctionOptionDefaultValue];
|
||||
_defaultValue = value;
|
||||
} else {
|
||||
[NSException raise:NSInvalidArgumentException format:@"Default value must be an MGLStyleValue"];
|
||||
}
|
||||
}
|
||||
|
||||
if ([options.allKeys containsObject:MGLStyleFunctionOptionInterpolationBase]) {
|
||||
if ([options[MGLStyleFunctionOptionInterpolationBase] isKindOfClass:[NSNumber class]]) {
|
||||
NSNumber *value = (NSNumber *)options[MGLStyleFunctionOptionInterpolationBase];
|
||||
_interpolationBase = [value floatValue];
|
||||
} else {
|
||||
[NSException raise:NSInvalidArgumentException format:@"Interpolation base must be an NSNumber that represents a CGFloat."];
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"<%@: %p, \
|
||||
interpolationMode = %lu, \
|
||||
stops = %@, \
|
||||
attributeName = %@, \
|
||||
defaultValue = %@, \
|
||||
interpolationBase = %f>",
|
||||
NSStringFromClass([self class]), (void *)self,
|
||||
(unsigned long)self.interpolationMode,
|
||||
self.stops,
|
||||
self.attributeName,
|
||||
self.defaultValue,
|
||||
self.interpolationBase];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(MGLCompositeStyleFunction *)other {
|
||||
return ([other isKindOfClass:[self class]]
|
||||
&& other.interpolationMode == self.interpolationMode
|
||||
&& [other.stops isEqualToDictionary:self.stops]
|
||||
&& [other.attributeName isEqual:self.attributeName]
|
||||
&& ((self.defaultValue && [other.defaultValue isEqual:self.defaultValue]) || (!self.defaultValue && !other.defaultValue))
|
||||
&& other.interpolationBase == self.interpolationBase);
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
return self.interpolationMode + self.stops.hash + self.attributeName.hash + self.interpolationBase;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -4,64 +4,62 @@
|
||||
|
||||
#import "NSValue+MGLStyleAttributeAdditions.h"
|
||||
#import "MGLTypes.h"
|
||||
|
||||
#import <mbgl/util/enum.hpp>
|
||||
|
||||
#include <mbgl/style/data_driven_property_value.hpp>
|
||||
|
||||
#include <mbgl/util/interpolate.hpp>
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#import "UIColor+MGLAdditions.h"
|
||||
#else
|
||||
#import "NSColor+MGLAdditions.h"
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
|
||||
template <typename MBGLType, typename ObjCType, typename MBGLElement = MBGLType, typename ObjCEnum = ObjCType>
|
||||
class MGLStyleValueTransformer {
|
||||
public:
|
||||
|
||||
// Convert an mbgl property value into an mgl style value
|
||||
MGLStyleValue<ObjCType> *toStyleValue(const mbgl::style::PropertyValue<MBGLType> &mbglValue) {
|
||||
if (mbglValue.isConstant()) {
|
||||
return toStyleConstantValue(mbglValue.asConstant());
|
||||
} else if (mbglValue.isFunction()) {
|
||||
return toStyleFunction(mbglValue.asFunction());
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
PropertyValueEvaluator evaluator;
|
||||
return mbglValue.evaluate(evaluator);
|
||||
}
|
||||
|
||||
// Convert an mbgl data driven property value into an mgl style value
|
||||
MGLStyleValue<ObjCType> *toDataDrivenStyleValue(const mbgl::style::DataDrivenPropertyValue<MBGLType> &mbglValue) {
|
||||
PropertyValueEvaluator evaluator;
|
||||
return mbglValue.evaluate(evaluator);
|
||||
}
|
||||
|
||||
// Convert an mbgl property value containing an enum into an mgl style value
|
||||
template <typename MBGLEnum = MBGLType,
|
||||
class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
|
||||
typename MGLEnum = ObjCEnum,
|
||||
class = typename std::enable_if<std::is_enum<MGLEnum>::value>::type>
|
||||
MGLStyleValue<ObjCType> *toEnumStyleValue(const mbgl::style::PropertyValue<MBGLEnum> &mbglValue) {
|
||||
if (mbglValue.isConstant()) {
|
||||
return toEnumStyleConstantValue<>(mbglValue.asConstant());
|
||||
} else if (mbglValue.isFunction()) {
|
||||
const auto &mbglStops = mbglValue.asFunction().getStops();
|
||||
NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()];
|
||||
for (const auto &mbglStop : mbglStops) {
|
||||
stops[@(mbglStop.first)] = toEnumStyleConstantValue<>(mbglStop.second);
|
||||
}
|
||||
return [MGLStyleFunction<NSValue *> functionWithInterpolationBase:mbglValue.asFunction().getBase() stops:stops];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
EnumPropertyValueEvaluator<MBGLEnum, ObjCEnum> evaluator;
|
||||
return mbglValue.evaluate(evaluator);
|
||||
}
|
||||
|
||||
// Convert an mgl style value into a non interpolatable (camera with interval stops) mbgl property value
|
||||
mbgl::style::PropertyValue<MBGLType> toPropertyValue(MGLStyleValue<ObjCType> *value) {
|
||||
if ([value isKindOfClass:[MGLSourceStyleFunction class]] || [value isKindOfClass:[MGLCompositeStyleFunction class]]) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"This property can only be set to camera functions. Use +[MGLStyleValue cameraFunctionValueWithinterpolationMode:stops:options:] instead."];
|
||||
return {};
|
||||
}
|
||||
|
||||
if ([value isKindOfClass:[MGLStyleConstantValue class]]) {
|
||||
MBGLType mbglValue;
|
||||
getMBGLValue([(MGLStyleConstantValue<ObjCType> *)value rawValue], mbglValue);
|
||||
return mbglValue;
|
||||
} else if ([value isKindOfClass:[MGLStyleFunction class]]) {
|
||||
MGLStyleFunction<ObjCType> *function = (MGLStyleFunction<ObjCType> *)value;
|
||||
__block std::vector<std::pair<float, MBGLType>> mbglStops;
|
||||
[function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(stopValue);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
mbglStops.emplace_back(zoomKey.floatValue, mbglStopValue.asConstant());
|
||||
}];
|
||||
return mbgl::style::Function<MBGLType>({{mbglStops}}, function.interpolationBase);
|
||||
return toMBGLConstantValue((MGLStyleConstantValue<ObjCType> *)value);
|
||||
} else if ([value isKindOfClass:[MGLCameraStyleFunction class]]) {
|
||||
MGLCameraStyleFunction<ObjCType> *cameraStyleFunction = (MGLCameraStyleFunction<ObjCType> *)value;
|
||||
// Intentionally ignore the stop type set by the developer becuase non interpolatable property values
|
||||
// can only have interval stops. This also allows for backwards compatiblity when the developer uses
|
||||
// a deprecated MGLStyleValue method (that used to create an MGLStyleFunction) to create a function
|
||||
// for properties that are piecewise-constant (i.e. enum, bool, string)
|
||||
return toMBGLIntervalCameraFunction(cameraStyleFunction);
|
||||
} else if (value) {
|
||||
[NSException raise:@"MGLAbstractClassException" format:
|
||||
@"The style value %@ cannot be applied to the style. "
|
||||
@@ -73,25 +71,224 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Convert an mgl style value into a non interpolatable (camera with exponential or interval stops) mbgl property value
|
||||
mbgl::style::PropertyValue<MBGLType> toInterpolatablePropertyValue(MGLStyleValue<ObjCType> *value) {
|
||||
if ([value isKindOfClass:[MGLSourceStyleFunction class]] || [value isKindOfClass:[MGLCompositeStyleFunction class]]) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"This property can only be set to camera functions. Use +[MGLStyleValue cameraFunctionValueWithinterpolationMode:stops:options:] instead."];
|
||||
return {};
|
||||
}
|
||||
|
||||
if ([value isKindOfClass:[MGLStyleConstantValue class]]) {
|
||||
return toMBGLConstantValue((MGLStyleConstantValue<ObjCType> *)value);
|
||||
} else if ([value isKindOfClass:[MGLCameraStyleFunction class]]) {
|
||||
MGLCameraStyleFunction<ObjCType> *cameraStyleFunction = (MGLCameraStyleFunction<ObjCType> *)value;
|
||||
switch (cameraStyleFunction.interpolationMode) {
|
||||
case MGLInterpolationModeExponential:
|
||||
return toMBGLExponentialCameraFunction(cameraStyleFunction);
|
||||
break;
|
||||
case MGLInterpolationModeInterval:
|
||||
return toMBGLIntervalCameraFunction(cameraStyleFunction);
|
||||
break;
|
||||
default:
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"A camera function must use either exponential or interval stops."];
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
} else if (value) {
|
||||
[NSException raise:@"MGLAbstractClassException" format:
|
||||
@"The style value %@ cannot be applied to the style. "
|
||||
@"Make sure the style value was created as a member of a concrete subclass of MGLStyleValue.",
|
||||
NSStringFromClass([value class])];
|
||||
return {};
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// Convert an mgl style value into a mbgl data driven property value
|
||||
mbgl::style::DataDrivenPropertyValue<MBGLType> toDataDrivenPropertyValue(MGLStyleValue<ObjCType> *value) {
|
||||
if ([value isKindOfClass:[MGLStyleConstantValue class]]) {
|
||||
return toMBGLConstantValue((MGLStyleConstantValue<ObjCType> *)value);
|
||||
} else if ([value isKindOfClass:[MGLCameraStyleFunction class]]) {
|
||||
MGLCameraStyleFunction<ObjCType> *cameraStyleFunction = (MGLCameraStyleFunction<ObjCType> *)value;
|
||||
switch (cameraStyleFunction.interpolationMode) {
|
||||
case MGLInterpolationModeExponential:
|
||||
return toMBGLExponentialCameraFunction(cameraStyleFunction);
|
||||
break;
|
||||
case MGLInterpolationModeInterval:
|
||||
return toMBGLIntervalCameraFunction(cameraStyleFunction);
|
||||
break;
|
||||
default:
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"A camera function must use either exponential or interval stops."];
|
||||
return {};
|
||||
}
|
||||
} else if ([value isKindOfClass:[MGLSourceStyleFunction class]]) {
|
||||
MGLSourceStyleFunction<ObjCType> *sourceStyleFunction = (MGLSourceStyleFunction<ObjCType> *)value;
|
||||
switch (sourceStyleFunction.interpolationMode) {
|
||||
case MGLInterpolationModeExponential:
|
||||
return toMBGLExponentialSourceFunction(sourceStyleFunction);
|
||||
break;
|
||||
case MGLInterpolationModeInterval:
|
||||
return toMBGLIntervalSourceFunction(sourceStyleFunction);
|
||||
break;
|
||||
case MGLInterpolationModeCategorical:
|
||||
return toMBGLCategoricalSourceFunction(sourceStyleFunction);
|
||||
break;
|
||||
case MGLInterpolationModeIdentity:
|
||||
return toMBGLIdentitySourceFunction(sourceStyleFunction);
|
||||
break;
|
||||
default:
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"A camera function must use exponential, interval, categorical, or identity stops."];
|
||||
return {};
|
||||
}
|
||||
} else if ([value isKindOfClass:[MGLCompositeStyleFunction class]]) {
|
||||
MGLCompositeStyleFunction<ObjCType> *compositeStyleFunction = (MGLCompositeStyleFunction<ObjCType> *)value;
|
||||
switch (compositeStyleFunction.interpolationMode) {
|
||||
case MGLInterpolationModeExponential: {
|
||||
__block std::map<float, mbgl::style::ExponentialStops<MBGLType>> outerStops = {};
|
||||
[compositeStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSDictionary * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
std::map<float, MBGLType> stops = {};
|
||||
for (NSNumber *key in stopValue.allKeys) {
|
||||
NSCAssert([key isKindOfClass:[NSNumber class]], @"Stop keys should be NSNumbers");
|
||||
MGLStyleValue<ObjCType> *value = stopValue[key];
|
||||
NSCAssert([value isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(value);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
stops[key.floatValue] = mbglStopValue.asConstant();
|
||||
}
|
||||
mbgl::style::ExponentialStops<MBGLType> innerStops = {stops, (float)compositeStyleFunction.interpolationBase};
|
||||
outerStops[zoomKey.floatValue] = innerStops;
|
||||
}];
|
||||
mbgl::style::CompositeFunction<MBGLType> compositeFunction = {compositeStyleFunction.attributeName.UTF8String, outerStops};
|
||||
if (compositeStyleFunction.defaultValue) {
|
||||
NSCAssert([compositeStyleFunction.defaultValue isKindOfClass:[MGLStyleConstantValue class]], @"Default value must be constant");
|
||||
MBGLType mbglValue;
|
||||
id mglValue = [(MGLStyleConstantValue<ObjCType> *)compositeStyleFunction.defaultValue rawValue];
|
||||
getMBGLValue(mglValue, mbglValue);
|
||||
compositeFunction.defaultValue = mbglValue;
|
||||
}
|
||||
return compositeFunction;
|
||||
}
|
||||
break;
|
||||
case MGLInterpolationModeInterval: {
|
||||
__block std::map<float, mbgl::style::IntervalStops<MBGLType>> outerStops = {};
|
||||
[compositeStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSDictionary * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
std::map<float, MBGLType> stops = {};
|
||||
for (NSNumber *key in stopValue.allKeys) {
|
||||
NSCAssert([key isKindOfClass:[NSNumber class]], @"Stop keys should be NSNumbers");
|
||||
MGLStyleValue<ObjCType> *value = stopValue[key];
|
||||
NSCAssert([value isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(value);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
stops[key.floatValue] = mbglStopValue.asConstant();
|
||||
}
|
||||
mbgl::style::IntervalStops<MBGLType> innerStops = {stops};
|
||||
outerStops[zoomKey.floatValue] = innerStops;
|
||||
}];
|
||||
mbgl::style::CompositeFunction<MBGLType> compositeFunction = {compositeStyleFunction.attributeName.UTF8String, outerStops};
|
||||
if (compositeStyleFunction.defaultValue) {
|
||||
NSCAssert([compositeStyleFunction.defaultValue isKindOfClass:[MGLStyleConstantValue class]], @"Default value must be constant");
|
||||
MBGLType mbglValue;
|
||||
id mglValue = [(MGLStyleConstantValue<ObjCType> *)compositeStyleFunction.defaultValue rawValue];
|
||||
getMBGLValue(mglValue, mbglValue);
|
||||
compositeFunction.defaultValue = mbglValue;
|
||||
}
|
||||
return compositeFunction;
|
||||
}
|
||||
break;
|
||||
case MGLInterpolationModeCategorical: {
|
||||
__block std::map<float, mbgl::style::CategoricalStops<MBGLType>> outerStops = {};
|
||||
[compositeStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSDictionary * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
__block std::map<mbgl::style::CategoricalValue, MBGLType> stops = {};
|
||||
[stopValue enumerateKeysAndObjectsUsingBlock:^(id _Nonnull categoryKey, MGLStyleValue<ObjCType> * _Nonnull innerValue, BOOL * _Nonnull stop) {
|
||||
NSCAssert([innerValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(innerValue);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
|
||||
if ([categoryKey isKindOfClass:[NSString class]]) {
|
||||
const std::string& convertedValueKey = [((NSString *)categoryKey) UTF8String];
|
||||
stops[mbgl::style::CategoricalValue(convertedValueKey)] = mbglStopValue.asConstant();
|
||||
} else if ([categoryKey isKindOfClass:[NSNumber class]]) {
|
||||
NSNumber *key = (NSNumber *)categoryKey;
|
||||
if ((strcmp([key objCType], @encode(char)) == 0) ||
|
||||
(strcmp([key objCType], @encode(BOOL)) == 0)) {
|
||||
stops[mbgl::style::CategoricalValue((bool)[key boolValue])] = mbglStopValue.asConstant();
|
||||
} else if (strcmp([key objCType], @encode(double)) == 0 ||
|
||||
strcmp([key objCType], @encode(float)) == 0) {
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Categorical stop keys must be strings, booleans, or integers");
|
||||
} else if ([key compare:@(0)] == NSOrderedDescending ||
|
||||
[key compare:@(0)] == NSOrderedSame ||
|
||||
[key compare:@(0)] == NSOrderedAscending) {
|
||||
stops[mbgl::style::CategoricalValue((int64_t)[key integerValue])] = mbglStopValue.asConstant();
|
||||
}
|
||||
}
|
||||
}];
|
||||
mbgl::style::CategoricalStops<MBGLType> categoricalStops = {stops};
|
||||
outerStops[zoomKey.floatValue] = categoricalStops;
|
||||
}];
|
||||
mbgl::style::CompositeFunction<MBGLType> compositeFunction = {compositeStyleFunction.attributeName.UTF8String, outerStops};
|
||||
if (compositeStyleFunction.defaultValue) {
|
||||
NSCAssert([compositeStyleFunction.defaultValue isKindOfClass:[MGLStyleConstantValue class]], @"Default value must be constant");
|
||||
MBGLType mbglValue;
|
||||
id mglValue = [(MGLStyleConstantValue<ObjCType> *)compositeStyleFunction.defaultValue rawValue];
|
||||
getMBGLValue(mglValue, mbglValue);
|
||||
compositeFunction.defaultValue = mbglValue;
|
||||
}
|
||||
return compositeFunction;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"A composite function must use exponential, interval, or categorical stops."];
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
} else if (value) {
|
||||
[NSException raise:@"MGLAbstractClassException" format:
|
||||
@"The style value %@ cannot be applied to the style. "
|
||||
@"Make sure the style value was created as a member of a concrete subclass of MGLStyleValue.",
|
||||
NSStringFromClass([value class])];
|
||||
return {};
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// Convert an mgl style value containing an enum into a mbgl property value containing an enum
|
||||
template <typename MBGLEnum = MBGLType,
|
||||
class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
|
||||
typename MGLEnum = ObjCEnum,
|
||||
class = typename std::enable_if<std::is_enum<MGLEnum>::value>::type>
|
||||
mbgl::style::PropertyValue<MBGLEnum> toEnumPropertyValue(MGLStyleValue<ObjCType> *value) {
|
||||
if ([value isKindOfClass:[MGLSourceStyleFunction class]] || [value isKindOfClass:[MGLCompositeStyleFunction class]]) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"This property can only be set to camera functions. Use +[MGLStyleValue cameraFunctionValueWithinterpolationMode:stops:options:] instead."];
|
||||
return {};
|
||||
}
|
||||
|
||||
if ([value isKindOfClass:[MGLStyleConstantValue class]]) {
|
||||
MBGLEnum mbglValue;
|
||||
getMBGLValue([(MGLStyleConstantValue<ObjCType> *)value rawValue], mbglValue);
|
||||
return mbglValue;
|
||||
} else if ([value isKindOfClass:[MGLStyleFunction class]]) {
|
||||
MGLStyleFunction<NSValue *> *function = (MGLStyleFunction<NSValue *> *)value;
|
||||
__block std::vector<std::pair<float, MBGLEnum>> mbglStops;
|
||||
[function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<NSValue *> * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
} else if ([value isKindOfClass:[MGLCameraStyleFunction class]]) {
|
||||
MGLCameraStyleFunction<NSValue *> *cameraStyleFunction = (MGLCameraStyleFunction<NSValue *> *)value;
|
||||
__block std::map<float, MBGLType> stops = {};
|
||||
[cameraStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<NSValue *> * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toEnumPropertyValue(stopValue);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
mbglStops.emplace_back(zoomKey.floatValue, mbglStopValue.asConstant());
|
||||
stops[zoomKey.floatValue] = mbglStopValue.asConstant();
|
||||
}];
|
||||
return mbgl::style::Function<MBGLEnum>({{mbglStops}}, function.interpolationBase);
|
||||
|
||||
// Enumerations can only ever use interval stops.
|
||||
mbgl::style::IntervalStops<MBGLType> intervalStops = {stops};
|
||||
|
||||
mbgl::style::CameraFunction<MBGLType> cameraFunction = {intervalStops};
|
||||
return cameraFunction;
|
||||
} else if (value) {
|
||||
[NSException raise:@"MGLAbstractClassException" format:
|
||||
@"The style value %@ cannot be applied to the style. "
|
||||
@@ -103,77 +300,140 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private: // Private utilities for converting from mgl to mbgl values
|
||||
|
||||
MGLStyleConstantValue<ObjCType> *toStyleConstantValue(const MBGLType mbglValue) {
|
||||
auto rawValue = toMGLRawStyleValue(mbglValue);
|
||||
return [MGLStyleConstantValue<ObjCType> valueWithRawValue:rawValue];
|
||||
MBGLType toMBGLConstantValue(MGLStyleConstantValue<ObjCType> *value) {
|
||||
MBGLType mbglValue;
|
||||
getMBGLValue(value.rawValue, mbglValue);
|
||||
return mbglValue;
|
||||
}
|
||||
|
||||
MGLStyleFunction<ObjCType> *toStyleFunction(const mbgl::style::Function<MBGLType> &mbglFunction) {
|
||||
const auto &mbglStops = mbglFunction.getStops();
|
||||
NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()];
|
||||
for (const auto &mbglStop : mbglStops) {
|
||||
auto rawValue = toMGLRawStyleValue(mbglStop.second);
|
||||
stops[@(mbglStop.first)] = [MGLStyleValue valueWithRawValue:rawValue];
|
||||
mbgl::style::CameraFunction<MBGLType> toMBGLExponentialCameraFunction(MGLCameraStyleFunction<ObjCType> *cameraStyleFunction) {
|
||||
__block std::map<float, MBGLType> stops = {};
|
||||
[cameraStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(stopValue);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
stops[zoomKey.floatValue] = mbglStopValue.asConstant();
|
||||
}];
|
||||
|
||||
// Camera function with Exponential stops
|
||||
mbgl::style::ExponentialStops<MBGLType> exponentialStops = {stops, (float)cameraStyleFunction.interpolationBase};
|
||||
mbgl::style::CameraFunction<MBGLType> cameraFunction = {exponentialStops};
|
||||
|
||||
return cameraFunction;
|
||||
}
|
||||
|
||||
mbgl::style::CameraFunction<MBGLType> toMBGLIntervalCameraFunction(MGLCameraStyleFunction<ObjCType> *cameraStyleFunction) {
|
||||
__block std::map<float, MBGLType> stops = {};
|
||||
[cameraStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(stopValue);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
stops[zoomKey.floatValue] = mbglStopValue.asConstant();
|
||||
}];
|
||||
|
||||
// Camera function with Interval stops
|
||||
mbgl::style::IntervalStops<MBGLType> intervalStops = {stops};
|
||||
mbgl::style::CameraFunction<MBGLType> cameraFunction = {intervalStops};
|
||||
|
||||
return cameraFunction;
|
||||
}
|
||||
|
||||
mbgl::style::SourceFunction<MBGLType> toMBGLCategoricalSourceFunction(MGLSourceStyleFunction<ObjCType> *sourceStyleFunction) {
|
||||
__block std::map<mbgl::style::CategoricalValue, MBGLType> stops = {};
|
||||
[sourceStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(id categoryKey, MGLStyleValue<ObjCType> *stopValue, BOOL *stop) {
|
||||
NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(stopValue);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
|
||||
if ([categoryKey isKindOfClass:[NSString class]]) {
|
||||
const std::string& convertedValueKey = [((NSString *)categoryKey) UTF8String];
|
||||
stops[mbgl::style::CategoricalValue(convertedValueKey)] = mbglStopValue.asConstant();
|
||||
} else if ([categoryKey isKindOfClass:[NSNumber class]]) {
|
||||
NSNumber *key = (NSNumber *)categoryKey;
|
||||
if ((strcmp([key objCType], @encode(char)) == 0) ||
|
||||
(strcmp([key objCType], @encode(BOOL)) == 0)) {
|
||||
stops[mbgl::style::CategoricalValue((bool)[key boolValue])] = mbglStopValue.asConstant();
|
||||
} else if (strcmp([key objCType], @encode(double)) == 0 ||
|
||||
strcmp([key objCType], @encode(float)) == 0) {
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Categorical stop keys must be strings, booleans, or integers");
|
||||
} else if ([key compare:@(0)] == NSOrderedDescending ||
|
||||
[key compare:@(0)] == NSOrderedSame ||
|
||||
[key compare:@(0)] == NSOrderedAscending) {
|
||||
stops[mbgl::style::CategoricalValue((int64_t)[key integerValue])] = mbglStopValue.asConstant();
|
||||
}
|
||||
}
|
||||
}];
|
||||
mbgl::style::CategoricalStops<MBGLType> categoricalStops = {stops};
|
||||
mbgl::style::SourceFunction<MBGLType> sourceFunction = {sourceStyleFunction.attributeName.UTF8String, categoricalStops};
|
||||
if (sourceStyleFunction.defaultValue) {
|
||||
NSCAssert([sourceStyleFunction.defaultValue isKindOfClass:[MGLStyleConstantValue class]], @"Default value must be constant");
|
||||
MBGLType mbglValue;
|
||||
id mglValue = [(MGLStyleConstantValue<ObjCType> *)sourceStyleFunction.defaultValue rawValue];
|
||||
getMBGLValue(mglValue, mbglValue);
|
||||
sourceFunction.defaultValue = mbglValue;
|
||||
}
|
||||
return [MGLStyleFunction<ObjCType> functionWithInterpolationBase:mbglFunction.getBase() stops:stops];
|
||||
return sourceFunction;
|
||||
}
|
||||
|
||||
template <typename MBGLEnum = MBGLType,
|
||||
class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
|
||||
typename MGLEnum = ObjCEnum,
|
||||
class = typename std::enable_if<std::is_enum<MGLEnum>::value>::type>
|
||||
MGLStyleConstantValue<ObjCType> *toEnumStyleConstantValue(const MBGLEnum mbglValue) {
|
||||
auto str = mbgl::Enum<MBGLEnum>::toString(mbglValue);
|
||||
MGLEnum mglType = *mbgl::Enum<MGLEnum>::toEnum(str);
|
||||
return [MGLStyleConstantValue<ObjCType> valueWithRawValue:[NSValue value:&mglType withObjCType:@encode(MGLEnum)]];
|
||||
}
|
||||
|
||||
NSNumber *toMGLRawStyleValue(const bool mbglStopValue) {
|
||||
return @(mbglStopValue);
|
||||
}
|
||||
|
||||
NSNumber *toMGLRawStyleValue(const float mbglStopValue) {
|
||||
return @(mbglStopValue);
|
||||
}
|
||||
|
||||
NSString *toMGLRawStyleValue(const std::string &mbglStopValue) {
|
||||
return @(mbglStopValue.c_str());
|
||||
}
|
||||
|
||||
// Offsets
|
||||
NSValue *toMGLRawStyleValue(const std::array<float, 2> &mbglStopValue) {
|
||||
return [NSValue mgl_valueWithOffsetArray:mbglStopValue];
|
||||
}
|
||||
|
||||
// Padding
|
||||
NSValue *toMGLRawStyleValue(const std::array<float, 4> &mbglStopValue) {
|
||||
return [NSValue mgl_valueWithPaddingArray:mbglStopValue];
|
||||
}
|
||||
|
||||
MGLColor *toMGLRawStyleValue(const mbgl::Color mbglStopValue) {
|
||||
return [MGLColor mgl_colorWithColor:mbglStopValue];
|
||||
}
|
||||
|
||||
ObjCType toMGLRawStyleValue(const std::vector<MBGLElement> &mbglStopValue) {
|
||||
NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()];
|
||||
for (const auto &mbglElement: mbglStopValue) {
|
||||
[array addObject:toMGLRawStyleValue(mbglElement)];
|
||||
mbgl::style::SourceFunction<MBGLType> toMBGLExponentialSourceFunction(MGLSourceStyleFunction<ObjCType> *sourceStyleFunction) {
|
||||
__block std::map<float, MBGLType> stops = {};
|
||||
[sourceStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(stopValue);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
stops[zoomKey.floatValue] = mbglStopValue.asConstant();
|
||||
}];
|
||||
mbgl::style::ExponentialStops<MBGLType> exponentialStops = {stops, (float)sourceStyleFunction.interpolationBase};
|
||||
mbgl::style::SourceFunction<MBGLType> sourceFunction = {sourceStyleFunction.attributeName.UTF8String, exponentialStops};
|
||||
if (sourceStyleFunction.defaultValue) {
|
||||
NSCAssert([sourceStyleFunction.defaultValue isKindOfClass:[MGLStyleConstantValue class]], @"Default value must be constant");
|
||||
MBGLType mbglValue;
|
||||
id mglValue = [(MGLStyleConstantValue<ObjCType> *)sourceStyleFunction.defaultValue rawValue];
|
||||
getMBGLValue(mglValue, mbglValue);
|
||||
sourceFunction.defaultValue = mbglValue;
|
||||
}
|
||||
return array;
|
||||
return sourceFunction;
|
||||
}
|
||||
|
||||
private:
|
||||
mbgl::style::SourceFunction<MBGLType> toMBGLIntervalSourceFunction(MGLSourceStyleFunction<ObjCType> *sourceStyleFunction) {
|
||||
__block std::map<float, MBGLType> stops = {};
|
||||
[sourceStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) {
|
||||
NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues");
|
||||
auto mbglStopValue = toPropertyValue(stopValue);
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
stops[zoomKey.floatValue] = mbglStopValue.asConstant();
|
||||
}];
|
||||
mbgl::style::IntervalStops<MBGLType> intervalStops = {stops};
|
||||
mbgl::style::SourceFunction<MBGLType> sourceFunction = {sourceStyleFunction.attributeName.UTF8String, intervalStops};
|
||||
if (sourceStyleFunction.defaultValue) {
|
||||
NSCAssert([sourceStyleFunction.defaultValue isKindOfClass:[MGLStyleConstantValue class]], @"Default value must be constant");
|
||||
MBGLType mbglValue;
|
||||
id mglValue = [(MGLStyleConstantValue<ObjCType> *)sourceStyleFunction.defaultValue rawValue];
|
||||
getMBGLValue(mglValue, mbglValue);
|
||||
sourceFunction.defaultValue = mbglValue;
|
||||
}
|
||||
return sourceFunction;
|
||||
}
|
||||
|
||||
mbgl::style::SourceFunction<MBGLType> toMBGLIdentitySourceFunction(MGLSourceStyleFunction<ObjCType> *sourceStyleFunction) {
|
||||
mbgl::style::IdentityStops<MBGLType> identityStops;
|
||||
mbgl::style::SourceFunction<MBGLType> sourceFunction = {sourceStyleFunction.attributeName.UTF8String, identityStops};
|
||||
return sourceFunction;
|
||||
}
|
||||
|
||||
// Bool
|
||||
void getMBGLValue(NSNumber *rawValue, bool &mbglValue) {
|
||||
mbglValue = !!rawValue.boolValue;
|
||||
}
|
||||
|
||||
// Float
|
||||
void getMBGLValue(NSNumber *rawValue, float &mbglValue) {
|
||||
mbglValue = rawValue.floatValue;
|
||||
}
|
||||
|
||||
// String
|
||||
void getMBGLValue(NSString *rawValue, std::string &mbglValue) {
|
||||
mbglValue = rawValue.UTF8String;
|
||||
}
|
||||
@@ -188,10 +448,12 @@ private:
|
||||
mbglValue = rawValue.mgl_paddingArrayValue;
|
||||
}
|
||||
|
||||
// Color
|
||||
void getMBGLValue(MGLColor *rawValue, mbgl::Color &mbglValue) {
|
||||
mbglValue = rawValue.mgl_color;
|
||||
}
|
||||
|
||||
// Array
|
||||
void getMBGLValue(ObjCType rawValue, std::vector<MBGLElement> &mbglValue) {
|
||||
mbglValue.reserve(rawValue.count);
|
||||
for (id obj in rawValue) {
|
||||
@@ -212,4 +474,265 @@ private:
|
||||
auto str = mbgl::Enum<MGLEnum>::toString(mglEnum);
|
||||
mbglValue = *mbgl::Enum<MBGLEnum>::toEnum(str);
|
||||
}
|
||||
|
||||
private: // Private utilities for converting from mbgl to mgl values
|
||||
|
||||
// Bool
|
||||
static NSNumber *toMGLRawStyleValue(const bool mbglStopValue) {
|
||||
return @(mbglStopValue);
|
||||
}
|
||||
|
||||
// Float
|
||||
static NSNumber *toMGLRawStyleValue(const float mbglStopValue) {
|
||||
return @(mbglStopValue);
|
||||
}
|
||||
|
||||
// Integer
|
||||
static NSNumber *toMGLRawStyleValue(const int64_t mbglStopValue) {
|
||||
return @(mbglStopValue);
|
||||
}
|
||||
|
||||
// String
|
||||
static NSString *toMGLRawStyleValue(const std::string &mbglStopValue) {
|
||||
return @(mbglStopValue.c_str());
|
||||
}
|
||||
|
||||
// Offsets
|
||||
static NSValue *toMGLRawStyleValue(const std::array<float, 2> &mbglStopValue) {
|
||||
return [NSValue mgl_valueWithOffsetArray:mbglStopValue];
|
||||
}
|
||||
|
||||
// Padding
|
||||
static NSValue *toMGLRawStyleValue(const std::array<float, 4> &mbglStopValue) {
|
||||
return [NSValue mgl_valueWithPaddingArray:mbglStopValue];
|
||||
}
|
||||
|
||||
// Color
|
||||
static MGLColor *toMGLRawStyleValue(const mbgl::Color mbglStopValue) {
|
||||
return [MGLColor mgl_colorWithColor:mbglStopValue];
|
||||
}
|
||||
|
||||
// Array
|
||||
static ObjCType toMGLRawStyleValue(const std::vector<MBGLElement> &mbglStopValue) {
|
||||
NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()];
|
||||
for (const auto &mbglElement: mbglStopValue) {
|
||||
[array addObject:toMGLRawStyleValue(mbglElement)];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Enumerations
|
||||
template <typename MBGLEnum = MBGLType, typename MGLEnum = ObjCEnum>
|
||||
static NSValue *toMGLRawStyleValue(const MBGLEnum &value) {
|
||||
auto str = mbgl::Enum<MBGLEnum>::toString(value);
|
||||
MGLEnum mglType = *mbgl::Enum<MGLEnum>::toEnum(str);
|
||||
return [NSValue value:&mglType withObjCType:@encode(MGLEnum)];
|
||||
}
|
||||
|
||||
// Converts mbgl stops to an equivilent NSDictionary for mgl
|
||||
static NSMutableDictionary *toConvertedStops(const std::map<float, MBGLType> &mbglStops) {
|
||||
NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()];
|
||||
for (const auto &mbglStop : mbglStops) {
|
||||
auto rawValue = toMGLRawStyleValue(mbglStop.second);
|
||||
stops[@(mbglStop.first)] = [MGLStyleValue valueWithRawValue:rawValue];
|
||||
}
|
||||
return stops;
|
||||
}
|
||||
|
||||
// Converts mbgl interval stop categorical values to an equivilant object for mgl
|
||||
class CategoricalValueVisitor {
|
||||
public:
|
||||
id operator()(const bool value) {
|
||||
return toMGLRawStyleValue(value);
|
||||
}
|
||||
|
||||
id operator()(const int64_t value) {
|
||||
return toMGLRawStyleValue(value);
|
||||
}
|
||||
|
||||
id operator()(const std::string value) {
|
||||
return toMGLRawStyleValue(value);
|
||||
}
|
||||
};
|
||||
|
||||
// Converts all types of mbgl property values containing enumerations into an equivilant mgl style value
|
||||
template <typename MBGLEnum = MBGLType, typename MGLEnum = ObjCEnum>
|
||||
class EnumPropertyValueEvaluator {
|
||||
public:
|
||||
id operator()(const mbgl::style::Undefined) const {
|
||||
return nil;
|
||||
}
|
||||
|
||||
id operator()(const MBGLEnum &value) const {
|
||||
auto str = mbgl::Enum<MBGLEnum>::toString(value);
|
||||
MGLEnum mglType = *mbgl::Enum<MGLEnum>::toEnum(str);
|
||||
return [MGLStyleConstantValue<ObjCType> valueWithRawValue:[NSValue value:&mglType withObjCType:@encode(MGLEnum)]];
|
||||
}
|
||||
|
||||
id operator()(const mbgl::style::CameraFunction<MBGLEnum> &mbglValue) const {
|
||||
CameraFunctionStopsVisitor visitor;
|
||||
return apply_visitor(visitor, mbglValue.stops);
|
||||
}
|
||||
};
|
||||
|
||||
// Converts all possible mbgl camera function stops into an equivilant mgl style value
|
||||
class CameraFunctionStopsVisitor {
|
||||
public:
|
||||
id operator()(const mbgl::style::ExponentialStops<MBGLType> &mbglStops) {
|
||||
return [MGLCameraStyleFunction functionWithInterpolationMode:MGLInterpolationModeExponential
|
||||
stops:toConvertedStops(mbglStops.stops)
|
||||
options:@{MGLStyleFunctionOptionInterpolationBase: @(mbglStops.base)}];
|
||||
}
|
||||
|
||||
id operator()(const mbgl::style::IntervalStops<MBGLType> &mbglStops) {
|
||||
return [MGLCameraStyleFunction functionWithInterpolationMode:MGLInterpolationModeInterval
|
||||
stops:toConvertedStops(mbglStops.stops)
|
||||
options:nil];
|
||||
}
|
||||
};
|
||||
|
||||
// Converts a source function and all possible mbgl source function stops into an equivilant mgl style value
|
||||
class SourceFunctionStopsVisitor {
|
||||
public:
|
||||
id operator()(const mbgl::style::ExponentialStops<MBGLType> &mbglStops) {
|
||||
MGLSourceStyleFunction *sourceFunction = [MGLSourceStyleFunction functionWithInterpolationMode:MGLInterpolationModeExponential
|
||||
stops:toConvertedStops(mbglStops.stops)
|
||||
attributeName:@(mbglFunction.property.c_str())
|
||||
options:@{MGLStyleFunctionOptionInterpolationBase: @(mbglStops.base)}];
|
||||
if (mbglFunction.defaultValue) {
|
||||
sourceFunction.defaultValue = [MGLStyleValue valueWithRawValue:toMGLRawStyleValue(*mbglFunction.defaultValue)];
|
||||
}
|
||||
return sourceFunction;
|
||||
}
|
||||
|
||||
id operator()(const mbgl::style::IntervalStops<MBGLType> &mbglStops) {
|
||||
MGLSourceStyleFunction *sourceFunction = [MGLSourceStyleFunction functionWithInterpolationMode:MGLInterpolationModeInterval
|
||||
stops:toConvertedStops(mbglStops.stops)
|
||||
attributeName:@(mbglFunction.property.c_str())
|
||||
options:nil];
|
||||
if (mbglFunction.defaultValue) {
|
||||
sourceFunction.defaultValue = [MGLStyleValue valueWithRawValue:toMGLRawStyleValue(*mbglFunction.defaultValue)];
|
||||
}
|
||||
return sourceFunction;
|
||||
}
|
||||
|
||||
id operator()(const mbgl::style::CategoricalStops<MBGLType> &mbglStops) {
|
||||
NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.stops.size()];
|
||||
for (const auto &mbglStop : mbglStops.stops) {
|
||||
auto categoricalValue = mbglStop.first;
|
||||
auto rawValue = toMGLRawStyleValue(mbglStop.second);
|
||||
CategoricalValueVisitor categoricalValueVisitor;
|
||||
id stopKey = apply_visitor(categoricalValueVisitor, categoricalValue);
|
||||
stops[stopKey] = [MGLStyleValue valueWithRawValue:rawValue];
|
||||
}
|
||||
|
||||
MGLSourceStyleFunction *sourceFunction = [MGLSourceStyleFunction functionWithInterpolationMode:MGLInterpolationModeCategorical
|
||||
stops:stops
|
||||
attributeName:@(mbglFunction.property.c_str())
|
||||
options:nil];
|
||||
if (mbglFunction.defaultValue) {
|
||||
sourceFunction.defaultValue = [MGLStyleValue valueWithRawValue:toMGLRawStyleValue(*mbglFunction.defaultValue)];
|
||||
}
|
||||
return sourceFunction;
|
||||
|
||||
}
|
||||
|
||||
id operator()(const mbgl::style::IdentityStops<MBGLType> &mbglStops) {
|
||||
return [MGLSourceStyleFunction functionWithInterpolationMode:MGLInterpolationModeIdentity
|
||||
stops:nil
|
||||
attributeName:@(mbglFunction.property.c_str()) options:nil];
|
||||
}
|
||||
|
||||
const mbgl::style::SourceFunction<MBGLType> &mbglFunction;
|
||||
};
|
||||
|
||||
// Converts a composite function and all possible mbgl stops into an equivilant mgl style value
|
||||
class CompositeFunctionStopsVisitor {
|
||||
public:
|
||||
id operator()(const std::map<float, mbgl::style::ExponentialStops<MBGLType>> &mbglStops) {
|
||||
float base = 1.0f;
|
||||
NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()];
|
||||
for (auto const& outerStop: mbglStops) {
|
||||
stops[@(outerStop.first)] = toConvertedStops(outerStop.second.stops);
|
||||
base = outerStop.second.base;
|
||||
}
|
||||
MGLCompositeStyleFunction *compositeFunction = [MGLCompositeStyleFunction functionWithInterpolationMode:MGLInterpolationModeExponential
|
||||
stops:stops
|
||||
attributeName:@(mbglFunction.property.c_str())
|
||||
options:@{MGLStyleFunctionOptionInterpolationBase: @(base)}];
|
||||
if (mbglFunction.defaultValue) {
|
||||
compositeFunction.defaultValue = [MGLStyleValue valueWithRawValue:toMGLRawStyleValue(*mbglFunction.defaultValue)];
|
||||
}
|
||||
return compositeFunction;
|
||||
}
|
||||
|
||||
id operator()(const std::map<float, mbgl::style::IntervalStops<MBGLType>> &mbglStops) {
|
||||
NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()];
|
||||
for (auto const& outerStop: mbglStops) {
|
||||
stops[@(outerStop.first)] = toConvertedStops(outerStop.second.stops);
|
||||
}
|
||||
MGLCompositeStyleFunction *compositeFunction = [MGLCompositeStyleFunction functionWithInterpolationMode:MGLInterpolationModeInterval
|
||||
stops:stops
|
||||
attributeName:@(mbglFunction.property.c_str())
|
||||
options:nil];
|
||||
if (mbglFunction.defaultValue) {
|
||||
compositeFunction.defaultValue = [MGLStyleValue valueWithRawValue:toMGLRawStyleValue(*mbglFunction.defaultValue)];
|
||||
}
|
||||
return compositeFunction;
|
||||
}
|
||||
|
||||
id operator()(const std::map<float, mbgl::style::CategoricalStops<MBGLType>> &mbglStops) {
|
||||
NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()];
|
||||
for (auto const& outerStop: mbglStops) {
|
||||
NSMutableDictionary *innerStops = [NSMutableDictionary dictionaryWithCapacity:outerStop.second.stops.size()];
|
||||
for (const auto &mbglStop : outerStop.second.stops) {
|
||||
auto categoricalValue = mbglStop.first;
|
||||
auto rawValue = toMGLRawStyleValue(mbglStop.second);
|
||||
CategoricalValueVisitor categoricalValueVisitor;
|
||||
id stopKey = apply_visitor(categoricalValueVisitor, categoricalValue);
|
||||
innerStops[stopKey] = [MGLStyleValue valueWithRawValue:rawValue];
|
||||
}
|
||||
stops[@(outerStop.first)] = innerStops;
|
||||
}
|
||||
|
||||
MGLCompositeStyleFunction *compositeFunction = [MGLCompositeStyleFunction functionWithInterpolationMode:MGLInterpolationModeCategorical
|
||||
stops:stops attributeName:@(mbglFunction.property.c_str())
|
||||
options:nil];
|
||||
if (mbglFunction.defaultValue) {
|
||||
compositeFunction.defaultValue = [MGLStyleValue valueWithRawValue:toMGLRawStyleValue(*mbglFunction.defaultValue)];
|
||||
}
|
||||
return compositeFunction;
|
||||
}
|
||||
|
||||
const mbgl::style::CompositeFunction<MBGLType> &mbglFunction;
|
||||
};
|
||||
|
||||
|
||||
// Converts all types of mbgl property values that don't contain enumerations into an equivilant mgl style value
|
||||
class PropertyValueEvaluator {
|
||||
public:
|
||||
id operator()(const mbgl::style::Undefined) const {
|
||||
return nil;
|
||||
}
|
||||
|
||||
id operator()(const MBGLType &value) const {
|
||||
auto rawValue = toMGLRawStyleValue(value);
|
||||
return [MGLStyleConstantValue<ObjCType> valueWithRawValue:rawValue];
|
||||
}
|
||||
|
||||
id operator()(const mbgl::style::CameraFunction<MBGLType> &mbglValue) const {
|
||||
CameraFunctionStopsVisitor visitor;
|
||||
return apply_visitor(visitor, mbglValue.stops);
|
||||
}
|
||||
|
||||
id operator()(const mbgl::style::SourceFunction<MBGLType> &mbglValue) const {
|
||||
SourceFunctionStopsVisitor visitor { mbglValue };
|
||||
return apply_visitor(visitor, mbglValue.stops);
|
||||
}
|
||||
|
||||
MGLCompositeStyleFunction<ObjCType> * operator()(const mbgl::style::CompositeFunction<MBGLType> &mbglValue) const {
|
||||
CompositeFunctionStopsVisitor visitor { mbglValue };
|
||||
return apply_visitor(visitor, mbglValue.stops);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -251,7 +251,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslationAnchor) {
|
||||
/**
|
||||
An `MGLSymbolStyleLayer` is a style layer that renders icon and text labels at
|
||||
points or along lines on the map.
|
||||
|
||||
|
||||
Use a symbol style layer to configure the visual appearance of labels for
|
||||
features in vector tiles loaded by an `MGLVectorSource` object or `MGLShape` or
|
||||
`MGLFeature` instances in an `MGLShapeSource` object.
|
||||
@@ -285,14 +285,14 @@ MGL_EXPORT
|
||||
/**
|
||||
If true, the icon will be visible even if it collides with other previously
|
||||
drawn symbols.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
|
||||
the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-allow-overlap"><code>icon-allow-overlap</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -304,14 +304,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
If true, other symbols can be visible even if they collide with the icon.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
|
||||
the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-ignore-placement"><code>icon-ignore-placement</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -323,7 +323,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
A string with {tokens} replaced, referencing the data property to pull from.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-image"><code>icon-image</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -336,11 +336,11 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
Offset distance of icon from its anchor.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing a `CGVector` struct set to 0 rightward and 0
|
||||
downward. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -348,11 +348,11 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
Offset distance of icon from its anchor.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing a `CGVector` struct set to 0 rightward and 0
|
||||
upward. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -362,11 +362,11 @@ MGL_EXPORT
|
||||
/**
|
||||
If true, text will display without their corresponding icons when the icon
|
||||
collides with other symbols and the text does not.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
|
||||
the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`, and
|
||||
`text` is non-`nil`. Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -375,13 +375,13 @@ MGL_EXPORT
|
||||
/**
|
||||
Size of the additional area around the icon bounding box used for detecting
|
||||
symbol collisions.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `2`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -389,16 +389,16 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Rotates the icon clockwise.
|
||||
|
||||
|
||||
This property is measured in degrees.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-rotate"><code>icon-rotate</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -411,11 +411,11 @@ MGL_EXPORT
|
||||
/**
|
||||
In combination with `symbolPlacement`, determines the rotation behavior of
|
||||
icons.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLIconRotationAlignmentAuto`. Set this property
|
||||
to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -423,14 +423,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Scale factor for icon. 1 is original size, 3 triples the size.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-size"><code>icon-size</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -442,11 +442,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Scales the icon to fit around the associated text.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLIconTextFitNone`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`, and
|
||||
`text` is non-`nil`. Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -455,13 +455,13 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
Size of the additional area added to dimensions determined by `iconTextFit`.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `UIEdgeInsetsZero`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`, and
|
||||
`text` is non-`nil`, and `iconTextFit` is set to an `MGLStyleValue` object
|
||||
containing an `NSValue` object containing `MGLIconTextFitBoth`,
|
||||
@@ -471,13 +471,13 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
Size of the additional area added to dimensions determined by `iconTextFit`.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `NSEdgeInsetsZero`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`, and
|
||||
`text` is non-`nil`, and `iconTextFit` is set to an `MGLStyleValue` object
|
||||
containing an `NSValue` object containing `MGLIconTextFitBoth`,
|
||||
@@ -488,17 +488,17 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
If true, the icon may be flipped to prevent it from being rendered upside-down.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
|
||||
the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`, and
|
||||
`iconRotationAlignment` is set to an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLIconRotationAlignmentMap`, and
|
||||
`symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue`
|
||||
object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-keep-upright"><code>icon-keep-upright</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -511,17 +511,17 @@ MGL_EXPORT
|
||||
/**
|
||||
If true, the text may be flipped vertically to prevent it from being rendered
|
||||
upside-down.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `YES`. Set this property to `nil` to reset it to
|
||||
the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`, and
|
||||
`textRotationAlignment` is set to an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLTextRotationAlignmentMap`, and
|
||||
`symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue`
|
||||
object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-keep-upright"><code>text-keep-upright</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -533,17 +533,17 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Maximum angle change between adjacent characters.
|
||||
|
||||
|
||||
This property is measured in degrees.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `45`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`, and
|
||||
`symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue`
|
||||
object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-max-angle"><code>text-max-angle</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -555,16 +555,16 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The maximum line width for text wrapping.
|
||||
|
||||
|
||||
This property is measured in ems.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `10`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-max-width"><code>text-max-width</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -579,11 +579,11 @@ MGL_EXPORT
|
||||
Recommended in layers that don't have enough padding in the vector tile to
|
||||
prevent collisions, or if it is a point symbol layer placed after a line symbol
|
||||
layer.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `NO`. 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/#layout-symbol-symbol-avoid-edges"><code>symbol-avoid-edges</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -595,7 +595,7 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Label placement relative to its geometry.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLSymbolPlacementPoint`. Set this property to
|
||||
`nil` to reset it to the default value.
|
||||
@@ -604,13 +604,13 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Distance between two symbol anchors.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `250`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `symbolPlacement` is set to an
|
||||
`MGLStyleValue` object containing an `NSValue` object containing
|
||||
`MGLSymbolPlacementLine`. Otherwise, it is ignored.
|
||||
@@ -620,10 +620,10 @@ MGL_EXPORT
|
||||
/**
|
||||
Value to use for a text label. Feature properties are specified using tokens
|
||||
like {field_name}.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing the
|
||||
empty string. 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/#layout-symbol-text-field"><code>text-field</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -636,14 +636,14 @@ MGL_EXPORT
|
||||
/**
|
||||
If true, the text will be visible even if it collides with other previously
|
||||
drawn symbols.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
|
||||
the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-allow-overlap"><code>text-allow-overlap</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -655,11 +655,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Part of the text placed closest to the anchor.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLTextAnchorCenter`. Set this property to `nil`
|
||||
to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -667,24 +667,24 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
An array of font face names used to display the text.
|
||||
|
||||
|
||||
Each font name must be included in the `{fontstack}` portion of the JSON
|
||||
stylesheet’s <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#glyphs"><code>glyphs</code></a>
|
||||
property. You can register a custom font when designing the style in Mapbox
|
||||
Studio. Fonts installed on the system are not used.
|
||||
|
||||
|
||||
The first font named in the array is applied to the text. For each character in
|
||||
the text, if the first font lacks a glyph for the character, the next font is
|
||||
applied as a fallback, and so on.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing the
|
||||
array `Open Sans Regular`, `Arial Unicode MS Regular`. Set this property to
|
||||
`nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-font"><code>text-font</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -696,16 +696,16 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Font size.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `16`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-size"><code>text-size</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -717,14 +717,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
If true, other symbols can be visible even if they collide with the text.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
|
||||
the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-ignore-placement"><code>text-ignore-placement</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -736,14 +736,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Text justification options.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLTextJustificationCenter`. Set this property to
|
||||
`nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-justify"><code>text-justify</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -755,13 +755,13 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Text tracking amount.
|
||||
|
||||
|
||||
This property is measured in ems.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -769,13 +769,13 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Text leading value for multi-line text.
|
||||
|
||||
|
||||
This property is measured in ems.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1.2`. Set this property to `nil` to
|
||||
reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -784,13 +784,13 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
Offset distance of text from its anchor.
|
||||
|
||||
|
||||
This property is measured in ems.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing a `CGVector` struct set to 0 ems rightward and 0
|
||||
ems downward. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -798,13 +798,13 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
Offset distance of text from its anchor.
|
||||
|
||||
|
||||
This property is measured in ems.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing a `CGVector` struct set to 0 ems rightward and 0
|
||||
ems upward. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -814,11 +814,11 @@ MGL_EXPORT
|
||||
/**
|
||||
If true, icons will display without their corresponding text when the text
|
||||
collides with other symbols and the icon does not.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing `NO`. Set this property to `nil` to reset it to
|
||||
the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`, and
|
||||
`iconImageName` is non-`nil`. Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -827,13 +827,13 @@ MGL_EXPORT
|
||||
/**
|
||||
Size of the additional area around the text bounding box used for detecting
|
||||
symbol collisions.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `2`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -841,11 +841,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Orientation of text when map is pitched.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLTextPitchAlignmentAuto`. Set this property to
|
||||
`nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -853,16 +853,16 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Rotates the text clockwise.
|
||||
|
||||
|
||||
This property is measured in degrees.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-rotate"><code>text-rotate</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -875,11 +875,11 @@ MGL_EXPORT
|
||||
/**
|
||||
In combination with `symbolPlacement`, determines the rotation behavior of the
|
||||
individual glyphs forming the text.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLTextRotationAlignmentAuto`. Set this property
|
||||
to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -887,11 +887,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Specifies how to capitalize text.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLTextTransformNone`. Set this property to `nil`
|
||||
to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -903,11 +903,11 @@ MGL_EXPORT
|
||||
/**
|
||||
The tint color to apply to the icon. The `iconImageName` property must be set
|
||||
to a template image.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`UIColor.blackColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -916,11 +916,11 @@ MGL_EXPORT
|
||||
/**
|
||||
The tint color to apply to the icon. The `iconImageName` property must be set
|
||||
to a template image.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`NSColor.blackColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -929,13 +929,13 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Fade out the halo towards the outside.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -945,11 +945,11 @@ MGL_EXPORT
|
||||
/**
|
||||
The color of the icon’s halo. The `iconImageName` property must be set to a
|
||||
template image.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`UIColor.clearColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -958,11 +958,11 @@ MGL_EXPORT
|
||||
/**
|
||||
The color of the icon’s halo. The `iconImageName` property must be set to a
|
||||
template image.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`NSColor.clearColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -971,13 +971,13 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Distance of halo to the icon outline.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -985,11 +985,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The opacity at which the icon will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
*/
|
||||
@@ -998,16 +998,16 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
Distance that the icon's anchor is moved from its original placement.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing a `CGVector` struct set to 0 points rightward and 0
|
||||
points downward. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-icon-translate"><code>icon-translate</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -1016,16 +1016,16 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
Distance that the icon's anchor is moved from its original placement.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing a `CGVector` struct set to 0 points rightward and 0
|
||||
points upward. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`.
|
||||
Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-icon-translate"><code>icon-translate</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -1037,14 +1037,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Controls the translation reference point.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLIconTranslationAnchorMap`. Set this property to
|
||||
`nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `iconImageName` is non-`nil`, and
|
||||
`iconTranslation` is non-`nil`. Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-icon-translate-anchor"><code>icon-translate-anchor</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -1056,11 +1056,11 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The color with which the text will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`UIColor.blackColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -1068,11 +1068,11 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The color with which the text will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`NSColor.blackColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -1081,13 +1081,13 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The halo's fadeout distance towards the outside.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -1096,11 +1096,11 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
The color of the text's halo, which helps it stand out from backgrounds.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`UIColor.clearColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -1108,11 +1108,11 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
The color of the text's halo, which helps it stand out from backgrounds.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing
|
||||
`NSColor.clearColor`. Set this property to `nil` to reset it to the default
|
||||
value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -1122,13 +1122,13 @@ MGL_EXPORT
|
||||
/**
|
||||
Distance of halo to the font outline. Max text halo width is 1/4 of the
|
||||
font-size.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `0`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -1136,11 +1136,11 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
The opacity at which the text will be drawn.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSNumber` object containing the float `1`. Set this property to `nil` to reset
|
||||
it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
*/
|
||||
@@ -1149,16 +1149,16 @@ MGL_EXPORT
|
||||
#if TARGET_OS_IPHONE
|
||||
/**
|
||||
Distance that the text's anchor is moved from its original placement.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing a `CGVector` struct set to 0 points rightward and 0
|
||||
points downward. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-text-translate"><code>text-translate</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -1167,16 +1167,16 @@ MGL_EXPORT
|
||||
#else
|
||||
/**
|
||||
Distance that the text's anchor is moved from its original placement.
|
||||
|
||||
|
||||
This property is measured in points.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing a `CGVector` struct set to 0 points rightward and 0
|
||||
points upward. Set this property to `nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`. Otherwise,
|
||||
it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-text-translate"><code>text-translate</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
@@ -1188,14 +1188,14 @@ MGL_EXPORT
|
||||
|
||||
/**
|
||||
Controls the translation reference point.
|
||||
|
||||
|
||||
The default value of this property is an `MGLStyleValue` object containing an
|
||||
`NSValue` object containing `MGLTextTranslationAnchorMap`. Set this property to
|
||||
`nil` to reset it to the default value.
|
||||
|
||||
|
||||
This property is only applied to the style if `text` is non-`nil`, and
|
||||
`textTranslation` is non-`nil`. Otherwise, it is ignored.
|
||||
|
||||
|
||||
This attribute corresponds to the <a
|
||||
href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-text-translate-anchor"><code>text-translate-anchor</code></a>
|
||||
layout property in the Mapbox Style Specification.
|
||||
|
||||
@@ -197,7 +197,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)iconAllowsOverlap {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconAllowOverlap() ?: self.rawLayer->getDefaultIconAllowOverlap();
|
||||
auto propertyValue = self.rawLayer->getIconAllowOverlap();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconAllowOverlap());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -218,7 +221,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)iconIgnoresPlacement {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconIgnorePlacement() ?: self.rawLayer->getDefaultIconIgnorePlacement();
|
||||
auto propertyValue = self.rawLayer->getIconIgnorePlacement();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconIgnorePlacement());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -239,7 +245,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSString *> *)iconImageName {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconImage() ?: self.rawLayer->getDefaultIconImage();
|
||||
auto propertyValue = self.rawLayer->getIconImage();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(self.rawLayer->getDefaultIconImage());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -253,15 +262,18 @@ namespace mbgl {
|
||||
- (void)setIconOffset:(MGLStyleValue<NSValue *> *)iconOffset {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(iconOffset);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toDataDrivenPropertyValue(iconOffset);
|
||||
self.rawLayer->setIconOffset(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSValue *> *)iconOffset {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconOffset() ?: self.rawLayer->getDefaultIconOffset();
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getIconOffset();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toDataDrivenStyleValue(self.rawLayer->getDefaultIconOffset());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconOptional:(MGLStyleValue<NSNumber *> *)iconOptional {
|
||||
@@ -274,36 +286,45 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)isIconOptional {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconOptional() ?: self.rawLayer->getDefaultIconOptional();
|
||||
auto propertyValue = self.rawLayer->getIconOptional();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconOptional());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconPadding:(MGLStyleValue<NSNumber *> *)iconPadding {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconPadding);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(iconPadding);
|
||||
self.rawLayer->setIconPadding(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)iconPadding {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconPadding() ?: self.rawLayer->getDefaultIconPadding();
|
||||
auto propertyValue = self.rawLayer->getIconPadding();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconPadding());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconRotation:(MGLStyleValue<NSNumber *> *)iconRotation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconRotation);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenPropertyValue(iconRotation);
|
||||
self.rawLayer->setIconRotate(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)iconRotation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconRotate() ?: self.rawLayer->getDefaultIconRotate();
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
auto propertyValue = self.rawLayer->getIconRotate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(self.rawLayer->getDefaultIconRotate());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconRotate:(MGLStyleValue<NSNumber *> *)iconRotate {
|
||||
@@ -323,21 +344,27 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)iconRotationAlignment {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconRotationAlignment() ?: self.rawLayer->getDefaultIconRotationAlignment();
|
||||
auto propertyValue = self.rawLayer->getIconRotationAlignment();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLIconRotationAlignment>().toEnumStyleValue(self.rawLayer->getDefaultIconRotationAlignment());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLIconRotationAlignment>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconScale:(MGLStyleValue<NSNumber *> *)iconScale {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconScale);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(iconScale);
|
||||
self.rawLayer->setIconSize(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)iconScale {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconSize() ?: self.rawLayer->getDefaultIconSize();
|
||||
auto propertyValue = self.rawLayer->getIconSize();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconSize());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -358,21 +385,27 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)iconTextFit {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconTextFit() ?: self.rawLayer->getDefaultIconTextFit();
|
||||
auto propertyValue = self.rawLayer->getIconTextFit();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::IconTextFitType, NSValue *, mbgl::style::IconTextFitType, MGLIconTextFit>().toEnumStyleValue(self.rawLayer->getDefaultIconTextFit());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::IconTextFitType, NSValue *, mbgl::style::IconTextFitType, MGLIconTextFit>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconTextFitPadding:(MGLStyleValue<NSValue *> *)iconTextFitPadding {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 4>, NSValue *>().toPropertyValue(iconTextFitPadding);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 4>, NSValue *>().toInterpolatablePropertyValue(iconTextFitPadding);
|
||||
self.rawLayer->setIconTextFitPadding(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSValue *> *)iconTextFitPadding {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconTextFitPadding() ?: self.rawLayer->getDefaultIconTextFitPadding();
|
||||
auto propertyValue = self.rawLayer->getIconTextFitPadding();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::array<float, 4>, NSValue *>().toStyleValue(self.rawLayer->getDefaultIconTextFitPadding());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 4>, NSValue *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -386,7 +419,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)keepsIconUpright {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconKeepUpright() ?: self.rawLayer->getDefaultIconKeepUpright();
|
||||
auto propertyValue = self.rawLayer->getIconKeepUpright();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconKeepUpright());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -407,7 +443,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)keepsTextUpright {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextKeepUpright() ?: self.rawLayer->getDefaultTextKeepUpright();
|
||||
auto propertyValue = self.rawLayer->getTextKeepUpright();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextKeepUpright());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -421,14 +460,17 @@ namespace mbgl {
|
||||
- (void)setMaximumTextAngle:(MGLStyleValue<NSNumber *> *)maximumTextAngle {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(maximumTextAngle);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(maximumTextAngle);
|
||||
self.rawLayer->setTextMaxAngle(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)maximumTextAngle {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextMaxAngle() ?: self.rawLayer->getDefaultTextMaxAngle();
|
||||
auto propertyValue = self.rawLayer->getTextMaxAngle();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextMaxAngle());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -442,14 +484,17 @@ namespace mbgl {
|
||||
- (void)setMaximumTextWidth:(MGLStyleValue<NSNumber *> *)maximumTextWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(maximumTextWidth);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(maximumTextWidth);
|
||||
self.rawLayer->setTextMaxWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)maximumTextWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextMaxWidth() ?: self.rawLayer->getDefaultTextMaxWidth();
|
||||
auto propertyValue = self.rawLayer->getTextMaxWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextMaxWidth());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -470,7 +515,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)symbolAvoidsEdges {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getSymbolAvoidEdges() ?: self.rawLayer->getDefaultSymbolAvoidEdges();
|
||||
auto propertyValue = self.rawLayer->getSymbolAvoidEdges();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultSymbolAvoidEdges());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -491,21 +539,27 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)symbolPlacement {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getSymbolPlacement() ?: self.rawLayer->getDefaultSymbolPlacement();
|
||||
auto propertyValue = self.rawLayer->getSymbolPlacement();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::SymbolPlacementType, NSValue *, mbgl::style::SymbolPlacementType, MGLSymbolPlacement>().toEnumStyleValue(self.rawLayer->getDefaultSymbolPlacement());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::SymbolPlacementType, NSValue *, mbgl::style::SymbolPlacementType, MGLSymbolPlacement>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setSymbolSpacing:(MGLStyleValue<NSNumber *> *)symbolSpacing {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(symbolSpacing);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(symbolSpacing);
|
||||
self.rawLayer->setSymbolSpacing(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)symbolSpacing {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getSymbolSpacing() ?: self.rawLayer->getDefaultSymbolSpacing();
|
||||
auto propertyValue = self.rawLayer->getSymbolSpacing();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultSymbolSpacing());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -519,7 +573,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSString *> *)text {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextField() ?: self.rawLayer->getDefaultTextField();
|
||||
auto propertyValue = self.rawLayer->getTextField();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(self.rawLayer->getDefaultTextField());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -540,7 +597,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)textAllowsOverlap {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextAllowOverlap() ?: self.rawLayer->getDefaultTextAllowOverlap();
|
||||
auto propertyValue = self.rawLayer->getTextAllowOverlap();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextAllowOverlap());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -561,7 +621,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)textAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextAnchor() ?: self.rawLayer->getDefaultTextAnchor();
|
||||
auto propertyValue = self.rawLayer->getTextAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toEnumStyleValue(self.rawLayer->getDefaultTextAnchor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -575,7 +638,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSArray<NSString *> *> *)textFontNames {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextFont() ?: self.rawLayer->getDefaultTextFont();
|
||||
auto propertyValue = self.rawLayer->getTextFont();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toStyleValue(self.rawLayer->getDefaultTextFont());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -589,14 +655,17 @@ namespace mbgl {
|
||||
- (void)setTextFontSize:(MGLStyleValue<NSNumber *> *)textFontSize {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textFontSize);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textFontSize);
|
||||
self.rawLayer->setTextSize(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)textFontSize {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextSize() ?: self.rawLayer->getDefaultTextSize();
|
||||
auto propertyValue = self.rawLayer->getTextSize();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextSize());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -617,7 +686,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)textIgnoresPlacement {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextIgnorePlacement() ?: self.rawLayer->getDefaultTextIgnorePlacement();
|
||||
auto propertyValue = self.rawLayer->getTextIgnorePlacement();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextIgnorePlacement());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -638,7 +710,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)textJustification {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextJustify() ?: self.rawLayer->getDefaultTextJustify();
|
||||
auto propertyValue = self.rawLayer->getTextJustify();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toEnumStyleValue(self.rawLayer->getDefaultTextJustify());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -652,42 +727,51 @@ namespace mbgl {
|
||||
- (void)setTextLetterSpacing:(MGLStyleValue<NSNumber *> *)textLetterSpacing {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textLetterSpacing);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textLetterSpacing);
|
||||
self.rawLayer->setTextLetterSpacing(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)textLetterSpacing {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextLetterSpacing() ?: self.rawLayer->getDefaultTextLetterSpacing();
|
||||
auto propertyValue = self.rawLayer->getTextLetterSpacing();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextLetterSpacing());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextLineHeight:(MGLStyleValue<NSNumber *> *)textLineHeight {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textLineHeight);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textLineHeight);
|
||||
self.rawLayer->setTextLineHeight(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)textLineHeight {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextLineHeight() ?: self.rawLayer->getDefaultTextLineHeight();
|
||||
auto propertyValue = self.rawLayer->getTextLineHeight();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextLineHeight());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextOffset:(MGLStyleValue<NSValue *> *)textOffset {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(textOffset);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toInterpolatablePropertyValue(textOffset);
|
||||
self.rawLayer->setTextOffset(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSValue *> *)textOffset {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextOffset() ?: self.rawLayer->getDefaultTextOffset();
|
||||
auto propertyValue = self.rawLayer->getTextOffset();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(self.rawLayer->getDefaultTextOffset());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -701,21 +785,27 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSNumber *> *)isTextOptional {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextOptional() ?: self.rawLayer->getDefaultTextOptional();
|
||||
auto propertyValue = self.rawLayer->getTextOptional();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextOptional());
|
||||
}
|
||||
return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextPadding:(MGLStyleValue<NSNumber *> *)textPadding {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textPadding);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textPadding);
|
||||
self.rawLayer->setTextPadding(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)textPadding {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextPadding() ?: self.rawLayer->getDefaultTextPadding();
|
||||
auto propertyValue = self.rawLayer->getTextPadding();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextPadding());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -729,21 +819,27 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)textPitchAlignment {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextPitchAlignment() ?: self.rawLayer->getDefaultTextPitchAlignment();
|
||||
auto propertyValue = self.rawLayer->getTextPitchAlignment();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextPitchAlignment>().toEnumStyleValue(self.rawLayer->getDefaultTextPitchAlignment());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextPitchAlignment>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextRotation:(MGLStyleValue<NSNumber *> *)textRotation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textRotation);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textRotation);
|
||||
self.rawLayer->setTextRotate(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)textRotation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextRotate() ?: self.rawLayer->getDefaultTextRotate();
|
||||
auto propertyValue = self.rawLayer->getTextRotate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextRotate());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -764,7 +860,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)textRotationAlignment {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextRotationAlignment() ?: self.rawLayer->getDefaultTextRotationAlignment();
|
||||
auto propertyValue = self.rawLayer->getTextRotationAlignment();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextRotationAlignment>().toEnumStyleValue(self.rawLayer->getDefaultTextRotationAlignment());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextRotationAlignment>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -778,7 +877,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)textTransform {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextTransform() ?: self.rawLayer->getDefaultTextTransform();
|
||||
auto propertyValue = self.rawLayer->getTextTransform();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TextTransformType, NSValue *, mbgl::style::TextTransformType, MGLTextTransform>().toEnumStyleValue(self.rawLayer->getDefaultTextTransform());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TextTransformType, NSValue *, mbgl::style::TextTransformType, MGLTextTransform>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -787,84 +889,102 @@ namespace mbgl {
|
||||
- (void)setIconColor:(MGLStyleValue<MGLColor *> *)iconColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(iconColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toInterpolatablePropertyValue(iconColor);
|
||||
self.rawLayer->setIconColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)iconColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconColor() ?: self.rawLayer->getDefaultIconColor();
|
||||
auto propertyValue = self.rawLayer->getIconColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(self.rawLayer->getDefaultIconColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconHaloBlur:(MGLStyleValue<NSNumber *> *)iconHaloBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconHaloBlur);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(iconHaloBlur);
|
||||
self.rawLayer->setIconHaloBlur(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)iconHaloBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconHaloBlur() ?: self.rawLayer->getDefaultIconHaloBlur();
|
||||
auto propertyValue = self.rawLayer->getIconHaloBlur();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconHaloBlur());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconHaloColor:(MGLStyleValue<MGLColor *> *)iconHaloColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(iconHaloColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toInterpolatablePropertyValue(iconHaloColor);
|
||||
self.rawLayer->setIconHaloColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)iconHaloColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconHaloColor() ?: self.rawLayer->getDefaultIconHaloColor();
|
||||
auto propertyValue = self.rawLayer->getIconHaloColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(self.rawLayer->getDefaultIconHaloColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconHaloWidth:(MGLStyleValue<NSNumber *> *)iconHaloWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconHaloWidth);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(iconHaloWidth);
|
||||
self.rawLayer->setIconHaloWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)iconHaloWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconHaloWidth() ?: self.rawLayer->getDefaultIconHaloWidth();
|
||||
auto propertyValue = self.rawLayer->getIconHaloWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconHaloWidth());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconOpacity:(MGLStyleValue<NSNumber *> *)iconOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconOpacity);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(iconOpacity);
|
||||
self.rawLayer->setIconOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)iconOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconOpacity() ?: self.rawLayer->getDefaultIconOpacity();
|
||||
auto propertyValue = self.rawLayer->getIconOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultIconOpacity());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setIconTranslation:(MGLStyleValue<NSValue *> *)iconTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(iconTranslation);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toInterpolatablePropertyValue(iconTranslation);
|
||||
self.rawLayer->setIconTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSValue *> *)iconTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconTranslate() ?: self.rawLayer->getDefaultIconTranslate();
|
||||
auto propertyValue = self.rawLayer->getIconTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(self.rawLayer->getDefaultIconTranslate());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -885,7 +1005,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)iconTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getIconTranslateAnchor() ?: self.rawLayer->getDefaultIconTranslateAnchor();
|
||||
auto propertyValue = self.rawLayer->getIconTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLIconTranslationAnchor>().toEnumStyleValue(self.rawLayer->getDefaultIconTranslateAnchor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLIconTranslationAnchor>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -899,84 +1022,102 @@ namespace mbgl {
|
||||
- (void)setTextColor:(MGLStyleValue<MGLColor *> *)textColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(textColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toInterpolatablePropertyValue(textColor);
|
||||
self.rawLayer->setTextColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)textColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextColor() ?: self.rawLayer->getDefaultTextColor();
|
||||
auto propertyValue = self.rawLayer->getTextColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(self.rawLayer->getDefaultTextColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextHaloBlur:(MGLStyleValue<NSNumber *> *)textHaloBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textHaloBlur);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textHaloBlur);
|
||||
self.rawLayer->setTextHaloBlur(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)textHaloBlur {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextHaloBlur() ?: self.rawLayer->getDefaultTextHaloBlur();
|
||||
auto propertyValue = self.rawLayer->getTextHaloBlur();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextHaloBlur());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextHaloColor:(MGLStyleValue<MGLColor *> *)textHaloColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue(textHaloColor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toInterpolatablePropertyValue(textHaloColor);
|
||||
self.rawLayer->setTextHaloColor(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<MGLColor *> *)textHaloColor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextHaloColor() ?: self.rawLayer->getDefaultTextHaloColor();
|
||||
auto propertyValue = self.rawLayer->getTextHaloColor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(self.rawLayer->getDefaultTextHaloColor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextHaloWidth:(MGLStyleValue<NSNumber *> *)textHaloWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textHaloWidth);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textHaloWidth);
|
||||
self.rawLayer->setTextHaloWidth(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)textHaloWidth {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextHaloWidth() ?: self.rawLayer->getDefaultTextHaloWidth();
|
||||
auto propertyValue = self.rawLayer->getTextHaloWidth();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextHaloWidth());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextOpacity:(MGLStyleValue<NSNumber *> *)textOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textOpacity);
|
||||
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toInterpolatablePropertyValue(textOpacity);
|
||||
self.rawLayer->setTextOpacity(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSNumber *> *)textOpacity {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextOpacity() ?: self.rawLayer->getDefaultTextOpacity();
|
||||
auto propertyValue = self.rawLayer->getTextOpacity();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(self.rawLayer->getDefaultTextOpacity());
|
||||
}
|
||||
return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextTranslation:(MGLStyleValue<NSValue *> *)textTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue(textTranslation);
|
||||
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toInterpolatablePropertyValue(textTranslation);
|
||||
self.rawLayer->setTextTranslate(mbglValue);
|
||||
}
|
||||
|
||||
- (MGLStyleValue<NSValue *> *)textTranslation {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextTranslate() ?: self.rawLayer->getDefaultTextTranslate();
|
||||
auto propertyValue = self.rawLayer->getTextTranslate();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(self.rawLayer->getDefaultTextTranslate());
|
||||
}
|
||||
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
@@ -997,7 +1138,10 @@ namespace mbgl {
|
||||
- (MGLStyleValue<NSValue *> *)textTranslationAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextTranslateAnchor() ?: self.rawLayer->getDefaultTextTranslateAnchor();
|
||||
auto propertyValue = self.rawLayer->getTextTranslateAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLTextTranslationAnchor>().toEnumStyleValue(self.rawLayer->getDefaultTextTranslateAnchor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLTextTranslationAnchor>().toEnumStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This file is generated.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
|
||||
#import "MGLStyleLayerTests.h"
|
||||
|
||||
@@ -28,26 +28,26 @@
|
||||
@"background-color should be unset initially.");
|
||||
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.backgroundColor;
|
||||
|
||||
MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.backgroundColor = styleValue;
|
||||
MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.backgroundColor = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
XCTAssertEqual(rawLayer->getBackgroundColor(), propertyValue,
|
||||
@"Setting backgroundColor to a constant value should update background-color.");
|
||||
XCTAssertEqualObjects(layer.backgroundColor, styleValue,
|
||||
XCTAssertEqualObjects(layer.backgroundColor, constantStyleValue,
|
||||
@"backgroundColor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.backgroundColor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::Color> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.backgroundColor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getBackgroundColor(), propertyValue,
|
||||
@"Setting backgroundColor to a function should update background-color.");
|
||||
XCTAssertEqualObjects(layer.backgroundColor, styleValue,
|
||||
@"backgroundColor should round-trip functions.");
|
||||
@"Setting backgroundColor to a camera function should update background-color.");
|
||||
XCTAssertEqualObjects(layer.backgroundColor, functionStyleValue,
|
||||
@"backgroundColor should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.backgroundColor = nil;
|
||||
XCTAssertTrue(rawLayer->getBackgroundColor().isUndefined(),
|
||||
@@ -62,26 +62,26 @@
|
||||
@"background-opacity should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.backgroundOpacity;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.backgroundOpacity = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.backgroundOpacity = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue,
|
||||
@"Setting backgroundOpacity to a constant value should update background-opacity.");
|
||||
XCTAssertEqualObjects(layer.backgroundOpacity, styleValue,
|
||||
XCTAssertEqualObjects(layer.backgroundOpacity, constantStyleValue,
|
||||
@"backgroundOpacity should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.backgroundOpacity = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.backgroundOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue,
|
||||
@"Setting backgroundOpacity to a function should update background-opacity.");
|
||||
XCTAssertEqualObjects(layer.backgroundOpacity, styleValue,
|
||||
@"backgroundOpacity should round-trip functions.");
|
||||
@"Setting backgroundOpacity to a camera function should update background-opacity.");
|
||||
XCTAssertEqualObjects(layer.backgroundOpacity, functionStyleValue,
|
||||
@"backgroundOpacity should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.backgroundOpacity = nil;
|
||||
XCTAssertTrue(rawLayer->getBackgroundOpacity().isUndefined(),
|
||||
@@ -96,32 +96,38 @@
|
||||
@"background-pattern should be unset initially.");
|
||||
MGLStyleValue<NSString *> *defaultStyleValue = layer.backgroundPattern;
|
||||
|
||||
MGLStyleValue<NSString *> *styleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Background Pattern"];
|
||||
layer.backgroundPattern = styleValue;
|
||||
MGLStyleValue<NSString *> *constantStyleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Background Pattern"];
|
||||
layer.backgroundPattern = constantStyleValue;
|
||||
mbgl::style::PropertyValue<std::string> propertyValue = { "Background Pattern" };
|
||||
XCTAssertEqual(rawLayer->getBackgroundPattern(), propertyValue,
|
||||
@"Setting backgroundPattern to a constant value should update background-pattern.");
|
||||
XCTAssertEqualObjects(layer.backgroundPattern, styleValue,
|
||||
XCTAssertEqualObjects(layer.backgroundPattern, constantStyleValue,
|
||||
@"backgroundPattern should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSString *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.backgroundPattern = styleValue;
|
||||
propertyValue = { mbgl::style::Function<std::string> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSString *> * functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.backgroundPattern = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<std::string> intervalStops = { {{18, "Background Pattern"}} };
|
||||
propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getBackgroundPattern(), propertyValue,
|
||||
@"Setting backgroundPattern to a function should update background-pattern.");
|
||||
XCTAssertEqualObjects(layer.backgroundPattern, styleValue,
|
||||
@"backgroundPattern should round-trip functions.");
|
||||
@"Setting backgroundPattern to a camera function should update background-pattern.");
|
||||
XCTAssertEqualObjects(layer.backgroundPattern, functionStyleValue,
|
||||
@"backgroundPattern should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.backgroundPattern = nil;
|
||||
XCTAssertTrue(rawLayer->getBackgroundPattern().isUndefined(),
|
||||
@"Unsetting backgroundPattern should return background-pattern to the default value.");
|
||||
XCTAssertEqualObjects(layer.backgroundPattern, defaultStyleValue,
|
||||
@"backgroundPattern should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.backgroundPattern = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.backgroundPattern = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This file is generated.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
|
||||
#import "MGLStyleLayerTests.h"
|
||||
|
||||
@@ -49,26 +49,49 @@
|
||||
@"circle-blur should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.circleBlur;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleBlur = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleBlur = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
|
||||
@"Setting circleBlur to a constant value should update circle-blur.");
|
||||
XCTAssertEqualObjects(layer.circleBlur, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleBlur, constantStyleValue,
|
||||
@"circleBlur should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleBlur = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleBlur = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
|
||||
@"Setting circleBlur to a function should update circle-blur.");
|
||||
XCTAssertEqualObjects(layer.circleBlur, styleValue,
|
||||
@"circleBlur should round-trip functions.");
|
||||
@"Setting circleBlur to a camera function should update circle-blur.");
|
||||
XCTAssertEqualObjects(layer.circleBlur, functionStyleValue,
|
||||
@"circleBlur should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.circleBlur = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
|
||||
@"Setting circleBlur to a source function should update circle-blur.");
|
||||
XCTAssertEqualObjects(layer.circleBlur, functionStyleValue,
|
||||
@"circleBlur should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.circleBlur = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
|
||||
@"Setting circleBlur to a composite function should update circle-blur.");
|
||||
XCTAssertEqualObjects(layer.circleBlur, functionStyleValue,
|
||||
@"circleBlur should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.circleBlur = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleBlur().isUndefined(),
|
||||
@@ -83,26 +106,49 @@
|
||||
@"circle-color should be unset initially.");
|
||||
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.circleColor;
|
||||
|
||||
MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.circleColor = styleValue;
|
||||
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.circleColor = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
|
||||
@"Setting circleColor to a constant value should update circle-color.");
|
||||
XCTAssertEqualObjects(layer.circleColor, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleColor, constantStyleValue,
|
||||
@"circleColor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleColor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::Color> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleColor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
|
||||
@"Setting circleColor to a function should update circle-color.");
|
||||
XCTAssertEqualObjects(layer.circleColor, styleValue,
|
||||
@"circleColor should round-trip functions.");
|
||||
@"Setting circleColor to a camera function should update circle-color.");
|
||||
XCTAssertEqualObjects(layer.circleColor, functionStyleValue,
|
||||
@"circleColor should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.circleColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
|
||||
@"Setting circleColor to a source function should update circle-color.");
|
||||
XCTAssertEqualObjects(layer.circleColor, functionStyleValue,
|
||||
@"circleColor should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.circleColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> innerStops = { { {18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<mbgl::Color>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
|
||||
@"Setting circleColor to a composite function should update circle-color.");
|
||||
XCTAssertEqualObjects(layer.circleColor, functionStyleValue,
|
||||
@"circleColor should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.circleColor = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleColor().isUndefined(),
|
||||
@@ -117,26 +163,49 @@
|
||||
@"circle-opacity should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.circleOpacity;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleOpacity = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleOpacity = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
|
||||
@"Setting circleOpacity to a constant value should update circle-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleOpacity, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleOpacity, constantStyleValue,
|
||||
@"circleOpacity should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleOpacity = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
|
||||
@"Setting circleOpacity to a function should update circle-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleOpacity, styleValue,
|
||||
@"circleOpacity should round-trip functions.");
|
||||
@"Setting circleOpacity to a camera function should update circle-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleOpacity, functionStyleValue,
|
||||
@"circleOpacity should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.circleOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
|
||||
@"Setting circleOpacity to a source function should update circle-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleOpacity, functionStyleValue,
|
||||
@"circleOpacity should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.circleOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
|
||||
@"Setting circleOpacity to a composite function should update circle-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleOpacity, functionStyleValue,
|
||||
@"circleOpacity should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.circleOpacity = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleOpacity().isUndefined(),
|
||||
@@ -151,26 +220,49 @@
|
||||
@"circle-radius should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.circleRadius;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleRadius = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleRadius = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
|
||||
@"Setting circleRadius to a constant value should update circle-radius.");
|
||||
XCTAssertEqualObjects(layer.circleRadius, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleRadius, constantStyleValue,
|
||||
@"circleRadius should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleRadius = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleRadius = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
|
||||
@"Setting circleRadius to a function should update circle-radius.");
|
||||
XCTAssertEqualObjects(layer.circleRadius, styleValue,
|
||||
@"circleRadius should round-trip functions.");
|
||||
@"Setting circleRadius to a camera function should update circle-radius.");
|
||||
XCTAssertEqualObjects(layer.circleRadius, functionStyleValue,
|
||||
@"circleRadius should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.circleRadius = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
|
||||
@"Setting circleRadius to a source function should update circle-radius.");
|
||||
XCTAssertEqualObjects(layer.circleRadius, functionStyleValue,
|
||||
@"circleRadius should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.circleRadius = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
|
||||
@"Setting circleRadius to a composite function should update circle-radius.");
|
||||
XCTAssertEqualObjects(layer.circleRadius, functionStyleValue,
|
||||
@"circleRadius should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.circleRadius = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleRadius().isUndefined(),
|
||||
@@ -185,32 +277,38 @@
|
||||
@"circle-pitch-scale should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.circleScaleAlignment;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLCircleScaleAlignment:MGLCircleScaleAlignmentViewport]];
|
||||
layer.circleScaleAlignment = styleValue;
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLCircleScaleAlignment:MGLCircleScaleAlignmentViewport]];
|
||||
layer.circleScaleAlignment = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::CirclePitchScaleType> propertyValue = { mbgl::style::CirclePitchScaleType::Viewport };
|
||||
XCTAssertEqual(rawLayer->getCirclePitchScale(), propertyValue,
|
||||
@"Setting circleScaleAlignment to a constant value should update circle-pitch-scale.");
|
||||
XCTAssertEqualObjects(layer.circleScaleAlignment, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleScaleAlignment, constantStyleValue,
|
||||
@"circleScaleAlignment should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleScaleAlignment = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::style::CirclePitchScaleType> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleScaleAlignment = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::CirclePitchScaleType> intervalStops = { {{18, mbgl::style::CirclePitchScaleType::Viewport}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::CirclePitchScaleType> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCirclePitchScale(), propertyValue,
|
||||
@"Setting circleScaleAlignment to a function should update circle-pitch-scale.");
|
||||
XCTAssertEqualObjects(layer.circleScaleAlignment, styleValue,
|
||||
@"circleScaleAlignment should round-trip functions.");
|
||||
@"Setting circleScaleAlignment to a camera function should update circle-pitch-scale.");
|
||||
XCTAssertEqualObjects(layer.circleScaleAlignment, functionStyleValue,
|
||||
@"circleScaleAlignment should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.circleScaleAlignment = nil;
|
||||
XCTAssertTrue(rawLayer->getCirclePitchScale().isUndefined(),
|
||||
@"Unsetting circleScaleAlignment should return circle-pitch-scale to the default value.");
|
||||
XCTAssertEqualObjects(layer.circleScaleAlignment, defaultStyleValue,
|
||||
@"circleScaleAlignment should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.circleScaleAlignment = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.circleScaleAlignment = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// circle-stroke-color
|
||||
@@ -219,26 +317,49 @@
|
||||
@"circle-stroke-color should be unset initially.");
|
||||
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.circleStrokeColor;
|
||||
|
||||
MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.circleStrokeColor = styleValue;
|
||||
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.circleStrokeColor = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
|
||||
@"Setting circleStrokeColor to a constant value should update circle-stroke-color.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeColor, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleStrokeColor, constantStyleValue,
|
||||
@"circleStrokeColor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleStrokeColor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::Color> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleStrokeColor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
|
||||
@"Setting circleStrokeColor to a function should update circle-stroke-color.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeColor, styleValue,
|
||||
@"circleStrokeColor should round-trip functions.");
|
||||
@"Setting circleStrokeColor to a camera function should update circle-stroke-color.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeColor, functionStyleValue,
|
||||
@"circleStrokeColor should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.circleStrokeColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
|
||||
@"Setting circleStrokeColor to a source function should update circle-stroke-color.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeColor, functionStyleValue,
|
||||
@"circleStrokeColor should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.circleStrokeColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> innerStops = { { {18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<mbgl::Color>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
|
||||
@"Setting circleStrokeColor to a composite function should update circle-stroke-color.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeColor, functionStyleValue,
|
||||
@"circleStrokeColor should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.circleStrokeColor = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleStrokeColor().isUndefined(),
|
||||
@@ -253,26 +374,49 @@
|
||||
@"circle-stroke-opacity should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.circleStrokeOpacity;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleStrokeOpacity = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleStrokeOpacity = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
|
||||
@"Setting circleStrokeOpacity to a constant value should update circle-stroke-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeOpacity, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleStrokeOpacity, constantStyleValue,
|
||||
@"circleStrokeOpacity should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleStrokeOpacity = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleStrokeOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
|
||||
@"Setting circleStrokeOpacity to a function should update circle-stroke-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeOpacity, styleValue,
|
||||
@"circleStrokeOpacity should round-trip functions.");
|
||||
@"Setting circleStrokeOpacity to a camera function should update circle-stroke-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeOpacity, functionStyleValue,
|
||||
@"circleStrokeOpacity should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.circleStrokeOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
|
||||
@"Setting circleStrokeOpacity to a source function should update circle-stroke-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeOpacity, functionStyleValue,
|
||||
@"circleStrokeOpacity should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.circleStrokeOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
|
||||
@"Setting circleStrokeOpacity to a composite function should update circle-stroke-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeOpacity, functionStyleValue,
|
||||
@"circleStrokeOpacity should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.circleStrokeOpacity = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleStrokeOpacity().isUndefined(),
|
||||
@@ -287,26 +431,49 @@
|
||||
@"circle-stroke-width should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.circleStrokeWidth;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleStrokeWidth = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.circleStrokeWidth = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
|
||||
@"Setting circleStrokeWidth to a constant value should update circle-stroke-width.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeWidth, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleStrokeWidth, constantStyleValue,
|
||||
@"circleStrokeWidth should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleStrokeWidth = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleStrokeWidth = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
|
||||
@"Setting circleStrokeWidth to a function should update circle-stroke-width.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeWidth, styleValue,
|
||||
@"circleStrokeWidth should round-trip functions.");
|
||||
@"Setting circleStrokeWidth to a camera function should update circle-stroke-width.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeWidth, functionStyleValue,
|
||||
@"circleStrokeWidth should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.circleStrokeWidth = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
|
||||
@"Setting circleStrokeWidth to a source function should update circle-stroke-width.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeWidth, functionStyleValue,
|
||||
@"circleStrokeWidth should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.circleStrokeWidth = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
|
||||
@"Setting circleStrokeWidth to a composite function should update circle-stroke-width.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeWidth, functionStyleValue,
|
||||
@"circleStrokeWidth should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.circleStrokeWidth = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleStrokeWidth().isUndefined(),
|
||||
@@ -321,32 +488,32 @@
|
||||
@"circle-translate should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.circleTranslation;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
|
||||
#if TARGET_OS_IPHONE
|
||||
[NSValue valueWithCGVector:CGVectorMake(1, 1)]
|
||||
#else
|
||||
[NSValue valueWithMGLVector:CGVectorMake(1, -1)]
|
||||
#endif
|
||||
];
|
||||
layer.circleTranslation = styleValue;
|
||||
layer.circleTranslation = constantStyleValue;
|
||||
mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
|
||||
XCTAssertEqual(rawLayer->getCircleTranslate(), propertyValue,
|
||||
@"Setting circleTranslation to a constant value should update circle-translate.");
|
||||
XCTAssertEqualObjects(layer.circleTranslation, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleTranslation, constantStyleValue,
|
||||
@"circleTranslation should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleTranslation = styleValue;
|
||||
propertyValue = { mbgl::style::Function<std::array<float, 2>> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleTranslation = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = { {{18, { 1, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleTranslate(), propertyValue,
|
||||
@"Setting circleTranslation to a function should update circle-translate.");
|
||||
XCTAssertEqualObjects(layer.circleTranslation, styleValue,
|
||||
@"circleTranslation should round-trip functions.");
|
||||
@"Setting circleTranslation to a camera function should update circle-translate.");
|
||||
XCTAssertEqualObjects(layer.circleTranslation, functionStyleValue,
|
||||
@"circleTranslation should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.circleTranslation = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleTranslate().isUndefined(),
|
||||
@@ -361,32 +528,38 @@
|
||||
@"circle-translate-anchor should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.circleTranslationAnchor;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLCircleTranslationAnchor:MGLCircleTranslationAnchorViewport]];
|
||||
layer.circleTranslationAnchor = styleValue;
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLCircleTranslationAnchor:MGLCircleTranslationAnchorViewport]];
|
||||
layer.circleTranslationAnchor = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
|
||||
XCTAssertEqual(rawLayer->getCircleTranslateAnchor(), propertyValue,
|
||||
@"Setting circleTranslationAnchor to a constant value should update circle-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.circleTranslationAnchor, styleValue,
|
||||
XCTAssertEqualObjects(layer.circleTranslationAnchor, constantStyleValue,
|
||||
@"circleTranslationAnchor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.circleTranslationAnchor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::style::TranslateAnchorType> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.circleTranslationAnchor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = { {{18, mbgl::style::TranslateAnchorType::Viewport}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleTranslateAnchor(), propertyValue,
|
||||
@"Setting circleTranslationAnchor to a function should update circle-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.circleTranslationAnchor, styleValue,
|
||||
@"circleTranslationAnchor should round-trip functions.");
|
||||
@"Setting circleTranslationAnchor to a camera function should update circle-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.circleTranslationAnchor, functionStyleValue,
|
||||
@"circleTranslationAnchor should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.circleTranslationAnchor = nil;
|
||||
XCTAssertTrue(rawLayer->getCircleTranslateAnchor().isUndefined(),
|
||||
@"Unsetting circleTranslationAnchor should return circle-translate-anchor to the default value.");
|
||||
XCTAssertEqualObjects(layer.circleTranslationAnchor, defaultStyleValue,
|
||||
@"circleTranslationAnchor should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.circleTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.circleTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This file is generated.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
|
||||
#import "MGLStyleLayerTests.h"
|
||||
|
||||
@@ -49,32 +49,38 @@
|
||||
@"fill-antialias should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.fillAntialiased;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@NO];
|
||||
layer.fillAntialiased = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@NO];
|
||||
layer.fillAntialiased = constantStyleValue;
|
||||
mbgl::style::PropertyValue<bool> propertyValue = { false };
|
||||
XCTAssertEqual(rawLayer->getFillAntialias(), propertyValue,
|
||||
@"Setting fillAntialiased to a constant value should update fill-antialias.");
|
||||
XCTAssertEqualObjects(layer.fillAntialiased, styleValue,
|
||||
XCTAssertEqualObjects(layer.fillAntialiased, constantStyleValue,
|
||||
@"fillAntialiased should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.fillAntialiased = styleValue;
|
||||
propertyValue = { mbgl::style::Function<bool> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.fillAntialiased = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<bool> intervalStops = { {{18, false}} };
|
||||
propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillAntialias(), propertyValue,
|
||||
@"Setting fillAntialiased to a function should update fill-antialias.");
|
||||
XCTAssertEqualObjects(layer.fillAntialiased, styleValue,
|
||||
@"fillAntialiased should round-trip functions.");
|
||||
@"Setting fillAntialiased to a camera function should update fill-antialias.");
|
||||
XCTAssertEqualObjects(layer.fillAntialiased, functionStyleValue,
|
||||
@"fillAntialiased should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.fillAntialiased = nil;
|
||||
XCTAssertTrue(rawLayer->getFillAntialias().isUndefined(),
|
||||
@"Unsetting fillAntialiased should return fill-antialias to the default value.");
|
||||
XCTAssertEqualObjects(layer.fillAntialiased, defaultStyleValue,
|
||||
@"fillAntialiased should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.fillAntialiased = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.fillAntialiased = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// fill-color
|
||||
@@ -83,26 +89,49 @@
|
||||
@"fill-color should be unset initially.");
|
||||
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.fillColor;
|
||||
|
||||
MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.fillColor = styleValue;
|
||||
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.fillColor = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
|
||||
@"Setting fillColor to a constant value should update fill-color.");
|
||||
XCTAssertEqualObjects(layer.fillColor, styleValue,
|
||||
XCTAssertEqualObjects(layer.fillColor, constantStyleValue,
|
||||
@"fillColor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.fillColor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::Color> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.fillColor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
|
||||
@"Setting fillColor to a function should update fill-color.");
|
||||
XCTAssertEqualObjects(layer.fillColor, styleValue,
|
||||
@"fillColor should round-trip functions.");
|
||||
@"Setting fillColor to a camera function should update fill-color.");
|
||||
XCTAssertEqualObjects(layer.fillColor, functionStyleValue,
|
||||
@"fillColor should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.fillColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
|
||||
@"Setting fillColor to a source function should update fill-color.");
|
||||
XCTAssertEqualObjects(layer.fillColor, functionStyleValue,
|
||||
@"fillColor should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.fillColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> innerStops = { { {18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<mbgl::Color>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
|
||||
@"Setting fillColor to a composite function should update fill-color.");
|
||||
XCTAssertEqualObjects(layer.fillColor, functionStyleValue,
|
||||
@"fillColor should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.fillColor = nil;
|
||||
XCTAssertTrue(rawLayer->getFillColor().isUndefined(),
|
||||
@@ -117,26 +146,49 @@
|
||||
@"fill-opacity should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.fillOpacity;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.fillOpacity = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.fillOpacity = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
|
||||
@"Setting fillOpacity to a constant value should update fill-opacity.");
|
||||
XCTAssertEqualObjects(layer.fillOpacity, styleValue,
|
||||
XCTAssertEqualObjects(layer.fillOpacity, constantStyleValue,
|
||||
@"fillOpacity should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.fillOpacity = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.fillOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
|
||||
@"Setting fillOpacity to a function should update fill-opacity.");
|
||||
XCTAssertEqualObjects(layer.fillOpacity, styleValue,
|
||||
@"fillOpacity should round-trip functions.");
|
||||
@"Setting fillOpacity to a camera function should update fill-opacity.");
|
||||
XCTAssertEqualObjects(layer.fillOpacity, functionStyleValue,
|
||||
@"fillOpacity should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.fillOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
|
||||
@"Setting fillOpacity to a source function should update fill-opacity.");
|
||||
XCTAssertEqualObjects(layer.fillOpacity, functionStyleValue,
|
||||
@"fillOpacity should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.fillOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
|
||||
@"Setting fillOpacity to a composite function should update fill-opacity.");
|
||||
XCTAssertEqualObjects(layer.fillOpacity, functionStyleValue,
|
||||
@"fillOpacity should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.fillOpacity = nil;
|
||||
XCTAssertTrue(rawLayer->getFillOpacity().isUndefined(),
|
||||
@@ -151,26 +203,49 @@
|
||||
@"fill-outline-color should be unset initially.");
|
||||
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.fillOutlineColor;
|
||||
|
||||
MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.fillOutlineColor = styleValue;
|
||||
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.fillOutlineColor = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
|
||||
@"Setting fillOutlineColor to a constant value should update fill-outline-color.");
|
||||
XCTAssertEqualObjects(layer.fillOutlineColor, styleValue,
|
||||
XCTAssertEqualObjects(layer.fillOutlineColor, constantStyleValue,
|
||||
@"fillOutlineColor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.fillOutlineColor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::Color> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.fillOutlineColor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
|
||||
@"Setting fillOutlineColor to a function should update fill-outline-color.");
|
||||
XCTAssertEqualObjects(layer.fillOutlineColor, styleValue,
|
||||
@"fillOutlineColor should round-trip functions.");
|
||||
@"Setting fillOutlineColor to a camera function should update fill-outline-color.");
|
||||
XCTAssertEqualObjects(layer.fillOutlineColor, functionStyleValue,
|
||||
@"fillOutlineColor should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.fillOutlineColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
|
||||
@"Setting fillOutlineColor to a source function should update fill-outline-color.");
|
||||
XCTAssertEqualObjects(layer.fillOutlineColor, functionStyleValue,
|
||||
@"fillOutlineColor should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.fillOutlineColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> innerStops = { { {18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<mbgl::Color>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
|
||||
@"Setting fillOutlineColor to a composite function should update fill-outline-color.");
|
||||
XCTAssertEqualObjects(layer.fillOutlineColor, functionStyleValue,
|
||||
@"fillOutlineColor should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.fillOutlineColor = nil;
|
||||
XCTAssertTrue(rawLayer->getFillOutlineColor().isUndefined(),
|
||||
@@ -185,32 +260,38 @@
|
||||
@"fill-pattern should be unset initially.");
|
||||
MGLStyleValue<NSString *> *defaultStyleValue = layer.fillPattern;
|
||||
|
||||
MGLStyleValue<NSString *> *styleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Fill Pattern"];
|
||||
layer.fillPattern = styleValue;
|
||||
MGLStyleValue<NSString *> *constantStyleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Fill Pattern"];
|
||||
layer.fillPattern = constantStyleValue;
|
||||
mbgl::style::PropertyValue<std::string> propertyValue = { "Fill Pattern" };
|
||||
XCTAssertEqual(rawLayer->getFillPattern(), propertyValue,
|
||||
@"Setting fillPattern to a constant value should update fill-pattern.");
|
||||
XCTAssertEqualObjects(layer.fillPattern, styleValue,
|
||||
XCTAssertEqualObjects(layer.fillPattern, constantStyleValue,
|
||||
@"fillPattern should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSString *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.fillPattern = styleValue;
|
||||
propertyValue = { mbgl::style::Function<std::string> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSString *> * functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.fillPattern = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<std::string> intervalStops = { {{18, "Fill Pattern"}} };
|
||||
propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillPattern(), propertyValue,
|
||||
@"Setting fillPattern to a function should update fill-pattern.");
|
||||
XCTAssertEqualObjects(layer.fillPattern, styleValue,
|
||||
@"fillPattern should round-trip functions.");
|
||||
@"Setting fillPattern to a camera function should update fill-pattern.");
|
||||
XCTAssertEqualObjects(layer.fillPattern, functionStyleValue,
|
||||
@"fillPattern should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.fillPattern = nil;
|
||||
XCTAssertTrue(rawLayer->getFillPattern().isUndefined(),
|
||||
@"Unsetting fillPattern should return fill-pattern to the default value.");
|
||||
XCTAssertEqualObjects(layer.fillPattern, defaultStyleValue,
|
||||
@"fillPattern should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.fillPattern = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.fillPattern = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// fill-translate
|
||||
@@ -219,32 +300,32 @@
|
||||
@"fill-translate should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.fillTranslation;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
|
||||
#if TARGET_OS_IPHONE
|
||||
[NSValue valueWithCGVector:CGVectorMake(1, 1)]
|
||||
#else
|
||||
[NSValue valueWithMGLVector:CGVectorMake(1, -1)]
|
||||
#endif
|
||||
];
|
||||
layer.fillTranslation = styleValue;
|
||||
layer.fillTranslation = constantStyleValue;
|
||||
mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
|
||||
XCTAssertEqual(rawLayer->getFillTranslate(), propertyValue,
|
||||
@"Setting fillTranslation to a constant value should update fill-translate.");
|
||||
XCTAssertEqualObjects(layer.fillTranslation, styleValue,
|
||||
XCTAssertEqualObjects(layer.fillTranslation, constantStyleValue,
|
||||
@"fillTranslation should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.fillTranslation = styleValue;
|
||||
propertyValue = { mbgl::style::Function<std::array<float, 2>> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.fillTranslation = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = { {{18, { 1, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillTranslate(), propertyValue,
|
||||
@"Setting fillTranslation to a function should update fill-translate.");
|
||||
XCTAssertEqualObjects(layer.fillTranslation, styleValue,
|
||||
@"fillTranslation should round-trip functions.");
|
||||
@"Setting fillTranslation to a camera function should update fill-translate.");
|
||||
XCTAssertEqualObjects(layer.fillTranslation, functionStyleValue,
|
||||
@"fillTranslation should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.fillTranslation = nil;
|
||||
XCTAssertTrue(rawLayer->getFillTranslate().isUndefined(),
|
||||
@@ -259,32 +340,38 @@
|
||||
@"fill-translate-anchor should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.fillTranslationAnchor;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLFillTranslationAnchor:MGLFillTranslationAnchorViewport]];
|
||||
layer.fillTranslationAnchor = styleValue;
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLFillTranslationAnchor:MGLFillTranslationAnchorViewport]];
|
||||
layer.fillTranslationAnchor = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
|
||||
XCTAssertEqual(rawLayer->getFillTranslateAnchor(), propertyValue,
|
||||
@"Setting fillTranslationAnchor to a constant value should update fill-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.fillTranslationAnchor, styleValue,
|
||||
XCTAssertEqualObjects(layer.fillTranslationAnchor, constantStyleValue,
|
||||
@"fillTranslationAnchor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.fillTranslationAnchor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::style::TranslateAnchorType> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.fillTranslationAnchor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = { {{18, mbgl::style::TranslateAnchorType::Viewport}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillTranslateAnchor(), propertyValue,
|
||||
@"Setting fillTranslationAnchor to a function should update fill-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.fillTranslationAnchor, styleValue,
|
||||
@"fillTranslationAnchor should round-trip functions.");
|
||||
@"Setting fillTranslationAnchor to a camera function should update fill-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.fillTranslationAnchor, functionStyleValue,
|
||||
@"fillTranslationAnchor should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.fillTranslationAnchor = nil;
|
||||
XCTAssertTrue(rawLayer->getFillTranslateAnchor().isUndefined(),
|
||||
@"Unsetting fillTranslationAnchor should return fill-translate-anchor to the default value.");
|
||||
XCTAssertEqualObjects(layer.fillTranslationAnchor, defaultStyleValue,
|
||||
@"fillTranslationAnchor should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.fillTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.fillTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This file is generated.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
|
||||
#import "MGLStyleLayerTests.h"
|
||||
|
||||
@@ -49,32 +49,38 @@
|
||||
@"line-cap should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.lineCap;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLineCap:MGLLineCapSquare]];
|
||||
layer.lineCap = styleValue;
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLineCap:MGLLineCapSquare]];
|
||||
layer.lineCap = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::LineCapType> propertyValue = { mbgl::style::LineCapType::Square };
|
||||
XCTAssertEqual(rawLayer->getLineCap(), propertyValue,
|
||||
@"Setting lineCap to a constant value should update line-cap.");
|
||||
XCTAssertEqualObjects(layer.lineCap, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineCap, constantStyleValue,
|
||||
@"lineCap should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineCap = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::style::LineCapType> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineCap = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::LineCapType> intervalStops = { {{18, mbgl::style::LineCapType::Square}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::LineCapType> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineCap(), propertyValue,
|
||||
@"Setting lineCap to a function should update line-cap.");
|
||||
XCTAssertEqualObjects(layer.lineCap, styleValue,
|
||||
@"lineCap should round-trip functions.");
|
||||
@"Setting lineCap to a camera function should update line-cap.");
|
||||
XCTAssertEqualObjects(layer.lineCap, functionStyleValue,
|
||||
@"lineCap should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.lineCap = nil;
|
||||
XCTAssertTrue(rawLayer->getLineCap().isUndefined(),
|
||||
@"Unsetting lineCap should return line-cap to the default value.");
|
||||
XCTAssertEqualObjects(layer.lineCap, defaultStyleValue,
|
||||
@"lineCap should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineCap = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineCap = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// line-join
|
||||
@@ -83,32 +89,38 @@
|
||||
@"line-join should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.lineJoin;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLineJoin:MGLLineJoinMiter]];
|
||||
layer.lineJoin = styleValue;
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLineJoin:MGLLineJoinMiter]];
|
||||
layer.lineJoin = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::LineJoinType> propertyValue = { mbgl::style::LineJoinType::Miter };
|
||||
XCTAssertEqual(rawLayer->getLineJoin(), propertyValue,
|
||||
@"Setting lineJoin to a constant value should update line-join.");
|
||||
XCTAssertEqualObjects(layer.lineJoin, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineJoin, constantStyleValue,
|
||||
@"lineJoin should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineJoin = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::style::LineJoinType> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineJoin = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::LineJoinType> intervalStops = { {{18, mbgl::style::LineJoinType::Miter}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::LineJoinType> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineJoin(), propertyValue,
|
||||
@"Setting lineJoin to a function should update line-join.");
|
||||
XCTAssertEqualObjects(layer.lineJoin, styleValue,
|
||||
@"lineJoin should round-trip functions.");
|
||||
@"Setting lineJoin to a camera function should update line-join.");
|
||||
XCTAssertEqualObjects(layer.lineJoin, functionStyleValue,
|
||||
@"lineJoin should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.lineJoin = nil;
|
||||
XCTAssertTrue(rawLayer->getLineJoin().isUndefined(),
|
||||
@"Unsetting lineJoin should return line-join to the default value.");
|
||||
XCTAssertEqualObjects(layer.lineJoin, defaultStyleValue,
|
||||
@"lineJoin should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineJoin = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineJoin = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// line-miter-limit
|
||||
@@ -117,26 +129,26 @@
|
||||
@"line-miter-limit should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.lineMiterLimit;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineMiterLimit = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineMiterLimit = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getLineMiterLimit(), propertyValue,
|
||||
@"Setting lineMiterLimit to a constant value should update line-miter-limit.");
|
||||
XCTAssertEqualObjects(layer.lineMiterLimit, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineMiterLimit, constantStyleValue,
|
||||
@"lineMiterLimit should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineMiterLimit = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineMiterLimit = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineMiterLimit(), propertyValue,
|
||||
@"Setting lineMiterLimit to a function should update line-miter-limit.");
|
||||
XCTAssertEqualObjects(layer.lineMiterLimit, styleValue,
|
||||
@"lineMiterLimit should round-trip functions.");
|
||||
@"Setting lineMiterLimit to a camera function should update line-miter-limit.");
|
||||
XCTAssertEqualObjects(layer.lineMiterLimit, functionStyleValue,
|
||||
@"lineMiterLimit should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.lineMiterLimit = nil;
|
||||
XCTAssertTrue(rawLayer->getLineMiterLimit().isUndefined(),
|
||||
@@ -151,26 +163,26 @@
|
||||
@"line-round-limit should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.lineRoundLimit;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineRoundLimit = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineRoundLimit = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getLineRoundLimit(), propertyValue,
|
||||
@"Setting lineRoundLimit to a constant value should update line-round-limit.");
|
||||
XCTAssertEqualObjects(layer.lineRoundLimit, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineRoundLimit, constantStyleValue,
|
||||
@"lineRoundLimit should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineRoundLimit = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineRoundLimit = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineRoundLimit(), propertyValue,
|
||||
@"Setting lineRoundLimit to a function should update line-round-limit.");
|
||||
XCTAssertEqualObjects(layer.lineRoundLimit, styleValue,
|
||||
@"lineRoundLimit should round-trip functions.");
|
||||
@"Setting lineRoundLimit to a camera function should update line-round-limit.");
|
||||
XCTAssertEqualObjects(layer.lineRoundLimit, functionStyleValue,
|
||||
@"lineRoundLimit should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.lineRoundLimit = nil;
|
||||
XCTAssertTrue(rawLayer->getLineRoundLimit().isUndefined(),
|
||||
@@ -185,26 +197,49 @@
|
||||
@"line-blur should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.lineBlur;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineBlur = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineBlur = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
|
||||
@"Setting lineBlur to a constant value should update line-blur.");
|
||||
XCTAssertEqualObjects(layer.lineBlur, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineBlur, constantStyleValue,
|
||||
@"lineBlur should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineBlur = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineBlur = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
|
||||
@"Setting lineBlur to a function should update line-blur.");
|
||||
XCTAssertEqualObjects(layer.lineBlur, styleValue,
|
||||
@"lineBlur should round-trip functions.");
|
||||
@"Setting lineBlur to a camera function should update line-blur.");
|
||||
XCTAssertEqualObjects(layer.lineBlur, functionStyleValue,
|
||||
@"lineBlur should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.lineBlur = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
|
||||
@"Setting lineBlur to a source function should update line-blur.");
|
||||
XCTAssertEqualObjects(layer.lineBlur, functionStyleValue,
|
||||
@"lineBlur should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.lineBlur = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
|
||||
@"Setting lineBlur to a composite function should update line-blur.");
|
||||
XCTAssertEqualObjects(layer.lineBlur, functionStyleValue,
|
||||
@"lineBlur should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.lineBlur = nil;
|
||||
XCTAssertTrue(rawLayer->getLineBlur().isUndefined(),
|
||||
@@ -219,26 +254,49 @@
|
||||
@"line-color should be unset initially.");
|
||||
MGLStyleValue<MGLColor *> *defaultStyleValue = layer.lineColor;
|
||||
|
||||
MGLStyleValue<MGLColor *> *styleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.lineColor = styleValue;
|
||||
mbgl::style::PropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
MGLStyleValue<MGLColor *> *constantStyleValue = [MGLStyleValue<MGLColor *> valueWithRawValue:[MGLColor redColor]];
|
||||
layer.lineColor = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<mbgl::Color> propertyValue = { { 1, 0, 0, 1 } };
|
||||
XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
|
||||
@"Setting lineColor to a constant value should update line-color.");
|
||||
XCTAssertEqualObjects(layer.lineColor, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineColor, constantStyleValue,
|
||||
@"lineColor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<MGLColor *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineColor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::Color> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<MGLColor *> * functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineColor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = { {{18, { 1, 0, 0, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
|
||||
@"Setting lineColor to a function should update line-color.");
|
||||
XCTAssertEqualObjects(layer.lineColor, styleValue,
|
||||
@"lineColor should round-trip functions.");
|
||||
@"Setting lineColor to a camera function should update line-color.");
|
||||
XCTAssertEqualObjects(layer.lineColor, functionStyleValue,
|
||||
@"lineColor should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.lineColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
|
||||
@"Setting lineColor to a source function should update line-color.");
|
||||
XCTAssertEqualObjects(layer.lineColor, functionStyleValue,
|
||||
@"lineColor should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<MGLColor *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.lineColor = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> innerStops = { { {18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<mbgl::Color>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
|
||||
@"Setting lineColor to a composite function should update line-color.");
|
||||
XCTAssertEqualObjects(layer.lineColor, functionStyleValue,
|
||||
@"lineColor should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.lineColor = nil;
|
||||
XCTAssertTrue(rawLayer->getLineColor().isUndefined(),
|
||||
@@ -253,32 +311,38 @@
|
||||
@"line-dasharray should be unset initially.");
|
||||
MGLStyleValue<NSArray<NSNumber *> *> *defaultStyleValue = layer.lineDashPattern;
|
||||
|
||||
MGLStyleValue<NSArray<NSNumber *> *> *styleValue = [MGLStyleValue<NSArray<NSNumber *> *> valueWithRawValue:@[@1, @2]];
|
||||
layer.lineDashPattern = styleValue;
|
||||
MGLStyleValue<NSArray<NSNumber *> *> *constantStyleValue = [MGLStyleValue<NSArray<NSNumber *> *> valueWithRawValue:@[@1, @2]];
|
||||
layer.lineDashPattern = constantStyleValue;
|
||||
mbgl::style::PropertyValue<std::vector<float>> propertyValue = { {1, 2} };
|
||||
XCTAssertEqual(rawLayer->getLineDasharray(), propertyValue,
|
||||
@"Setting lineDashPattern to a constant value should update line-dasharray.");
|
||||
XCTAssertEqualObjects(layer.lineDashPattern, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineDashPattern, constantStyleValue,
|
||||
@"lineDashPattern should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSArray<NSNumber *> *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineDashPattern = styleValue;
|
||||
propertyValue = { mbgl::style::Function<std::vector<float>> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSArray<NSNumber *> *> * functionStyleValue = [MGLStyleValue<NSArray<NSNumber *> *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineDashPattern = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<std::vector<float>> intervalStops = { {{18, {1, 2}}} };
|
||||
propertyValue = mbgl::style::CameraFunction<std::vector<float>> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineDasharray(), propertyValue,
|
||||
@"Setting lineDashPattern to a function should update line-dasharray.");
|
||||
XCTAssertEqualObjects(layer.lineDashPattern, styleValue,
|
||||
@"lineDashPattern should round-trip functions.");
|
||||
@"Setting lineDashPattern to a camera function should update line-dasharray.");
|
||||
XCTAssertEqualObjects(layer.lineDashPattern, functionStyleValue,
|
||||
@"lineDashPattern should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.lineDashPattern = nil;
|
||||
XCTAssertTrue(rawLayer->getLineDasharray().isUndefined(),
|
||||
@"Unsetting lineDashPattern should return line-dasharray to the default value.");
|
||||
XCTAssertEqualObjects(layer.lineDashPattern, defaultStyleValue,
|
||||
@"lineDashPattern should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSArray<NSNumber *> *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineDashPattern = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSArray<NSNumber *> *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineDashPattern = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// line-gap-width
|
||||
@@ -287,26 +351,49 @@
|
||||
@"line-gap-width should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.lineGapWidth;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineGapWidth = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineGapWidth = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
|
||||
@"Setting lineGapWidth to a constant value should update line-gap-width.");
|
||||
XCTAssertEqualObjects(layer.lineGapWidth, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineGapWidth, constantStyleValue,
|
||||
@"lineGapWidth should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineGapWidth = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineGapWidth = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
|
||||
@"Setting lineGapWidth to a function should update line-gap-width.");
|
||||
XCTAssertEqualObjects(layer.lineGapWidth, styleValue,
|
||||
@"lineGapWidth should round-trip functions.");
|
||||
@"Setting lineGapWidth to a camera function should update line-gap-width.");
|
||||
XCTAssertEqualObjects(layer.lineGapWidth, functionStyleValue,
|
||||
@"lineGapWidth should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.lineGapWidth = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
|
||||
@"Setting lineGapWidth to a source function should update line-gap-width.");
|
||||
XCTAssertEqualObjects(layer.lineGapWidth, functionStyleValue,
|
||||
@"lineGapWidth should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.lineGapWidth = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
|
||||
@"Setting lineGapWidth to a composite function should update line-gap-width.");
|
||||
XCTAssertEqualObjects(layer.lineGapWidth, functionStyleValue,
|
||||
@"lineGapWidth should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.lineGapWidth = nil;
|
||||
XCTAssertTrue(rawLayer->getLineGapWidth().isUndefined(),
|
||||
@@ -321,26 +408,49 @@
|
||||
@"line-offset should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.lineOffset;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineOffset = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineOffset = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
|
||||
@"Setting lineOffset to a constant value should update line-offset.");
|
||||
XCTAssertEqualObjects(layer.lineOffset, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineOffset, constantStyleValue,
|
||||
@"lineOffset should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineOffset = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineOffset = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
|
||||
@"Setting lineOffset to a function should update line-offset.");
|
||||
XCTAssertEqualObjects(layer.lineOffset, styleValue,
|
||||
@"lineOffset should round-trip functions.");
|
||||
@"Setting lineOffset to a camera function should update line-offset.");
|
||||
XCTAssertEqualObjects(layer.lineOffset, functionStyleValue,
|
||||
@"lineOffset should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.lineOffset = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
|
||||
@"Setting lineOffset to a source function should update line-offset.");
|
||||
XCTAssertEqualObjects(layer.lineOffset, functionStyleValue,
|
||||
@"lineOffset should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.lineOffset = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
|
||||
@"Setting lineOffset to a composite function should update line-offset.");
|
||||
XCTAssertEqualObjects(layer.lineOffset, functionStyleValue,
|
||||
@"lineOffset should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.lineOffset = nil;
|
||||
XCTAssertTrue(rawLayer->getLineOffset().isUndefined(),
|
||||
@@ -355,26 +465,49 @@
|
||||
@"line-opacity should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.lineOpacity;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineOpacity = styleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineOpacity = constantStyleValue;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
|
||||
@"Setting lineOpacity to a constant value should update line-opacity.");
|
||||
XCTAssertEqualObjects(layer.lineOpacity, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineOpacity, constantStyleValue,
|
||||
@"lineOpacity should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineOpacity = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
|
||||
@"Setting lineOpacity to a function should update line-opacity.");
|
||||
XCTAssertEqualObjects(layer.lineOpacity, styleValue,
|
||||
@"lineOpacity should round-trip functions.");
|
||||
@"Setting lineOpacity to a camera function should update line-opacity.");
|
||||
XCTAssertEqualObjects(layer.lineOpacity, functionStyleValue,
|
||||
@"lineOpacity should round-trip camera functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.lineOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
|
||||
@"Setting lineOpacity to a source function should update line-opacity.");
|
||||
XCTAssertEqualObjects(layer.lineOpacity, functionStyleValue,
|
||||
@"lineOpacity should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.lineOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<float> innerStops = { { {18, 0xff}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<float>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
|
||||
@"Setting lineOpacity to a composite function should update line-opacity.");
|
||||
XCTAssertEqualObjects(layer.lineOpacity, functionStyleValue,
|
||||
@"lineOpacity should round-trip composite functions.");
|
||||
|
||||
|
||||
layer.lineOpacity = nil;
|
||||
XCTAssertTrue(rawLayer->getLineOpacity().isUndefined(),
|
||||
@@ -389,32 +522,38 @@
|
||||
@"line-pattern should be unset initially.");
|
||||
MGLStyleValue<NSString *> *defaultStyleValue = layer.linePattern;
|
||||
|
||||
MGLStyleValue<NSString *> *styleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Line Pattern"];
|
||||
layer.linePattern = styleValue;
|
||||
MGLStyleValue<NSString *> *constantStyleValue = [MGLStyleValue<NSString *> valueWithRawValue:@"Line Pattern"];
|
||||
layer.linePattern = constantStyleValue;
|
||||
mbgl::style::PropertyValue<std::string> propertyValue = { "Line Pattern" };
|
||||
XCTAssertEqual(rawLayer->getLinePattern(), propertyValue,
|
||||
@"Setting linePattern to a constant value should update line-pattern.");
|
||||
XCTAssertEqualObjects(layer.linePattern, styleValue,
|
||||
XCTAssertEqualObjects(layer.linePattern, constantStyleValue,
|
||||
@"linePattern should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSString *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.linePattern = styleValue;
|
||||
propertyValue = { mbgl::style::Function<std::string> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSString *> * functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.linePattern = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<std::string> intervalStops = { {{18, "Line Pattern"}} };
|
||||
propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLinePattern(), propertyValue,
|
||||
@"Setting linePattern to a function should update line-pattern.");
|
||||
XCTAssertEqualObjects(layer.linePattern, styleValue,
|
||||
@"linePattern should round-trip functions.");
|
||||
@"Setting linePattern to a camera function should update line-pattern.");
|
||||
XCTAssertEqualObjects(layer.linePattern, functionStyleValue,
|
||||
@"linePattern should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.linePattern = nil;
|
||||
XCTAssertTrue(rawLayer->getLinePattern().isUndefined(),
|
||||
@"Unsetting linePattern should return line-pattern to the default value.");
|
||||
XCTAssertEqualObjects(layer.linePattern, defaultStyleValue,
|
||||
@"linePattern should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.linePattern = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSString *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.linePattern = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// line-translate
|
||||
@@ -423,32 +562,32 @@
|
||||
@"line-translate should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.lineTranslation;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:
|
||||
#if TARGET_OS_IPHONE
|
||||
[NSValue valueWithCGVector:CGVectorMake(1, 1)]
|
||||
#else
|
||||
[NSValue valueWithMGLVector:CGVectorMake(1, -1)]
|
||||
#endif
|
||||
];
|
||||
layer.lineTranslation = styleValue;
|
||||
layer.lineTranslation = constantStyleValue;
|
||||
mbgl::style::PropertyValue<std::array<float, 2>> propertyValue = { { 1, 1 } };
|
||||
XCTAssertEqual(rawLayer->getLineTranslate(), propertyValue,
|
||||
@"Setting lineTranslation to a constant value should update line-translate.");
|
||||
XCTAssertEqualObjects(layer.lineTranslation, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineTranslation, constantStyleValue,
|
||||
@"lineTranslation should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineTranslation = styleValue;
|
||||
propertyValue = { mbgl::style::Function<std::array<float, 2>> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineTranslation = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = { {{18, { 1, 1 }}} };
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineTranslate(), propertyValue,
|
||||
@"Setting lineTranslation to a function should update line-translate.");
|
||||
XCTAssertEqualObjects(layer.lineTranslation, styleValue,
|
||||
@"lineTranslation should round-trip functions.");
|
||||
@"Setting lineTranslation to a camera function should update line-translate.");
|
||||
XCTAssertEqualObjects(layer.lineTranslation, functionStyleValue,
|
||||
@"lineTranslation should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.lineTranslation = nil;
|
||||
XCTAssertTrue(rawLayer->getLineTranslate().isUndefined(),
|
||||
@@ -463,32 +602,38 @@
|
||||
@"line-translate-anchor should be unset initially.");
|
||||
MGLStyleValue<NSValue *> *defaultStyleValue = layer.lineTranslationAnchor;
|
||||
|
||||
MGLStyleValue<NSValue *> *styleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLineTranslationAnchor:MGLLineTranslationAnchorViewport]];
|
||||
layer.lineTranslationAnchor = styleValue;
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLineTranslationAnchor:MGLLineTranslationAnchorViewport]];
|
||||
layer.lineTranslationAnchor = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType> propertyValue = { mbgl::style::TranslateAnchorType::Viewport };
|
||||
XCTAssertEqual(rawLayer->getLineTranslateAnchor(), propertyValue,
|
||||
@"Setting lineTranslationAnchor to a constant value should update line-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.lineTranslationAnchor, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineTranslationAnchor, constantStyleValue,
|
||||
@"lineTranslationAnchor should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSValue *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineTranslationAnchor = styleValue;
|
||||
propertyValue = { mbgl::style::Function<mbgl::style::TranslateAnchorType> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSValue *> * functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineTranslationAnchor = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = { {{18, mbgl::style::TranslateAnchorType::Viewport}} };
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineTranslateAnchor(), propertyValue,
|
||||
@"Setting lineTranslationAnchor to a function should update line-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.lineTranslationAnchor, styleValue,
|
||||
@"lineTranslationAnchor should round-trip functions.");
|
||||
@"Setting lineTranslationAnchor to a camera function should update line-translate-anchor.");
|
||||
XCTAssertEqualObjects(layer.lineTranslationAnchor, functionStyleValue,
|
||||
@"lineTranslationAnchor should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.lineTranslationAnchor = nil;
|
||||
XCTAssertTrue(rawLayer->getLineTranslateAnchor().isUndefined(),
|
||||
@"Unsetting lineTranslationAnchor should return line-translate-anchor to the default value.");
|
||||
XCTAssertEqualObjects(layer.lineTranslationAnchor, defaultStyleValue,
|
||||
@"lineTranslationAnchor should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineTranslationAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// line-width
|
||||
@@ -497,26 +642,26 @@
|
||||
@"line-width should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.lineWidth;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineWidth = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.lineWidth = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
|
||||
@"Setting lineWidth to a constant value should update line-width.");
|
||||
XCTAssertEqualObjects(layer.lineWidth, styleValue,
|
||||
XCTAssertEqualObjects(layer.lineWidth, constantStyleValue,
|
||||
@"lineWidth should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.lineWidth = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.lineWidth = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
|
||||
@"Setting lineWidth to a function should update line-width.");
|
||||
XCTAssertEqualObjects(layer.lineWidth, styleValue,
|
||||
@"lineWidth should round-trip functions.");
|
||||
@"Setting lineWidth to a camera function should update line-width.");
|
||||
XCTAssertEqualObjects(layer.lineWidth, functionStyleValue,
|
||||
@"lineWidth should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.lineWidth = nil;
|
||||
XCTAssertTrue(rawLayer->getLineWidth().isUndefined(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This file is generated.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
|
||||
#import "MGLStyleLayerTests.h"
|
||||
|
||||
@@ -31,26 +31,26 @@
|
||||
@"raster-brightness-max should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.maximumRasterBrightness;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.maximumRasterBrightness = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.maximumRasterBrightness = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getRasterBrightnessMax(), propertyValue,
|
||||
@"Setting maximumRasterBrightness to a constant value should update raster-brightness-max.");
|
||||
XCTAssertEqualObjects(layer.maximumRasterBrightness, styleValue,
|
||||
XCTAssertEqualObjects(layer.maximumRasterBrightness, constantStyleValue,
|
||||
@"maximumRasterBrightness should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.maximumRasterBrightness = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.maximumRasterBrightness = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterBrightnessMax(), propertyValue,
|
||||
@"Setting maximumRasterBrightness to a function should update raster-brightness-max.");
|
||||
XCTAssertEqualObjects(layer.maximumRasterBrightness, styleValue,
|
||||
@"maximumRasterBrightness should round-trip functions.");
|
||||
@"Setting maximumRasterBrightness to a camera function should update raster-brightness-max.");
|
||||
XCTAssertEqualObjects(layer.maximumRasterBrightness, functionStyleValue,
|
||||
@"maximumRasterBrightness should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.maximumRasterBrightness = nil;
|
||||
XCTAssertTrue(rawLayer->getRasterBrightnessMax().isUndefined(),
|
||||
@@ -65,26 +65,26 @@
|
||||
@"raster-brightness-min should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.minimumRasterBrightness;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.minimumRasterBrightness = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.minimumRasterBrightness = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getRasterBrightnessMin(), propertyValue,
|
||||
@"Setting minimumRasterBrightness to a constant value should update raster-brightness-min.");
|
||||
XCTAssertEqualObjects(layer.minimumRasterBrightness, styleValue,
|
||||
XCTAssertEqualObjects(layer.minimumRasterBrightness, constantStyleValue,
|
||||
@"minimumRasterBrightness should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.minimumRasterBrightness = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.minimumRasterBrightness = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterBrightnessMin(), propertyValue,
|
||||
@"Setting minimumRasterBrightness to a function should update raster-brightness-min.");
|
||||
XCTAssertEqualObjects(layer.minimumRasterBrightness, styleValue,
|
||||
@"minimumRasterBrightness should round-trip functions.");
|
||||
@"Setting minimumRasterBrightness to a camera function should update raster-brightness-min.");
|
||||
XCTAssertEqualObjects(layer.minimumRasterBrightness, functionStyleValue,
|
||||
@"minimumRasterBrightness should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.minimumRasterBrightness = nil;
|
||||
XCTAssertTrue(rawLayer->getRasterBrightnessMin().isUndefined(),
|
||||
@@ -99,26 +99,26 @@
|
||||
@"raster-contrast should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.rasterContrast;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterContrast = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterContrast = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getRasterContrast(), propertyValue,
|
||||
@"Setting rasterContrast to a constant value should update raster-contrast.");
|
||||
XCTAssertEqualObjects(layer.rasterContrast, styleValue,
|
||||
XCTAssertEqualObjects(layer.rasterContrast, constantStyleValue,
|
||||
@"rasterContrast should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.rasterContrast = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.rasterContrast = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterContrast(), propertyValue,
|
||||
@"Setting rasterContrast to a function should update raster-contrast.");
|
||||
XCTAssertEqualObjects(layer.rasterContrast, styleValue,
|
||||
@"rasterContrast should round-trip functions.");
|
||||
@"Setting rasterContrast to a camera function should update raster-contrast.");
|
||||
XCTAssertEqualObjects(layer.rasterContrast, functionStyleValue,
|
||||
@"rasterContrast should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.rasterContrast = nil;
|
||||
XCTAssertTrue(rawLayer->getRasterContrast().isUndefined(),
|
||||
@@ -133,26 +133,26 @@
|
||||
@"raster-fade-duration should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.rasterFadeDuration;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterFadeDuration = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterFadeDuration = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getRasterFadeDuration(), propertyValue,
|
||||
@"Setting rasterFadeDuration to a constant value should update raster-fade-duration.");
|
||||
XCTAssertEqualObjects(layer.rasterFadeDuration, styleValue,
|
||||
XCTAssertEqualObjects(layer.rasterFadeDuration, constantStyleValue,
|
||||
@"rasterFadeDuration should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.rasterFadeDuration = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.rasterFadeDuration = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterFadeDuration(), propertyValue,
|
||||
@"Setting rasterFadeDuration to a function should update raster-fade-duration.");
|
||||
XCTAssertEqualObjects(layer.rasterFadeDuration, styleValue,
|
||||
@"rasterFadeDuration should round-trip functions.");
|
||||
@"Setting rasterFadeDuration to a camera function should update raster-fade-duration.");
|
||||
XCTAssertEqualObjects(layer.rasterFadeDuration, functionStyleValue,
|
||||
@"rasterFadeDuration should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.rasterFadeDuration = nil;
|
||||
XCTAssertTrue(rawLayer->getRasterFadeDuration().isUndefined(),
|
||||
@@ -167,26 +167,26 @@
|
||||
@"raster-hue-rotate should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.rasterHueRotation;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterHueRotation = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterHueRotation = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getRasterHueRotate(), propertyValue,
|
||||
@"Setting rasterHueRotation to a constant value should update raster-hue-rotate.");
|
||||
XCTAssertEqualObjects(layer.rasterHueRotation, styleValue,
|
||||
XCTAssertEqualObjects(layer.rasterHueRotation, constantStyleValue,
|
||||
@"rasterHueRotation should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.rasterHueRotation = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.rasterHueRotation = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterHueRotate(), propertyValue,
|
||||
@"Setting rasterHueRotation to a function should update raster-hue-rotate.");
|
||||
XCTAssertEqualObjects(layer.rasterHueRotation, styleValue,
|
||||
@"rasterHueRotation should round-trip functions.");
|
||||
@"Setting rasterHueRotation to a camera function should update raster-hue-rotate.");
|
||||
XCTAssertEqualObjects(layer.rasterHueRotation, functionStyleValue,
|
||||
@"rasterHueRotation should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.rasterHueRotation = nil;
|
||||
XCTAssertTrue(rawLayer->getRasterHueRotate().isUndefined(),
|
||||
@@ -201,26 +201,26 @@
|
||||
@"raster-opacity should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.rasterOpacity;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterOpacity = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterOpacity = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getRasterOpacity(), propertyValue,
|
||||
@"Setting rasterOpacity to a constant value should update raster-opacity.");
|
||||
XCTAssertEqualObjects(layer.rasterOpacity, styleValue,
|
||||
XCTAssertEqualObjects(layer.rasterOpacity, constantStyleValue,
|
||||
@"rasterOpacity should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.rasterOpacity = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.rasterOpacity = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterOpacity(), propertyValue,
|
||||
@"Setting rasterOpacity to a function should update raster-opacity.");
|
||||
XCTAssertEqualObjects(layer.rasterOpacity, styleValue,
|
||||
@"rasterOpacity should round-trip functions.");
|
||||
@"Setting rasterOpacity to a camera function should update raster-opacity.");
|
||||
XCTAssertEqualObjects(layer.rasterOpacity, functionStyleValue,
|
||||
@"rasterOpacity should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.rasterOpacity = nil;
|
||||
XCTAssertTrue(rawLayer->getRasterOpacity().isUndefined(),
|
||||
@@ -235,26 +235,26 @@
|
||||
@"raster-saturation should be unset initially.");
|
||||
MGLStyleValue<NSNumber *> *defaultStyleValue = layer.rasterSaturation;
|
||||
|
||||
MGLStyleValue<NSNumber *> *styleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterSaturation = styleValue;
|
||||
MGLStyleValue<NSNumber *> *constantStyleValue = [MGLStyleValue<NSNumber *> valueWithRawValue:@0xff];
|
||||
layer.rasterSaturation = constantStyleValue;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
XCTAssertEqual(rawLayer->getRasterSaturation(), propertyValue,
|
||||
@"Setting rasterSaturation to a constant value should update raster-saturation.");
|
||||
XCTAssertEqualObjects(layer.rasterSaturation, styleValue,
|
||||
XCTAssertEqualObjects(layer.rasterSaturation, constantStyleValue,
|
||||
@"rasterSaturation should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.rasterSaturation = styleValue;
|
||||
propertyValue = { mbgl::style::Function<float> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<NSNumber *> * functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.rasterSaturation = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = { {{18, 0xff}} };
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterSaturation(), propertyValue,
|
||||
@"Setting rasterSaturation to a function should update raster-saturation.");
|
||||
XCTAssertEqualObjects(layer.rasterSaturation, styleValue,
|
||||
@"rasterSaturation should round-trip functions.");
|
||||
@"Setting rasterSaturation to a camera function should update raster-saturation.");
|
||||
XCTAssertEqualObjects(layer.rasterSaturation, functionStyleValue,
|
||||
@"rasterSaturation should round-trip camera functions.");
|
||||
|
||||
|
||||
|
||||
layer.rasterSaturation = nil;
|
||||
XCTAssertTrue(rawLayer->getRasterSaturation().isUndefined(),
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
const enumProperties = locals.enumProperties;
|
||||
-%>
|
||||
// This file is generated.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`.
|
||||
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
||||
|
||||
#import "MGLStyleLayerTests.h"
|
||||
|
||||
@@ -61,26 +61,54 @@
|
||||
@"<%- originalPropertyName(property) %> should be unset initially.");
|
||||
MGLStyleValue<<%- propertyType(property) %>> *defaultStyleValue = layer.<%- objCName(property) %>;
|
||||
|
||||
MGLStyleValue<<%- propertyType(property) %>> *styleValue = [MGLStyleValue<<%- propertyType(property) %>> valueWithRawValue:<%- objCTestValue(property, type, 3) %>];
|
||||
layer.<%- objCName(property) %> = styleValue;
|
||||
MGLStyleValue<<%- propertyType(property) %>> *constantStyleValue = [MGLStyleValue<<%- propertyType(property) %>> valueWithRawValue:<%- objCTestValue(property, type, 3) %>];
|
||||
layer.<%- objCName(property) %> = constantStyleValue;
|
||||
<% if (property["property-function"]) { -%>
|
||||
mbgl::style::DataDrivenPropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> };
|
||||
<% } else { -%>
|
||||
mbgl::style::PropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> };
|
||||
<% } -%>
|
||||
XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
|
||||
@"Setting <%- objCName(property) %> to a constant value should update <%- originalPropertyName(property) %>.");
|
||||
XCTAssertEqualObjects(layer.<%- objCName(property) %>, styleValue,
|
||||
XCTAssertEqualObjects(layer.<%- objCName(property) %>, constantStyleValue,
|
||||
@"<%- objCName(property) %> should round-trip constant values.");
|
||||
|
||||
styleValue = [MGLStyleValue<<%- propertyType(property) %>> valueWithStops:@{
|
||||
@18: styleValue,
|
||||
}];
|
||||
layer.<%- objCName(property) %> = styleValue;
|
||||
propertyValue = { mbgl::style::Function<<%- mbglType(property) %>> {
|
||||
{{ 18, propertyValue.asConstant() }},
|
||||
1,
|
||||
}};
|
||||
MGLStyleValue<<%- propertyType(property) %>> * functionStyleValue = [MGLStyleValue<<%- propertyType(property) %>> valueWithInterpolationMode:MGLInterpolationModeInterval cameraStops:@{@18: constantStyleValue} options:nil];
|
||||
layer.<%- objCName(property) %> = functionStyleValue;
|
||||
|
||||
mbgl::style::IntervalStops<<%- mbglType(property) %>> intervalStops = { {{18, <%- mbglTestValue(property, type) %>}} };
|
||||
propertyValue = mbgl::style::CameraFunction<<%- mbglType(property) %>> { intervalStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
|
||||
@"Setting <%- objCName(property) %> to a function should update <%- originalPropertyName(property) %>.");
|
||||
XCTAssertEqualObjects(layer.<%- objCName(property) %>, styleValue,
|
||||
@"<%- objCName(property) %> should round-trip functions.");
|
||||
@"Setting <%- objCName(property) %> to a camera function should update <%- originalPropertyName(property) %>.");
|
||||
XCTAssertEqualObjects(layer.<%- objCName(property) %>, functionStyleValue,
|
||||
@"<%- objCName(property) %> should round-trip camera functions.");
|
||||
|
||||
<% if (property["property-function"]) { -%>
|
||||
functionStyleValue = [MGLStyleValue<<%- propertyType(property) %>> valueWithInterpolationMode:MGLInterpolationModeExponential sourceStops:@{@18: constantStyleValue} attributeName:@"keyName" options:nil];
|
||||
layer.<%- objCName(property) %> = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<<%- mbglType(property) %>> exponentialStops = { {{18, <%- mbglTestValue(property, type) %>}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<<%- mbglType(property) %>> { "keyName", exponentialStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
|
||||
@"Setting <%- objCName(property) %> to a source function should update <%- originalPropertyName(property) %>.");
|
||||
XCTAssertEqualObjects(layer.<%- objCName(property) %>, functionStyleValue,
|
||||
@"<%- objCName(property) %> should round-trip source functions.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<<%- propertyType(property) %>> valueWithInterpolationMode:MGLInterpolationModeExponential compositeStops:@{@10: @{@18: constantStyleValue}} attributeName:@"keyName" options:nil];
|
||||
layer.<%- objCName(property) %> = functionStyleValue;
|
||||
|
||||
mbgl::style::ExponentialStops<<%- mbglType(property) %>> innerStops = { { {18, <%- mbglTestValue(property, type) %>}}, 1.0 };
|
||||
std::map<float, mbgl::style::ExponentialStops<<%- mbglType(property) %>>> compositeStops = { {10.0, innerStops} };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<<%- mbglType(property) %>> { "keyName", compositeStops };
|
||||
|
||||
XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
|
||||
@"Setting <%- objCName(property) %> to a composite function should update <%- originalPropertyName(property) %>.");
|
||||
XCTAssertEqualObjects(layer.<%- objCName(property) %>, functionStyleValue,
|
||||
@"<%- objCName(property) %> should round-trip composite functions.");
|
||||
<% } -%>
|
||||
<% if (!property.required) { -%>
|
||||
|
||||
layer.<%- objCName(property) %> = nil;
|
||||
@@ -88,6 +116,14 @@
|
||||
@"Unsetting <%- objCName(property) %> should return <%- originalPropertyName(property) %> to the default value.");
|
||||
XCTAssertEqualObjects(layer.<%- objCName(property) %>, defaultStyleValue,
|
||||
@"<%- objCName(property) %> should return the default value after being unset.");
|
||||
<% } -%>
|
||||
<% if (property["function"] == "piecewise-constant") { -%>
|
||||
|
||||
functionStyleValue = [MGLStyleValue<<%- propertyType(property) %>> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.<%- objCName(property) %> = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<<%- propertyType(property) %>> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.<%- objCName(property) %> = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
<% } -%>
|
||||
}
|
||||
<% } -%>
|
||||
|
||||
@@ -5,8 +5,9 @@ import Mapbox
|
||||
extension MGLStyleValueTests {
|
||||
|
||||
func testConstantValues() {
|
||||
let shapeSource = MGLShapeSource(identifier: "test", shape: nil, options: nil)
|
||||
let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "test", source: shapeSource)
|
||||
let shapeSource = MGLShapeSource(identifier: "source", shape: nil, options: nil)
|
||||
let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "symbolLayer", source: shapeSource)
|
||||
let circleStyleLayer = MGLCircleStyleLayer(identifier: "circleLayer", source: shapeSource)
|
||||
|
||||
// Boolean
|
||||
symbolStyleLayer.iconAllowsOverlap = MGLStyleConstantValue(rawValue: true)
|
||||
@@ -19,20 +20,287 @@ extension MGLStyleValueTests {
|
||||
// String
|
||||
symbolStyleLayer.text = MGLStyleConstantValue(rawValue: "{name}")
|
||||
XCTAssertEqual((symbolStyleLayer.text as! MGLStyleConstantValue<NSString>).rawValue, "{name}")
|
||||
|
||||
var circleTranslationOne = CGVector(dx: 100, dy: 0)
|
||||
let circleTranslationValueOne = NSValue(bytes: &circleTranslationOne, objCType: "{CGVector=dd}")
|
||||
|
||||
// non-data-driven (interpolatable property value), set to constant style value
|
||||
let expectedCircleTranslationValue = MGLStyleValue<NSValue>(rawValue: circleTranslationValueOne)
|
||||
circleStyleLayer.circleTranslation = expectedCircleTranslationValue
|
||||
XCTAssertEqual(circleStyleLayer.circleTranslation, expectedCircleTranslationValue)
|
||||
|
||||
// non-data-driven (enumeration property value), set to constant style value
|
||||
let expectedCircleScaleAlignmentValue = MGLStyleValue<NSValue>(rawValue: NSValue(mglCircleScaleAlignment: .map))
|
||||
circleStyleLayer.circleScaleAlignment = expectedCircleScaleAlignmentValue
|
||||
XCTAssertEqual(circleStyleLayer.circleScaleAlignment, expectedCircleScaleAlignmentValue)
|
||||
}
|
||||
|
||||
func testFunctions() {
|
||||
|
||||
func testDeprecatedFunctions() {
|
||||
let shapeSource = MGLShapeSource(identifier: "test", shape: nil, options: nil)
|
||||
let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "test", source: shapeSource)
|
||||
|
||||
// Boolean
|
||||
let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "symbolLayer", source: shapeSource)
|
||||
|
||||
// deprecated function, stops with float values
|
||||
let iconHaloBlurStyleValue = MGLStyleValue<NSNumber>(interpolationBase: 1.0, stops: [1: MGLStyleValue(rawValue: 0),
|
||||
2: MGLStyleValue(rawValue: 1),
|
||||
3: MGLStyleValue(rawValue: 2),
|
||||
4: MGLStyleValue(rawValue: 3)])
|
||||
symbolStyleLayer.iconHaloBlur = iconHaloBlurStyleValue
|
||||
XCTAssertEqual(symbolStyleLayer.iconHaloBlur!, iconHaloBlurStyleValue)
|
||||
|
||||
// deprecated function, stops with boolean values
|
||||
let stops: [NSNumber: MGLStyleValue<NSNumber>] = [
|
||||
1: MGLStyleValue(rawValue: true),
|
||||
2: MGLStyleValue(rawValue: false),
|
||||
3: MGLStyleValue(rawValue: true),
|
||||
4: MGLStyleValue(rawValue: false),
|
||||
]
|
||||
let iconAllowsOverlapStyleValue = MGLStyleValue<NSNumber>(interpolationBase: 1, stops: stops)
|
||||
symbolStyleLayer.iconAllowsOverlap = iconAllowsOverlapStyleValue
|
||||
// iconAllowsOverlap is boolean so mgl and mbgl conversions will coerce the developers stops into interval stops
|
||||
let expectedIconAllowsOverlapStyleValue = MGLStyleValue<NSNumber>(
|
||||
interpolationMode: .interval,
|
||||
cameraStops: stops,
|
||||
options: nil
|
||||
)
|
||||
XCTAssertEqual(symbolStyleLayer.iconAllowsOverlap, expectedIconAllowsOverlapStyleValue)
|
||||
}
|
||||
|
||||
func testFunctionsWithNonDataDrivenProperties() {
|
||||
let shapeSource = MGLShapeSource(identifier: "test", shape: nil, options: nil)
|
||||
let circleStyleLayer = MGLCircleStyleLayer(identifier: "circleLayer", source: shapeSource)
|
||||
|
||||
var circleTranslationOne = CGVector(dx: 100, dy: 0)
|
||||
let circleTranslationValueOne = NSValue(bytes: &circleTranslationOne, objCType: "{CGVector=dd}")
|
||||
var circleTranslationTwo = CGVector(dx: 0, dy: 0)
|
||||
let circleTranslationValueTwo = NSValue(bytes: &circleTranslationTwo, objCType: "{CGVector=dd}")
|
||||
|
||||
let circleTranslationStops = [
|
||||
0: MGLStyleValue<NSValue>(rawValue: circleTranslationValueOne),
|
||||
10: MGLStyleValue<NSValue>(rawValue: circleTranslationValueTwo)
|
||||
]
|
||||
|
||||
// non-data-driven (interpolatable property value), camera function with CGVector (NSValue) stop values
|
||||
let expectedCircleTranslationValue = MGLStyleValue<NSValue>(
|
||||
interpolationMode: .interval,
|
||||
cameraStops: circleTranslationStops,
|
||||
options: nil
|
||||
)
|
||||
circleStyleLayer.circleTranslation = expectedCircleTranslationValue
|
||||
XCTAssertEqual(circleStyleLayer.circleTranslation, expectedCircleTranslationValue)
|
||||
|
||||
// non-data-driven (enumeration property value), camera function with MGLCircleScaleAlignment enum (NSValue) stop values
|
||||
let scaleAlignmentStops = [
|
||||
0: MGLStyleValue(rawValue: NSValue(mglCircleScaleAlignment: .map)),
|
||||
10: MGLStyleValue(rawValue: NSValue(mglCircleScaleAlignment: .viewport))
|
||||
]
|
||||
let expectedCircleScaleAlignmentValue = MGLStyleValue<NSValue>(
|
||||
interpolationMode: .interval,
|
||||
cameraStops: scaleAlignmentStops,
|
||||
options: nil
|
||||
)
|
||||
circleStyleLayer.circleScaleAlignment = expectedCircleScaleAlignmentValue
|
||||
XCTAssertEqual(circleStyleLayer.circleScaleAlignment, expectedCircleScaleAlignmentValue)
|
||||
}
|
||||
|
||||
func testFunctionsWithDataDrivenProperties() {
|
||||
let shapeSource = MGLShapeSource(identifier: "test", shape: nil, options: nil)
|
||||
let circleStyleLayer = MGLCircleStyleLayer(identifier: "circleLayer", source: shapeSource)
|
||||
|
||||
#if os(iOS) || os(watchOS) || os(tvOS)
|
||||
|
||||
// data-driven, camera function with exponential color stop values
|
||||
let redGreenStops = [
|
||||
0: MGLStyleValue<UIColor>(rawValue: .red),
|
||||
10: MGLStyleValue<UIColor>(rawValue: .red),
|
||||
15: MGLStyleValue<UIColor>(rawValue: .green)
|
||||
]
|
||||
symbolStyleLayer.iconAllowsOverlap = MGLStyleFunction<NSNumber>(interpolationBase: 1, stops: stops)
|
||||
XCTAssertEqual((symbolStyleLayer.iconAllowsOverlap as! MGLStyleFunction<NSNumber>), MGLStyleFunction(interpolationBase: 1, stops: stops))
|
||||
let expectedCircleColorValue = MGLStyleValue<UIColor>(
|
||||
interpolationMode: .exponential,
|
||||
cameraStops: redGreenStops,
|
||||
options: [.interpolationBase: 10.0]
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedCircleColorValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedCircleColorValue)
|
||||
|
||||
// data-driven, source function with categorical color stop values with string attribute keys
|
||||
let redOnlyStops = [
|
||||
"red": MGLStyleValue<UIColor>(rawValue: .red)
|
||||
]
|
||||
let expectedRedCategoricalValue = MGLStyleValue<UIColor>(
|
||||
interpolationMode: .categorical,
|
||||
sourceStops: redOnlyStops,
|
||||
attributeName: "red",
|
||||
options: [.defaultValue: MGLStyleValue<UIColor>(rawValue: .cyan)]
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedRedCategoricalValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedRedCategoricalValue)
|
||||
|
||||
// data-driven, source function with categorical color stop values with integer attribute keys
|
||||
let greenOrangeStops = [
|
||||
0: MGLStyleValue<UIColor>(rawValue: .green),
|
||||
100: MGLStyleValue<UIColor>(rawValue: .orange)
|
||||
]
|
||||
let expectedGreenOrangeCategoricalValue = MGLStyleValue<UIColor>(
|
||||
interpolationMode: .categorical,
|
||||
sourceStops: greenOrangeStops,
|
||||
attributeName: "temp",
|
||||
options: [.defaultValue: MGLStyleValue<UIColor>(rawValue: .red)]
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedGreenOrangeCategoricalValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedGreenOrangeCategoricalValue)
|
||||
|
||||
// data-driven, source function with exponential color stop values
|
||||
let expectedRedGreenSourceExponentialValue = MGLStyleValue<UIColor>(
|
||||
interpolationMode: .exponential,
|
||||
sourceStops: redGreenStops,
|
||||
attributeName: "temp",
|
||||
options: nil
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedRedGreenSourceExponentialValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedRedGreenSourceExponentialValue)
|
||||
|
||||
// data-driven, identity source function
|
||||
let expectedSourceIdentityValue = MGLStyleValue<UIColor>(
|
||||
interpolationMode: .identity,
|
||||
sourceStops: nil,
|
||||
attributeName: "size",
|
||||
options: nil
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedSourceIdentityValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedSourceIdentityValue)
|
||||
|
||||
#elseif os(macOS)
|
||||
|
||||
// data-driven, camera function with exponential color stop values
|
||||
let redGreenStops = [
|
||||
0: MGLStyleValue<NSColor>(rawValue: .red),
|
||||
10: MGLStyleValue<NSColor>(rawValue: .red),
|
||||
15: MGLStyleValue<NSColor>(rawValue: .green)
|
||||
]
|
||||
let expectedCircleColorValue = MGLStyleValue<NSColor>(
|
||||
interpolationMode: .exponential,
|
||||
cameraStops: redGreenStops,
|
||||
options: [.interpolationBase: 10.0]
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedCircleColorValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedCircleColorValue)
|
||||
|
||||
// data-driven, source function with categorical color stop values with string typed keys
|
||||
let redOnlyStops = [
|
||||
"red": MGLStyleValue<NSColor>(rawValue: .red)
|
||||
]
|
||||
let expectedRedCategoricalValue = MGLStyleValue<NSColor>(
|
||||
interpolationMode: .categorical,
|
||||
|
||||
sourceStops: redOnlyStops,
|
||||
attributeName: "red",
|
||||
options: [.defaultValue: MGLStyleValue<NSColor>(rawValue: .cyan)]
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedRedCategoricalValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedRedCategoricalValue)
|
||||
|
||||
// data-driven, source function with categorical color stop values with integer attribute keys
|
||||
let greenOrangeStops = [
|
||||
0: MGLStyleValue<NSColor>(rawValue: .green),
|
||||
100: MGLStyleValue<NSColor>(rawValue: .orange)
|
||||
]
|
||||
let expectedGreenOrangeCategoricalValue = MGLStyleValue<NSColor>(
|
||||
interpolationMode: .categorical,
|
||||
sourceStops: greenOrangeStops,
|
||||
attributeName: "temp",
|
||||
options: [.defaultValue: MGLStyleValue<NSColor>(rawValue: .red)]
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedGreenOrangeCategoricalValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedGreenOrangeCategoricalValue)
|
||||
|
||||
// data-driven, source function with exponential color stop values
|
||||
let expectedRedGreenSourceExponentialValue = MGLStyleValue<NSColor>(
|
||||
interpolationMode: .exponential,
|
||||
sourceStops: redGreenStops,
|
||||
attributeName: "temp",
|
||||
options: nil
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedRedGreenSourceExponentialValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedRedGreenSourceExponentialValue)
|
||||
|
||||
// data-driven, identity source function
|
||||
let expectedSourceIdentityValue = MGLStyleValue<NSColor>(
|
||||
interpolationMode: .identity,
|
||||
sourceStops: nil,
|
||||
attributeName: "size",
|
||||
options: nil
|
||||
)
|
||||
circleStyleLayer.circleColor = expectedSourceIdentityValue
|
||||
XCTAssertEqual(circleStyleLayer.circleColor, expectedSourceIdentityValue)
|
||||
|
||||
#endif
|
||||
|
||||
// data-driven, source function with categorical color stop values with boolean attribute keys
|
||||
let booleanCategoricalStops = [
|
||||
false: MGLStyleValue<NSNumber>(rawValue: 0),
|
||||
true: MGLStyleValue<NSNumber>(rawValue: 2)
|
||||
]
|
||||
let expectedCircleBlurCategoricalValue = MGLStyleValue<NSNumber>(
|
||||
interpolationMode: .categorical,
|
||||
sourceStops: booleanCategoricalStops,
|
||||
attributeName: "fuzzy",
|
||||
options: [.defaultValue: MGLStyleValue<NSNumber>(rawValue: 42)]
|
||||
)
|
||||
circleStyleLayer.circleBlur = expectedCircleBlurCategoricalValue
|
||||
XCTAssertEqual(circleStyleLayer.circleBlur, expectedCircleBlurCategoricalValue)
|
||||
|
||||
// data-driven, composite function with inner categorical color stop values with string attribute keys nested in outer camera stops
|
||||
let smallRadius = MGLStyleValue<NSNumber>(rawValue: 5)
|
||||
let mediumRadius = MGLStyleValue<NSNumber>(rawValue: 10)
|
||||
let largeRadius = MGLStyleValue<NSNumber>(rawValue: 20)
|
||||
let radiusCompositeCategoricalStops: [NSNumber: [String: MGLStyleValue<NSNumber>]] = [
|
||||
0: ["green": smallRadius],
|
||||
10: ["green": smallRadius],
|
||||
15: ["green": largeRadius],
|
||||
20: ["green": largeRadius]
|
||||
]
|
||||
let defaultRadius = MGLStyleValue<NSNumber>(rawValue: 2)
|
||||
let expectedCompositeCategoricalValue = MGLStyleValue<NSNumber>(
|
||||
interpolationMode: .categorical,
|
||||
compositeStops: radiusCompositeCategoricalStops,
|
||||
attributeName: "color",
|
||||
options: [.defaultValue: defaultRadius]
|
||||
)
|
||||
circleStyleLayer.circleRadius = expectedCompositeCategoricalValue
|
||||
XCTAssertEqual(circleStyleLayer.circleRadius, expectedCompositeCategoricalValue)
|
||||
|
||||
// data-driven, composite function with inner exponential color stop values nested in outer camera stops
|
||||
let radiusCompositeExponentialOrIntervalStops: [NSNumber: [NSNumber: MGLStyleValue<NSNumber>]] = [
|
||||
0: [0: smallRadius],
|
||||
10: [200: smallRadius],
|
||||
20: [200: largeRadius]
|
||||
]
|
||||
let expectedCompositeExponentialValue = MGLStyleValue<NSNumber>(
|
||||
interpolationMode: .exponential,
|
||||
compositeStops: radiusCompositeExponentialOrIntervalStops,
|
||||
attributeName: "temp",
|
||||
options: [.defaultValue: mediumRadius]
|
||||
)
|
||||
circleStyleLayer.circleRadius = expectedCompositeExponentialValue
|
||||
XCTAssertEqual(circleStyleLayer.circleRadius, expectedCompositeExponentialValue)
|
||||
|
||||
// get a value back
|
||||
if let returnedCircleRadius = circleStyleLayer.circleRadius as? MGLCompositeStyleFunction<NSNumber> {
|
||||
if let returnedStops = returnedCircleRadius.stops as NSDictionary? as? [NSNumber: [NSNumber: MGLStyleValue<NSNumber>]] {
|
||||
let lhs: MGLStyleValue<NSNumber> = returnedStops[0]!.values.first!
|
||||
let rhs: MGLStyleValue<NSNumber> = radiusCompositeExponentialOrIntervalStops[0]!.values.first!
|
||||
XCTAssertEqual(lhs, rhs)
|
||||
}
|
||||
}
|
||||
|
||||
// data-driven, composite function with inner interval color stop values nested in outer camera stops
|
||||
let expectedCompositeIntervalValue = MGLStyleValue<NSNumber>(
|
||||
interpolationMode: .interval,
|
||||
compositeStops: radiusCompositeExponentialOrIntervalStops,
|
||||
attributeName: "temp",
|
||||
options: nil
|
||||
)
|
||||
circleStyleLayer.circleRadius = expectedCompositeIntervalValue
|
||||
XCTAssertEqual(circleStyleLayer.circleRadius, expectedCompositeIntervalValue)
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,8 +6,6 @@
|
||||
#import "MBXAnnotationView.h"
|
||||
#import "MBXUserLocationAnnotationView.h"
|
||||
|
||||
#import "MGLFillStyleLayer.h"
|
||||
|
||||
#import <Mapbox/Mapbox.h>
|
||||
|
||||
#import <objc/runtime.h>
|
||||
@@ -72,6 +70,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsRuntimeStylingRows) {
|
||||
MBXSettingsRuntimeStylingRasterSource,
|
||||
MBXSettingsRuntimeStylingCountryLabels,
|
||||
MBXSettingsRuntimeStylingRouteLine,
|
||||
MBXSettingsRuntimeStylingDDSPolygon,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
@@ -336,6 +335,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
@"Style Raster Source",
|
||||
[NSString stringWithFormat:@"Label Countries in %@", (_usingLocaleBasedCountryLabels ? @"Local Language" : [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:[self bestLanguageForUser]])],
|
||||
@"Add Route Line",
|
||||
@"Dynamically Style Polygon",
|
||||
]];
|
||||
break;
|
||||
case MBXSettingsMiscellaneous:
|
||||
@@ -497,6 +497,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
case MBXSettingsRuntimeStylingRouteLine:
|
||||
[self styleRouteLine];
|
||||
break;
|
||||
case MBXSettingsRuntimeStylingDDSPolygon:
|
||||
[self stylePolygonWithDDS];
|
||||
break;
|
||||
default:
|
||||
NSAssert(NO, @"All runtime styling setting rows should be implemented");
|
||||
break;
|
||||
@@ -739,22 +742,24 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
- (void)styleWaterLayer
|
||||
{
|
||||
MGLFillStyleLayer *waterLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"water"];
|
||||
MGLStyleValue *waterColorFunction = [MGLStyleValue<UIColor *> valueWithStops:@{
|
||||
@6.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor yellowColor]],
|
||||
@8.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor blueColor]],
|
||||
@10.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor redColor]],
|
||||
@12.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor greenColor]],
|
||||
@14.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor blueColor]],
|
||||
}];
|
||||
NSDictionary *waterColorStops = @{@6.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor yellowColor]],
|
||||
@8.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor blueColor]],
|
||||
@10.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor redColor]],
|
||||
@12.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor greenColor]],
|
||||
@14.0f: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor blueColor]]};
|
||||
MGLStyleValue *waterColorFunction = [MGLStyleValue<UIColor *> valueWithInterpolationMode:MGLInterpolationModeExponential
|
||||
cameraStops:waterColorStops
|
||||
options: nil];
|
||||
waterLayer.fillColor = waterColorFunction;
|
||||
|
||||
MGLStyleValue *fillAntialiasedFunction = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@11: [MGLStyleValue<NSNumber *> valueWithRawValue:@YES],
|
||||
@12: [MGLStyleValue<NSNumber *> valueWithRawValue:@NO],
|
||||
@13: [MGLStyleValue<NSNumber *> valueWithRawValue:@YES],
|
||||
@14: [MGLStyleValue<NSNumber *> valueWithRawValue:@NO],
|
||||
@15: [MGLStyleValue<NSNumber *> valueWithRawValue:@YES],
|
||||
}];
|
||||
NSDictionary *fillAntialiasedStops = @{@11: [MGLStyleValue<NSNumber *> valueWithRawValue:@YES],
|
||||
@12: [MGLStyleValue<NSNumber *> valueWithRawValue:@NO],
|
||||
@13: [MGLStyleValue<NSNumber *> valueWithRawValue:@YES],
|
||||
@14: [MGLStyleValue<NSNumber *> valueWithRawValue:@NO],
|
||||
@15: [MGLStyleValue<NSNumber *> valueWithRawValue:@YES]};
|
||||
MGLStyleValue *fillAntialiasedFunction = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval
|
||||
cameraStops:fillAntialiasedStops
|
||||
options:nil];
|
||||
waterLayer.fillAntialiased = fillAntialiasedFunction;
|
||||
}
|
||||
|
||||
@@ -763,21 +768,23 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
MGLLineStyleLayer *roadLayer = (MGLLineStyleLayer *)[self.mapView.style layerWithIdentifier:@"road-primary"];
|
||||
roadLayer.lineColor = [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor blackColor]];
|
||||
|
||||
MGLStyleValue *lineWidthFunction = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@5: [MGLStyleValue<NSNumber *> valueWithRawValue:@5],
|
||||
@10: [MGLStyleValue<NSNumber *> valueWithRawValue:@15],
|
||||
@15: [MGLStyleValue<NSNumber *> valueWithRawValue:@30],
|
||||
}];
|
||||
|
||||
MGLStyleValue *roadLineColor = [MGLStyleValue<UIColor *> valueWithStops:@{
|
||||
@10: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor purpleColor]],
|
||||
@13: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor yellowColor]],
|
||||
@16: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor cyanColor]],
|
||||
}];
|
||||
roadLayer.lineColor = roadLineColor;
|
||||
NSDictionary *lineWidthStops = @{@5: [MGLStyleValue<NSNumber *> valueWithRawValue:@5],
|
||||
@10: [MGLStyleValue<NSNumber *> valueWithRawValue:@15],
|
||||
@15: [MGLStyleValue<NSNumber *> valueWithRawValue:@30]};
|
||||
MGLStyleValue *lineWidthFunction = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential
|
||||
cameraStops:lineWidthStops
|
||||
options:nil];
|
||||
roadLayer.lineWidth = lineWidthFunction;
|
||||
roadLayer.lineGapWidth = lineWidthFunction;
|
||||
|
||||
NSDictionary *roadLineColorStops = @{@10: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor purpleColor]],
|
||||
@13: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor yellowColor]],
|
||||
@16: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor cyanColor]]};
|
||||
MGLStyleValue *roadLineColor = [MGLStyleValue<UIColor *> valueWithInterpolationMode:MGLInterpolationModeExponential
|
||||
cameraStops:roadLineColorStops
|
||||
options: nil];
|
||||
roadLayer.lineColor = roadLineColor;
|
||||
|
||||
roadLayer.visible = YES;
|
||||
roadLayer.maximumZoomLevel = 15;
|
||||
roadLayer.minimumZoomLevel = 13;
|
||||
@@ -790,10 +797,10 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
[self.mapView.style addSource:rasterSource];
|
||||
|
||||
MGLRasterStyleLayer *rasterLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"my-raster-layer" source:rasterSource];
|
||||
MGLStyleValue *opacityFunction = [MGLStyleValue<NSNumber *> valueWithStops:@{
|
||||
@20.0f: [MGLStyleValue<NSNumber *> valueWithRawValue:@1.0f],
|
||||
@5.0f: [MGLStyleValue<NSNumber *> valueWithRawValue:@0.0f],
|
||||
}];
|
||||
MGLStyleValue *opacityFunction = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeExponential
|
||||
cameraStops:@{@20.0f: [MGLStyleValue<NSNumber *> valueWithRawValue:@1.0f],
|
||||
@5.0f: [MGLStyleValue<NSNumber *> valueWithRawValue:@0.0f]}
|
||||
options:nil];
|
||||
rasterLayer.rasterOpacity = opacityFunction;
|
||||
[self.mapView.style addLayer:rasterLayer];
|
||||
}
|
||||
@@ -822,7 +829,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
self.mapView.style.transitionDuration = 5;
|
||||
self.mapView.style.transitionDelay = 1;
|
||||
MGLFillStyleLayer *buildingLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"building"];
|
||||
buildingLayer.fillColor = [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor blackColor]];
|
||||
buildingLayer.fillColor = [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor purpleColor]];
|
||||
}
|
||||
|
||||
- (void)styleFerryLayer
|
||||
@@ -857,18 +864,6 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
});
|
||||
}
|
||||
|
||||
+ (MGLStyleConstantValue<NSValue *> *)testEnum:(NSUInteger)value type:(const char *)type
|
||||
{
|
||||
return [MGLStyleConstantValue<NSValue *> valueWithRawValue:[NSValue value:&value withObjCType:type]];
|
||||
}
|
||||
|
||||
+ (MGLStyleFunction<NSValue *> *)testEnumFunction:(NSUInteger)value type:(const char *)type
|
||||
{
|
||||
return [MGLStyleFunction<NSValue *> valueWithStops:@{
|
||||
@18: [self testEnum:value type:type],
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)styleFilteredLines
|
||||
{
|
||||
// set style and focus on lower 48
|
||||
@@ -1204,6 +1199,48 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
[self.mapView.style addLayer:routeLayer];
|
||||
}
|
||||
|
||||
- (void)stylePolygonWithDDS {
|
||||
CLLocationCoordinate2D leftCoords[] = {
|
||||
{37.73081027834234, -122.49412536621094},
|
||||
{37.7566013348511, -122.49412536621094},
|
||||
{37.7566013348511, -122.46253967285156},
|
||||
{37.73081027834234, -122.46253967285156},
|
||||
{37.73081027834234, -122.49412536621094},
|
||||
};
|
||||
CLLocationCoordinate2D rightCoords[] = {
|
||||
{37.73135334055843, -122.44640350341795},
|
||||
{37.75741564287944, -122.44640350341795},
|
||||
{37.75741564287944, -122.41310119628906},
|
||||
{37.73135334055843, -122.41310119628906},
|
||||
{37.73135334055843, -122.44640350341795},
|
||||
};
|
||||
MGLPolygonFeature *leftFeature = [MGLPolygonFeature polygonWithCoordinates:leftCoords count:5];
|
||||
leftFeature.attributes = @{@"fill": @(YES)};
|
||||
|
||||
MGLPolygonFeature *rightFeature = [MGLPolygonFeature polygonWithCoordinates:rightCoords count:5];
|
||||
rightFeature.attributes = @{@"opacity": @(0.5)};
|
||||
|
||||
MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shape-source" features:@[leftFeature, rightFeature] options:nil];
|
||||
[self.mapView.style addSource:shapeSource];
|
||||
|
||||
// source, categorical function that sets any feature with a "fill" attribute value of true to red color and anything without to green
|
||||
MGLFillStyleLayer *fillStyleLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fill-layer" source:shapeSource];
|
||||
NSDictionary *stops = @{@(YES): [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor greenColor]]};
|
||||
NSDictionary *fillColorOptions = @{MGLStyleFunctionOptionDefaultValue: [MGLStyleValue<UIColor *> valueWithRawValue:[UIColor redColor]]};
|
||||
fillStyleLayer.fillColor = [MGLStyleValue<UIColor *> valueWithInterpolationMode:MGLInterpolationModeCategorical
|
||||
sourceStops:stops
|
||||
attributeName:@"fill"
|
||||
options:fillColorOptions];
|
||||
|
||||
// source, identity function that sets any feature with an "opacity" attribute to use that value and anything without to 1.0
|
||||
NSDictionary *fillOpacityOptions = @{MGLStyleFunctionOptionDefaultValue: [MGLStyleValue<NSNumber *> valueWithRawValue:@(1.0)]};
|
||||
fillStyleLayer.fillOpacity = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity
|
||||
sourceStops:nil
|
||||
attributeName:@"opacity"
|
||||
options:fillOpacityOptions];
|
||||
[self.mapView.style addLayer:fillStyleLayer];
|
||||
}
|
||||
|
||||
- (void)styleLabelLanguageForLayersNamed:(NSArray<NSString *> *)layers
|
||||
{
|
||||
_usingLocaleBasedCountryLabels = !_usingLocaleBasedCountryLabels;
|
||||
@@ -1219,8 +1256,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
if ([label.rawValue hasPrefix:@"{name"]) {
|
||||
layer.text = [MGLStyleValue valueWithRawValue:language];
|
||||
}
|
||||
} else if ([layer.text isKindOfClass:[MGLStyleFunction class]]) {
|
||||
MGLStyleFunction *function = (MGLStyleFunction<NSString *> *)layer.text;
|
||||
}
|
||||
else if ([layer.text isKindOfClass:[MGLCameraStyleFunction class]]) {
|
||||
MGLCameraStyleFunction *function = (MGLCameraStyleFunction<NSString *> *)layer.text;
|
||||
[function.stops enumerateKeysAndObjectsUsingBlock:^(id zoomLevel, id stop, BOOL *done) {
|
||||
if ([stop isKindOfClass:[MGLStyleConstantValue class]]) {
|
||||
MGLStyleConstantValue *label = (MGLStyleConstantValue<NSString *> *)stop;
|
||||
|
||||
@@ -906,8 +906,8 @@
|
||||
DA72620A1DEEE3480043BB89 /* MGLOpenGLStyleLayer.mm */,
|
||||
353933FA1D3FB7C0003F57D7 /* MGLRasterStyleLayer.h */,
|
||||
35136D411D42274500C20EFD /* MGLRasterStyleLayer.mm */,
|
||||
35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */,
|
||||
35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */,
|
||||
35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */,
|
||||
35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */,
|
||||
353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */,
|
||||
35136D441D42275100C20EFD /* MGLSymbolStyleLayer.mm */,
|
||||
|
||||
@@ -373,8 +373,9 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
|
||||
if ([layer.text isKindOfClass:[MGLStyleConstantValue class]]) {
|
||||
NSString *textField = [(MGLStyleConstantValue<NSString *> *)layer.text rawValue];
|
||||
layer.text = [MGLStyleValue<NSString *> valueWithRawValue:stringByLocalizingString(textField)];
|
||||
} else if ([layer.text isKindOfClass:[MGLStyleFunction class]]) {
|
||||
MGLStyleFunction *function = (MGLStyleFunction<NSString *> *)layer.text;
|
||||
}
|
||||
else if ([layer.text isKindOfClass:[MGLCameraStyleFunction class]]) {
|
||||
MGLCameraStyleFunction *function = (MGLCameraStyleFunction<NSString *> *)layer.text;
|
||||
NSMutableDictionary *stops = function.stops.mutableCopy;
|
||||
[stops enumerateKeysAndObjectsUsingBlock:^(NSNumber *zoomLevel, MGLStyleConstantValue<NSString *> *stop, BOOL *done) {
|
||||
NSString *textField = stop.rawValue;
|
||||
|
||||
Reference in New Issue
Block a user