Authored by Justin R. Miller

merged upstream develop

... ... @@ -593,8 +593,6 @@
- (RMProjectedRect)projectedRectFromLatitudeLongitudeBounds:(RMSphericalTrapezium)bounds
{
float pixelBuffer = kZoomRectPixelBuffer;
CLLocationCoordinate2D southWest = bounds.southWest;
CLLocationCoordinate2D northEast = bounds.northEast;
CLLocationCoordinate2D midpoint = {
... ... @@ -619,18 +617,18 @@
if ((myPoint.x / self.bounds.size.width) < (myPoint.y / self.bounds.size.height))
{
if ((myPoint.y / (self.bounds.size.height - pixelBuffer)) > 1)
if ((myPoint.y / self.bounds.size.height) > 1)
{
zoomRect.size.width = self.bounds.size.width * (myPoint.y / (self.bounds.size.height - pixelBuffer));
zoomRect.size.height = self.bounds.size.height * (myPoint.y / (self.bounds.size.height - pixelBuffer));
zoomRect.size.width = self.bounds.size.width * (myPoint.y / self.bounds.size.height);
zoomRect.size.height = self.bounds.size.height * (myPoint.y / self.bounds.size.height);
}
}
else
{
if ((myPoint.x / (self.bounds.size.width - pixelBuffer)) > 1)
if ((myPoint.x / self.bounds.size.width) > 1)
{
zoomRect.size.width = self.bounds.size.width * (myPoint.x / (self.bounds.size.width - pixelBuffer));
zoomRect.size.height = self.bounds.size.height * (myPoint.x / (self.bounds.size.width - pixelBuffer));
zoomRect.size.width = self.bounds.size.width * (myPoint.x / self.bounds.size.width);
zoomRect.size.height = self.bounds.size.height * (myPoint.x / self.bounds.size.width);
}
}
... ... @@ -1020,8 +1018,6 @@
else
{
// Convert northEast/southWest into RMMercatorRect and call zoomWithBounds
float pixelBuffer = kZoomRectPixelBuffer;
CLLocationCoordinate2D midpoint = {
.latitude = (northEast.latitude + southWest.latitude) / 2,
.longitude = (northEast.longitude + southWest.longitude) / 2
... ... @@ -1044,18 +1040,18 @@
if ((myPoint.x / self.bounds.size.width) < (myPoint.y / self.bounds.size.height))
{
if ((myPoint.y / (self.bounds.size.height - pixelBuffer)) > 1)
if ((myPoint.y / self.bounds.size.height) > 1)
{
zoomRect.size.width = self.bounds.size.width * (myPoint.y / (self.bounds.size.height - pixelBuffer));
zoomRect.size.height = self.bounds.size.height * (myPoint.y / (self.bounds.size.height - pixelBuffer));
zoomRect.size.width = self.bounds.size.width * (myPoint.y / self.bounds.size.height);
zoomRect.size.height = self.bounds.size.height * (myPoint.y / self.bounds.size.height);
}
}
else
{
if ((myPoint.x / (self.bounds.size.width - pixelBuffer)) > 1)
if ((myPoint.x / self.bounds.size.width) > 1)
{
zoomRect.size.width = self.bounds.size.width * (myPoint.x / (self.bounds.size.width - pixelBuffer));
zoomRect.size.height = self.bounds.size.height * (myPoint.x / (self.bounds.size.width - pixelBuffer));
zoomRect.size.width = self.bounds.size.width * (myPoint.x / self.bounds.size.width);
zoomRect.size.height = self.bounds.size.height * (myPoint.x / self.bounds.size.width);
}
}
... ...
... ... @@ -98,6 +98,7 @@ typedef enum : short {
*
* @param cache A memory-based or disk-based cache. */
- (void)addCache:(id <RMTileCache>)cache;
- (void)insertCache:(id <RMTileCache>)cache atIndex:(NSUInteger)index;
- (void)didReceiveMemoryWarning;
... ...
... ... @@ -128,6 +128,16 @@
});
}
- (void)insertCache:(id <RMTileCache>)cache atIndex:(NSUInteger)index
{
dispatch_barrier_async(_tileCacheQueue, ^{
if (index >= [_tileCaches count])
[_tileCaches addObject:cache];
else
[_tileCaches insertObject:cache atIndex:index];
});
}
+ (NSNumber *)tileHash:(RMTile)tile
{
return [NSNumber numberWithUnsignedLongLong:RMTileKey(tile)];
... ...
... ... @@ -12,9 +12,9 @@
@implementation RMUserLocation
@synthesize updating;
@synthesize location;
@synthesize heading;
@synthesize updating = _updating;
@synthesize location = _location;
@synthesize heading = _heading;
- (id)initWithMapView:(RMMapView *)aMapView coordinate:(CLLocationCoordinate2D)aCoordinate andTitle:(NSString *)aTitle
{
... ... @@ -34,8 +34,10 @@
- (void)dealloc
{
[location release]; location = nil;
[heading release]; heading = nil;
[layer release]; layer = nil;
[annotationType release]; annotationType = nil;
[_location release]; _location = nil;
[_heading release]; _heading = nil;
[super dealloc];
}
... ... @@ -46,23 +48,23 @@
- (void)setLocation:(CLLocation *)newLocation
{
if ([newLocation distanceFromLocation:location] && newLocation.coordinate.latitude != 0 && newLocation.coordinate.longitude != 0)
if ([newLocation distanceFromLocation:_location] && newLocation.coordinate.latitude != 0 && newLocation.coordinate.longitude != 0)
{
[self willChangeValueForKey:@"location"];
[location release];
location = [newLocation retain];
self.coordinate = location.coordinate;
[_location release];
_location = [newLocation retain];
self.coordinate = _location.coordinate;
[self didChangeValueForKey:@"location"];
}
}
- (void)setHeading:(CLHeading *)newHeading
{
if (newHeading.trueHeading != heading.trueHeading)
if (newHeading.trueHeading != _heading.trueHeading)
{
[self willChangeValueForKey:@"heading"];
[heading release];
heading = [newHeading retain];
[_heading release];
_heading = [newHeading retain];
[self didChangeValueForKey:@"heading"];
}
}
... ...
... ... @@ -34,39 +34,39 @@ typedef enum {
@implementation RMUserTrackingBarButtonItem
@synthesize mapView = _mapView;
@synthesize segmentedControl;
@synthesize buttonImageView;
@synthesize activityView;
@synthesize state;
@synthesize segmentedControl = _segmentedControl;
@synthesize buttonImageView = _buttonImageView;
@synthesize activityView = _activityView;
@synthesize state = _state;
- (id)initWithMapView:(RMMapView *)mapView
{
if ( ! (self = [super initWithCustomView:[[UIControl alloc] initWithFrame:CGRectMake(0, 0, 32, 32)]]))
return nil;
segmentedControl = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@""]] retain];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[segmentedControl setWidth:32.0 forSegmentAtIndex:0];
segmentedControl.userInteractionEnabled = NO;
segmentedControl.tintColor = self.tintColor;
segmentedControl.center = self.customView.center;
_segmentedControl = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@""]] retain];
_segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[_segmentedControl setWidth:32.0 forSegmentAtIndex:0];
_segmentedControl.userInteractionEnabled = NO;
_segmentedControl.tintColor = self.tintColor;
_segmentedControl.center = self.customView.center;
[self.customView addSubview:segmentedControl];
[self.customView addSubview:_segmentedControl];
buttonImageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TrackingLocation.png"]] retain];
buttonImageView.contentMode = UIViewContentModeCenter;
buttonImageView.frame = CGRectMake(0, 0, 32, 32);
buttonImageView.center = self.customView.center;
buttonImageView.userInteractionEnabled = NO;
_buttonImageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TrackingLocation.png"]] retain];
_buttonImageView.contentMode = UIViewContentModeCenter;
_buttonImageView.frame = CGRectMake(0, 0, 32, 32);
_buttonImageView.center = self.customView.center;
_buttonImageView.userInteractionEnabled = NO;
[self.customView addSubview:buttonImageView];
[self.customView addSubview:_buttonImageView];
activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] retain];
activityView.hidesWhenStopped = YES;
activityView.center = self.customView.center;
activityView.userInteractionEnabled = NO;
_activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] retain];
_activityView.hidesWhenStopped = YES;
_activityView.center = self.customView.center;
_activityView.userInteractionEnabled = NO;
[self.customView addSubview:activityView];
[self.customView addSubview:_activityView];
[((UIControl *)self.customView) addTarget:self action:@selector(changeMode:) forControlEvents:UIControlEventTouchUpInside];
... ... @@ -75,7 +75,7 @@ typedef enum {
[_mapView addObserver:self forKeyPath:@"userTrackingMode" options:NSKeyValueObservingOptionNew context:nil];
[_mapView addObserver:self forKeyPath:@"userLocation.location" options:NSKeyValueObservingOptionNew context:nil];
state = RMUserTrackingButtonStateLocation;
_state = RMUserTrackingButtonStateLocation;
[self updateAppearance];
... ... @@ -84,9 +84,9 @@ typedef enum {
- (void)dealloc
{
[segmentedControl release]; segmentedControl = nil;
[buttonImageView release]; buttonImageView = nil;
[activityView release]; activityView = nil;
[_segmentedControl release]; _segmentedControl = nil;
[_buttonImageView release]; _buttonImageView = nil;
[_activityView release]; _activityView = nil;
[_mapView removeObserver:self forKeyPath:@"userTrackingMode"];
[_mapView removeObserver:self forKeyPath:@"userLocation.location"];
[_mapView release]; _mapView = nil;
... ... @@ -116,7 +116,7 @@ typedef enum {
{
[super setTintColor:newTintColor];
segmentedControl.tintColor = newTintColor;
_segmentedControl.tintColor = newTintColor;
}
#pragma mark -
... ... @@ -132,7 +132,7 @@ typedef enum {
{
// "selection" state
//
segmentedControl.selectedSegmentIndex = (_mapView.userTrackingMode == RMUserTrackingModeNone ? UISegmentedControlNoSegment : 0);
_segmentedControl.selectedSegmentIndex = (_mapView.userTrackingMode == RMUserTrackingModeNone ? UISegmentedControlNoSegment : 0);
// activity/image state
//
... ... @@ -145,28 +145,28 @@ typedef enum {
options:UIViewAnimationOptionBeginFromCurrentState
animations:^(void)
{
buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
_buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
_activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
}
completion:^(BOOL finished)
{
buttonImageView.hidden = YES;
_buttonImageView.hidden = YES;
[activityView startAnimating];
[_activityView startAnimating];
[UIView animateWithDuration:0.25 animations:^(void)
{
buttonImageView.transform = CGAffineTransformIdentity;
activityView.transform = CGAffineTransformIdentity;
_buttonImageView.transform = CGAffineTransformIdentity;
_activityView.transform = CGAffineTransformIdentity;
}];
}];
state = RMUserTrackingButtonStateActivity;
_state = RMUserTrackingButtonStateActivity;
}
else
{
if ((_mapView.userTrackingMode != RMUserTrackingModeFollowWithHeading && state != RMUserTrackingButtonStateLocation) ||
(_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading && state != RMUserTrackingButtonStateHeading))
if ((_mapView.userTrackingMode != RMUserTrackingModeFollowWithHeading && _state != RMUserTrackingButtonStateLocation) ||
(_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading && _state != RMUserTrackingButtonStateHeading))
{
// if image state doesn't match mode, update it
//
... ... @@ -175,24 +175,24 @@ typedef enum {
options:UIViewAnimationOptionBeginFromCurrentState
animations:^(void)
{
buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
_buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
_activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
}
completion:^(BOOL finished)
{
buttonImageView.image = [UIImage imageNamed:(_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? @"TrackingHeading.png" : @"TrackingLocation.png")];
buttonImageView.hidden = NO;
_buttonImageView.image = [UIImage imageNamed:(_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? @"TrackingHeading.png" : @"TrackingLocation.png")];
_buttonImageView.hidden = NO;
[activityView stopAnimating];
[_activityView stopAnimating];
[UIView animateWithDuration:0.25 animations:^(void)
{
buttonImageView.transform = CGAffineTransformIdentity;
activityView.transform = CGAffineTransformIdentity;
_buttonImageView.transform = CGAffineTransformIdentity;
_activityView.transform = CGAffineTransformIdentity;
}];
}];
state = (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? RMUserTrackingButtonStateHeading : RMUserTrackingButtonStateLocation);
_state = (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? RMUserTrackingButtonStateHeading : RMUserTrackingButtonStateLocation);
}
}
}
... ...
... ... @@ -12,7 +12,7 @@
#endif
#if DEBUG
#define RMLog(args...) NSLog(@"%@", [NSString stringWithFormat: args])
#define RMLog(args...) NSLog(@"%@", [NSString stringWithFormat: args])
#define LogMethod() NSLog(@"logged method call: -[%@ %@] (line %d)", self, NSStringFromSelector(_cmd), __LINE__)
#define WarnDeprecated() NSLog(@"***** WARNING: deprecated method call: -[%@ %@] (line %d)", self, NSStringFromSelector(_cmd), __LINE__)
#else
... ...