PageRenderTime 60ms CodeModel.GetById 44ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/MapView/Map/RMMercatorToScreenProjection.h

http://github.com/route-me/route-me
C Header | 94 lines | 36 code | 17 blank | 41 comment | 0 complexity | ad2a8da2073ba217febb023b02c64088 MD5 | raw file
 1//
 2//  RMMercatorToScreenProjection.h
 3//
 4// Copyright (c) 2008-2009, Route-Me Contributors
 5// All rights reserved.
 6//
 7// Redistribution and use in source and binary forms, with or without
 8// modification, are permitted provided that the following conditions are met:
 9//
10// * Redistributions of source code must retain the above copyright notice, this
11//   list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above copyright notice,
13//   this list of conditions and the following disclaimer in the documentation
14//   and/or other materials provided with the distribution.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
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
26// POSSIBILITY OF SUCH DAMAGE.
27
28#import <Foundation/Foundation.h>
29#import <CoreGraphics/CoreGraphics.h>
30
31#import "RMFoundation.h"
32
33@class RMProjection;
34
35/// This is a stateful projection. As the screen moves around, so too do projections change.
36@interface RMMercatorToScreenProjection : NSObject
37{
38	/// What the screen is currently looking at.
39	RMProjectedPoint origin;
40
41	/// The mercator -or-whatever- projection that the map is in.
42	/// This projection move linearly with the screen.
43	RMProjection *projection;
44	
45	/// Bounds of the screen in pixels
46	/// \bug name is "screenBounds" but is probably the view, not the whole screen?
47	CGRect screenBounds;
48
49	/// \brief meters per pixel
50	float metersPerPixel;
51}
52
53- (id) initFromProjection: (RMProjection*) projection ToScreenBounds: (CGRect)aScreenBounds;
54
55/// Deltas in screen coordinates.
56- (RMProjectedPoint)movePoint: (RMProjectedPoint)aPoint by:(CGSize) delta;
57/// Deltas in screen coordinates.
58- (RMProjectedRect)moveRect: (RMProjectedRect)aRect by:(CGSize) delta;
59
60/// pivot given in screen coordinates.
61- (RMProjectedPoint)zoomPoint: (RMProjectedPoint)aPoint byFactor: (float)factor near:(CGPoint) pivot;
62/// pivot given in screen coordinates.
63- (RMProjectedRect)zoomRect: (RMProjectedRect)aRect byFactor: (float)factor near:(CGPoint) pivot;
64
65/// Move the screen.
66- (void) moveScreenBy: (CGSize) delta;
67- (void) zoomScreenByFactor: (float) factor near:(CGPoint) aPoint;
68
69/// Project -> screen coordinates.
70- (CGPoint)projectXYPoint:(RMProjectedPoint)aPoint withMetersPerPixel:(float)aScale;
71/// Project -> screen coordinates.
72- (CGPoint) projectXYPoint: (RMProjectedPoint) aPoint;
73/// Project -> screen coordinates.
74- (CGRect) projectXYRect: (RMProjectedRect) aRect;
75
76- (RMProjectedPoint) projectScreenPointToXY: (CGPoint) aPoint;
77- (RMProjectedRect) projectScreenRectToXY: (CGRect) aRect;
78- (RMProjectedSize)projectScreenSizeToXY: (CGSize) aSize;
79- (RMProjectedPoint)projectScreenPointToXY: (CGPoint) aPixelPoint withMetersPerPixel:(float)aScale;
80
81- (RMProjectedRect) projectedBounds;
82- (void) setProjectedBounds: (RMProjectedRect) bounds;
83- (RMProjectedPoint) projectedCenter;
84- (void) setProjectedCenter: (RMProjectedPoint) aPoint;
85- (void) setScreenBounds:(CGRect)rect;
86- (CGRect) screenBounds;
87
88@property (assign, readwrite) float metersPerPixel;
89
90@property (assign, readwrite) RMProjectedPoint origin;
91@property (nonatomic,readonly) RMProjection *projection;
92-(void)deepCopy:(RMMercatorToScreenProjection *)copy;
93
94@end