Skip to content
This repository
Browse code

Merge pull request #137 from afarnham/d97bd192846fb05fd5a49647bfb83e9…

…6787c8afb

A couple additional functions for helping to create projected sizes and rects
  • Loading branch information...
commit 0446a67b4192e807a690d1d65cda02a4dca8c1ff 2 parents e44299a + d97bd19
vyskocil vyskocil authored

Showing 2 changed files with 39 additions and 3 deletions. Show diff stats Hide diff stats

  1. +26 0 MapView/Map/RMFoundation.c
  2. +13 3 MapView/Map/RMFoundation.h
26 MapView/Map/RMFoundation.c
@@ -49,6 +49,14 @@ bool RMProjectedRectInterectsProjectedRect(RMProjectedRect rect1, RMProjectedRec
49 49
50 50 }
51 51
  52 +bool RMProjectedSizeEqualToProjectedSize(RMProjectedSize size1, RMProjectedSize size2) {
  53 + return ((size1.width == size2.width) && (size1.height == size2.height));
  54 +}
  55 +
  56 +bool RMProjectedRectEqualToProjectedRect(RMProjectedRect rect1, RMProjectedRect rect2) {
  57 + return (RMProjectedPointEqualToProjectedPoint(rect1.origin, rect2.origin) && RMProjectedSizeEqualToProjectedSize(rect1.size, rect2.size));
  58 +}
  59 +
52 60 RMProjectedPoint RMScaleProjectedPointAboutPoint(RMProjectedPoint point, float factor, RMProjectedPoint pivot)
53 61 {
54 62 point.easting = (point.easting - pivot.easting) * factor + pivot.easting;
@@ -88,6 +96,13 @@ RMProjectedPoint RMMakeProjectedPoint (double easting, double northing)
88 96 return point;
89 97 }
90 98
  99 +RMProjectedSize RMMakeProjectedSize(double width, double height) {
  100 + RMProjectedSize size = {
  101 + width, height
  102 + };
  103 + return size;
  104 +}
  105 +
91 106 RMProjectedRect RMMakeProjectedRect (double easting, double northing, double width, double height)
92 107 {
93 108 RMProjectedRect rect = {
@@ -97,3 +112,14 @@ RMProjectedRect RMMakeProjectedRect (double easting, double northing, double wi
97 112
98 113 return rect;
99 114 }
  115 +
  116 +double RMProjectedRectGetMidEasting(RMProjectedRect rect) {
  117 + return (rect.origin.easting + rect.size.width / 2);
  118 +}
  119 +
  120 +double RMProjectedRectGetMidNorthing(RMProjectedRect rect){
  121 + return (rect.origin.northing + rect.size.height / 2);
  122 +}
  123 +
  124 +
  125 +
16 MapView/Map/RMFoundation.h
@@ -48,7 +48,11 @@ typedef struct {
48 48
49 49 /// \brief The function checks whether two passed projected points are equal.
50 50 bool RMProjectedPointEqualToProjectedPoint(RMProjectedPoint point1, RMProjectedPoint point2);
51   -/// \brief The function returs true, if passed rects intersect each other.
  51 +/// \brief The fuction returns true if the passed sizes are equal
  52 +bool RMProjectedSizeEqualToProjectedSize(RMProjectedSize size1, RMProjectedSize size2);
  53 +/// \brief The fuction returns true if the passed rects are equal
  54 +bool RMProjectedRectEqualToProjectedRect(RMProjectedRect rect1, RMProjectedRect rect2);
  55 +/// \brief The function returns true if passed rects intersect each other.
52 56 bool RMProjectedRectInterectsProjectedRect(RMProjectedRect rect1, RMProjectedRect rect2);
53 57
54 58 RMProjectedPoint RMScaleProjectedPointAboutPoint (RMProjectedPoint point, float factor, RMProjectedPoint pivot);
@@ -56,6 +60,12 @@ RMProjectedRect RMScaleProjectedRectAboutPoint(RMProjectedRect rect, float fa
56 60 RMProjectedPoint RMTranslateProjectedPointBy (RMProjectedPoint point, RMProjectedSize delta);
57 61 RMProjectedRect RMTranslateProjectedRectBy (RMProjectedRect rect, RMProjectedSize delta);
58 62
59   -RMProjectedPoint RMMakeProjectedPoint (double easting, double northing);
60   -RMProjectedRect RMMakeProjectedRect (double easting, double northing, double width, double height);
  63 +RMProjectedPoint RMMakeProjectedPoint (double easting, double northing);
  64 +RMProjectedSize RMMakeProjectedSize(double width, double height);
  65 +RMProjectedRect RMMakeProjectedRect (double easting, double northing, double width, double height);
61 66
  67 +/// \brief The function returns the midpoint easting of the given rect.
  68 +double RMProjectedRectGetMidEasting(RMProjectedRect rect);
  69 +
  70 +/// \brief The function returns the midpoint northing of the given rect.
  71 +double RMProjectedRectGetMidNorthing(RMProjectedRect rect);

0 comments on commit 0446a67

Please sign in to comment.
Something went wrong with that request. Please try again.