This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts a previous change to vector / raster sources that added initializers to those classes so they could take certain tileset properties and create their own mbgl::Tileset objects. Now, a new MGLTileSet class that wraps all available core Tileset options can be created and passed into the sources. The sources pass that tileset object along to core.
- Loading branch information
Showing
10 changed files
with
145 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
#import "MGLSource.h" | ||
#import "MGLTypes.h" | ||
|
||
@class MGLTileSet; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface MGLRasterSource : MGLSource | ||
|
||
@property (nonatomic, readonly, copy) NSURL *URL; | ||
@property (nonatomic, readonly, assign) CGFloat tileSize; | ||
@property (nonatomic, readonly, copy) NS_ARRAY_OF(NSString *) *tileURLTemplates; | ||
@property (nonatomic, readonly) uint8_t minimumZoomLevel; | ||
@property (nonatomic, readonly) uint8_t maximumZoomLevel; | ||
@property (nonatomic, readonly, nullable) MGLTileSet *tileSet; | ||
|
||
- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url tileSize:(CGFloat)tileSize; | ||
|
||
- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier tileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates minimumZoomLevel:(NSUInteger)minimumZoomLevel maximumZoomLevel:(NSUInteger)maximumZoomLevel; | ||
- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier tileSize:(CGFloat)tileSize tileSet:(MGLTileSet *)tileSet; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "MGLTypes.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef NS_ENUM(NSUInteger, MGLTileSetScheme) { | ||
MGLTileSetSchemeXYZ = 0, | ||
MGLTileSetSchemeTMS | ||
}; | ||
|
||
@interface MGLTileSet : NSObject | ||
|
||
@property (nonatomic, copy) NS_ARRAY_OF(NSString *) *tileURLTemplates; | ||
@property (nonatomic) NSUInteger minimumZoomLevel; | ||
@property (nonatomic) NSUInteger maximumZoomLevel; | ||
@property (nonatomic, copy) NSString *attribution; | ||
@property (nonatomic) MGLTileSetScheme scheme; | ||
|
||
- (instancetype)initWithTileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates; | ||
- (instancetype)initWithTileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates minimumZoomLevel:(NSUInteger)minimumZoomLevel maximumZoomLevel:(NSUInteger)maximumZoomLevel; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#import "MGLTileSet.h" | ||
|
||
#include <mbgl/util/tileset.hpp> | ||
|
||
@implementation MGLTileSet | ||
{ | ||
BOOL _minimumZoomLevelIsSet; | ||
BOOL _maximumZoomLevelIsSet; | ||
} | ||
|
||
- (instancetype)initWithTileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates | ||
{ | ||
if (self = [super init]) | ||
{ | ||
_tileURLTemplates = tileURLTemplates; | ||
} | ||
return self; | ||
} | ||
|
||
- (instancetype)initWithTileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates minimumZoomLevel:(NSUInteger)minimumZoomLevel maximumZoomLevel:(NSUInteger)maximumZoomLevel | ||
{ | ||
if (self = [super init]) | ||
{ | ||
_tileURLTemplates = tileURLTemplates; | ||
_minimumZoomLevel = minimumZoomLevel; | ||
_minimumZoomLevelIsSet = YES; | ||
_maximumZoomLevel = maximumZoomLevel; | ||
_maximumZoomLevelIsSet = YES; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)setMinimumZoomLevel:(NSUInteger)minimumZoomLevel | ||
{ | ||
_minimumZoomLevel = minimumZoomLevel; | ||
_minimumZoomLevelIsSet = YES; | ||
} | ||
|
||
- (void)setMaximumZoomLevel:(NSUInteger)maximumZoomLevel | ||
{ | ||
_maximumZoomLevel = maximumZoomLevel; | ||
_maximumZoomLevelIsSet = YES; | ||
} | ||
|
||
- (mbgl::Tileset)mbglTileset | ||
{ | ||
mbgl::Tileset tileset; | ||
|
||
for (NSString *tileURLTemplate in self.tileURLTemplates) | ||
{ | ||
tileset.tiles.push_back(tileURLTemplate.UTF8String); | ||
} | ||
|
||
// set the minimum / maximum zoom range to the values specified by this class if they | ||
// were set. otherwise, use the core objects default values | ||
uint8_t minimumZoomLevel = _minimumZoomLevelIsSet ? self.minimumZoomLevel : tileset.zoomRange.min; | ||
uint8_t maximumZoomLevel = _maximumZoomLevelIsSet ? self.maximumZoomLevel : tileset.zoomRange.max; | ||
tileset.zoomRange = mbgl::Range<uint8_t>(minimumZoomLevel, maximumZoomLevel); | ||
|
||
if (self.attribution) | ||
{ | ||
tileset.attribution = self.attribution.UTF8String; | ||
} | ||
|
||
if (self.scheme == MGLTileSetSchemeTMS) { | ||
tileset.scheme = mbgl::Tileset::Scheme::TMS; | ||
} | ||
|
||
return tileset; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#import "MGLTileSet.h" | ||
|
||
#include <mbgl/util/tileset.hpp> | ||
|
||
@interface MGLTileSet (Private) | ||
|
||
- (mbgl::Tileset)mbglTileset; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters