...
|
...
|
@@ -26,6 +26,8 @@ |
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
#import "RMTileCacheDownloadOperation.h"
|
|
|
#import "RMAbstractWebMapSource.h"
|
|
|
#import "RMConfiguration.h"
|
|
|
|
|
|
@implementation RMTileCacheDownloadOperation
|
|
|
{
|
...
|
...
|
@@ -39,6 +41,8 @@ |
|
|
if (!(self = [super init]))
|
|
|
return nil;
|
|
|
|
|
|
NSAssert([_source isKindOfClass:[RMAbstractWebMapSource class]], @"only web-based tile sources are supported for downloading");
|
|
|
|
|
|
_tile = tile;
|
|
|
_source = source;
|
|
|
_cache = cache;
|
...
|
...
|
@@ -54,13 +58,27 @@ |
|
|
if ([self isCancelled])
|
|
|
return;
|
|
|
|
|
|
if ( ! [_cache cachedImage:_tile withCacheKey:[_source uniqueTilecacheKey]])
|
|
|
if ( ! [_cache cachedImage:_tile withCacheKey:[_source uniqueTilecacheKey] bypassingMemoryCache:YES])
|
|
|
{
|
|
|
if ([self isCancelled])
|
|
|
return;
|
|
|
|
|
|
if ( ! [_source imageForTile:_tile inCache:_cache])
|
|
|
NSURL *tileURL = [(RMAbstractWebMapSource *)_source URLForTile:_tile];
|
|
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:tileURL];
|
|
|
request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
|
|
|
NSError *error = nil;
|
|
|
NSData *data = [NSURLConnection sendBrandedSynchronousRequest:request
|
|
|
returningResponse:nil
|
|
|
error:&error];
|
|
|
|
|
|
if ( ! data || error != nil)
|
|
|
{
|
|
|
[self cancel];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
[_cache addDiskCachedImageData:data forTile:_tile withCacheKey:[_source uniqueTilecacheKey]];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|