* [ios] Removed changelog entry for Terrarium The broader feature is new to v4.0.0 as well. * [ios, macos] Localize expressions more thoroughly Replaced the MGLStyle.localizesLabels property with a -localizeLabelsIntoLocale: method that allows the caller to specify the locale to localize into. Also exposed a per-expression localization method for developers who want to vary behavior from layer to layer. * [macos] Offer English labels if preferred language is unsupported * [ios, macos] Removed dead code * [ios] Use new localization method in iosapp * [ios, macos] Fixed local name labels * [ios, macos] Convert tokens to key path expressions in stop dictionaries * [ios, macos] Streamlined token upgrading Separated token upgrading into a separate process that only happens as part of the MGLSymbolStyleLayer.text and MGLSymbolStyleLayer.iconImageName properties’ getters, so that it’s easy to remove later when mbgl changes obviate this workaround. Removed the replacesTokens parameter to the expression localization methods. * [ios, macos] Preserve whitespace between tokens * [ios, macos] Moved token replacement to a consistent category Fixed a build warning. * [ios, macos] Replace tokens in all string-typed getters For consistency, replace tokens with key paths in all string-typed style paint and layout properties. * [ios, macos] Test token replacement Added tests for replacement of tokens with key paths in expressions. Fixed token replacement for raw strings in stop dictionaries. Avoid sticking a single string inside an mgl_join: call. * [ios, macos] Test token replacement, localization Added unit tests of token replacement and localization of expressions. Only NSExpression is responsible for resolving the preferred language now, since NSLocale tends to tack a region code onto the locale identifier and the NSExpression method can be called independently anyways. Added a private variation of +[MGLVectorTileSource preferredMapboxStreetsLanguage] that takes an array of preferred languages. Fixed localization of non-expressions in stop dictionaries. * [ios, macos] Dictionary keys aren’t necessarily zoom levels
337 lines
12 KiB
Plaintext
337 lines
12 KiB
Plaintext
// This file is generated.
|
|
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
|
|
|
|
#import "MGLSource.h"
|
|
#import "NSPredicate+MGLAdditions.h"
|
|
#import "NSDate+MGLAdditions.h"
|
|
#import "MGLStyleLayer_Private.h"
|
|
#import "MGLStyleValue_Private.h"
|
|
#import "MGLFillExtrusionStyleLayer.h"
|
|
|
|
#include <mbgl/style/transition_options.hpp>
|
|
#include <mbgl/style/layers/fill_extrusion_layer.hpp>
|
|
|
|
namespace mbgl {
|
|
|
|
MBGL_DEFINE_ENUM(MGLFillExtrusionTranslationAnchor, {
|
|
{ MGLFillExtrusionTranslationAnchorMap, "map" },
|
|
{ MGLFillExtrusionTranslationAnchorViewport, "viewport" },
|
|
});
|
|
|
|
}
|
|
|
|
@interface MGLFillExtrusionStyleLayer ()
|
|
|
|
@property (nonatomic, readonly) mbgl::style::FillExtrusionLayer *rawLayer;
|
|
|
|
@end
|
|
|
|
@implementation MGLFillExtrusionStyleLayer
|
|
|
|
- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source
|
|
{
|
|
auto layer = std::make_unique<mbgl::style::FillExtrusionLayer>(identifier.UTF8String, source.identifier.UTF8String);
|
|
return self = [super initWithPendingLayer:std::move(layer)];
|
|
}
|
|
|
|
- (mbgl::style::FillExtrusionLayer *)rawLayer
|
|
{
|
|
return (mbgl::style::FillExtrusionLayer *)super.rawLayer;
|
|
}
|
|
|
|
- (NSString *)sourceIdentifier
|
|
{
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
return @(self.rawLayer->getSourceID().c_str());
|
|
}
|
|
|
|
- (NSString *)sourceLayerIdentifier
|
|
{
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto layerID = self.rawLayer->getSourceLayer();
|
|
return layerID.empty() ? nil : @(layerID.c_str());
|
|
}
|
|
|
|
- (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier
|
|
{
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
|
|
}
|
|
|
|
- (void)setPredicate:(NSPredicate *)predicate
|
|
{
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter());
|
|
}
|
|
|
|
- (NSPredicate *)predicate
|
|
{
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()];
|
|
}
|
|
|
|
#pragma mark - Accessing the Paint Attributes
|
|
|
|
- (void)setFillExtrusionBase:(NSExpression *)fillExtrusionBase {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::DataDrivenPropertyValue<float>>(fillExtrusionBase);
|
|
self.rawLayer->setFillExtrusionBase(mbglValue);
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionBase {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getFillExtrusionBase();
|
|
if (propertyValue.isUndefined()) {
|
|
propertyValue = self.rawLayer->getDefaultFillExtrusionBase();
|
|
}
|
|
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
|
}
|
|
|
|
- (void)setFillExtrusionBaseTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setFillExtrusionBaseTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)fillExtrusionBaseTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionBaseTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
- (void)setFillExtrusionColor:(NSExpression *)fillExtrusionColor {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::DataDrivenPropertyValue<mbgl::Color>>(fillExtrusionColor);
|
|
self.rawLayer->setFillExtrusionColor(mbglValue);
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionColor {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getFillExtrusionColor();
|
|
if (propertyValue.isUndefined()) {
|
|
propertyValue = self.rawLayer->getDefaultFillExtrusionColor();
|
|
}
|
|
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(propertyValue);
|
|
}
|
|
|
|
- (void)setFillExtrusionColorTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setFillExtrusionColorTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)fillExtrusionColorTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionColorTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
- (void)setFillExtrusionHeight:(NSExpression *)fillExtrusionHeight {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::DataDrivenPropertyValue<float>>(fillExtrusionHeight);
|
|
self.rawLayer->setFillExtrusionHeight(mbglValue);
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionHeight {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getFillExtrusionHeight();
|
|
if (propertyValue.isUndefined()) {
|
|
propertyValue = self.rawLayer->getDefaultFillExtrusionHeight();
|
|
}
|
|
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
|
}
|
|
|
|
- (void)setFillExtrusionHeightTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setFillExtrusionHeightTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)fillExtrusionHeightTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionHeightTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
- (void)setFillExtrusionOpacity:(NSExpression *)fillExtrusionOpacity {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionOpacity);
|
|
self.rawLayer->setFillExtrusionOpacity(mbglValue);
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionOpacity {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getFillExtrusionOpacity();
|
|
if (propertyValue.isUndefined()) {
|
|
propertyValue = self.rawLayer->getDefaultFillExtrusionOpacity();
|
|
}
|
|
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
|
|
}
|
|
|
|
- (void)setFillExtrusionOpacityTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setFillExtrusionOpacityTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)fillExtrusionOpacityTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionOpacityTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
- (void)setFillExtrusionPattern:(NSExpression *)fillExtrusionPattern {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue<mbgl::style::PropertyValue<std::string>>(fillExtrusionPattern);
|
|
self.rawLayer->setFillExtrusionPattern(mbglValue);
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionPattern {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getFillExtrusionPattern();
|
|
if (propertyValue.isUndefined()) {
|
|
propertyValue = self.rawLayer->getDefaultFillExtrusionPattern();
|
|
}
|
|
NSExpression *expression = MGLStyleValueTransformer<std::string, NSString *>().toExpression(propertyValue);
|
|
return expression.mgl_expressionByReplacingTokensWithKeyPaths;
|
|
}
|
|
|
|
- (void)setFillExtrusionPatternTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setFillExtrusionPatternTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)fillExtrusionPatternTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionPatternTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
- (void)setFillExtrusionTranslation:(NSExpression *)fillExtrusionTranslation {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(fillExtrusionTranslation);
|
|
self.rawLayer->setFillExtrusionTranslate(mbglValue);
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionTranslation {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getFillExtrusionTranslate();
|
|
if (propertyValue.isUndefined()) {
|
|
propertyValue = self.rawLayer->getDefaultFillExtrusionTranslate();
|
|
}
|
|
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toExpression(propertyValue);
|
|
}
|
|
|
|
- (void)setFillExtrusionTranslationTransition:(MGLTransition )transition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } };
|
|
self.rawLayer->setFillExtrusionTranslateTransition(options);
|
|
}
|
|
|
|
- (MGLTransition)fillExtrusionTranslationTransition {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionTranslateTransition();
|
|
MGLTransition transition;
|
|
transition.duration = MGLTimeIntervalFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
|
|
transition.delay = MGLTimeIntervalFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
|
|
|
|
return transition;
|
|
}
|
|
|
|
- (void)setFillExtrusionTranslate:(NSExpression *)fillExtrusionTranslate {
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionTranslate {
|
|
return self.fillExtrusionTranslation;
|
|
}
|
|
|
|
- (void)setFillExtrusionTranslationAnchor:(NSExpression *)fillExtrusionTranslationAnchor {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillExtrusionTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(fillExtrusionTranslationAnchor);
|
|
self.rawLayer->setFillExtrusionTranslateAnchor(mbglValue);
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionTranslationAnchor {
|
|
MGLAssertStyleLayerIsValid();
|
|
|
|
auto propertyValue = self.rawLayer->getFillExtrusionTranslateAnchor();
|
|
if (propertyValue.isUndefined()) {
|
|
propertyValue = self.rawLayer->getDefaultFillExtrusionTranslateAnchor();
|
|
}
|
|
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillExtrusionTranslationAnchor>().toExpression(propertyValue);
|
|
}
|
|
|
|
- (void)setFillExtrusionTranslateAnchor:(NSExpression *)fillExtrusionTranslateAnchor {
|
|
}
|
|
|
|
- (NSExpression *)fillExtrusionTranslateAnchor {
|
|
return self.fillExtrusionTranslationAnchor;
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation NSValue (MGLFillExtrusionStyleLayerAdditions)
|
|
|
|
+ (NSValue *)valueWithMGLFillExtrusionTranslationAnchor:(MGLFillExtrusionTranslationAnchor)fillExtrusionTranslationAnchor {
|
|
return [NSValue value:&fillExtrusionTranslationAnchor withObjCType:@encode(MGLFillExtrusionTranslationAnchor)];
|
|
}
|
|
|
|
- (MGLFillExtrusionTranslationAnchor)MGLFillExtrusionTranslationAnchorValue {
|
|
MGLFillExtrusionTranslationAnchor fillExtrusionTranslationAnchor;
|
|
[self getValue:&fillExtrusionTranslationAnchor];
|
|
return fillExtrusionTranslationAnchor;
|
|
}
|
|
|
|
@end
|