Authored by Justin R. Miller

merged upstream develop

@@ -593,8 +593,6 @@ @@ -593,8 +593,6 @@
593 593
594 - (RMProjectedRect)projectedRectFromLatitudeLongitudeBounds:(RMSphericalTrapezium)bounds 594 - (RMProjectedRect)projectedRectFromLatitudeLongitudeBounds:(RMSphericalTrapezium)bounds
595 { 595 {
596 - float pixelBuffer = kZoomRectPixelBuffer;  
597 -  
598 CLLocationCoordinate2D southWest = bounds.southWest; 596 CLLocationCoordinate2D southWest = bounds.southWest;
599 CLLocationCoordinate2D northEast = bounds.northEast; 597 CLLocationCoordinate2D northEast = bounds.northEast;
600 CLLocationCoordinate2D midpoint = { 598 CLLocationCoordinate2D midpoint = {
@@ -619,18 +617,18 @@ @@ -619,18 +617,18 @@
619 617
620 if ((myPoint.x / self.bounds.size.width) < (myPoint.y / self.bounds.size.height)) 618 if ((myPoint.x / self.bounds.size.width) < (myPoint.y / self.bounds.size.height))
621 { 619 {
622 - if ((myPoint.y / (self.bounds.size.height - pixelBuffer)) > 1) 620 + if ((myPoint.y / self.bounds.size.height) > 1)
623 { 621 {
624 - zoomRect.size.width = self.bounds.size.width * (myPoint.y / (self.bounds.size.height - pixelBuffer));  
625 - zoomRect.size.height = self.bounds.size.height * (myPoint.y / (self.bounds.size.height - pixelBuffer)); 622 + zoomRect.size.width = self.bounds.size.width * (myPoint.y / self.bounds.size.height);
  623 + zoomRect.size.height = self.bounds.size.height * (myPoint.y / self.bounds.size.height);
626 } 624 }
627 } 625 }
628 else 626 else
629 { 627 {
630 - if ((myPoint.x / (self.bounds.size.width - pixelBuffer)) > 1) 628 + if ((myPoint.x / self.bounds.size.width) > 1)
631 { 629 {
632 - zoomRect.size.width = self.bounds.size.width * (myPoint.x / (self.bounds.size.width - pixelBuffer));  
633 - zoomRect.size.height = self.bounds.size.height * (myPoint.x / (self.bounds.size.width - pixelBuffer)); 630 + zoomRect.size.width = self.bounds.size.width * (myPoint.x / self.bounds.size.width);
  631 + zoomRect.size.height = self.bounds.size.height * (myPoint.x / self.bounds.size.width);
634 } 632 }
635 } 633 }
636 634
@@ -1020,8 +1018,6 @@ @@ -1020,8 +1018,6 @@
1020 else 1018 else
1021 { 1019 {
1022 // Convert northEast/southWest into RMMercatorRect and call zoomWithBounds 1020 // Convert northEast/southWest into RMMercatorRect and call zoomWithBounds
1023 - float pixelBuffer = kZoomRectPixelBuffer;  
1024 -  
1025 CLLocationCoordinate2D midpoint = { 1021 CLLocationCoordinate2D midpoint = {
1026 .latitude = (northEast.latitude + southWest.latitude) / 2, 1022 .latitude = (northEast.latitude + southWest.latitude) / 2,
1027 .longitude = (northEast.longitude + southWest.longitude) / 2 1023 .longitude = (northEast.longitude + southWest.longitude) / 2
@@ -1044,18 +1040,18 @@ @@ -1044,18 +1040,18 @@
1044 1040
1045 if ((myPoint.x / self.bounds.size.width) < (myPoint.y / self.bounds.size.height)) 1041 if ((myPoint.x / self.bounds.size.width) < (myPoint.y / self.bounds.size.height))
1046 { 1042 {
1047 - if ((myPoint.y / (self.bounds.size.height - pixelBuffer)) > 1) 1043 + if ((myPoint.y / self.bounds.size.height) > 1)
1048 { 1044 {
1049 - zoomRect.size.width = self.bounds.size.width * (myPoint.y / (self.bounds.size.height - pixelBuffer));  
1050 - zoomRect.size.height = self.bounds.size.height * (myPoint.y / (self.bounds.size.height - pixelBuffer)); 1045 + zoomRect.size.width = self.bounds.size.width * (myPoint.y / self.bounds.size.height);
  1046 + zoomRect.size.height = self.bounds.size.height * (myPoint.y / self.bounds.size.height);
1051 } 1047 }
1052 } 1048 }
1053 else 1049 else
1054 { 1050 {
1055 - if ((myPoint.x / (self.bounds.size.width - pixelBuffer)) > 1) 1051 + if ((myPoint.x / self.bounds.size.width) > 1)
1056 { 1052 {
1057 - zoomRect.size.width = self.bounds.size.width * (myPoint.x / (self.bounds.size.width - pixelBuffer));  
1058 - zoomRect.size.height = self.bounds.size.height * (myPoint.x / (self.bounds.size.width - pixelBuffer)); 1053 + zoomRect.size.width = self.bounds.size.width * (myPoint.x / self.bounds.size.width);
  1054 + zoomRect.size.height = self.bounds.size.height * (myPoint.x / self.bounds.size.width);
1059 } 1055 }
1060 } 1056 }
1061 1057
@@ -98,6 +98,7 @@ typedef enum : short { @@ -98,6 +98,7 @@ typedef enum : short {
98 * 98 *
99 * @param cache A memory-based or disk-based cache. */ 99 * @param cache A memory-based or disk-based cache. */
100 - (void)addCache:(id <RMTileCache>)cache; 100 - (void)addCache:(id <RMTileCache>)cache;
  101 +- (void)insertCache:(id <RMTileCache>)cache atIndex:(NSUInteger)index;
101 102
102 - (void)didReceiveMemoryWarning; 103 - (void)didReceiveMemoryWarning;
103 104
@@ -128,6 +128,16 @@ @@ -128,6 +128,16 @@
128 }); 128 });
129 } 129 }
130 130
  131 +- (void)insertCache:(id <RMTileCache>)cache atIndex:(NSUInteger)index
  132 +{
  133 + dispatch_barrier_async(_tileCacheQueue, ^{
  134 + if (index >= [_tileCaches count])
  135 + [_tileCaches addObject:cache];
  136 + else
  137 + [_tileCaches insertObject:cache atIndex:index];
  138 + });
  139 +}
  140 +
131 + (NSNumber *)tileHash:(RMTile)tile 141 + (NSNumber *)tileHash:(RMTile)tile
132 { 142 {
133 return [NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]; 143 return [NSNumber numberWithUnsignedLongLong:RMTileKey(tile)];
@@ -12,9 +12,9 @@ @@ -12,9 +12,9 @@
12 12
13 @implementation RMUserLocation 13 @implementation RMUserLocation
14 14
15 -@synthesize updating;  
16 -@synthesize location;  
17 -@synthesize heading; 15 +@synthesize updating = _updating;
  16 +@synthesize location = _location;
  17 +@synthesize heading = _heading;
18 18
19 - (id)initWithMapView:(RMMapView *)aMapView coordinate:(CLLocationCoordinate2D)aCoordinate andTitle:(NSString *)aTitle 19 - (id)initWithMapView:(RMMapView *)aMapView coordinate:(CLLocationCoordinate2D)aCoordinate andTitle:(NSString *)aTitle
20 { 20 {
@@ -34,8 +34,10 @@ @@ -34,8 +34,10 @@
34 34
35 - (void)dealloc 35 - (void)dealloc
36 { 36 {
37 - [location release]; location = nil;  
38 - [heading release]; heading = nil; 37 + [layer release]; layer = nil;
  38 + [annotationType release]; annotationType = nil;
  39 + [_location release]; _location = nil;
  40 + [_heading release]; _heading = nil;
39 [super dealloc]; 41 [super dealloc];
40 } 42 }
41 43
@@ -46,23 +48,23 @@ @@ -46,23 +48,23 @@
46 48
47 - (void)setLocation:(CLLocation *)newLocation 49 - (void)setLocation:(CLLocation *)newLocation
48 { 50 {
49 - if ([newLocation distanceFromLocation:location] && newLocation.coordinate.latitude != 0 && newLocation.coordinate.longitude != 0) 51 + if ([newLocation distanceFromLocation:_location] && newLocation.coordinate.latitude != 0 && newLocation.coordinate.longitude != 0)
50 { 52 {
51 [self willChangeValueForKey:@"location"]; 53 [self willChangeValueForKey:@"location"];
52 - [location release];  
53 - location = [newLocation retain];  
54 - self.coordinate = location.coordinate; 54 + [_location release];
  55 + _location = [newLocation retain];
  56 + self.coordinate = _location.coordinate;
55 [self didChangeValueForKey:@"location"]; 57 [self didChangeValueForKey:@"location"];
56 } 58 }
57 } 59 }
58 60
59 - (void)setHeading:(CLHeading *)newHeading 61 - (void)setHeading:(CLHeading *)newHeading
60 { 62 {
61 - if (newHeading.trueHeading != heading.trueHeading) 63 + if (newHeading.trueHeading != _heading.trueHeading)
62 { 64 {
63 [self willChangeValueForKey:@"heading"]; 65 [self willChangeValueForKey:@"heading"];
64 - [heading release];  
65 - heading = [newHeading retain]; 66 + [_heading release];
  67 + _heading = [newHeading retain];
66 [self didChangeValueForKey:@"heading"]; 68 [self didChangeValueForKey:@"heading"];
67 } 69 }
68 } 70 }
@@ -34,39 +34,39 @@ typedef enum { @@ -34,39 +34,39 @@ typedef enum {
34 @implementation RMUserTrackingBarButtonItem 34 @implementation RMUserTrackingBarButtonItem
35 35
36 @synthesize mapView = _mapView; 36 @synthesize mapView = _mapView;
37 -@synthesize segmentedControl;  
38 -@synthesize buttonImageView;  
39 -@synthesize activityView;  
40 -@synthesize state; 37 +@synthesize segmentedControl = _segmentedControl;
  38 +@synthesize buttonImageView = _buttonImageView;
  39 +@synthesize activityView = _activityView;
  40 +@synthesize state = _state;
41 41
42 - (id)initWithMapView:(RMMapView *)mapView 42 - (id)initWithMapView:(RMMapView *)mapView
43 { 43 {
44 if ( ! (self = [super initWithCustomView:[[UIControl alloc] initWithFrame:CGRectMake(0, 0, 32, 32)]])) 44 if ( ! (self = [super initWithCustomView:[[UIControl alloc] initWithFrame:CGRectMake(0, 0, 32, 32)]]))
45 return nil; 45 return nil;
46 46
47 - segmentedControl = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@""]] retain];  
48 - segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;  
49 - [segmentedControl setWidth:32.0 forSegmentAtIndex:0];  
50 - segmentedControl.userInteractionEnabled = NO;  
51 - segmentedControl.tintColor = self.tintColor;  
52 - segmentedControl.center = self.customView.center; 47 + _segmentedControl = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@""]] retain];
  48 + _segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
  49 + [_segmentedControl setWidth:32.0 forSegmentAtIndex:0];
  50 + _segmentedControl.userInteractionEnabled = NO;
  51 + _segmentedControl.tintColor = self.tintColor;
  52 + _segmentedControl.center = self.customView.center;
53 53
54 - [self.customView addSubview:segmentedControl]; 54 + [self.customView addSubview:_segmentedControl];
55 55
56 - buttonImageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TrackingLocation.png"]] retain];  
57 - buttonImageView.contentMode = UIViewContentModeCenter;  
58 - buttonImageView.frame = CGRectMake(0, 0, 32, 32);  
59 - buttonImageView.center = self.customView.center;  
60 - buttonImageView.userInteractionEnabled = NO; 56 + _buttonImageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TrackingLocation.png"]] retain];
  57 + _buttonImageView.contentMode = UIViewContentModeCenter;
  58 + _buttonImageView.frame = CGRectMake(0, 0, 32, 32);
  59 + _buttonImageView.center = self.customView.center;
  60 + _buttonImageView.userInteractionEnabled = NO;
61 61
62 - [self.customView addSubview:buttonImageView]; 62 + [self.customView addSubview:_buttonImageView];
63 63
64 - activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] retain];  
65 - activityView.hidesWhenStopped = YES;  
66 - activityView.center = self.customView.center;  
67 - activityView.userInteractionEnabled = NO; 64 + _activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] retain];
  65 + _activityView.hidesWhenStopped = YES;
  66 + _activityView.center = self.customView.center;
  67 + _activityView.userInteractionEnabled = NO;
68 68
69 - [self.customView addSubview:activityView]; 69 + [self.customView addSubview:_activityView];
70 70
71 [((UIControl *)self.customView) addTarget:self action:@selector(changeMode:) forControlEvents:UIControlEventTouchUpInside]; 71 [((UIControl *)self.customView) addTarget:self action:@selector(changeMode:) forControlEvents:UIControlEventTouchUpInside];
72 72
@@ -75,7 +75,7 @@ typedef enum { @@ -75,7 +75,7 @@ typedef enum {
75 [_mapView addObserver:self forKeyPath:@"userTrackingMode" options:NSKeyValueObservingOptionNew context:nil]; 75 [_mapView addObserver:self forKeyPath:@"userTrackingMode" options:NSKeyValueObservingOptionNew context:nil];
76 [_mapView addObserver:self forKeyPath:@"userLocation.location" options:NSKeyValueObservingOptionNew context:nil]; 76 [_mapView addObserver:self forKeyPath:@"userLocation.location" options:NSKeyValueObservingOptionNew context:nil];
77 77
78 - state = RMUserTrackingButtonStateLocation; 78 + _state = RMUserTrackingButtonStateLocation;
79 79
80 [self updateAppearance]; 80 [self updateAppearance];
81 81
@@ -84,9 +84,9 @@ typedef enum { @@ -84,9 +84,9 @@ typedef enum {
84 84
85 - (void)dealloc 85 - (void)dealloc
86 { 86 {
87 - [segmentedControl release]; segmentedControl = nil;  
88 - [buttonImageView release]; buttonImageView = nil;  
89 - [activityView release]; activityView = nil; 87 + [_segmentedControl release]; _segmentedControl = nil;
  88 + [_buttonImageView release]; _buttonImageView = nil;
  89 + [_activityView release]; _activityView = nil;
90 [_mapView removeObserver:self forKeyPath:@"userTrackingMode"]; 90 [_mapView removeObserver:self forKeyPath:@"userTrackingMode"];
91 [_mapView removeObserver:self forKeyPath:@"userLocation.location"]; 91 [_mapView removeObserver:self forKeyPath:@"userLocation.location"];
92 [_mapView release]; _mapView = nil; 92 [_mapView release]; _mapView = nil;
@@ -116,7 +116,7 @@ typedef enum { @@ -116,7 +116,7 @@ typedef enum {
116 { 116 {
117 [super setTintColor:newTintColor]; 117 [super setTintColor:newTintColor];
118 118
119 - segmentedControl.tintColor = newTintColor; 119 + _segmentedControl.tintColor = newTintColor;
120 } 120 }
121 121
122 #pragma mark - 122 #pragma mark -
@@ -132,7 +132,7 @@ typedef enum { @@ -132,7 +132,7 @@ typedef enum {
132 { 132 {
133 // "selection" state 133 // "selection" state
134 // 134 //
135 - segmentedControl.selectedSegmentIndex = (_mapView.userTrackingMode == RMUserTrackingModeNone ? UISegmentedControlNoSegment : 0); 135 + _segmentedControl.selectedSegmentIndex = (_mapView.userTrackingMode == RMUserTrackingModeNone ? UISegmentedControlNoSegment : 0);
136 136
137 // activity/image state 137 // activity/image state
138 // 138 //
@@ -145,28 +145,28 @@ typedef enum { @@ -145,28 +145,28 @@ typedef enum {
145 options:UIViewAnimationOptionBeginFromCurrentState 145 options:UIViewAnimationOptionBeginFromCurrentState
146 animations:^(void) 146 animations:^(void)
147 { 147 {
148 - buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);  
149 - activityView.transform = CGAffineTransformMakeScale(0.01, 0.01); 148 + _buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
  149 + _activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
150 } 150 }
151 completion:^(BOOL finished) 151 completion:^(BOOL finished)
152 { 152 {
153 - buttonImageView.hidden = YES; 153 + _buttonImageView.hidden = YES;
154 154
155 - [activityView startAnimating]; 155 + [_activityView startAnimating];
156 156
157 [UIView animateWithDuration:0.25 animations:^(void) 157 [UIView animateWithDuration:0.25 animations:^(void)
158 { 158 {
159 - buttonImageView.transform = CGAffineTransformIdentity;  
160 - activityView.transform = CGAffineTransformIdentity; 159 + _buttonImageView.transform = CGAffineTransformIdentity;
  160 + _activityView.transform = CGAffineTransformIdentity;
161 }]; 161 }];
162 }]; 162 }];
163 163
164 - state = RMUserTrackingButtonStateActivity; 164 + _state = RMUserTrackingButtonStateActivity;
165 } 165 }
166 else 166 else
167 { 167 {
168 - if ((_mapView.userTrackingMode != RMUserTrackingModeFollowWithHeading && state != RMUserTrackingButtonStateLocation) ||  
169 - (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading && state != RMUserTrackingButtonStateHeading)) 168 + if ((_mapView.userTrackingMode != RMUserTrackingModeFollowWithHeading && _state != RMUserTrackingButtonStateLocation) ||
  169 + (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading && _state != RMUserTrackingButtonStateHeading))
170 { 170 {
171 // if image state doesn't match mode, update it 171 // if image state doesn't match mode, update it
172 // 172 //
@@ -175,24 +175,24 @@ typedef enum { @@ -175,24 +175,24 @@ typedef enum {
175 options:UIViewAnimationOptionBeginFromCurrentState 175 options:UIViewAnimationOptionBeginFromCurrentState
176 animations:^(void) 176 animations:^(void)
177 { 177 {
178 - buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);  
179 - activityView.transform = CGAffineTransformMakeScale(0.01, 0.01); 178 + _buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
  179 + _activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
180 } 180 }
181 completion:^(BOOL finished) 181 completion:^(BOOL finished)
182 { 182 {
183 - buttonImageView.image = [UIImage imageNamed:(_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? @"TrackingHeading.png" : @"TrackingLocation.png")];  
184 - buttonImageView.hidden = NO; 183 + _buttonImageView.image = [UIImage imageNamed:(_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? @"TrackingHeading.png" : @"TrackingLocation.png")];
  184 + _buttonImageView.hidden = NO;
185 185
186 - [activityView stopAnimating]; 186 + [_activityView stopAnimating];
187 187
188 [UIView animateWithDuration:0.25 animations:^(void) 188 [UIView animateWithDuration:0.25 animations:^(void)
189 { 189 {
190 - buttonImageView.transform = CGAffineTransformIdentity;  
191 - activityView.transform = CGAffineTransformIdentity; 190 + _buttonImageView.transform = CGAffineTransformIdentity;
  191 + _activityView.transform = CGAffineTransformIdentity;
192 }]; 192 }];
193 }]; 193 }];
194 194
195 - state = (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? RMUserTrackingButtonStateHeading : RMUserTrackingButtonStateLocation); 195 + _state = (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? RMUserTrackingButtonStateHeading : RMUserTrackingButtonStateLocation);
196 } 196 }
197 } 197 }
198 } 198 }
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 #endif 12 #endif
13 13
14 #if DEBUG 14 #if DEBUG
15 -#define RMLog(args...) NSLog(@"%@", [NSString stringWithFormat: args]) 15 +#define RMLog(args...) NSLog(@"%@", [NSString stringWithFormat: args])
16 #define LogMethod() NSLog(@"logged method call: -[%@ %@] (line %d)", self, NSStringFromSelector(_cmd), __LINE__) 16 #define LogMethod() NSLog(@"logged method call: -[%@ %@] (line %d)", self, NSStringFromSelector(_cmd), __LINE__)
17 #define WarnDeprecated() NSLog(@"***** WARNING: deprecated method call: -[%@ %@] (line %d)", self, NSStringFromSelector(_cmd), __LINE__) 17 #define WarnDeprecated() NSLog(@"***** WARNING: deprecated method call: -[%@ %@] (line %d)", self, NSStringFromSelector(_cmd), __LINE__)
18 #else 18 #else