10 #ifndef _DATUM_TEST_H_
11 #define _DATUM_TEST_H_
15 #include <cxxtest/TestSuite.h>
37 {9, 3637397.3, 504490.29, 32.8747, -128.952},
38 {13, 7020000.00, 601000.00, 63.29460, -102.98545},
39 {45, 4041000.00, 310000.00, -53.74495, 84.11865},
40 {30, 1000000.00, 320000.00, 9.04290, -4.63762},
41 {1, 2006662.71, 536362.95, -72.036631, -175.94358},
42 {22, 3000000.00, 340000.00, 27.11319, -52.61415},
43 {43, 4000000.00, 350000.00, -54.12621, 72.704513},
44 {32, 5000000.00, 360000.00, 45.13959, 7.21936},
45 {51, 6000000.00, 370000.00, -36.136002, 121.55516},
46 {23, 7000000.00, 380000.00, 63.1093989, -47.378387},
47 {27, 8000000.00, 390000.00, -18.085908, -22.039540},
48 {18, 1000000.00, 400000.00, 9.0454332, -75.909879},
49 {52, 2000000.00, 410000.00, -72.08165, 126.37834},
50 {37, 3000000.00, 420000.00, 27.1201503, 38.19282790},
51 {28, 3000000.00, 430000.00, -63.1225521, -16.3878649},
52 {19, 4000000.00, 440000.00, 36.142861187, -69.66692297},
53 {16, 5002000.00, 450000.00, -45.1337036, -87.6358752},
54 {10, 6653097.435007, 611544.041980, 60, -121},
55 {9, 3988112.0, 770420.7, 36, -126.00001},
56 {10, 3988112.0, 229587.58, 36, -125.9999},
57 {16, 3319206.291, 403549.8474, 30, -88},
58 {27, 1879826.693, 393552.2529, 17, -22},
59 {43, 3320469.355, 692915.1064, 30, 77},
60 {51, 6653097.504, 388455.9545, 60, 121},
61 {55, 4429673.051, 670725.4996, 40, 149},
62 {53, 5792297.556, 324396.6244, -38, 133},
63 {36, 5127641.036, 419825.74, -44, 32},
64 {54, 1453013.284, 525110.2007, -77, 142},
65 {7, 2791172.394, 452844.8776, -65, -142},
66 {27, 8894421.383, 609600.7722, -10, -20},
67 {17, 3903379.219, 627928.1961, -55, -79},
68 {31, 0, 500000, 0, 3},
69 {31, 0, 166021.5497, 0, 0},
85 unsigned int zone = 0;
86 double northings = 0.0, eastings = 0.0;
87 bool northernHemi =
true;
90 for(
int i = 0; testData[i].
zone != 0; i++ )
93 D2R( testData[i].lon ),
94 northings, eastings, zone, northernHemi );
96 snprintf( message, 79,
"Testing lat/long %.3lf,%.3lf", testData[i].lat, testData[i].lon );
97 TSM_ASSERT_EQUALS( message, error, 0 );
98 TSM_ASSERT_EQUALS( message, zone, testData[i].zone );
99 TSM_ASSERT_DELTA( message, northings, testData[i].northings,
UTMFUDGE );
100 TSM_ASSERT_DELTA( message, eastings, testData[i].eastings,
UTMFUDGE );
101 TSM_ASSERT_EQUALS( message, northernHemi, ( testData[i].lat >= 0 ) );
103 double lat = 0.0, lon = 0.0;
113 TSM_ASSERT_EQUALS( message, error , 0 );
114 TSM_ASSERT_DELTA( message, lat, testData[i].lat,
LATLONFUDGE );
115 TSM_ASSERT_DELTA( message, lon, testData[i].lon,
LATLONFUDGE );
124 for(
int i = 0; testData[i].
zone != 0; i++ )
126 double lat = 0.0, lon = 0.0;
133 testData[i].eastings,
135 testData[i].lat >= 0,
139 snprintf( message, 79,
"Testing N/E %.3lf,%.3lf", testData[i].northings, testData[i].eastings );
140 TSM_ASSERT_EQUALS( message, error, 0 );
141 TSM_ASSERT_DELTA( message, lat, testData[i].lat,
LATLONFUDGE );
142 TSM_ASSERT_DELTA( message, lon, testData[i].lon,
LATLONFUDGE );
145 double northings = 0.0, eastings = 0.0;
146 unsigned int zone = 0;
147 bool northernHemi =
true;
150 northings, eastings, zone, northernHemi );
152 TSM_ASSERT_EQUALS( message, error, 0 );
153 TSM_ASSERT_EQUALS( message, zone, testData[i].zone );
154 TSM_ASSERT_DELTA( message, northings, testData[i].northings,
UTMFUDGE );
155 TSM_ASSERT_DELTA( message, eastings, testData[i].eastings,
UTMFUDGE );
156 TSM_ASSERT_EQUALS( message, northernHemi, ( testData[i].lat >= 0 ) );
166 #endif // _DATUM_TEST_H
Contains the CodedStr class declaration.
void testUtmToLatLon(void)
Definition: Datum_Test.h:121
#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
const double LATLONFUDGE
Definition: Datum_Test.h:18
unsigned int zone
Definition: Datum_Test.h:23
void testLatLonToUtm(void)
Definition: Datum_Test.h:83
static long LatLonToUtm(const double lat, const double lon, double &northings, double &eastings, unsigned int &zone, bool &northernHemi)
Converts a lat and lon (in radians!) to northings/eastings/zone.
Definition: Datum.h:66
Definition: Datum_Test.h:21
double lat
Definition: Datum_Test.h:25
double lon
Definition: Datum_Test.h:25
DatumDataStruct testData[]
The original test data set was generated using the spreadsheet at: http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM originally as a utm-to-latlon and latlon-to-utm set (should be easy to tell apart based on the round numbers).
Definition: Datum_Test.h:35
double eastings
Definition: Datum_Test.h:24
static long UtmToLatLon(const double northings, const double eastings, const unsigned int zone, const bool northernHemi, double &lat, double &lon)
Converts a UTM and zone to lat/lon (in radians!).
Definition: Datum.h:49
double northings
Definition: Datum_Test.h:24
Units tests for class Datum
Definition: Datum_Test.h:79
const double UTMFUDGE
Definition: Datum_Test.h:17