Authored by Justin R. Miller

fixes #110: properly query local tile sources

... ... @@ -12,6 +12,8 @@
#import "RMTileSource.h"
#import "RMTileImage.h"
#import "RMTileCache.h"
#import "RMMBTilesSource.h"
#import "RMDBMapSource.h"
@implementation RMMapTiledLayerView
{
... ... @@ -118,20 +120,31 @@
if (zoom >= _tileSource.minZoom && zoom <= _tileSource.maxZoom)
{
tileImage = [[_mapView tileCache] cachedImage:RMTileMake(x, y, zoom) withCacheKey:[_tileSource uniqueTilecacheKey]];
if ( ! tileImage)
if ([_tileSource isKindOfClass:[RMMBTilesSource class]] || [_tileSource isKindOfClass:[RMDBMapSource class]])
{
// for local tiles, query the source directly since trivial blocking
//
tileImage = [_tileSource imageForTile:RMTileMake(x, y, zoom) inCache:[_mapView tileCache]];
}
else
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void)
// for non-local tiles, consult cache directly first, else fetch asynchronously
//
tileImage = [[_mapView tileCache] cachedImage:RMTileMake(x, y, zoom) withCacheKey:[_tileSource uniqueTilecacheKey]];
if ( ! tileImage)
{
if ([_tileSource imageForTile:RMTileMake(x, y, zoom) inCache:[_mapView tileCache]])
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void)
{
dispatch_async(dispatch_get_main_queue(), ^(void)
if ([_tileSource imageForTile:RMTileMake(x, y, zoom) inCache:[_mapView tileCache]])
{
[self.layer setNeedsDisplay];
});
}
});
dispatch_async(dispatch_get_main_queue(), ^(void)
{
[self.layer setNeedsDisplay];
});
}
});
}
}
}
... ...