summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/MGLTilePyramidOfflineRegion.mm')
-rw-r--r--platform/darwin/src/MGLTilePyramidOfflineRegion.mm154
1 files changed, 0 insertions, 154 deletions
diff --git a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
deleted file mode 100644
index 73fcaa91d8..0000000000
--- a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
+++ /dev/null
@@ -1,154 +0,0 @@
-#import "MGLTilePyramidOfflineRegion.h"
-
-#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
- #import <Cocoa/Cocoa.h>
-#endif
-
-#import "MGLOfflineRegion_Private.h"
-#import "MGLTilePyramidOfflineRegion_Private.h"
-#import "MGLGeometry_Private.h"
-#import "MGLStyle.h"
-#import "MGLLoggingConfiguration_Private.h"
-
-#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
-#import "MMEConstants.h"
-#endif
-
-@interface MGLTilePyramidOfflineRegion () <MGLOfflineRegion_Private, MGLTilePyramidOfflineRegion_Private>
-
-@end
-
-@implementation MGLTilePyramidOfflineRegion {
- NSURL *_styleURL;
-}
-
-@synthesize styleURL = _styleURL;
-@synthesize includesIdeographicGlyphs = _includesIdeographicGlyphs;
-
--(NSDictionary *)offlineStartEventAttributes {
- return @{
- #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- MMEEventKeyShapeForOfflineRegion: @"tileregion",
- MMEEventKeyMinZoomLevel: @(self.minimumZoomLevel),
- MMEEventKeyMaxZoomLevel: @(self.maximumZoomLevel),
- MMEEventKeyStyleURL: self.styleURL.absoluteString ?: [NSNull null]
- #endif
- };
-}
-
-+ (BOOL)supportsSecureCoding {
- return YES;
-}
-
-- (instancetype)init {
- MGLLogInfo(@"Calling this initializer is not allowed.");
- [NSException raise:NSGenericException format:
- @"-[MGLTilePyramidOfflineRegion init] is unavailable. "
- @"Use -initWithStyleURL:bounds:fromZoomLevel:toZoomLevel: instead."];
- return nil;
-}
-
-- (instancetype)initWithStyleURL:(NSURL *)styleURL bounds:(MGLCoordinateBounds)bounds fromZoomLevel:(double)minimumZoomLevel toZoomLevel:(double)maximumZoomLevel {
- MGLLogDebug(@"Initializing styleURL: %@ bounds: %@ fromZoomLevel: %f toZoomLevel: %f", styleURL, MGLStringFromCoordinateBounds(bounds), minimumZoomLevel, maximumZoomLevel);
- if (self = [super init]) {
- if (!styleURL) {
- styleURL = [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion];
- }
-
- if (!styleURL.scheme) {
- [NSException raise:MGLInvalidStyleURLException format:
- @"%@ does not support setting a relative file URL as the style URL. "
- @"To download the online resources required by this style, "
- @"specify a URL to an online copy of this style. "
- @"For Mapbox-hosted styles, use the mapbox: scheme.",
- NSStringFromClass([self class])];
- }
-
- _styleURL = styleURL;
- _bounds = bounds;
- _minimumZoomLevel = minimumZoomLevel;
- _maximumZoomLevel = maximumZoomLevel;
- _includesIdeographicGlyphs = NO;
- }
- return self;
-}
-
-- (instancetype)initWithOfflineRegionDefinition:(const mbgl::OfflineTilePyramidRegionDefinition &)definition {
- NSURL *styleURL = [NSURL URLWithString:@(definition.styleURL.c_str())];
- MGLCoordinateBounds bounds = MGLCoordinateBoundsFromLatLngBounds(definition.bounds);
- MGLTilePyramidOfflineRegion* result = [self initWithStyleURL:styleURL bounds:bounds fromZoomLevel:definition.minZoom toZoomLevel:definition.maxZoom];
- result.includesIdeographicGlyphs = definition.includeIdeographs;
- return result;
-}
-
-- (const mbgl::OfflineRegionDefinition)offlineRegionDefinition {
-#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- const float scaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale];
-#elif TARGET_OS_MAC
- const float scaleFactor = [NSScreen mainScreen].backingScaleFactor;
-#endif
- return mbgl::OfflineTilePyramidRegionDefinition(_styleURL.absoluteString.UTF8String,
- MGLLatLngBoundsFromCoordinateBounds(_bounds),
- _minimumZoomLevel, _maximumZoomLevel,
- scaleFactor, _includesIdeographicGlyphs);
-}
-
-- (nullable instancetype)initWithCoder:(NSCoder *)coder {
- MGLLogInfo(@"Initializing with coder.");
- NSURL *styleURL = [coder decodeObjectForKey:@"styleURL"];
- CLLocationCoordinate2D sw = CLLocationCoordinate2DMake([coder decodeDoubleForKey:@"southWestLatitude"],
- [coder decodeDoubleForKey:@"southWestLongitude"]);
- CLLocationCoordinate2D ne = CLLocationCoordinate2DMake([coder decodeDoubleForKey:@"northEastLatitude"],
- [coder decodeDoubleForKey:@"northEastLongitude"]);
- MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(sw, ne);
- double minimumZoomLevel = [coder decodeDoubleForKey:@"minimumZoomLevel"];
- double maximumZoomLevel = [coder decodeDoubleForKey:@"maximumZoomLevel"];
-
- MGLTilePyramidOfflineRegion* result = [self initWithStyleURL:styleURL bounds:bounds fromZoomLevel:minimumZoomLevel toZoomLevel:maximumZoomLevel];
- result.includesIdeographicGlyphs = [coder decodeBoolForKey:@"includesIdeographicGlyphs"];
- return result;
-}
-
-- (void)encodeWithCoder:(NSCoder *)coder
-{
- [coder encodeObject:_styleURL forKey:@"styleURL"];
- [coder encodeDouble:_bounds.sw.latitude forKey:@"southWestLatitude"];
- [coder encodeDouble:_bounds.sw.longitude forKey:@"southWestLongitude"];
- [coder encodeDouble:_bounds.ne.latitude forKey:@"northEastLatitude"];
- [coder encodeDouble:_bounds.ne.longitude forKey:@"northEastLongitude"];
- [coder encodeDouble:_maximumZoomLevel forKey:@"maximumZoomLevel"];
- [coder encodeDouble:_minimumZoomLevel forKey:@"minimumZoomLevel"];
- [coder encodeBool:_includesIdeographicGlyphs forKey:@"includesIdeographicGlyphs"];
-}
-
-- (id)copyWithZone:(nullable NSZone *)zone {
- MGLTilePyramidOfflineRegion* result = [[[self class] allocWithZone:zone] initWithStyleURL:_styleURL bounds:_bounds fromZoomLevel:_minimumZoomLevel toZoomLevel:_maximumZoomLevel];
- result.includesIdeographicGlyphs = _includesIdeographicGlyphs;
- return result;
-}
-
-- (BOOL)isEqual:(id)other {
- if (other == self) {
- return YES;
- }
- if (![other isKindOfClass:[self class]]) {
- return NO;
- }
-
- MGLTilePyramidOfflineRegion *otherRegion = other;
- return (_minimumZoomLevel == otherRegion->_minimumZoomLevel
- && _maximumZoomLevel == otherRegion->_maximumZoomLevel
- && MGLCoordinateBoundsEqualToCoordinateBounds(_bounds, otherRegion->_bounds)
- && [_styleURL isEqual:otherRegion->_styleURL]
- && _includesIdeographicGlyphs == otherRegion->_includesIdeographicGlyphs);
-}
-
-- (NSUInteger)hash {
- return (_styleURL.hash
- + @(_bounds.sw.latitude).hash + @(_bounds.sw.longitude).hash
- + @(_bounds.ne.latitude).hash + @(_bounds.ne.longitude).hash
- + @(_minimumZoomLevel).hash + @(_maximumZoomLevel).hash
- + @(_includesIdeographicGlyphs).hash);
-}
-
-@end