fixes #110: properly query local tile sources
Showing
1 changed file
with
23 additions
and
10 deletions
@@ -12,6 +12,8 @@ | @@ -12,6 +12,8 @@ | ||
12 | #import "RMTileSource.h" | 12 | #import "RMTileSource.h" |
13 | #import "RMTileImage.h" | 13 | #import "RMTileImage.h" |
14 | #import "RMTileCache.h" | 14 | #import "RMTileCache.h" |
15 | +#import "RMMBTilesSource.h" | ||
16 | +#import "RMDBMapSource.h" | ||
15 | 17 | ||
16 | @implementation RMMapTiledLayerView | 18 | @implementation RMMapTiledLayerView |
17 | { | 19 | { |
@@ -118,20 +120,31 @@ | @@ -118,20 +120,31 @@ | ||
118 | 120 | ||
119 | if (zoom >= _tileSource.minZoom && zoom <= _tileSource.maxZoom) | 121 | if (zoom >= _tileSource.minZoom && zoom <= _tileSource.maxZoom) |
120 | { | 122 | { |
121 | - tileImage = [[_mapView tileCache] cachedImage:RMTileMake(x, y, zoom) withCacheKey:[_tileSource uniqueTilecacheKey]]; | ||
122 | - | ||
123 | - if ( ! tileImage) | 123 | + if ([_tileSource isKindOfClass:[RMMBTilesSource class]] || [_tileSource isKindOfClass:[RMDBMapSource class]]) |
124 | + { | ||
125 | + // for local tiles, query the source directly since trivial blocking | ||
126 | + // | ||
127 | + tileImage = [_tileSource imageForTile:RMTileMake(x, y, zoom) inCache:[_mapView tileCache]]; | ||
128 | + } | ||
129 | + else | ||
124 | { | 130 | { |
125 | - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) | 131 | + // for non-local tiles, consult cache directly first, else fetch asynchronously |
132 | + // | ||
133 | + tileImage = [[_mapView tileCache] cachedImage:RMTileMake(x, y, zoom) withCacheKey:[_tileSource uniqueTilecacheKey]]; | ||
134 | + | ||
135 | + if ( ! tileImage) | ||
126 | { | 136 | { |
127 | - if ([_tileSource imageForTile:RMTileMake(x, y, zoom) inCache:[_mapView tileCache]]) | 137 | + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) |
128 | { | 138 | { |
129 | - dispatch_async(dispatch_get_main_queue(), ^(void) | 139 | + if ([_tileSource imageForTile:RMTileMake(x, y, zoom) inCache:[_mapView tileCache]]) |
130 | { | 140 | { |
131 | - [self.layer setNeedsDisplay]; | ||
132 | - }); | ||
133 | - } | ||
134 | - }); | 141 | + dispatch_async(dispatch_get_main_queue(), ^(void) |
142 | + { | ||
143 | + [self.layer setNeedsDisplay]; | ||
144 | + }); | ||
145 | + } | ||
146 | + }); | ||
147 | + } | ||
135 | } | 148 | } |
136 | } | 149 | } |
137 | 150 |
-
Please register or login to post a comment