Authored by Joseph G

Removed quartz renderer. Added some overlay stuff.

... ... @@ -16,27 +16,36 @@
@implementation RMCoreAnimationRenderer
- (id) initForView: (UIView*)view WithContent: (RMMapContents *)_contents
- (id) initWithContent: (RMMapContents *)_contents
{
if (![super initForView:view WithContent:_contents])
if (![super initWithContent:_contents])
return nil;
// NOTE: RMMapContents may still be initialising when this function
// is called. Be careful using any of methods - they might return
// strange data.
layer = [[CAScrollLayer layer] retain];
layer.anchorPoint = CGPointMake(0.0f, 0.0f);
layer.masksToBounds = YES;
layer.frame = [view bounds];
// If the frame is set incorrectly here, it will be fixed when setRenderer is called in RMMapContents
layer.frame = [content screenBounds];
NSMutableDictionary *customActions=[NSMutableDictionary dictionaryWithDictionary:[layer actions]];
NSMutableDictionary *customActions = [NSMutableDictionary dictionaryWithDictionary:[layer actions]];
[customActions setObject:[NSNull null] forKey:@"sublayers"];
layer.actions = customActions;
layer.delegate = self;
[[view layer] addSublayer:layer];
return self;
}
-(void) dealloc
{
[layer release];
[super dealloc];
}
-(void)mapImageLoaded: (NSNotification*)notification
{
}
... ... @@ -93,6 +102,11 @@
return @"CoreAnimation map renderer";
}
- (CALayer*) layer
{
return layer;
}
/*
- (void)moveBy: (CGSize) delta
{
... ...
... ... @@ -7,28 +7,33 @@
//
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import "RMMercator.h"
#import "RMMapLayer.h"
@class RMMapRenderer;
@class RMMapContents;
@interface RMLayerSet : NSObject
@interface RMLayerSet : RMMapLayer
{
NSMutableArray *layers;
// This is the set of all sublayers, including those offscreen.
// It is ordered back to front.
NSMutableArray *set;
CALayer *container;
// We need this reference so we can access the projections...
RMMapContents *mapContents;
}
- (void)insertSublayer:(RMMapLayer*) layer below:(RMMapLayer*)sibling;
- (void)insertSublayer:(RMMapLayer*) layer above:(RMMapLayer*)sibling;
- (void)removeSublayer:(RMMapLayer*) layer;
- (id)initForContents: (RMMapContents *)contents;
//- (void)insertSublayer:(RMMapLayer*) layer below:(RMMapLayer*)sibling;
//- (void)insertSublayer:(RMMapLayer*) layer above:(RMMapLayer*)sibling;
//- (void)removeSublayer:(RMMapLayer*) layer;
- (void)moveToMercator: (RMMercatorPoint)mercator;
- (void)moveBy: (CGSize) delta;
- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center;
-(void) drawRect: (CGRect)rect;
-(CALayer*) layer;
//-(void) drawRect: (CGRect)rect;
//-(CALayer*) layer;
@end
... ...
... ... @@ -11,50 +11,81 @@
@implementation RMLayerSet
- (id) init
- (id)initForContents: (RMMapContents *)_contents
{
if (![super init])
return nil;
container = [[CALayer alloc] init];
set = [[NSMutableArray alloc] init];
mapContents = _contents;
return self;
}
- (void)setSublayers: (NSArray*)array
{
[set removeAllObjects];
[set addObjectsFromArray:array];
[super setSublayers:array];
}
- (void)addSublayer:(CALayer *)layer
{
[set addObject:layer];
[super addSublayer:layer];
}
- (void)insertSublayer:(CALayer *)layer above:(CALayer *)siblingLayer
{
int index = [set indexOfObject:siblingLayer];
[set insertObject:layer atIndex:index + 1];
[super insertSublayer:layer above:siblingLayer];
}
- (void)insertSublayer:(CALayer *)layer below:(CALayer *)siblingLayer
{
int index = [set indexOfObject:siblingLayer];
[set insertObject:layer atIndex:index];
[super insertSublayer:layer below:siblingLayer];
}
- (void)insertSublayer:(CALayer *)layer atIndex:(unsigned)index
{
[set insertObject:layer atIndex:index];
// TODO: Fix this.
[super addSublayer:layer];
}
/*
- (void)insertSublayer:(RMMapLayer*) layer below:(RMMapLayer*)sibling;
- (void)insertSublayer:(RMMapLayer*) layer above:(RMMapLayer*)sibling;
- (void)removeSublayer:(RMMapLayer*) layer;
*/
- (void)moveToMercator: (RMMercatorPoint)mercator
{
// TODO: Me
}
- (void)moveToMercator: (RMMercatorPoint)mercator;
*/
- (void)moveBy: (CGSize) delta
{
for (id layer in layers)
for (id layer in set)
{
if ([layer respondsToSelector:@selector(moveBy:)])
// if ([layer respondsToSelector:@selector(moveBy:)])
[layer moveBy:delta];
// if layer moves on and offscreen...
}
}
- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center
{
for (id layer in layers)
for (id layer in set)
{
if ([layer respondsToSelector:@selector(zoomByFactor:Near:)])
// if ([layer respondsToSelector:@selector(zoomByFactor:Near:)])
[layer zoomByFactor:zoomFactor Near:center];
}
}
-(CALayer*) layer
{
return container;
}
-(void) drawRect: (CGRect)rect
{
NSLog(@"Map layers not currently supported using quartz renderer");
}
@end
... ...
... ... @@ -23,7 +23,12 @@
@interface RMMapContents : NSObject
{
// TODO: Also support NSView.
// UIView *targetView;
// This is the underlying UIView's layer.
CALayer *layer;
RMMapLayer *background;
RMMapLayer *overlay;
// Latlong is calculated dynamically from mercatorBounds.
RMLatLongToMercatorProjection *latLongToMercatorProjection;
... ... @@ -56,6 +61,8 @@
@property (readonly) id<RMTileSource> tileSource;
@property (readonly) CALayer *layer;
- (id) initForView: (UIView*) view;
// Designated initialiser
... ...
... ... @@ -20,7 +20,6 @@
#import "RMOpenStreetMapsSource.h"
#import "RMCoreAnimationRenderer.h"
#import "RMQuartzRenderer.h"
#import "RMCachedTileSource.h"
@implementation RMMapContents
... ... @@ -29,8 +28,7 @@
- (id) initForView: (UIView*) view
{
id<RMTileSource> _tileSource = [[RMOpenStreetMapsSource alloc] init];
RMMapRenderer *_renderer = [[RMCoreAnimationRenderer alloc] initForView:view WithContent:self];
// RMMapRenderer *_renderer = [[RMQuartzRenderer alloc] initForView:view WithContent:self];
RMMapRenderer *_renderer = [[RMCoreAnimationRenderer alloc] initWithContent:self];
CLLocationCoordinate2D here;
here.latitude = -33.9464;
... ... @@ -62,8 +60,19 @@
- (void) setRenderer: (RMMapRenderer*) newRenderer
{
if (renderer == newRenderer)
return;
[[renderer layer] removeFromSuperlayer];
[renderer release];
renderer = [newRenderer retain];
// CGRect rect = [self screenBounds];
// NSLog(@"%f %f %f %f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
[[renderer layer] setFrame:[self screenBounds]];
[layer addSublayer:[renderer layer]];
}
- (id) initForView: (UIView*) view WithTileSource: (id<RMTileSource>)_tileSource WithRenderer: (RMMapRenderer*)_renderer LookingAt:(CLLocationCoordinate2D)latlong
... ... @@ -82,6 +91,8 @@
imagesOnScreen = nil;
tileLoader = nil;
layer = [[view layer] retain];
[self setTileSource:_tileSource];
[self setRenderer:_renderer];
... ... @@ -102,6 +113,20 @@
return self;
}
-(void) dealloc
{
[renderer release];
[tileSource release];
[tileLoader release];
[latLongToMercatorProjection release];
[mercatorToTileProjection release];
[mercatorToScreenProjection release];
[tileSource release];
[layer release];
[super dealloc];
}
#pragma mark Forwarded Events
- (void)moveToLatLong: (CLLocationCoordinate2D)latlong
... ... @@ -169,7 +194,10 @@
-(CGRect) screenBounds
{
return [mercatorToScreenProjection screenBounds];
if (mercatorToScreenProjection != nil)
return [mercatorToScreenProjection screenBounds];
else
return CGRectMake(0, 0, 0, 0);
}
-(float) scale
... ... @@ -217,6 +245,11 @@
return [[tileSource retain] autorelease];
}
- (CALayer *)layer
{
return [[layer retain] autorelease];
}
static BOOL _performExpensiveOperations = YES;
+ (BOOL) performExpensiveOperations
{
... ...
... ... @@ -7,6 +7,7 @@
//
#import "RMMapLayer.h"
#import "RMPixel.h"
@implementation RMMapLayer
... ... @@ -28,12 +29,15 @@
- (void)moveBy: (CGSize) delta
{
self.position = RMTranslateCGPointBy(self.position, delta);
}
- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center
{
CGRect currentRect = CGRectMake(self.position.x, self.position.y, self.bounds.size.width, self.bounds.size.height);
CGRect newRect = RMScaleCGRectAboutPoint(currentRect, zoomFactor, center);
self.position = newRect.origin;
self.bounds = CGRectMake(0, 0, newRect.size.width, newRect.size.height);
}
@end
... ...
... ... @@ -20,8 +20,10 @@
RMMapContents *content;
}
- (id) initForView: (UIView*) view WithContent: (RMMapContents *)contents;
- (id) initWithContent: (RMMapContents *)contents;
- (void) setNeedsDisplay;
- (void)drawRect:(CGRect)rect;
- (CALayer*) layer;
@end
... ...
... ... @@ -13,7 +13,7 @@
@implementation RMMapRenderer
// Designated initialiser
- (id) initForView: (UIView*) view WithContent: (RMMapContents *)_contents
- (id) initWithContent: (RMMapContents *)_contents
{
if (![super init])
return nil;
... ... @@ -44,4 +44,9 @@
- (void)drawRect:(CGRect)rect
{ }
- (CALayer*) layer
{
return nil;
}
@end
... ...
... ... @@ -8,9 +8,12 @@
#import <UIKit/UIKit.h>
#import "RMMapLayer.h"
#import "RMMercator.h"
@class UIImage;
@interface RMMarker : RMMapLayer {
RMMercatorPoint point;
}
- (id) initWithCGImage: (CGImageRef) image;
... ...
... ... @@ -8,7 +8,6 @@
#import "RMMarker.h"
@implementation RMMarker
- (id) initWithCGImage: (CGImageRef) image
... ...
//
// QuartzRenderer.h
// RouteMe
//
// Created by Joseph Gentle on 8/09/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "RMMapRenderer.h"
@class UIView;
@interface RMQuartzRenderer : RMMapRenderer {
UIView *view;
}
@end
//
// QuartzRenderer.m
// RouteMe
//
// Created by Joseph Gentle on 8/09/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "RMQuartzRenderer.h"
#import <TargetConditionals.h>
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
#import "RMMapContents.h"
#import "RMTileImage.h"
@implementation RMQuartzRenderer
- (id) initForView: (UIView*)_view WithContent: (RMMapContents *)_contents
{
if (![super initForView:view WithContent:_contents])
return nil;
// We do not retain this so there's not a circular dependancy.
view = _view;
return self;
}
-(void) dealloc
{
[super dealloc];
}
-(NSString*) description
{
return @"Quartz 2D map renderer";
}
- (void)drawRect:(CGRect)rect
{
[[content imagesOnScreen] drawRect:rect];
}
- (void)setNeedsDisplay
{
[view setNeedsDisplay];
}
- (void)tileDidFinishLoading: (RMTileImage *)image
{
[view setNeedsDisplay];
}
@end
... ... @@ -192,7 +192,8 @@
NSEnumerator *enumerator = [images objectEnumerator];
RMTileImage *object;
while ((object = [enumerator nextObject])) {
while ((object = [enumerator nextObject]))
{
if (RMTilesEqual(tile, [object tile]))
return object;
}
... ...
... ... @@ -91,7 +91,7 @@ NSString* const RMResumeExpensiveOperations = @"RMResumeExpensiveOperations";
if ([self screenIsLoaded])
return;
NSLog(@"assemble count = %d", [[content imagesOnScreen] count]);
// NSLog(@"assemble count = %d", [[content imagesOnScreen] count]);
RMTileRect newTileRect = [content tileBounds];
... ...
... ... @@ -126,48 +126,9 @@
CGContextDrawImage(theContext, rect, image);
}
/*
-(CGPoint) projectMercatorPoint: (MercatorPoint) mercator
- (CALayer*) layer
{
CGPoint point;
point.x = (mercator.x - topLeft.x) / scale;
point.y = -(mercator.y - topLeft.y) / scale;
return point;
return layer;
}
-(CGRect) projectMercatorRect: (MercatorRect) mercator
{
CGRect rect;
rect.origin = [self projectMercatorPoint: mercator.origin];
mercator.size.width = rect.size.width / scale;
mercator.size.height = rect.size.height / scale;
return rect;
}
-(MercatorPoint) projectInversePoint: (CGPoint) point
{
MercatorPoint mercator;
mercator.x = (scale * point.x) + topLeft.x;
mercator.y = -(scale * point.y) + topLeft.y;
return mercator;
}
-(MercatorRect) projectInverseRect: (CGRect) rect
{
MercatorRect mercator;
mercator.origin = [self projectInversePoint: rect.origin];
mercator.size.width = rect.size.width * scale;
mercator.size.height = rect.size.height * scale;
return mercator;
}
-(MercatorRect) bounds
{
MercatorRect rect;
rect.origin = topLeft;
rect.size.width = viewSize.width * scale;
rect.size.height = viewSize.height * scale;
return rect;
}*/
@end
... ...
... ... @@ -18,7 +18,6 @@
B83E66C30E80F053001663B6 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B83E65680E80E830001663B6 /* QuartzCore.framework */; };
B83E67170E80F1CE001663B6 /* loading.png in Resources */ = {isa = PBXBuildFile; fileRef = B83E670F0E80F1B5001663B6 /* loading.png */; };
B8C974170E8A19B2007D16AD /* RMMercatorToScreenProjection.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64C80E80E73F001663B6 /* RMMercatorToScreenProjection.h */; };
B8C974180E8A19B2007D16AD /* RMQuartzRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64BA0E80E73F001663B6 /* RMQuartzRenderer.h */; };
B8C974190E8A19B2007D16AD /* RMMapRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64CA0E80E73F001663B6 /* RMMapRenderer.h */; };
B8C9741D0E8A19B2007D16AD /* RMCoreAnimationRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64BD0E80E73F001663B6 /* RMCoreAnimationRenderer.h */; };
B8C974200E8A19B2007D16AD /* RMDiskCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B83E64D40E80E73F001663B6 /* RMDiskCache.h */; };
... ... @@ -36,7 +35,6 @@
B8C974300E8A19B2007D16AD /* RMLatLong.h in Headers */ = {isa = PBXBuildFile; fileRef = B8D27AFB0E8780CD00F596FE /* RMLatLong.h */; };
B8C974310E8A19B2007D16AD /* RMAbstractMecatorWebSource.h in Headers */ = {isa = PBXBuildFile; fileRef = C7A967500E8412930031BA75 /* RMAbstractMecatorWebSource.h */; };
B8C974350E8A19B2007D16AD /* RMMercatorToScreenProjection.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64C90E80E73F001663B6 /* RMMercatorToScreenProjection.m */; };
B8C974370E8A19B2007D16AD /* RMQuartzRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64BB0E80E73F001663B6 /* RMQuartzRenderer.m */; };
B8C974380E8A19B2007D16AD /* RMMapRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64CB0E80E73F001663B6 /* RMMapRenderer.m */; };
B8C9743A0E8A19B2007D16AD /* RMCoreAnimationRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64BE0E80E73F001663B6 /* RMCoreAnimationRenderer.m */; };
B8C9743F0E8A19B2007D16AD /* RMTileImage.m in Sources */ = {isa = PBXBuildFile; fileRef = B83E64D90E80E73F001663B6 /* RMTileImage.m */; };
... ... @@ -126,8 +124,6 @@
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B83E64B60E80E73F001663B6 /* RMPixel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMPixel.h; sourceTree = "<group>"; };
B83E64B70E80E73F001663B6 /* RMPixel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = RMPixel.c; sourceTree = "<group>"; };
B83E64BA0E80E73F001663B6 /* RMQuartzRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMQuartzRenderer.h; sourceTree = "<group>"; };
B83E64BB0E80E73F001663B6 /* RMQuartzRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMQuartzRenderer.m; sourceTree = "<group>"; };
B83E64BD0E80E73F001663B6 /* RMCoreAnimationRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMCoreAnimationRenderer.h; sourceTree = "<group>"; };
B83E64BE0E80E73F001663B6 /* RMCoreAnimationRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMCoreAnimationRenderer.m; sourceTree = "<group>"; };
B83E64C40E80E73F001663B6 /* RMTiledLayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMTiledLayerController.h; sourceTree = "<group>"; };
... ... @@ -300,20 +296,10 @@
B83E64CB0E80E73F001663B6 /* RMMapRenderer.m */,
B83E64C30E80E73F001663B6 /* Tiled Layer Renderer */,
B83E64BC0E80E73F001663B6 /* Core Animation Renderer */,
B83E64B90E80E73F001663B6 /* Quartz Renderer */,
);
name = Renderers;
sourceTree = "<group>";
};
B83E64B90E80E73F001663B6 /* Quartz Renderer */ = {
isa = PBXGroup;
children = (
B83E64BA0E80E73F001663B6 /* RMQuartzRenderer.h */,
B83E64BB0E80E73F001663B6 /* RMQuartzRenderer.m */,
);
name = "Quartz Renderer";
sourceTree = "<group>";
};
B83E64BC0E80E73F001663B6 /* Core Animation Renderer */ = {
isa = PBXGroup;
children = (
... ... @@ -417,8 +403,8 @@
B86F26A80E8742ED007A3773 /* Layers */ = {
isa = PBXGroup;
children = (
B8F3FC600EA2B382004D8F85 /* RMMapLayer.m */,
B86F26AC0E87442C007A3773 /* RMMapLayer.h */,
B8F3FC600EA2B382004D8F85 /* RMMapLayer.m */,
B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */,
B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */,
B8F3FC620EA2E792004D8F85 /* RMMarker.h */,
... ... @@ -478,7 +464,6 @@
buildActionMask = 2147483647;
files = (
B8C974170E8A19B2007D16AD /* RMMercatorToScreenProjection.h in Headers */,
B8C974180E8A19B2007D16AD /* RMQuartzRenderer.h in Headers */,
B8C974190E8A19B2007D16AD /* RMMapRenderer.h in Headers */,
B8C9741D0E8A19B2007D16AD /* RMCoreAnimationRenderer.h in Headers */,
B8C974200E8A19B2007D16AD /* RMDiskCache.h in Headers */,
... ... @@ -614,7 +599,6 @@
buildActionMask = 2147483647;
files = (
B8C974350E8A19B2007D16AD /* RMMercatorToScreenProjection.m in Sources */,
B8C974370E8A19B2007D16AD /* RMQuartzRenderer.m in Sources */,
B8C974380E8A19B2007D16AD /* RMMapRenderer.m in Sources */,
B8C9743A0E8A19B2007D16AD /* RMCoreAnimationRenderer.m in Sources */,
B8C9743F0E8A19B2007D16AD /* RMTileImage.m in Sources */,
... ...