aboutsummaryrefslogtreecommitdiff
path: root/iosApp/WhirlyGlobeMaplyComponent.xcframework/ios-arm64/WhirlyGlobeMaplyComponent.framework/Headers/MaplyVectorStyle.h
blob: cecf6d991b721d24456bbd81537e3eaf031a4d8c (plain)
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
/*  MaplyVectorStyle.h
 *  WhirlyGlobe-MaplyComponent
 *
 *  Created by Steve Gifford on 1/3/14.
 *  Copyright 2011-2022 mousebird consulting
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#import <UIKit/UIKit.h>
#import <WhirlyGlobeMaplyComponent/MaplyTileSourceNew.h>
#import <WhirlyGlobeMaplyComponent/MaplyBaseViewController.h>

@class MaplyVectorTileData;

/** 
    Settings that control how vector tiles look in relation to their styles.
    
    These are set based on the sort of device we're on, particularly retina vs. non-retina.  They can be manipulated directly as well for your needs.
  */
@interface MaplyVectorStyleSettings : NSObject

/// Initialize with the (presumably) retina scale
- (instancetype __nonnull)initWithScale:(CGFloat)scale;

/// Line widths will be scaled by this amount before display.
@property (nonatomic) float lineScale;
/// Text sizes will be scaled by this amount before display.
@property (nonatomic) float textScale;
/// Markers (symbols+circles) will be scaled by this amount before display.
@property (nonatomic) float markerScale;
/// Symbols will be scaled by this amount before display.
@property (nonatomic) float symbolScale;
/// Circles will be scaled by this amount before display.
@property (nonatomic) float circleScale;
/// Importance for markers in the layout engine
@property (nonatomic) float markerImportance;
/// Default marker size when none is specified
@property (nonatomic) float markerSize;
/// Importance for labels in the layout engine
@property (nonatomic) float labelImportance;
/// If set we'll use the zoom levels defined in the style
@property (nonatomic) bool useZoomLevels;

/// For symbols we'll try to pull a UUID out of this field to stick in the marker and label uniqueID
@property (nonatomic,nullable) NSString *uuidField;

/// Draw priority calculated as offset from here
@property (nonatomic) int baseDrawPriority;

/// Offset between levels
@property (nonatomic) int drawPriorityPerLevel;

/** 
    The overall map scale calculations will be scaled by this amount.
    
    We use the map scale calculations to figure out what is dispalyed and when.  Not what to load in, mind you, that's a separate, but related calculation.  This controls the scaling of those calculations.  Scale it down to load things in later, up to load them in sooner.
  */
@property (nonatomic) float mapScaleScale;

/// Dashed lines will be scaled by this amount before display.
@property (nonatomic) float dashPatternScale;

/// Use widened vectors (which do anti-aliasing and such)
@property (nonatomic) bool useWideVectors;

/// Where we're using old vectors (e.g. not wide) scale them by this amount
@property (nonatomic) float oldVecWidthScale;

/// If we're using widened vectors, only activate them for strokes wider than this.  Defaults to zero.
@property (nonatomic) float wideVecCuttoff;

/// If set, this is the shader we'll use on the areal features.
@property (nonatomic,strong) NSString * _Nullable arealShaderName;

/// If set, we'll make all the features selectable.  If not, we won't.
@property (nonatomic) bool selectable;

/// If set, icons will be loaded from this directory
@property (nonatomic, strong) NSString * _Nullable iconDirectory;

/// The default font family for all text
@property (nonatomic,strong) NSString * _Nullable fontName;

@end

@protocol MaplyVectorStyle;

/** 
    Protocol for styling the vectors.
 
    You pass in an object which adheres to this protocol and will style
 the vectors read by a MaplyMapnikVectorTiles object.  In general, this will be
 a parsed Mapnik vector file, but you can substitute your own logic as well.
 */
@protocol MaplyVectorStyleDelegate <NSObject>

/** 
    Return the styles that apply to the given feature (attributes).
 */
- (nullable NSArray *)stylesForFeatureWithAttributes:(NSDictionary *__nonnull)attributes
                                              onTile:(MaplyTileID)tileID
                                             inLayer:(NSString *__nonnull)layer
                                               viewC:(NSObject<MaplyRenderControllerProtocol> *__nonnull)viewC;

/// Return true if the given layer is meant to display for the given tile (zoom level)
- (BOOL)layerShouldDisplay:(NSString *__nonnull)layer tile:(MaplyTileID)tileID;

/// Return the style associated with the given UUID.
- (nullable NSObject<MaplyVectorStyle> *)styleForUUID:(long long)uiid viewC:(NSObject<MaplyRenderControllerProtocol> *__nonnull)viewC;

/// Return the style for the background
- (nullable NSObject<MaplyVectorStyle> *)backgroundStyleViewC:(NSObject<MaplyRenderControllerProtocol> *__nonnull)viewC;

// Return a list of all the styles in no particular order.  Needed for categories and indexing
- (NSArray * __nonnull)allStyles;

@end

/** 
    Base protocol for the vector styles.
    
    Maply Vector Style is the protocol the your vector style needs to
    implement for the vector tile parsers to recognize it.
  */
@protocol MaplyVectorStyle<NSObject>

/// Unique Identifier for this style
- (long long) uuid;

/// Category used for sorting
- (NSString * _Nullable) getCategory;

/// Set if this geometry is additive (e.g. sticks around) rather than replacement
- (bool) geomAdditive;

/// Construct objects related to this style based on the input data.
- (void)buildObjects:(NSArray * _Nonnull)vecObjs
             forTile:(MaplyVectorTileData * __nonnull)tileData
               viewC:(NSObject<MaplyRenderControllerProtocol> * _Nonnull)viewC
                desc:(NSDictionary * _Nullable)desc;

/// Construct objects related to this style based on the input data.
- (void)buildObjects:(NSArray * _Nonnull)vecObjs
             forTile:(MaplyVectorTileData * __nonnull)tileData
               viewC:(NSObject<MaplyRenderControllerProtocol> * _Nonnull)viewC
                desc:(NSDictionary * _Nullable)desc
            cancelFn:(bool(^__nullable)(void))cancelFn;

@end

#ifdef __cplusplus
extern "C" {
#endif
/** 
    Use a style delegate to interpret vector data.
 
    Run the style delegate against the given vectors.  The resulting features are added to the
 given view controller using the thread mode specified.
 
    @param vecObjs An array of MaplyVectorObject.
 
    @param styleDelegate The style delegate that controls how the vectors will look.
 
    @param viewC View controller to add the geometry to.
 
    @param threadMode MaplyThreadCurrent will block until all the features are added.  MaplyThreadAny will do some of the work on another thread.
 */
NSArray<MaplyComponentObject*> * _Nonnull AddMaplyVectorsUsingStyle(NSArray<MaplyVectorObject*> * _Nonnull vecObjs,
                                                                    NSObject<MaplyVectorStyleDelegate> * _Nonnull styleDelegate,
                                                                    NSObject<MaplyRenderControllerProtocol> * _Nonnull viewC,
                                                                    MaplyThreadMode threadMode);

/**
    Use a style delegate to interpret vector data.
 
    Run the style delegate against the given vectors.  The resulting features are added to the
 given view controller using the thread mode specified.
 
    @param vecObjs An array of MaplyVectorObject.
 
    @param styleDelegate The style delegate that controls how the vectors will look.
 
    @param viewC View controller to add the geometry to.

    @param tileId The tile where the feature originates.
 
    @param enable Automatically enable the generated objects
 
    @param threadMode MaplyThreadCurrent will block until all the features are added.  MaplyThreadAny will do some of the work on another thread.
 
    @param desc Additional attributes to include with the generated component objects
 */
NSArray<MaplyComponentObject*> * _Nonnull AddMaplyVectorsUsingStyleAndAttributes(
    NSArray<MaplyVectorObject*> * _Nonnull vecObjs,
    NSObject<MaplyVectorStyleDelegate> * _Nonnull styleDelegate,
    NSObject<MaplyRenderControllerProtocol> * _Nonnull viewC,
    MaplyTileID tileId,
    bool enable,
    MaplyThreadMode threadMode,
    NSDictionary * _Nullable desc);

#ifdef __cplusplus
}
#endif