LRAUV  revA
Location_Test.h
Go to the documentation of this file.
1 
9 #ifndef _LOCATION_TEST_H_
10 #define _LOCATION_TEST_H_
11 
12 
13 #include "Location.h"
14 #include "utils/AuvMath.h"
15 
16 #include <cxxtest/TestSuite.h>
17 
23 class Location_Test : public CxxTest::TestSuite
24 {
25 public:
26 
28  void testGetBearing( void )
29  {
30  float bearing = Location::GetBearing( D2R( 36.8 ), D2R( -121.8 ), D2R( 36.85 ), D2R( -121.85 ) );
31  TS_ASSERT_DELTA( R2D( bearing ), -38.6611, 0.0002 );
32  }
33 
35  void testGetDistance( void )
36  {
37  double shortDist = 7121.457;
38  double distance = Location::GetDistance( D2R( 36.8 ), D2R( -121.8 ), D2R( 36.85 ), D2R( -121.85 ) );
39  TS_ASSERT_DELTA( distance, shortDist, shortDist / 10000 );
40  double medDist( 2280495.4 );
41  distance = Location::GetDistance( D2R( 36.8 ), D2R( -121.8 ), D2R( 50 ), D2R( -100 ) );
42  TS_ASSERT_DELTA( distance, medDist, medDist / 500 );
43  double longDist( 15654367.0 );
44  distance = Location::GetDistance( D2R( 36.8 ), D2R( -121.8 ), D2R( -5.0 ), D2R( 33.0 ) );
45  TS_ASSERT_DELTA( distance, longDist, longDist / 500 );
46  }
47 
49  void testGetDistanceFast( void )
50  {
51  double shortDist = 7121.457;
52  double distance = Location::GetDistanceFast( D2R( 36.8 ), D2R( -121.8 ), D2R( 36.85 ), D2R( -121.85 ) );
53  TS_ASSERT_DELTA( distance, shortDist, shortDist / 10000 );
54  double medDist( 2280495.4 );
55  distance = Location::GetDistanceFast( D2R( 36.8 ), D2R( -121.8 ), D2R( 50 ), D2R( -100 ) );
56  TS_ASSERT_DELTA( distance, medDist, medDist / 400 );
57  }
58 
60  void testAtBearing( void )
61  {
62  double latitude = D2R( 36.8 );
63  double longitude = D2R( -121.8 );
64  Location::AtBearing( D2R( -38.6611 ), 7122.0, latitude, longitude );
65  TS_ASSERT_DELTA( R2D( latitude ), 36.85, 0.0001 );
66  TS_ASSERT_DELTA( R2D( longitude ), -121.85, 0.0001 );
67  }
68 
70  void testNorthingsDelta( void )
71  {
72  double latitude = D2R( 36.8 );
73  float northingsDelta = 1000;
74  latitude = Location::NorthingsDelta( latitude, northingsDelta );
75  TS_ASSERT_DELTA( R2D( latitude ), 36.80889, 0.0002 );
76  }
77 
78 };
79 
80 #endif // _LOCATION_TEST_H
void testGetDistance(void)
Test Location::GetDistance.
Definition: Location_Test.h:35
#define R2D(x)
A macro for converting radians to degrees.
Definition: AuvMath.h:44
#define D2R(x)
A macro for converting degrees to radians.
Definition: AuvMath.h:40
static double GetBearing(const double &latitude0, const double &longitude0, const double &latitude1, const double &longitude1)
Definition: Location.cpp:289
void testNorthingsDelta(void)
Test Location::NorthingsDelta.
Definition: Location_Test.h:70
Contains the AuvMath class declaration.
static double GetDistanceFast(const double &latitude0, const double &longitude0, const double &latitude1, const double &longitude1)
Definition: Location.cpp:328
void testAtBearing(void)
Test Location::AtBearing.
Definition: Location_Test.h:60
Unit tests for Location class.
Definition: Location_Test.h:23
void testGetDistanceFast(void)
Test Location::GetDistanceFast.
Definition: Location_Test.h:49
static double GetDistance(const double &latitude0, const double &longitude0, const double &latitude1, const double &longitude1)
Definition: Location.cpp:320
static double NorthingsDelta(const double startLat, const float northingsDelta)
Definition: Location.cpp:427
static void AtBearing(const float bearing, const float distance, double &lat, double &lon)
Definition: Location.cpp:348
Contains the Location class definition.
void testGetBearing(void)
Test Location::GetBearing.
Definition: Location_Test.h:28