Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 with 39 additions and 3 deletions.
  1. +26 −0 MapView/Map/RMFoundation.c
  2. +13 −3 MapView/Map/RMFoundation.h
26 MapView/Map/RMFoundation.c
View
@@ -49,6 +49,14 @@ bool RMProjectedRectInterectsProjectedRect(RMProjectedRect rect1, RMProjectedRec
}
+bool RMProjectedSizeEqualToProjectedSize(RMProjectedSize size1, RMProjectedSize size2) {
+ return ((size1.width == size2.width) && (size1.height == size2.height));
+}
+
+bool RMProjectedRectEqualToProjectedRect(RMProjectedRect rect1, RMProjectedRect rect2) {
+ return (RMProjectedPointEqualToProjectedPoint(rect1.origin, rect2.origin) && RMProjectedSizeEqualToProjectedSize(rect1.size, rect2.size));
+}
+
RMProjectedPoint RMScaleProjectedPointAboutPoint(RMProjectedPoint point, float factor, RMProjectedPoint pivot)
{
point.easting = (point.easting - pivot.easting) * factor + pivot.easting;
@@ -88,6 +96,13 @@ RMProjectedPoint RMMakeProjectedPoint (double easting, double northing)
return point;
}
+RMProjectedSize RMMakeProjectedSize(double width, double height) {
+ RMProjectedSize size = {
+ width, height
+ };
+ return size;
+}
+
RMProjectedRect RMMakeProjectedRect (double easting, double northing, double width, double height)
{
RMProjectedRect rect = {
@@ -97,3 +112,14 @@ RMProjectedRect RMMakeProjectedRect (double easting, double northing, double wi
return rect;
}
+
+double RMProjectedRectGetMidEasting(RMProjectedRect rect) {
+ return (rect.origin.easting + rect.size.width / 2);
+}
+
+double RMProjectedRectGetMidNorthing(RMProjectedRect rect){
+ return (rect.origin.northing + rect.size.height / 2);
+}
+
+
+
16 MapView/Map/RMFoundation.h
View
@@ -48,7 +48,11 @@ typedef struct {
/// \brief The function checks whether two passed projected points are equal.
bool RMProjectedPointEqualToProjectedPoint(RMProjectedPoint point1, RMProjectedPoint point2);
-/// \brief The function returs true, if passed rects intersect each other.
+/// \brief The fuction returns true if the passed sizes are equal
+bool RMProjectedSizeEqualToProjectedSize(RMProjectedSize size1, RMProjectedSize size2);
+/// \brief The fuction returns true if the passed rects are equal
+bool RMProjectedRectEqualToProjectedRect(RMProjectedRect rect1, RMProjectedRect rect2);
+/// \brief The function returns true if passed rects intersect each other.
bool RMProjectedRectInterectsProjectedRect(RMProjectedRect rect1, RMProjectedRect rect2);
RMProjectedPoint RMScaleProjectedPointAboutPoint (RMProjectedPoint point, float factor, RMProjectedPoint pivot);
@@ -56,6 +60,12 @@ RMProjectedRect RMScaleProjectedRectAboutPoint(RMProjectedRect rect, float fa
RMProjectedPoint RMTranslateProjectedPointBy (RMProjectedPoint point, RMProjectedSize delta);
RMProjectedRect RMTranslateProjectedRectBy (RMProjectedRect rect, RMProjectedSize delta);
-RMProjectedPoint RMMakeProjectedPoint (double easting, double northing);
-RMProjectedRect RMMakeProjectedRect (double easting, double northing, double width, double height);
+RMProjectedPoint RMMakeProjectedPoint (double easting, double northing);
+RMProjectedSize RMMakeProjectedSize(double width, double height);
+RMProjectedRect RMMakeProjectedRect (double easting, double northing, double width, double height);
+/// \brief The function returns the midpoint easting of the given rect.
+double RMProjectedRectGetMidEasting(RMProjectedRect rect);
+
+/// \brief The function returns the midpoint northing of the given rect.
+double RMProjectedRectGetMidNorthing(RMProjectedRect rect);
Please sign in to comment.
Something went wrong with that request. Please try again.