-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathDRAppDelegate.m
188 lines (161 loc) · 8.35 KB
/
DRAppDelegate.m
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
//
// DRAppDelegate.m
// EarthViewExample
//
// Created by Ross Anderson on 4/14/12.
// Copyright (c) 2012 Ross Anderson. All rights reserved.
//
#import "DRAppDelegate.h"
#import "RASceneGraphController.h"
#import "RAWorldTour.h"
// NOTICE:
// The imagery tile sets below are for example use only. Please consult with the
// individual copyright holder of each tile set before using it in your app. The
// Dancing Robots tile sets (the defaults below) may not be used in your own
// app without permission.
#define IMAGERY_DATASET 1
#define TERRAIN_DATASET 1
@implementation DRAppDelegate {
RAWorldTour * tourController;
}
@synthesize window = _window;
@synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[RASceneGraphController alloc] initWithNibName:@"SceneView_iPhone" bundle:nil];
} else {
self.viewController = [[RASceneGraphController alloc] initWithNibName:@"SceneView_iPad" bundle:nil];
}
// allow caching for tile images
[[NSURLCache sharedURLCache] setMemoryCapacity:4*1024*1024];
[[NSURLCache sharedURLCache] setDiskCapacity:128*1024*1024];
// setup the tile set used
RATileDatabase * database = [RATileDatabase new];
database.bounds = CGRectMake( -180,-90,360,180 );
database.googleTileConvention = YES;
database.minzoom = 2;
switch( IMAGERY_DATASET ) {
case 1:
if ( [[UIScreen mainScreen] scale] > 1.5 ) {
// Dancing Robots Streets Retina: https://tiles.mapbox.com/v3/dancingrobots.map-lqzbpv0l.jsonp
database.baseUrlStrings = [NSArray arrayWithObjects:
@"http://a.tiles.mapbox.com/v3/dancingrobots.map-lqzbpv0l/{z}/{x}/{y}.png",
@"http://b.tiles.mapbox.com/v3/dancingrobots.map-lqzbpv0l/{z}/{x}/{y}.png",
@"http://c.tiles.mapbox.com/v3/dancingrobots.map-lqzbpv0l/{z}/{x}/{y}.png",
@"http://d.tiles.mapbox.com/v3/dancingrobots.map-lqzbpv0l/{z}/{x}/{y}.png",
nil];
} else {
// Dancing Robots Streets: https://tiles.mapbox.com/v3/dancingrobots.map-zlkx39ti.jsonp
database.baseUrlStrings = [NSArray arrayWithObjects:
@"http://a.tiles.mapbox.com/v3/dancingrobots.map-zlkx39ti/{z}/{x}/{y}.png",
@"http://b.tiles.mapbox.com/v3/dancingrobots.map-zlkx39ti/{z}/{x}/{y}.png",
@"http://c.tiles.mapbox.com/v3/dancingrobots.map-zlkx39ti/{z}/{x}/{y}.png",
@"http://d.tiles.mapbox.com/v3/dancingrobots.map-zlkx39ti/{z}/{x}/{y}.png",
nil];
}
database.maxzoom = 17;
break;
case 2:
// MapBox Streets: http://tiles.mapbox.com/v3/mapbox.mapbox-streets.jsonp
database.baseUrlStrings = [NSArray arrayWithObjects:
@"http://a.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png",
@"http://b.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png",
@"http://c.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png",
@"http://d.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png",
nil];
database.maxzoom = 17;
break;
case 3:
// Sample database from: http://tiles.mapbox.com/v3/mapbox.blue-marble-topo-bathy-jul.jsonp
database.baseUrlStrings = [NSArray arrayWithObjects:
@"http://a.tiles.mapbox.com/v3/mapbox.blue-marble-topo-bathy-jul/{z}/{x}/{y}.png",
@"http://b.tiles.mapbox.com/v3/mapbox.blue-marble-topo-bathy-jul/{z}/{x}/{y}.png",
@"http://c.tiles.mapbox.com/v3/mapbox.blue-marble-topo-bathy-jul/{z}/{x}/{y}.png",
@"http://d.tiles.mapbox.com/v3/mapbox.blue-marble-topo-bathy-jul/{z}/{x}/{y}.png",
nil];
database.maxzoom = 8;
break;
case 4:
// OpenStreetMap
database.baseUrlStrings = [NSArray arrayWithObjects:
@"http://a.tile.openstreetmap.org/{z}/{x}/{y}.png",
@"http://b.tile.openstreetmap.org/{z}/{x}/{y}.png",
@"http://c.tile.openstreetmap.org/{z}/{x}/{y}.png",
nil];
database.maxzoom = 18;
break;
case 5:
// Stamen Maps Watercolor - http://maps.stamen.com/watercolor
database.baseUrlStrings = [NSArray arrayWithObjects:
@"http://a.tile.stamen.com/watercolor/{z}/{x}/{y}.png",
@"http://b.tile.stamen.com/watercolor/{z}/{x}/{y}.png",
@"http://c.tile.stamen.com/watercolor/{z}/{x}/{y}.png",
nil];
database.maxzoom = 17;
break;
default:
database = nil;
break;
}
self.viewController.pager.imageryDatabase = database;
// setup height tile dataset
database = [RATileDatabase new];
database.bounds = CGRectMake( -180,-90,360,180 );
database.googleTileConvention = YES;
database.minzoom = 2;
switch ( TERRAIN_DATASET ) {
case 1:
// Dancing Robots Topography: http://a.tiles.mapbox.com/v3/dancingrobots.globe-topo.json
// Based on NOAA GLOBE dataset: http://www.ngdc.noaa.gov/mgg/topo/gltiles.html
database.baseUrlStrings = [NSArray arrayWithObjects:
@"http://a.tiles.mapbox.com/v3/dancingrobots.globe-topo/{z}/{x}/{y}.png",
@"http://b.tiles.mapbox.com/v3/dancingrobots.globe-topo/{z}/{x}/{y}.png",
@"http://c.tiles.mapbox.com/v3/dancingrobots.globe-topo/{z}/{x}/{y}.png",
@"http://d.tiles.mapbox.com/v3/dancingrobots.globe-topo/{z}/{x}/{y}.png",
nil];
database.maxzoom = 8;
break;
default:
database = nil;
break;
}
self.viewController.pager.terrainDatabase = database;
#if 0
// add world tour
tourController = [RAWorldTour new];
tourController.manipulator = self.viewController.manipulator;
UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:tourController action:@selector(startOrStop:)];
[recognizer setNumberOfTapsRequired:4];
[self.viewController.view addGestureRecognizer:recognizer];
[tourController start: self];
#endif
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end