Permalink
Browse files

Cleaned up some code. Made most of the project compile as a native ma…

…cosx app.

Still some work to do here though.
  • Loading branch information...
1 parent 355abc8 commit 3beebf67e7b222de2fa1fda577dd87a7fe0e9f9b @josephg josephg committed Sep 22, 2008
@@ -36,6 +36,11 @@ -(void) dealloc
[super dealloc];
}
+-(NSString*) tileURL: (RMTile) tile
+{
+ @throw [NSException exceptionWithName:@"RMAbstractMethodInvocation" reason:@"tileURL invoked on AbstractMercatorWebSource. Override this method when instantiating abstract class." userInfo:nil];
+}
+
-(RMTileImage *) tileImage: (RMTile)tile
{
RMTileImage* image = [RMTileImage imageWithTile: tile FromURL:[self tileURL:tile]];
@@ -0,0 +1,15 @@
+//
+// Layer.h
+// MapView
+//
+// Created by Joseph Gentle on 22/09/08.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface Layer : NSObject {
+
+}
+
+@end
@@ -0,0 +1,13 @@
+//
+// Layer.m
+// MapView
+//
+// Created by Joseph Gentle on 22/09/08.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "Layer.h"
+
+@implementation Layer
+
+@end
@@ -6,7 +6,7 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
#import "RMMapRenderer.h"
@class RMLayeredTileLoader;
@@ -7,17 +7,16 @@
//
#import "RMCoreAnimationRenderer.h"
-#import "RMMapView.h"
#import <QuartzCore/QuartzCore.h>
#import "RMLayeredTileLoader.h"
#import "RMMathUtils.h"
#import "RMLayerToScreenProjection.h"
@implementation RMCoreAnimationRenderer
-- (id) initWithView: (RMMapView *)_view
+- (id) initWithView: (id<RenderingTarget>)_view
{
- RMScreenProjection *_proj = [[RMScreenProjection alloc] initWithBounds:[_view bounds]];
+ RMScreenProjection *_proj = [[RMScreenProjection alloc] initWithBounds:[_view cgBounds]];
//[[LayerToScreenProjection alloc] initWithBounds:[_view bounds] InLayer:[_view layer]];
if (![super initWithView:_view ProjectingIn:_proj])
@@ -36,7 +35,7 @@ - (id) initWithView: (RMMapView *)_view
// [layer addSublayer:sublayer];
- [view.layer addSublayer:[tileLoader layer]];
+ [[view layer] addSublayer:[tileLoader layer]];
return self;
}
@@ -6,7 +6,8 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-#import <UIKit/UIKit.h>
+
+#import <Foundation/Foundation.h>
#import "RMTileCache.h"
@interface RMDiskCache : NSObject<RMTileCache>
@@ -6,7 +6,7 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
#import "RMTileImage.h"
@interface RMFileTileImage : RMTileImage {
@@ -6,7 +6,7 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
#import "RMMercator.h"
#import "RMTile.h"
@@ -0,0 +1,48 @@
+/*
+ * RMLatLong.h
+ * MapView
+ *
+ * Created by Joseph Gentle on 22/09/08.
+ * Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#ifndef _RMLATLONG_H_
+#define _RMLATLONG_H_
+
+#import <TargetConditionals.h>
+#if TARGET_OS_IPHONE
+#import <CoreLocation/CoreLocation.h>
+#else
+
+/* From CoreLocation by Apple inc. Copyright 2008 Apple Computer, Inc. All rights reserved. */
+
+/*
+ * CLLocationDegrees
+ *
+ * Discussion:
+ * Type used to represent a latitude or longitude coordinate in degrees under the WGS 84 reference
+ * frame. The degree can be positive (North and East) or negative (South and West).
+ */
+typedef double CLLocationDegrees;
+/*
+ * CLLocationCoordinate2D
+ *
+ * Discussion:
+ * A structure that contains a geographical coordinate.
+ *
+ * Fields:
+ * latitude:
+ * The latitude in degrees.
+ * longitude:
+ * The longitude in degrees.
+ */
+typedef struct {
+ CLLocationDegrees latitude;
+ CLLocationDegrees longitude;
+} CLLocationCoordinate2D;
+
+
+#endif
+
+#endif
@@ -6,7 +6,7 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
#import "RMScreenProjection.h"
@class CALayer;
@@ -6,11 +6,13 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
#import "RMTileLoader.h"
#import "RMMercator.h"
+@class CALayer;
+
@interface RMLayeredTileLoader : RMTileLoader {
CALayer *layer;
}
@@ -6,22 +6,35 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
-#import <UIKit/UIKit.h>
+#import <Foundation/Foundation.h>
#import "RMMercator.h"
-@class RMMapView;
+@class CALayer;
+@protocol RMTileSource;
+
+@protocol RenderingTarget<NSObject>
+
+-(void) setNeedsDisplay;
+-(CGRect) cgBounds;
+-(id<RMTileSource>) tileSource;
+@optional
+-(CALayer*) layer;
+
+@end
+
+
@class RMScreenProjection;
@interface RMMapRenderer : NSObject
{
RMScreenProjection *screenProjection;
- RMMapView *view;
+ id<RenderingTarget> view;
}
// Designated initialiser
-- (id) initWithView: (RMMapView *)_view ProjectingIn: (RMScreenProjection*) _screenProjection;
+- (id) initWithView: (id<RenderingTarget>)_view ProjectingIn: (RMScreenProjection*) _screenProjection;
// This makes a screen projection from the view
-- (id) initWithView: (RMMapView *)view;
+- (id) initWithView: (id<RenderingTarget>)view;
- (void)drawRect:(CGRect)rect;
@@ -9,7 +9,6 @@
#import "RMMapRenderer.h"
#import "RMScreenProjection.h"
#import "RMFractalTileProjection.h"
-#import "RMMapView.h"
#import "RMTileSource.h"
#import "RMTileImage.h"
@@ -19,7 +18,7 @@ @implementation RMMapRenderer
@synthesize screenProjection;
// Designated initialiser
-- (id) initWithView: (RMMapView *)_view ProjectingIn: (RMScreenProjection*) _screenProjection
+- (id) initWithView: (id<RenderingTarget>)_view ProjectingIn: (RMScreenProjection*) _screenProjection
{
if (![super init])
return nil;
@@ -32,9 +31,9 @@ - (id) initWithView: (RMMapView *)_view ProjectingIn: (RMScreenProjection*) _scr
return self;
}
-- (id) initWithView: (RMMapView *)_view
+- (id) initWithView: (id<RenderingTarget>)_view
{
- RMScreenProjection *_screenProjection = [[RMScreenProjection alloc] initWithBounds:[_view bounds]];
+ RMScreenProjection *_screenProjection = [[RMScreenProjection alloc] initWithBounds:[_view cgBounds]];
return [self initWithView:_view ProjectingIn:_screenProjection];
}
@@ -6,7 +6,15 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
+#import <TargetConditionals.h>
+
+///// This class is only valid for the iphone.
+#if !TARGET_OS_IPHONE
+#error This is only valid on the iphone.
+#endif
+
#import <UIKit/UIKit.h>
+
#import "RMMercator.h"
//#import "MapRenderer.h"
//#import "TileSource.h"
@@ -22,7 +30,7 @@ typedef struct {
//@class TileSource;
//@class TileImageSet;
-@interface RMMapView : UIView {
+@interface RMMapView<RenderingTarget> : UIView {
id<RMTileSource> tileSource;
RMMapRenderer *renderer;
@@ -46,3 +54,4 @@ typedef struct {
@property (retain, readwrite, nonatomic) id<RMTileSource> tileSource;
@end
+
Oops, something went wrong. Retry.

0 comments on commit 3beebf6

Please sign in to comment.