forked from mapbox/mapbox-gl-native-ios
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MGLFillExtrusionStyleLayer.mm
363 lines (264 loc) · 13.1 KB
/
MGLFillExtrusionStyleLayer.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
// This file is generated.
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
#import "MGLSource.h"
#import "NSPredicate+MGLPrivateAdditions.h"
#import "NSDate+MGLAdditions.h"
#import "MGLStyleLayer_Private.h"
#import "MGLStyleValue_Private.h"
#import "MGLFillExtrusionStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
#import "MGLFillExtrusionStyleLayer_Private.h"
#include <mbgl/style/layers/fill_extrusion_layer.hpp>
#include <mbgl/style/transition_options.hpp>
namespace mbgl {
MBGL_DEFINE_ENUM(MGLFillExtrusionTranslationAnchor, {
{ MGLFillExtrusionTranslationAnchorMap, "map" },
{ MGLFillExtrusionTranslationAnchorViewport, "viewport" },
});
}
@interface MGLFillExtrusionStyleLayer ()
@property (nonatomic, readonly) mbgl::style::FillExtrusionLayer *rawLayer;
@end
@implementation MGLFillExtrusionStyleLayer
- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source
{
MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source);
auto layer = std::make_unique<mbgl::style::FillExtrusionLayer>(identifier.UTF8String, source.identifier.UTF8String);
return self = [super initWithPendingLayer:std::move(layer)];
}
- (mbgl::style::FillExtrusionLayer *)rawLayer
{
return (mbgl::style::FillExtrusionLayer *)super.rawLayer;
}
- (NSString *)sourceIdentifier
{
MGLAssertStyleLayerIsValid();
return @(self.rawLayer->getSourceID().c_str());
}
- (NSString *)sourceLayerIdentifier
{
MGLAssertStyleLayerIsValid();
auto layerID = self.rawLayer->getSourceLayer();
return layerID.empty() ? nil : @(layerID.c_str());
}
- (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier
{
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier);
self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: "");
}
- (void)setPredicate:(NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting predicate: %@", predicate);
self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter());
}
- (NSPredicate *)predicate
{
MGLAssertStyleLayerIsValid();
return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()];
}
#pragma mark - Accessing the Paint Attributes
- (void)setFillExtrusionBase:(NSExpression *)fillExtrusionBase {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionBase: %@", fillExtrusionBase);
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionBase, true);
self.rawLayer->setFillExtrusionBase(mbglValue);
}
- (NSExpression *)fillExtrusionBase {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getFillExtrusionBase();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultFillExtrusionBase();
}
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
}
- (void)setFillExtrusionBaseTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionBaseTransition: %@", MGLStringFromMGLTransition(transition));
self.rawLayer->setFillExtrusionBaseTransition(MGLOptionsFromTransition(transition));
}
- (MGLTransition)fillExtrusionBaseTransition {
MGLAssertStyleLayerIsValid();
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionBaseTransition();
return MGLTransitionFromOptions(transitionOptions);
}
- (void)setFillExtrusionColor:(NSExpression *)fillExtrusionColor {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionColor: %@", fillExtrusionColor);
auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(fillExtrusionColor, true);
self.rawLayer->setFillExtrusionColor(mbglValue);
}
- (NSExpression *)fillExtrusionColor {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getFillExtrusionColor();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultFillExtrusionColor();
}
return MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toExpression(propertyValue);
}
- (void)setFillExtrusionColorTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionColorTransition: %@", MGLStringFromMGLTransition(transition));
self.rawLayer->setFillExtrusionColorTransition(MGLOptionsFromTransition(transition));
}
- (MGLTransition)fillExtrusionColorTransition {
MGLAssertStyleLayerIsValid();
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionColorTransition();
return MGLTransitionFromOptions(transitionOptions);
}
- (void)setFillExtrusionHasVerticalGradient:(NSExpression *)fillExtrusionHasVerticalGradient {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionHasVerticalGradient: %@", fillExtrusionHasVerticalGradient);
auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(fillExtrusionHasVerticalGradient, false);
self.rawLayer->setFillExtrusionVerticalGradient(mbglValue);
}
- (NSExpression *)fillExtrusionHasVerticalGradient {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getFillExtrusionVerticalGradient();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultFillExtrusionVerticalGradient();
}
return MGLStyleValueTransformer<bool, NSNumber *>().toExpression(propertyValue);
}
- (void)setFillExtrusionVerticalGradient:(NSExpression *)fillExtrusionVerticalGradient {
}
- (NSExpression *)fillExtrusionVerticalGradient {
return self.fillExtrusionHasVerticalGradient;
}
- (void)setFillExtrusionHeight:(NSExpression *)fillExtrusionHeight {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionHeight: %@", fillExtrusionHeight);
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionHeight, true);
self.rawLayer->setFillExtrusionHeight(mbglValue);
}
- (NSExpression *)fillExtrusionHeight {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getFillExtrusionHeight();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultFillExtrusionHeight();
}
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
}
- (void)setFillExtrusionHeightTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionHeightTransition: %@", MGLStringFromMGLTransition(transition));
self.rawLayer->setFillExtrusionHeightTransition(MGLOptionsFromTransition(transition));
}
- (MGLTransition)fillExtrusionHeightTransition {
MGLAssertStyleLayerIsValid();
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionHeightTransition();
return MGLTransitionFromOptions(transitionOptions);
}
- (void)setFillExtrusionOpacity:(NSExpression *)fillExtrusionOpacity {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionOpacity: %@", fillExtrusionOpacity);
auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionOpacity, false);
self.rawLayer->setFillExtrusionOpacity(mbglValue);
}
- (NSExpression *)fillExtrusionOpacity {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getFillExtrusionOpacity();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultFillExtrusionOpacity();
}
return MGLStyleValueTransformer<float, NSNumber *>().toExpression(propertyValue);
}
- (void)setFillExtrusionOpacityTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionOpacityTransition: %@", MGLStringFromMGLTransition(transition));
self.rawLayer->setFillExtrusionOpacityTransition(MGLOptionsFromTransition(transition));
}
- (MGLTransition)fillExtrusionOpacityTransition {
MGLAssertStyleLayerIsValid();
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionOpacityTransition();
return MGLTransitionFromOptions(transitionOptions);
}
- (void)setFillExtrusionPattern:(NSExpression *)fillExtrusionPattern {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionPattern: %@", fillExtrusionPattern);
auto mbglValue = MGLStyleValueTransformer<mbgl::style::expression::Image, NSString *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::expression::Image>>(fillExtrusionPattern, true);
self.rawLayer->setFillExtrusionPattern(mbglValue);
}
- (NSExpression *)fillExtrusionPattern {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getFillExtrusionPattern();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultFillExtrusionPattern();
}
return MGLStyleValueTransformer<mbgl::style::expression::Image, NSString *>().toExpression(propertyValue);
}
- (void)setFillExtrusionPatternTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionPatternTransition: %@", MGLStringFromMGLTransition(transition));
self.rawLayer->setFillExtrusionPatternTransition(MGLOptionsFromTransition(transition));
}
- (MGLTransition)fillExtrusionPatternTransition {
MGLAssertStyleLayerIsValid();
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionPatternTransition();
return MGLTransitionFromOptions(transitionOptions);
}
- (void)setFillExtrusionTranslation:(NSExpression *)fillExtrusionTranslation {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionTranslation: %@", fillExtrusionTranslation);
auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(fillExtrusionTranslation, false);
self.rawLayer->setFillExtrusionTranslate(mbglValue);
}
- (NSExpression *)fillExtrusionTranslation {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getFillExtrusionTranslate();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultFillExtrusionTranslate();
}
return MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toExpression(propertyValue);
}
- (void)setFillExtrusionTranslationTransition:(MGLTransition )transition {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionTranslationTransition: %@", MGLStringFromMGLTransition(transition));
self.rawLayer->setFillExtrusionTranslateTransition(MGLOptionsFromTransition(transition));
}
- (MGLTransition)fillExtrusionTranslationTransition {
MGLAssertStyleLayerIsValid();
mbgl::style::TransitionOptions transitionOptions = self.rawLayer->getFillExtrusionTranslateTransition();
return MGLTransitionFromOptions(transitionOptions);
}
- (void)setFillExtrusionTranslate:(NSExpression *)fillExtrusionTranslate {
}
- (NSExpression *)fillExtrusionTranslate {
return self.fillExtrusionTranslation;
}
- (void)setFillExtrusionTranslationAnchor:(NSExpression *)fillExtrusionTranslationAnchor {
MGLAssertStyleLayerIsValid();
MGLLogDebug(@"Setting fillExtrusionTranslationAnchor: %@", fillExtrusionTranslationAnchor);
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillExtrusionTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(fillExtrusionTranslationAnchor, false);
self.rawLayer->setFillExtrusionTranslateAnchor(mbglValue);
}
- (NSExpression *)fillExtrusionTranslationAnchor {
MGLAssertStyleLayerIsValid();
auto propertyValue = self.rawLayer->getFillExtrusionTranslateAnchor();
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefaultFillExtrusionTranslateAnchor();
}
return MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillExtrusionTranslationAnchor>().toExpression(propertyValue);
}
- (void)setFillExtrusionTranslateAnchor:(NSExpression *)fillExtrusionTranslateAnchor {
}
- (NSExpression *)fillExtrusionTranslateAnchor {
return self.fillExtrusionTranslationAnchor;
}
@end
@implementation NSValue (MGLFillExtrusionStyleLayerAdditions)
+ (NSValue *)valueWithMGLFillExtrusionTranslationAnchor:(MGLFillExtrusionTranslationAnchor)fillExtrusionTranslationAnchor {
return [NSValue value:&fillExtrusionTranslationAnchor withObjCType:@encode(MGLFillExtrusionTranslationAnchor)];
}
- (MGLFillExtrusionTranslationAnchor)MGLFillExtrusionTranslationAnchorValue {
MGLFillExtrusionTranslationAnchor fillExtrusionTranslationAnchor;
[self getValue:&fillExtrusionTranslationAnchor];
return fillExtrusionTranslationAnchor;
}
@end
namespace mbgl {
MGLStyleLayer* FillExtrusionStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
return [[MGLFillExtrusionStyleLayer alloc] initWithRawLayer:rawLayer];
}
} // namespace mbgl