Authored by Hal Mueller

corrected use of -description in tile cache, and added parameterization of CloudMade tiles

... ... @@ -92,5 +92,10 @@
{
}
-(NSString *)uniqueTilecacheKey
{
@throw [NSException exceptionWithName:@"RMAbstractMethodInvocation" reason:@"uniqueTilecacheKey invoked on AbstractMercatorWebSource. Override this method when instantiating abstract class." userInfo:nil];
}
@end
... ...
... ... @@ -31,9 +31,13 @@
@interface RMCloudMadeMapSource : RMAbstractMercatorWebSource <RMAbstractMercatorWebSource>
{
NSUInteger cloudmadeStyleNumber;
}
+(int)tileSideLength;
/// designated initializer
- (id) initWithStyleNumber:(NSUInteger)styleNumber;
+ (int)tileSideLength;
- (id)initWithStyleNumber:(NSUInteger)theCloudmadeStyleNumber;
@end
... ...
... ... @@ -31,17 +31,39 @@
@implementation RMCloudMadeMapSource
-(NSString*) tileURL: (RMTile) tile
#define kDefaultCloudMadeStyleNumber 7
- (id) init
{
return [self initWithStyleNumber:kDefaultCloudMadeStyleNumber];
}
/// designated initializer
- (id) initWithStyleNumber:(NSUInteger)styleNumber
{
NSAssert((styleNumber > 0), @"CloudMade style number must be positive");
if (self = [super init]) {
if (styleNumber > 0)
cloudmadeStyleNumber = styleNumber;
else
cloudmadeStyleNumber = kDefaultCloudMadeStyleNumber;
}
return self;
}
- (NSString*) tileURL: (RMTile) tile
{
NSAssert4(((tile.zoom >= self.minZoom) && (tile.zoom <= self.maxZoom)),
@"%@ tried to retrieve tile with zoomLevel %d, outside source's defined range %f to %f",
self, tile.zoom, self.minZoom, self.maxZoom);
return [NSString stringWithFormat:@"http://a.tile.cloudmade.com/0199bdee456e59ce950b0156029d6934/2/%d/%d/%d/%d.png",[RMCloudMadeMapSource tileSideLength], tile.zoom, tile.x, tile.y];
return [NSString stringWithFormat:@"http://tile.cloudmade.com/0199bdee456e59ce950b0156029d6934/%d/%d/%d/%d/%d.png",
cloudmadeStyleNumber,
[RMCloudMadeMapSource tileSideLength], tile.zoom, tile.x, tile.y];
}
-(NSString*) description
-(NSString*) uniqueTilecacheKey
{
return @"CloudMadeMaps";
return [NSString stringWithFormat:@"CloudMadeMaps%d", cloudmadeStyleNumber];
}
+(int)tileSideLength
... ...
... ... @@ -116,11 +116,6 @@
[[image layer] removeFromSuperlayer];
}
-(NSString*) description
{
return @"CoreAnimation map renderer";
}
- (void)setFrame:(CGRect)frame
{
layer.frame = [content screenBounds];
... ...
... ... @@ -46,7 +46,7 @@
if ([paths count] > 0) // Should only be one...
{
NSString *filename = [NSString stringWithFormat:@"Map%@.sqlite", [source description]];
NSString *filename = [NSString stringWithFormat:@"Map%@.sqlite", [source uniqueTilecacheKey]];
return [[paths objectAtIndex:0] stringByAppendingPathComponent:filename];
}
... ...
... ... @@ -37,7 +37,7 @@
return [NSString stringWithFormat:@"http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/%d/%d/%d.png", tile.zoom, tile.x, tile.y];
}
-(NSString*) description
-(NSString*) uniqueTilecacheKey
{
return @"OpenAerialMap";
}
... ...
... ... @@ -37,9 +37,9 @@
return [NSString stringWithFormat:@"http://tile.openstreetmap.org/%d/%d/%d.png", tile.zoom, tile.x, tile.y];
}
-(NSString*) description
-(NSString*) uniqueTilecacheKey
{
return @"OpenStreetMaps";
return @"OpenStreetMap";
}
@end
... ...
... ... @@ -48,4 +48,6 @@
-(void) didReceiveMemoryWarning;
-(NSString *)uniqueTilecacheKey;
@end
... ...
... ... @@ -73,9 +73,9 @@
return [NSString stringWithFormat:@"http://%@%d.ortho.tiles.virtualearth.net/tiles/%@%@%@?g=15", mapType, 3, mapType, quadKey, mapExtension];
}
-(NSString*) description
-(NSString*) uniqueTilecacheKey
{
return @"Microsoft VirtualEarth";
return @"MicrosoftVirtualEarth";
}
@end
... ...
... ... @@ -691,9 +691,7 @@
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = MapView_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = (
"NS_BLOCK_ASSERTIONS=1",
);
GCC_PREPROCESSOR_DEFINITIONS = "NS_BLOCK_ASSERTIONS=1";
HEADER_SEARCH_PATHS = ../Proj4;
PREBINDING = NO;
PRODUCT_NAME = MapView;
... ...