|
@@ -26,6 +26,8 @@ |
|
@@ -26,6 +26,8 @@ |
26
|
// POSSIBILITY OF SUCH DAMAGE.
|
26
|
// POSSIBILITY OF SUCH DAMAGE.
|
27
|
|
27
|
|
28
|
#import "RMTileCacheDownloadOperation.h"
|
28
|
#import "RMTileCacheDownloadOperation.h"
|
|
|
29
|
+#import "RMAbstractWebMapSource.h"
|
|
|
30
|
+#import "RMConfiguration.h"
|
29
|
|
31
|
|
30
|
@implementation RMTileCacheDownloadOperation
|
32
|
@implementation RMTileCacheDownloadOperation
|
31
|
{
|
33
|
{
|
|
@@ -39,6 +41,8 @@ |
|
@@ -39,6 +41,8 @@ |
39
|
if (!(self = [super init]))
|
41
|
if (!(self = [super init]))
|
40
|
return nil;
|
42
|
return nil;
|
41
|
|
43
|
|
|
|
44
|
+ NSAssert([_source isKindOfClass:[RMAbstractWebMapSource class]], @"only web-based tile sources are supported for downloading");
|
|
|
45
|
+
|
42
|
_tile = tile;
|
46
|
_tile = tile;
|
43
|
_source = source;
|
47
|
_source = source;
|
44
|
_cache = cache;
|
48
|
_cache = cache;
|
|
@@ -54,13 +58,27 @@ |
|
@@ -54,13 +58,27 @@ |
54
|
if ([self isCancelled])
|
58
|
if ([self isCancelled])
|
55
|
return;
|
59
|
return;
|
56
|
|
60
|
|
57
|
- if ( ! [_cache cachedImage:_tile withCacheKey:[_source uniqueTilecacheKey]])
|
61
|
+ if ( ! [_cache cachedImage:_tile withCacheKey:[_source uniqueTilecacheKey] bypassingMemoryCache:YES])
|
58
|
{
|
62
|
{
|
59
|
if ([self isCancelled])
|
63
|
if ([self isCancelled])
|
60
|
return;
|
64
|
return;
|
61
|
|
65
|
|
62
|
- if ( ! [_source imageForTile:_tile inCache:_cache])
|
66
|
+ NSURL *tileURL = [(RMAbstractWebMapSource *)_source URLForTile:_tile];
|
|
|
67
|
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:tileURL];
|
|
|
68
|
+ request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
|
|
|
69
|
+ NSError *error = nil;
|
|
|
70
|
+ NSData *data = [NSURLConnection sendBrandedSynchronousRequest:request
|
|
|
71
|
+ returningResponse:nil
|
|
|
72
|
+ error:&error];
|
|
|
73
|
+
|
|
|
74
|
+ if ( ! data || error != nil)
|
|
|
75
|
+ {
|
63
|
[self cancel];
|
76
|
[self cancel];
|
|
|
77
|
+ }
|
|
|
78
|
+ else
|
|
|
79
|
+ {
|
|
|
80
|
+ [_cache addDiskCachedImageData:data forTile:_tile withCacheKey:[_source uniqueTilecacheKey]];
|
|
|
81
|
+ }
|
64
|
}
|
82
|
}
|
65
|
}
|
83
|
}
|
66
|
|
84
|
|