Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Commit

Permalink
fixes #110: properly query local tile sources
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Sep 11, 2012
1 parent 68a1933 commit ab6b9c1
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions MapView/Map/RMMapTiledLayerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#import "RMTileSource.h"
#import "RMTileImage.h"
#import "RMTileCache.h"
#import "RMMBTilesSource.h"
#import "RMDBMapSource.h"

@implementation RMMapTiledLayerView
{
Expand Down Expand Up @@ -118,20 +120,31 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context

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];
});
}
});
}
}
}

Expand Down

0 comments on commit ab6b9c1

Please sign in to comment.