/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. #import <Foundation/Foundation.h>
  28. #import <CoreGraphics/CoreGraphics.h>
  29. #import "RMFoundation.h"
  30. @class RMProjection;
  31. /// This is a stateful projection. As the screen moves around, so too do projections change.
  32. @interface RMMercatorToScreenProjection : NSObject
  33. {
  34. /// What the screen is currently looking at.
  35. RMProjectedPoint origin;
  36. /// The mercator -or-whatever- projection that the map is in.
  37. /// This projection move linearly with the screen.
  38. RMProjection *projection;
  39. /// Bounds of the screen in pixels
  40. /// \bug name is "screenBounds" but is probably the view, not the whole screen?
  41. CGRect screenBounds;
  42. /// \brief meters per pixel
  43. float metersPerPixel;
  44. }
  45. - (id) initFromProjection: (RMProjection*) projection ToScreenBounds: (CGRect)aScreenBounds;
  46. /// Deltas in screen coordinates.
  47. - (RMProjectedPoint)movePoint: (RMProjectedPoint)aPoint by:(CGSize) delta;
  48. /// Deltas in screen coordinates.
  49. - (RMProjectedRect)moveRect: (RMProjectedRect)aRect by:(CGSize) delta;
  50. /// pivot given in screen coordinates.
  51. - (RMProjectedPoint)zoomPoint: (RMProjectedPoint)aPoint byFactor: (float)factor near:(CGPoint) pivot;
  52. /// pivot given in screen coordinates.
  53. - (RMProjectedRect)zoomRect: (RMProjectedRect)aRect byFactor: (float)factor near:(CGPoint) pivot;
  54. /// Move the screen.
  55. - (void) moveScreenBy: (CGSize) delta;
  56. - (void) zoomScreenByFactor: (float) factor near:(CGPoint) aPoint;
  57. /// Project -> screen coordinates.
  58. - (CGPoint)projectXYPoint:(RMProjectedPoint)aPoint withMetersPerPixel:(float)aScale;
  59. /// Project -> screen coordinates.
  60. - (CGPoint) projectXYPoint: (RMProjectedPoint) aPoint;
  61. /// Project -> screen coordinates.
  62. - (CGRect) projectXYRect: (RMProjectedRect) aRect;
  63. - (RMProjectedPoint) projectScreenPointToXY: (CGPoint) aPoint;
  64. - (RMProjectedRect) projectScreenRectToXY: (CGRect) aRect;
  65. - (RMProjectedSize)projectScreenSizeToXY: (CGSize) aSize;
  66. - (RMProjectedPoint)projectScreenPointToXY: (CGPoint) aPixelPoint withMetersPerPixel:(float)aScale;
  67. - (RMProjectedRect) projectedBounds;
  68. - (void) setProjectedBounds: (RMProjectedRect) bounds;
  69. - (RMProjectedPoint) projectedCenter;
  70. - (void) setProjectedCenter: (RMProjectedPoint) aPoint;
  71. - (void) setScreenBounds:(CGRect)rect;
  72. - (CGRect) screenBounds;
  73. @property (assign, readwrite) float metersPerPixel;
  74. @property (assign, readwrite) RMProjectedPoint origin;
  75. @property (nonatomic,readonly) RMProjection *projection;
  76. -(void)deepCopy:(RMMercatorToScreenProjection *)copy;
  77. @end