Authored by Thomas Rasch

o Refactoring: Moved error and missing tiles to RMTileImage

... ... @@ -59,6 +59,9 @@
+ (RMTileImage *)dummyTile:(RMTile)tile;
+ (UIImage *)errorTile;
+ (UIImage *)missingTile;
//- (void)drawInRect:(CGRect)rect;
- (void)draw;
... ...
... ... @@ -36,6 +36,11 @@
#import "RMTileCache.h"
#import "RMPixel.h"
static BOOL _didLoadErrorTile = NO;
static BOOL _didLoadMissingTile = NO;
static UIImage *_errorTile = nil;
static UIImage *_missingTile = nil;
@implementation RMTileImage
@synthesize screenLocation, tile, layer, lastUsedTime;
... ... @@ -84,6 +89,39 @@
[super dealloc];
}
#pragma mark -
/// \bug This functionality belongs on the tile source, and should not be freestanding.
+ (UIImage *)errorTile
{
if (_errorTile)
return _errorTile;
if (_didLoadErrorTile)
return nil;
_errorTile = [[UIImage imageNamed:@"error.png"] retain];
_didLoadErrorTile = YES;
return _errorTile;
}
+ (UIImage *)missingTile
{
if (_missingTile)
return _missingTile;
if (_didLoadMissingTile)
return nil;
_missingTile = [[UIImage imageNamed:@"missing.png"] retain];
_didLoadMissingTile = YES;
return _missingTile;
}
#pragma mark -
- (void)draw
{
}
... ...
//
// RMTileProxy.h
//
// Copyright (c) 2008-2009, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/Foundation.h>
#import "RMTile.h"
@class RMTileImage;
/// Has only class methods defined, to return generic "error image", "not-yet-loaded image", and proxy images.
/// \bug This functionality belongs on the tile source, and should not be freestanding.
@interface RMTileProxy : NSObject {
}
+ (UIImage *)errorTile;
+ (UIImage *)missingTile;
@end
//
// RMTileProxy.m
//
// Copyright (c) 2008-2009, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#import "RMTileProxy.h"
@implementation RMTileProxy
static BOOL _didLoadErrorTile = NO;
static BOOL _didLoadMissingTile = NO;
static UIImage *_errorTile = nil;
static UIImage *_missingTile = nil;
+ (UIImage *)errorTile
{
if (_errorTile)
return _errorTile;
if (_didLoadErrorTile)
return nil;
_errorTile = [[UIImage imageNamed:@"error.png"] retain];
_didLoadErrorTile = YES;
return _errorTile;
}
+ (UIImage *)missingTile
{
if (_missingTile)
return _missingTile;
if (_didLoadMissingTile)
return nil;
_missingTile = [[UIImage imageNamed:@"missing.png"] retain];
_didLoadMissingTile = YES;
return _missingTile;
}
@end
... ... @@ -99,8 +99,7 @@ NSString *RMWebTileImageNotificationErrorKey = @"RMWebTileImageNotificationError
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
if (!connection) {
[super displayProxy:[RMTileProxy errorTile]];
[[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:self];
[super displayProxy:[RMTileImage errorTile]];
}
}
... ... @@ -147,7 +146,7 @@ NSString *RMWebTileImageNotificationErrorKey = @"RMWebTileImageNotificationError
if (statusCode < 400) { // Success
}
else if (statusCode == 404) { // Not Found
[super displayProxy:[RMTileProxy missingTile]];
[super displayProxy:[RMTileImage missingTile]];
NSError *error = [NSError errorWithDomain:RMWebTileImageErrorDomain
code:RMWebTileImageErrorNotFoundResponse
... ...
... ... @@ -81,7 +81,6 @@
2BEC604E0F8AC73D008FB858 /* RMTileImage.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64D90E80E73F001663B6 /* RMTileImage.m */; };
2BEC604F0F8AC73E008FB858 /* RMTileImageSet.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64E10E80E73F001663B6 /* RMTileImageSet.m */; };
2BEC60500F8AC73F008FB858 /* RMTileLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64C70E80E73F001663B6 /* RMTileLoader.m */; };
2BEC60510F8AC740008FB858 /* RMTileProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64DB0E80E73F001663B6 /* RMTileProxy.m */; };
2BEC60540F8AC744008FB858 /* RMWebTileImage.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64DD0E80E73F001663B6 /* RMWebTileImage.m */; };
2BEC60960F8ACBF1008FB858 /* libProj4.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 38D818500F6F67B90034598B /* libProj4.a */; };
2BEC612D0F8ACC1E008FB858 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B83E65590E80E7EB001663B6 /* CoreFoundation.framework */; };
... ... @@ -145,8 +144,6 @@
B8C9745D0E8A19E6007D16AD /* RMTileImageSet.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64E10E80E73F001663B6 /* RMTileImageSet.m */; };
B8C9745E0E8A19E6007D16AD /* RMTileLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64C60E80E73F001663B6 /* RMTileLoader.h */; };
B8C9745F0E8A19E7007D16AD /* RMTileLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64C70E80E73F001663B6 /* RMTileLoader.m */; };
B8C974600E8A19E7007D16AD /* RMTileProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64DA0E80E73F001663B6 /* RMTileProxy.h */; };
B8C974610E8A19E8007D16AD /* RMTileProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64DB0E80E73F001663B6 /* RMTileProxy.m */; };
B8C974620E8A19E8007D16AD /* RMTileSource.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64EC0E80E73F001663B6 /* RMTileSource.h */; };
B8C974670E8A19EB007D16AD /* RMWebTileImage.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64DC0E80E73F001663B6 /* RMWebTileImage.h */; };
B8C974680E8A19EB007D16AD /* RMWebTileImage.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64DD0E80E73F001663B6 /* RMWebTileImage.m */; };
... ... @@ -265,8 +262,6 @@
B83E64D70E80E73F001663B6 /* RMTile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = RMTile.c; sourceTree = "<group>"; };
B83E64D80E80E73F001663B6 /* RMTileImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMTileImage.h; sourceTree = "<group>"; };
B83E64D90E80E73F001663B6 /* RMTileImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMTileImage.m; sourceTree = "<group>"; };
B83E64DA0E80E73F001663B6 /* RMTileProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMTileProxy.h; sourceTree = "<group>"; };
B83E64DB0E80E73F001663B6 /* RMTileProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMTileProxy.m; sourceTree = "<group>"; };
B83E64DC0E80E73F001663B6 /* RMWebTileImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMWebTileImage.h; sourceTree = "<group>"; };
B83E64DD0E80E73F001663B6 /* RMWebTileImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMWebTileImage.m; sourceTree = "<group>"; };
B83E64DE0E80E73F001663B6 /* RMFileTileImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMFileTileImage.h; sourceTree = "<group>"; };
... ... @@ -515,8 +510,6 @@
B83E64D90E80E73F001663B6 /* RMTileImage.m */,
D1437B31122869E400888DAE /* RMDBTileImage.h */,
D1437B30122869E400888DAE /* RMDBTileImage.m */,
B83E64DA0E80E73F001663B6 /* RMTileProxy.h */,
B83E64DB0E80E73F001663B6 /* RMTileProxy.m */,
B83E64DC0E80E73F001663B6 /* RMWebTileImage.h */,
B83E64DD0E80E73F001663B6 /* RMWebTileImage.m */,
B83E64DE0E80E73F001663B6 /* RMFileTileImage.h */,
... ... @@ -707,7 +700,6 @@
B8C974310E8A19B2007D16AD /* RMAbstractMercatorWebSource.h in Headers */,
B8C9745C0E8A19E5007D16AD /* RMTileImageSet.h in Headers */,
B8C9745E0E8A19E6007D16AD /* RMTileLoader.h in Headers */,
B8C974600E8A19E7007D16AD /* RMTileProxy.h in Headers */,
B8C974620E8A19E8007D16AD /* RMTileSource.h in Headers */,
B8C974670E8A19EB007D16AD /* RMWebTileImage.h in Headers */,
B8C9746B0E8A1A50007D16AD /* RMMapView.h in Headers */,
... ... @@ -908,7 +900,6 @@
2BEC604E0F8AC73D008FB858 /* RMTileImage.m in Sources */,
2BEC604F0F8AC73E008FB858 /* RMTileImageSet.m in Sources */,
2BEC60500F8AC73F008FB858 /* RMTileLoader.m in Sources */,
2BEC60510F8AC740008FB858 /* RMTileProxy.m in Sources */,
2BEC60540F8AC744008FB858 /* RMWebTileImage.m in Sources */,
2B5BDCDB0F8C17A500848078 /* GTMCALayer+UnitTesting.m in Sources */,
2B5BDCDC0F8C17A500848078 /* GTMIPhoneUnitTestDelegate.m in Sources */,
... ... @@ -942,7 +933,6 @@
B8C9744C0E8A19B2007D16AD /* RMAbstractMercatorWebSource.m in Sources */,
B8C9745D0E8A19E6007D16AD /* RMTileImageSet.m in Sources */,
B8C9745F0E8A19E7007D16AD /* RMTileLoader.m in Sources */,
B8C974610E8A19E8007D16AD /* RMTileProxy.m in Sources */,
B8C974680E8A19EB007D16AD /* RMWebTileImage.m in Sources */,
B8C9746C0E8A1A50007D16AD /* RMMapView.m in Sources */,
B8C974B90E8A280A007D16AD /* RMMapContents.m in Sources */,
... ...