corrected use of -description in tile cache, and added parameterization of CloudMade tiles
Showing
10 changed files
with
46 additions
and
20 deletions
@@ -92,5 +92,10 @@ | @@ -92,5 +92,10 @@ | ||
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | +-(NSString *)uniqueTilecacheKey | ||
96 | +{ | ||
97 | + @throw [NSException exceptionWithName:@"RMAbstractMethodInvocation" reason:@"uniqueTilecacheKey invoked on AbstractMercatorWebSource. Override this method when instantiating abstract class." userInfo:nil]; | ||
98 | +} | ||
99 | + | ||
95 | @end | 100 | @end |
96 | 101 |
@@ -31,9 +31,13 @@ | @@ -31,9 +31,13 @@ | ||
31 | 31 | ||
32 | @interface RMCloudMadeMapSource : RMAbstractMercatorWebSource <RMAbstractMercatorWebSource> | 32 | @interface RMCloudMadeMapSource : RMAbstractMercatorWebSource <RMAbstractMercatorWebSource> |
33 | { | 33 | { |
34 | - | 34 | + NSUInteger cloudmadeStyleNumber; |
35 | } | 35 | } |
36 | 36 | ||
37 | -+(int)tileSideLength; | 37 | +/// designated initializer |
38 | +- (id) initWithStyleNumber:(NSUInteger)styleNumber; | ||
39 | + | ||
40 | ++ (int)tileSideLength; | ||
41 | +- (id)initWithStyleNumber:(NSUInteger)theCloudmadeStyleNumber; | ||
38 | 42 | ||
39 | @end | 43 | @end |
@@ -31,17 +31,39 @@ | @@ -31,17 +31,39 @@ | ||
31 | 31 | ||
32 | @implementation RMCloudMadeMapSource | 32 | @implementation RMCloudMadeMapSource |
33 | 33 | ||
34 | --(NSString*) tileURL: (RMTile) tile | 34 | +#define kDefaultCloudMadeStyleNumber 7 |
35 | + | ||
36 | +- (id) init | ||
37 | +{ | ||
38 | + return [self initWithStyleNumber:kDefaultCloudMadeStyleNumber]; | ||
39 | +} | ||
40 | + | ||
41 | +/// designated initializer | ||
42 | +- (id) initWithStyleNumber:(NSUInteger)styleNumber | ||
43 | +{ | ||
44 | + NSAssert((styleNumber > 0), @"CloudMade style number must be positive"); | ||
45 | + if (self = [super init]) { | ||
46 | + if (styleNumber > 0) | ||
47 | + cloudmadeStyleNumber = styleNumber; | ||
48 | + else | ||
49 | + cloudmadeStyleNumber = kDefaultCloudMadeStyleNumber; | ||
50 | + } | ||
51 | + return self; | ||
52 | +} | ||
53 | + | ||
54 | +- (NSString*) tileURL: (RMTile) tile | ||
35 | { | 55 | { |
36 | NSAssert4(((tile.zoom >= self.minZoom) && (tile.zoom <= self.maxZoom)), | 56 | NSAssert4(((tile.zoom >= self.minZoom) && (tile.zoom <= self.maxZoom)), |
37 | @"%@ tried to retrieve tile with zoomLevel %d, outside source's defined range %f to %f", | 57 | @"%@ tried to retrieve tile with zoomLevel %d, outside source's defined range %f to %f", |
38 | self, tile.zoom, self.minZoom, self.maxZoom); | 58 | self, tile.zoom, self.minZoom, self.maxZoom); |
39 | - return [NSString stringWithFormat:@"http://a.tile.cloudmade.com/0199bdee456e59ce950b0156029d6934/2/%d/%d/%d/%d.png",[RMCloudMadeMapSource tileSideLength], tile.zoom, tile.x, tile.y]; | 59 | + return [NSString stringWithFormat:@"http://tile.cloudmade.com/0199bdee456e59ce950b0156029d6934/%d/%d/%d/%d/%d.png", |
60 | + cloudmadeStyleNumber, | ||
61 | + [RMCloudMadeMapSource tileSideLength], tile.zoom, tile.x, tile.y]; | ||
40 | } | 62 | } |
41 | 63 | ||
42 | --(NSString*) description | 64 | +-(NSString*) uniqueTilecacheKey |
43 | { | 65 | { |
44 | - return @"CloudMadeMaps"; | 66 | + return [NSString stringWithFormat:@"CloudMadeMaps%d", cloudmadeStyleNumber]; |
45 | } | 67 | } |
46 | 68 | ||
47 | +(int)tileSideLength | 69 | +(int)tileSideLength |
@@ -116,11 +116,6 @@ | @@ -116,11 +116,6 @@ | ||
116 | [[image layer] removeFromSuperlayer]; | 116 | [[image layer] removeFromSuperlayer]; |
117 | } | 117 | } |
118 | 118 | ||
119 | --(NSString*) description | ||
120 | -{ | ||
121 | - return @"CoreAnimation map renderer"; | ||
122 | -} | ||
123 | - | ||
124 | - (void)setFrame:(CGRect)frame | 119 | - (void)setFrame:(CGRect)frame |
125 | { | 120 | { |
126 | layer.frame = [content screenBounds]; | 121 | layer.frame = [content screenBounds]; |
@@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
46 | 46 | ||
47 | if ([paths count] > 0) // Should only be one... | 47 | if ([paths count] > 0) // Should only be one... |
48 | { | 48 | { |
49 | - NSString *filename = [NSString stringWithFormat:@"Map%@.sqlite", [source description]]; | 49 | + NSString *filename = [NSString stringWithFormat:@"Map%@.sqlite", [source uniqueTilecacheKey]]; |
50 | 50 | ||
51 | return [[paths objectAtIndex:0] stringByAppendingPathComponent:filename]; | 51 | return [[paths objectAtIndex:0] stringByAppendingPathComponent:filename]; |
52 | } | 52 | } |
@@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
37 | return [NSString stringWithFormat:@"http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/%d/%d/%d.png", tile.zoom, tile.x, tile.y]; | 37 | return [NSString stringWithFormat:@"http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/%d/%d/%d.png", tile.zoom, tile.x, tile.y]; |
38 | } | 38 | } |
39 | 39 | ||
40 | --(NSString*) description | 40 | +-(NSString*) uniqueTilecacheKey |
41 | { | 41 | { |
42 | return @"OpenAerialMap"; | 42 | return @"OpenAerialMap"; |
43 | } | 43 | } |
@@ -37,9 +37,9 @@ | @@ -37,9 +37,9 @@ | ||
37 | return [NSString stringWithFormat:@"http://tile.openstreetmap.org/%d/%d/%d.png", tile.zoom, tile.x, tile.y]; | 37 | return [NSString stringWithFormat:@"http://tile.openstreetmap.org/%d/%d/%d.png", tile.zoom, tile.x, tile.y]; |
38 | } | 38 | } |
39 | 39 | ||
40 | --(NSString*) description | 40 | +-(NSString*) uniqueTilecacheKey |
41 | { | 41 | { |
42 | - return @"OpenStreetMaps"; | 42 | + return @"OpenStreetMap"; |
43 | } | 43 | } |
44 | 44 | ||
45 | @end | 45 | @end |
@@ -73,9 +73,9 @@ | @@ -73,9 +73,9 @@ | ||
73 | return [NSString stringWithFormat:@"http://%@%d.ortho.tiles.virtualearth.net/tiles/%@%@%@?g=15", mapType, 3, mapType, quadKey, mapExtension]; | 73 | return [NSString stringWithFormat:@"http://%@%d.ortho.tiles.virtualearth.net/tiles/%@%@%@?g=15", mapType, 3, mapType, quadKey, mapExtension]; |
74 | } | 74 | } |
75 | 75 | ||
76 | --(NSString*) description | 76 | +-(NSString*) uniqueTilecacheKey |
77 | { | 77 | { |
78 | - return @"Microsoft VirtualEarth"; | 78 | + return @"MicrosoftVirtualEarth"; |
79 | } | 79 | } |
80 | 80 | ||
81 | @end | 81 | @end |
@@ -691,9 +691,7 @@ | @@ -691,9 +691,7 @@ | ||
691 | GCC_ENABLE_FIX_AND_CONTINUE = NO; | 691 | GCC_ENABLE_FIX_AND_CONTINUE = NO; |
692 | GCC_PRECOMPILE_PREFIX_HEADER = YES; | 692 | GCC_PRECOMPILE_PREFIX_HEADER = YES; |
693 | GCC_PREFIX_HEADER = MapView_Prefix.pch; | 693 | GCC_PREFIX_HEADER = MapView_Prefix.pch; |
694 | - GCC_PREPROCESSOR_DEFINITIONS = ( | ||
695 | - "NS_BLOCK_ASSERTIONS=1", | ||
696 | - ); | 694 | + GCC_PREPROCESSOR_DEFINITIONS = "NS_BLOCK_ASSERTIONS=1"; |
697 | HEADER_SEARCH_PATHS = ../Proj4; | 695 | HEADER_SEARCH_PATHS = ../Proj4; |
698 | PREBINDING = NO; | 696 | PREBINDING = NO; |
699 | PRODUCT_NAME = MapView; | 697 | PRODUCT_NAME = MapView; |
-
Please register or login to post a comment