Authored by Quazie

Round one of the removing of magic numbers. Please let me know if #defines are …

…what we want, if not I'll change them.  Also, take a peek at RMGlobalConstants.  Thanks
@@ -27,6 +27,12 @@ @@ -27,6 +27,12 @@
27 27
28 #import "RMTileSource.h" 28 #import "RMTileSource.h"
29 29
  30 +#pragma mark --- begin constants ---
  31 +#define kDefaultTileSize 256
  32 +#define kDefaultMinTileZoom 0
  33 +#define kDefaultMaxTileZoom 18
  34 +#pragma mark --- end constants ---
  35 +
30 @protocol RMAbstractMercatorWebSource 36 @protocol RMAbstractMercatorWebSource
31 37
32 -(NSString*) tileURL: (RMTile) tile; 38 -(NSString*) tileURL: (RMTile) tile;
@@ -54,16 +54,16 @@ @@ -54,16 +54,16 @@
54 54
55 +(int)tileSideLength 55 +(int)tileSideLength
56 { 56 {
57 - return 256; 57 + return kDefaultTileSize;
58 } 58 }
59 59
60 -(float) minZoom 60 -(float) minZoom
61 { 61 {
62 - return 0; 62 + return kDefaultMinTileZoom;
63 } 63 }
64 -(float) maxZoom 64 -(float) maxZoom
65 { 65 {
66 - return 18; 66 + return kDefaultMaxTileZoom;
67 } 67 }
68 68
69 /// \bug magic string literals 69 /// \bug magic string literals
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
27 - 27 +#import "RMGlobalConstants.h"
28 #import "RMCoreAnimationRenderer.h" 28 #import "RMCoreAnimationRenderer.h"
29 #import <QuartzCore/QuartzCore.h> 29 #import <QuartzCore/QuartzCore.h>
30 #import "RMTile.h" 30 #import "RMTile.h"
@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 // strange data. 45 // strange data.
46 46
47 layer = [[CAScrollLayer layer] retain]; 47 layer = [[CAScrollLayer layer] retain];
48 - layer.anchorPoint = CGPointMake(0.0f, 0.0f); 48 + layer.anchorPoint = kTheOrigin;
49 layer.masksToBounds = YES; 49 layer.masksToBounds = YES;
50 // If the frame is set incorrectly here, it will be fixed when setRenderer is called in RMMapContents 50 // If the frame is set incorrectly here, it will be fixed when setRenderer is called in RMMapContents
51 layer.frame = [content screenBounds]; 51 layer.frame = [content screenBounds];
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
27 - 27 +#import "RMGlobalConstants.h"
28 #import "RMGeoHash.h" 28 #import "RMGeoHash.h"
29 29
30 static NSString *BASE32 = @"0123456789bcdefghjkmnpqrstuvwxyz"; 30 static NSString *BASE32 = @"0123456789bcdefghjkmnpqrstuvwxyz";
@@ -49,8 +49,8 @@ static NSString *BORDERS[4][2] = @@ -49,8 +49,8 @@ static NSString *BORDERS[4][2] =
49 int bit=0, ch=0; 49 int bit=0, ch=0;
50 NSMutableString *geohash = [[[NSMutableString string] retain] autorelease]; 50 NSMutableString *geohash = [[[NSMutableString string] retain] autorelease];
51 51
52 - CLLocationCoordinate2D loc1 = { -90.0, -180.0 };  
53 - CLLocationCoordinate2D loc2 = { 90.0, 180.0 }; 52 + CLLocationCoordinate2D loc1 = { -kMaxLat, -kMaxLong };
  53 + CLLocationCoordinate2D loc2 = { kMaxLat, kMaxLong };
54 CLLocationDegrees mid; 54 CLLocationDegrees mid;
55 55
56 int hashLen = 0; 56 int hashLen = 0;
@@ -86,10 +86,10 @@ static NSString *BORDERS[4][2] = @@ -86,10 +86,10 @@ static NSString *BORDERS[4][2] =
86 + (void) convert: (NSString *)geohash toMin: (CLLocationCoordinate2D *)loc1 max: (CLLocationCoordinate2D *)loc2 86 + (void) convert: (NSString *)geohash toMin: (CLLocationCoordinate2D *)loc1 max: (CLLocationCoordinate2D *)loc2
87 { 87 {
88 BOOL is_even = TRUE; 88 BOOL is_even = TRUE;
89 - loc1->latitude = -90.0;  
90 - loc1->longitude = -180.0;  
91 - loc2->latitude = 90.0;  
92 - loc2->longitude = 180.0; 89 + loc1->latitude = -kMaxLat;
  90 + loc1->longitude = -kMaxLong;
  91 + loc2->latitude = kMaxLat;
  92 + loc2->longitude = kMaxLong;
93 NSRange range; 93 NSRange range;
94 int cd, mask; 94 int cd, mask;
95 int geohashLen = [geohash length]; 95 int geohashLen = [geohash length];
  1 +/*
  2 + * RMGlobalConstants.h
  3 + * MapView
  4 + *
  5 + * Created by My Home on 4/29/09.
  6 + * Copyright 2009 Brandon "Quazie" Kwaselow. All rights reserved.
  7 + *
  8 + */
  9 +
  10 +#define kTheOrigin CGPointMake(0,0)
  11 +#define kEmptyRect CGRectMake(0, 0, 0, 0)
  12 +#define kMaxLong 180
  13 +#define kMaxLat 90
@@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
31 #import <TargetConditionals.h> 31 #import <TargetConditionals.h>
32 #if TARGET_OS_IPHONE 32 #if TARGET_OS_IPHONE
33 #import <CoreLocation/CoreLocation.h> 33 #import <CoreLocation/CoreLocation.h>
  34 +#import "RMGlobalConstants.h"
34 35
35 /*! \struct RMSphericalTrapezium 36 /*! \struct RMSphericalTrapezium
36 37
@@ -80,9 +81,9 @@ typedef struct { @@ -80,9 +81,9 @@ typedef struct {
80 typedef CLLocationCoordinate2D RMLatLong; 81 typedef CLLocationCoordinate2D RMLatLong;
81 82
82 /// \bug magic numbers 83 /// \bug magic numbers
83 -static const double kRMMinLatitude = -90.0f;  
84 -static const double kRMMaxLatitude = 90.0f;  
85 -static const double kRMMinLongitude = -180.0f;  
86 -static const double kRMMaxLongitude = 180.0f; 84 +static const double kRMMinLatitude = -kMaxLat;
  85 +static const double kRMMaxLatitude = kMaxLat;
  86 +static const double kRMMinLongitude = -kMaxLong;
  87 +static const double kRMMaxLongitude = kMaxLong;
87 88
88 #endif 89 #endif
@@ -43,8 +43,8 @@ enum { @@ -43,8 +43,8 @@ enum {
43 RMMapMinWidthBound = 2 43 RMMapMinWidthBound = 2
44 }; 44 };
45 45
46 -#define kDefaultInitialLatitude -33.858771;  
47 -#define kDefaultInitialLongitude 151.201596; 46 +#define kDefaultInitialLatitude -33.858771
  47 +#define kDefaultInitialLongitude 151.201596
48 48
49 #define kDefaultMinimumZoomLevel 0.0 49 #define kDefaultMinimumZoomLevel 0.0
50 #define kDefaultMaximumZoomLevel 25.0 50 #define kDefaultMaximumZoomLevel 25.0
@@ -24,6 +24,7 @@ @@ -24,6 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
  27 +#import "RMGlobalConstants.h"
27 #import "RMMapContents.h" 28 #import "RMMapContents.h"
28 29
29 #import "RMMapView.h" 30 #import "RMMapView.h"
@@ -47,6 +48,8 @@ @@ -47,6 +48,8 @@
47 #import "RMMarker.h" 48 #import "RMMarker.h"
48 49
49 50
  51 +
  52 +
50 @interface RMMapContents (PrivateMethods) 53 @interface RMMapContents (PrivateMethods)
51 - (void)animatedZoomStep:(NSTimer *)timer; 54 - (void)animatedZoomStep:(NSTimer *)timer;
52 @end 55 @end
@@ -62,6 +65,13 @@ @@ -62,6 +65,13 @@
62 @synthesize maxZoom; 65 @synthesize maxZoom;
63 @synthesize markerManager; 66 @synthesize markerManager;
64 67
  68 +#pragma mark --- begin constants ----
  69 +#define kZoomAnimationStepTime 0.03f
  70 +#define kZoomAnimationAnimationTime 0.1f
  71 +#define kiPhoneMilimeteresPerPixel .1543
  72 +#define kZoomRectPixelBuffer 50
  73 +#pragma mark --- end constants ----
  74 +
65 #pragma mark Initialisation 75 #pragma mark Initialisation
66 76
67 - (id)initWithView: (UIView*) view 77 - (id)initWithView: (UIView*) view
@@ -375,8 +385,8 @@ @@ -375,8 +385,8 @@
375 - (void)adjustMapPlacementWithScale:(float)aScale 385 - (void)adjustMapPlacementWithScale:(float)aScale
376 { 386 {
377 CGSize adjustmentDelta = {0.0, 0.0}; 387 CGSize adjustmentDelta = {0.0, 0.0};
378 - RMLatLong rightEdgeLatLong = {0, 180};  
379 - RMLatLong leftEdgeLatLong = {0,- 180}; 388 + RMLatLong rightEdgeLatLong = {0, kMaxLong};
  389 + RMLatLong leftEdgeLatLong = {0,- kMaxLong};
380 390
381 CGPoint rightEdge = [self latLongToPixel:rightEdgeLatLong withMetersPerPixel:aScale]; 391 CGPoint rightEdge = [self latLongToPixel:rightEdgeLatLong withMetersPerPixel:aScale];
382 CGPoint leftEdge = [self latLongToPixel:leftEdgeLatLong withMetersPerPixel:aScale]; 392 CGPoint leftEdge = [self latLongToPixel:leftEdgeLatLong withMetersPerPixel:aScale];
@@ -438,9 +448,8 @@ @@ -438,9 +448,8 @@
438 float targetZoom = zoomDelta + [self zoom]; 448 float targetZoom = zoomDelta + [self zoom];
439 449
440 // goal is to complete the animation in animTime seconds 450 // goal is to complete the animation in animTime seconds
441 -/// \bug magic numbers  
442 - static const float stepTime = 0.03f;  
443 - static const float animTime = 0.1f; 451 + static const float stepTime = kZoomAnimationStepTime;
  452 + static const float animTime = kZoomAnimationAnimationTime;
444 float nSteps = animTime / stepTime; 453 float nSteps = animTime / stepTime;
445 float zoomIncr = zoomDelta / nSteps; 454 float zoomIncr = zoomDelta / nSteps;
446 455
@@ -737,7 +746,7 @@ @@ -737,7 +746,7 @@
737 if (mercatorToScreenProjection != nil) 746 if (mercatorToScreenProjection != nil)
738 return [mercatorToScreenProjection screenBounds]; 747 return [mercatorToScreenProjection screenBounds];
739 else 748 else
740 - return CGRectMake(0, 0, 0, 0); 749 + return kEmptyRect;
741 } 750 }
742 751
743 -(float) metersPerPixel 752 -(float) metersPerPixel
@@ -748,7 +757,7 @@ @@ -748,7 +757,7 @@
748 -(void) setMetersPerPixel: (float) newMPP 757 -(void) setMetersPerPixel: (float) newMPP
749 { 758 {
750 float zoomFactor = newMPP / self.metersPerPixel; 759 float zoomFactor = newMPP / self.metersPerPixel;
751 - CGPoint pivot = CGPointMake(0,0); 760 + CGPoint pivot = kTheOrigin;
752 761
753 [mercatorToScreenProjection setMetersPerPixel:newMPP]; 762 [mercatorToScreenProjection setMetersPerPixel:newMPP];
754 [imagesOnScreen zoomByFactor:zoomFactor near:pivot]; 763 [imagesOnScreen zoomByFactor:zoomFactor near:pivot];
@@ -859,8 +868,7 @@ static BOOL _performExpensiveOperations = YES; @@ -859,8 +868,7 @@ static BOOL _performExpensiveOperations = YES;
859 868
860 - (double)scaleDenominator { 869 - (double)scaleDenominator {
861 double routemeMetersPerPixel = [self metersPerPixel]; 870 double routemeMetersPerPixel = [self metersPerPixel];
862 - /// \bug magic number  
863 - double iphoneMillimetersPerPixel = .1543; 871 + double iphoneMillimetersPerPixel = kiPhoneMilimeteresPerPixel;
864 double truescaleDenominator = routemeMetersPerPixel / (0.001 * iphoneMillimetersPerPixel) ; 872 double truescaleDenominator = routemeMetersPerPixel / (0.001 * iphoneMillimetersPerPixel) ;
865 return truescaleDenominator; 873 return truescaleDenominator;
866 } 874 }
@@ -883,7 +891,7 @@ static BOOL _performExpensiveOperations = YES; @@ -883,7 +891,7 @@ static BOOL _performExpensiveOperations = YES;
883 else 891 else
884 { 892 {
885 //convert ne/sw into RMMercatorRect and call zoomWithBounds 893 //convert ne/sw into RMMercatorRect and call zoomWithBounds
886 - float pixelBuffer = 50; 894 + float pixelBuffer = kZoomRectPixelBuffer;
887 CLLocationCoordinate2D midpoint = { 895 CLLocationCoordinate2D midpoint = {
888 .latitude = (ne.latitude + sw.latitude) / 2, 896 .latitude = (ne.latitude + sw.latitude) / 2,
889 .longitude = (ne.longitude + sw.longitude) / 2 897 .longitude = (ne.longitude + sw.longitude) / 2
@@ -974,12 +982,12 @@ static BOOL _performExpensiveOperations = YES; @@ -974,12 +982,12 @@ static BOOL _performExpensiveOperations = YES;
974 // westerly computations: 982 // westerly computations:
975 // -179, -178 -> -179 (min) 983 // -179, -178 -> -179 (min)
976 // -179, 179 -> 179 (max) 984 // -179, 179 -> 179 (max)
977 - if (fabs(northwestLL.longitude - southwestLL.longitude) <= 180.) 985 + if (fabs(northwestLL.longitude - southwestLL.longitude) <= kMaxLong)
978 boundingBox.southwest.longitude = fmin(northwestLL.longitude, southwestLL.longitude); 986 boundingBox.southwest.longitude = fmin(northwestLL.longitude, southwestLL.longitude);
979 else 987 else
980 boundingBox.southwest.longitude = fmax(northwestLL.longitude, southwestLL.longitude); 988 boundingBox.southwest.longitude = fmax(northwestLL.longitude, southwestLL.longitude);
981 989
982 - if (fabs(northeastLL.longitude - southeastLL.longitude) <= 180.) 990 + if (fabs(northeastLL.longitude - southeastLL.longitude) <= kMaxLong)
983 boundingBox.northeast.longitude = fmax(northeastLL.longitude, southeastLL.longitude); 991 boundingBox.northeast.longitude = fmax(northeastLL.longitude, southeastLL.longitude);
984 else 992 else
985 boundingBox.northeast.longitude = fmin(northeastLL.longitude, southeastLL.longitude); 993 boundingBox.northeast.longitude = fmin(northeastLL.longitude, southeastLL.longitude);
@@ -48,6 +48,11 @@ @@ -48,6 +48,11 @@
48 @synthesize deceleration; 48 @synthesize deceleration;
49 @synthesize contents; 49 @synthesize contents;
50 50
  51 +#pragma mark --- begin constants ----
  52 +#define kDefaultDeceleartionFactor .88f
  53 +#define kMinDecelerationDelta 0.01f
  54 +#pragma mark --- end constants ----
  55 +
51 - (RMMarkerManager*)markerManager 56 - (RMMarkerManager*)markerManager
52 { 57 {
53 return self.contents.markerManager; 58 return self.contents.markerManager;
@@ -59,7 +64,7 @@ @@ -59,7 +64,7 @@
59 64
60 enableDragging = YES; 65 enableDragging = YES;
61 enableZoom = YES; 66 enableZoom = YES;
62 - decelerationFactor = 0.88f; 67 + decelerationFactor = kDefaultDeceleartionFactor;
63 deceleration = NO; 68 deceleration = NO;
64 69
65 // [self recalculateImageSet]; 70 // [self recalculateImageSet];
@@ -510,7 +515,7 @@ @@ -510,7 +515,7 @@
510 } 515 }
511 516
512 - (void)incrementDeceleration:(NSTimer *)timer { 517 - (void)incrementDeceleration:(NSTimer *)timer {
513 - if (ABS(_decelerationDelta.width) < 0.01f && ABS(_decelerationDelta.height) < 0.01f) { 518 + if (ABS(_decelerationDelta.width) < kMinDecelerationDelta && ABS(_decelerationDelta.height) < kMinDecelerationDelta) {
514 [self stopDeceleration]; 519 [self stopDeceleration];
515 return; 520 return;
516 } 521 }
@@ -37,7 +37,6 @@ @@ -37,7 +37,6 @@
37 @synthesize textForegroundColor; 37 @synthesize textForegroundColor;
38 @synthesize textBackgroundColor; 38 @synthesize textBackgroundColor;
39 39
40 -/// \bug magic number  
41 #define defaultMarkerAnchorPoint CGPointMake(0.5, 0.5) 40 #define defaultMarkerAnchorPoint CGPointMake(0.5, 0.5)
42 41
43 + (UIFont *)defaultFont 42 + (UIFont *)defaultFont
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
27 - 27 +#import "RMGlobalConstants.h"
28 #import "RMMercatorToScreenProjection.h" 28 #import "RMMercatorToScreenProjection.h"
29 #include "RMProjection.h" 29 #include "RMProjection.h"
30 30
@@ -115,7 +115,7 @@ @@ -115,7 +115,7 @@
115 //RMLog(@"test: %f %f", test.x, test.y); 115 //RMLog(@"test: %f %f", test.x, test.y);
116 //RMLog(@"correct: %f %f", origin.easting, origin.y); 116 //RMLog(@"correct: %f %f", origin.easting, origin.y);
117 117
118 -// CGPoint p = [self projectMercatorPoint:[self projectScreenPointToMercator:CGPointMake(0,0)]]; 118 +// CGPoint p = [self projectMercatorPoint:[self projectScreenPointToMercator:kTheOrigin]];
119 // RMLog(@"origin at %f %f", p.x, p.y); 119 // RMLog(@"origin at %f %f", p.x, p.y);
120 // CGPoint q = [self projectMercatorPoint:[self projectScreenPointToMercator:CGPointMake(100,100)]]; 120 // CGPoint q = [self projectMercatorPoint:[self projectScreenPointToMercator:CGPointMake(100,100)]];
121 // RMLog(@"100 100 at %f %f", q.x, q.y); 121 // RMLog(@"100 100 at %f %f", q.x, q.y);
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
27 - 27 +#import "RMGlobalConstants.h"
28 #import "RMPath.h" 28 #import "RMPath.h"
29 #import "RMMapView.h" 29 #import "RMMapView.h"
30 #import "RMMapContents.h" 30 #import "RMMapContents.h"
@@ -36,6 +36,8 @@ @@ -36,6 +36,8 @@
36 36
37 @synthesize origin; 37 @synthesize origin;
38 38
  39 +#define kDefaultLineWidth 100
  40 +
39 /// \bug default values for lineWidth, lineColor, fillColor are hardcoded 41 /// \bug default values for lineWidth, lineColor, fillColor are hardcoded
40 - (id) initWithContents: (RMMapContents*)aContents 42 - (id) initWithContents: (RMMapContents*)aContents
41 { 43 {
@@ -46,7 +48,7 @@ @@ -46,7 +48,7 @@
46 48
47 path = CGPathCreateMutable(); 49 path = CGPathCreateMutable();
48 50
49 - lineWidth = 100.0f; 51 + lineWidth = kDefaultLineWidth;
50 drawingMode = kCGPathFillStroke; 52 drawingMode = kCGPathFillStroke;
51 lineColor = [UIColor blackColor]; 53 lineColor = [UIColor blackColor];
52 fillColor = [UIColor redColor]; 54 fillColor = [UIColor redColor];
@@ -89,7 +91,7 @@ @@ -89,7 +91,7 @@
89 boundsInMercators.size.width += 2*lineWidth; 91 boundsInMercators.size.width += 2*lineWidth;
90 boundsInMercators.size.height += 2*lineWidth; 92 boundsInMercators.size.height += 2*lineWidth;
91 93
92 - CGRect pixelBounds = RMScaleCGRectAboutPoint(boundsInMercators, 1.0f / scale, CGPointMake(0,0)); 94 + CGRect pixelBounds = RMScaleCGRectAboutPoint(boundsInMercators, 1.0f / scale, kTheOrigin);
93 95
94 // RMLog(@"old bounds: %f %f %f %f", self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, self.bounds.size.height); 96 // RMLog(@"old bounds: %f %f %f %f", self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, self.bounds.size.height);
95 self.bounds = pixelBounds; 97 self.bounds = pixelBounds;
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
27 - 27 +#import "RMGlobalConstants.h"
28 #import "proj_api.h" 28 #import "proj_api.h"
29 #import "RMProjection.h" 29 #import "RMProjection.h"
30 30
@@ -174,7 +174,7 @@ static RMProjection* _osgb = nil; @@ -174,7 +174,7 @@ static RMProjection* _osgb = nil;
174 } 174 }
175 else 175 else
176 { 176 {
177 - RMProjectedRect theBounds = RMMakeProjectedRect(-180, -90, 360, 180); 177 + RMProjectedRect theBounds = RMMakeProjectedRect(-kMaxLong, -kMaxLat, 360, kMaxLong);
178 178
179 /// \bug magic numbers embedded in code, this one's probably ok 179 /// \bug magic numbers embedded in code, this one's probably ok
180 _latlong = [[RMProjection alloc] initWithString:@"+proj=latlong +ellps=WGS84" InBounds: theBounds]; 180 _latlong = [[RMProjection alloc] initWithString:@"+proj=latlong +ellps=WGS84" InBounds: theBounds];
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
27 - 27 +#import "RMGlobalConstants.h"
28 #import "RMTileImage.h" 28 #import "RMTileImage.h"
29 #import "RMWebTileImage.h" 29 #import "RMWebTileImage.h"
30 #import "RMTileLoader.h" 30 #import "RMTileLoader.h"
@@ -52,7 +52,7 @@ NSString * const RMMapImageLoadingCancelledNotification = @"MapImageLoadingCance @@ -52,7 +52,7 @@ NSString * const RMMapImageLoadingCancelledNotification = @"MapImageLoadingCance
52 loadingPriorityCount = 0; 52 loadingPriorityCount = 0;
53 lastUsedTime = nil; 53 lastUsedTime = nil;
54 dataPending = nil; 54 dataPending = nil;
55 - screenLocation = CGRectMake(0, 0, 0, 0); 55 + screenLocation = kEmptyRect;
56 56
57 [self touch]; 57 [self touch];
58 58
@@ -228,7 +228,7 @@ NSString * const RMMapImageLoadingCancelledNotification = @"MapImageLoadingCance @@ -228,7 +228,7 @@ NSString * const RMMapImageLoadingCancelledNotification = @"MapImageLoadingCance
228 { 228 {
229 layer = [[CALayer alloc] init]; 229 layer = [[CALayer alloc] init];
230 layer.contents = nil; 230 layer.contents = nil;
231 - layer.anchorPoint = CGPointMake(0.0f, 0.0f); 231 + layer.anchorPoint = kTheOrigin;
232 layer.bounds = CGRectMake(0, 0, screenLocation.size.width, screenLocation.size.height); 232 layer.bounds = CGRectMake(0, 0, screenLocation.size.width, screenLocation.size.height);
233 layer.position = screenLocation.origin; 233 layer.position = screenLocation.origin;
234 234
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
27 - 27 +#import "RMGlobalConstants.h"w
28 #import "RMTileLoader.h" 28 #import "RMTileLoader.h"
29 29
30 #import "RMTileImage.h" 30 #import "RMTileImage.h"
@@ -80,7 +80,7 @@ NSString* const RMTileRequested = @"RMTileRequested"; @@ -80,7 +80,7 @@ NSString* const RMTileRequested = @"RMTileRequested";
80 80
81 -(void) clearLoadedBounds 81 -(void) clearLoadedBounds
82 { 82 {
83 - loadedBounds = CGRectMake(0, 0, 0, 0); 83 + loadedBounds = kEmptyRect;
84 // loadedTiles.origin.tile = RMTileDummy(); 84 // loadedTiles.origin.tile = RMTileDummy();
85 } 85 }
86 -(BOOL) screenIsLoaded 86 -(BOOL) screenIsLoaded
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE. 26 // POSSIBILITY OF SUCH DAMAGE.
27 - 27 +#import "RMGlobalConstants.h"
28 #import "RMTiledLayerController.h" 28 #import "RMTiledLayerController.h"
29 #import "RMFractalTileProjection.h" 29 #import "RMFractalTileProjection.h"
30 #import "RMTileSource.h" 30 #import "RMTileSource.h"
@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 55
56 RMXYRect boundsRect = tileProjection.bounds; 56 RMXYRect boundsRect = tileProjection.bounds;
57 layer.bounds = CGRectMake(boundsRect.origin.x, boundsRect.origin.y, boundsRect.size.width, boundsRect.size.height) ; 57 layer.bounds = CGRectMake(boundsRect.origin.x, boundsRect.origin.y, boundsRect.size.width, boundsRect.size.height) ;
58 - layer.position = CGPointMake(0, 0); 58 + layer.position = kTheOrigin;
59 59
60 [self setScale:1]; 60 [self setScale:1];
61 [layer setNeedsDisplay]; 61 [layer setNeedsDisplay];
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 33
34 - (NSString*) tileURL: (RMTile) tile 34 - (NSString*) tileURL: (RMTile) tile
35 { 35 {
36 - NSInteger zoom = 18 - tile.zoom; 36 + NSInteger zoom = kDefaultMaxTileZoom - tile.zoom;
37 NSInteger shift = tile.zoom -1; 37 NSInteger shift = tile.zoom -1;
38 NSInteger x = tile.x; 38 NSInteger x = tile.x;
39 NSInteger y = pow(2,shift)-1-tile.y; 39 NSInteger y = pow(2,shift)-1-tile.y;
@@ -96,6 +96,7 @@ @@ -96,6 +96,7 @@
96 2BEC61320F8ACC24008FB858 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B83E65680E80E830001663B6 /* QuartzCore.framework */; }; 96 2BEC61320F8ACC24008FB858 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B83E65680E80E830001663B6 /* QuartzCore.framework */; };
97 2BEC61330F8ACC25008FB858 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 97 2BEC61330F8ACC25008FB858 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
98 3849889C0F6F758100496293 /* libProj4.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 38D818500F6F67B90034598B /* libProj4.a */; }; 98 3849889C0F6F758100496293 /* libProj4.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 38D818500F6F67B90034598B /* libProj4.a */; };
  99 + 96492C400FA8AD3400EBA6D2 /* RMGlobalConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 96492C3F0FA8AD3400EBA6D2 /* RMGlobalConstants.h */; };
99 96FE8E360F72D01B00A11CF0 /* RMYahooMapSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FE8E340F72D01B00A11CF0 /* RMYahooMapSource.h */; }; 100 96FE8E360F72D01B00A11CF0 /* RMYahooMapSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FE8E340F72D01B00A11CF0 /* RMYahooMapSource.h */; };
100 96FE8E370F72D01B00A11CF0 /* RMYahooMapSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FE8E350F72D01B00A11CF0 /* RMYahooMapSource.m */; }; 101 96FE8E370F72D01B00A11CF0 /* RMYahooMapSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 96FE8E350F72D01B00A11CF0 /* RMYahooMapSource.m */; };
101 B8474B9A0EB40094006A0BC1 /* FMDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = B8474B8D0EB40094006A0BC1 /* FMDatabase.h */; }; 102 B8474B9A0EB40094006A0BC1 /* FMDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = B8474B8D0EB40094006A0BC1 /* FMDatabase.h */; };
@@ -244,6 +245,7 @@ @@ -244,6 +245,7 @@
244 3866784C0F6B9B9200C56B17 /* MapView.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapView.framework; path = build/MapView.framework; sourceTree = "<group>"; }; 245 3866784C0F6B9B9200C56B17 /* MapView.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapView.framework; path = build/MapView.framework; sourceTree = "<group>"; };
245 38DAD5490F739BAD00D1DF51 /* Canonical.framework.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = Canonical.framework.tar; sourceTree = "<group>"; }; 246 38DAD5490F739BAD00D1DF51 /* Canonical.framework.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = Canonical.framework.tar; sourceTree = "<group>"; };
246 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 247 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  248 + 96492C3F0FA8AD3400EBA6D2 /* RMGlobalConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMGlobalConstants.h; sourceTree = "<group>"; };
247 966504690F6869810036562A /* loading.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = loading.png; sourceTree = "<group>"; }; 249 966504690F6869810036562A /* loading.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = loading.png; sourceTree = "<group>"; };
248 96FE8E340F72D01B00A11CF0 /* RMYahooMapSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMYahooMapSource.h; sourceTree = "<group>"; }; 250 96FE8E340F72D01B00A11CF0 /* RMYahooMapSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMYahooMapSource.h; sourceTree = "<group>"; };
249 96FE8E350F72D01B00A11CF0 /* RMYahooMapSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMYahooMapSource.m; sourceTree = "<group>"; }; 251 96FE8E350F72D01B00A11CF0 /* RMYahooMapSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMYahooMapSource.m; sourceTree = "<group>"; };
@@ -642,6 +644,7 @@ @@ -642,6 +644,7 @@
642 B8C9740D0E8A196E007D16AD /* Map */ = { 644 B8C9740D0E8A196E007D16AD /* Map */ = {
643 isa = PBXGroup; 645 isa = PBXGroup;
644 children = ( 646 children = (
  647 + 96492C3F0FA8AD3400EBA6D2 /* RMGlobalConstants.h */,
645 090FE3130ECD71A500035FBC /* RMTilesUpdateDelegate.h */, 648 090FE3130ECD71A500035FBC /* RMTilesUpdateDelegate.h */,
646 B8C974690E8A1A50007D16AD /* RMMapView.h */, 649 B8C974690E8A1A50007D16AD /* RMMapView.h */,
647 B8C9746A0E8A1A50007D16AD /* RMMapView.m */, 650 B8C9746A0E8A1A50007D16AD /* RMMapView.m */,
@@ -737,6 +740,7 @@ @@ -737,6 +740,7 @@
737 2B5682720F68E36000E8DF40 /* RMOpenAerialMapSource.h in Headers */, 740 2B5682720F68E36000E8DF40 /* RMOpenAerialMapSource.h in Headers */,
738 96FE8E360F72D01B00A11CF0 /* RMYahooMapSource.h in Headers */, 741 96FE8E360F72D01B00A11CF0 /* RMYahooMapSource.h in Headers */,
739 F5C12D2A0F8A86CA00A894D2 /* RMGeoHash.h in Headers */, 742 F5C12D2A0F8A86CA00A894D2 /* RMGeoHash.h in Headers */,
  743 + 96492C400FA8AD3400EBA6D2 /* RMGlobalConstants.h in Headers */,
740 ); 744 );
741 runOnlyForDeploymentPostprocessing = 0; 745 runOnlyForDeploymentPostprocessing = 0;
742 }; 746 };