testAugerCoordinateSystem.cc
Go to the documentation of this file.
1 
10 // header for unit test testCS
11 #include <utl/AugerCoordinateSystem.h>
12 #include <utl/CoordinateSystem.h>
13 #include <utl/Point.h>
14 #include <utl/UTMPoint.h>
15 #include <utl/AugerUnits.h>
16 #include <tst/Verify.h>
17 #include <utl/Triple.h>
18 
19 #include <cppunit/extensions/HelperMacros.h>
20 
21 using namespace utl;
22 using namespace tst;
23 
24 
28 class testAugerCoordinateSystem : public CppUnit::TestFixture {
29 
30  CPPUNIT_TEST_SUITE(testAugerCoordinateSystem);
31  CPPUNIT_TEST(testCS);
32  CPPUNIT_TEST(testSiteCS);
33  CPPUNIT_TEST_SUITE_END();
34 
35 private:
36  void
38  {
39  const ReferenceEllipsoid e =
41  double lat, lon, h;
42  boost::tie(lat, lon, h) = e.PointToLatitudeLongitudeHeight(p);
43 
44  const CoordinateSystemPtr ecef = e.GetECEF();
46 
47  const Point o(0,0,0, cs); // origin in local CS
48  // should be the same point ...
49  CPPUNIT_ASSERT(Verify<CloseTo>(
50  o.GetCoordinates(ecef), p.GetCoordinates(ecef)));
51 
52  CPPUNIT_ASSERT(Verify<CloseTo>(
53  p.GetCoordinates(cs), Triple(0,0,0)));
54 
55  const Point pNorth(0, 10*m, 0, cs);
56  // going north should not change longitude
57  CPPUNIT_ASSERT(Verify<CloseTo>(
58  lon, e.PointToLatitudeLongitudeHeight(pNorth).get<1>()));
59  // going north should change height only to second order
60  CPPUNIT_ASSERT(Verify<CloseTo>(
61  h - e.PointToLatitudeLongitudeHeight(pNorth).get<2>(), 0., 10*micrometer));
62 
63  const Point pUp(0, 0, 1*km, cs);
64  // going up should change neither latitude
65  CPPUNIT_ASSERT(Verify<CloseTo>(
66  lat, e.PointToLatitudeLongitudeHeight(pUp).get<0>()));
67  // nor longitude
68  CPPUNIT_ASSERT(Verify<CloseTo>(
69  lon, e.PointToLatitudeLongitudeHeight(pUp).get<1>()));
70  }
71 
72 public:
73  void setUp() { }
74 
75  void tearDown() { }
76 
77  void
79  {
80  const ReferenceEllipsoid e =
82  const CoordinateSystemPtr ecef = e.GetECEF();
83 
84  const UTMPoint centralCampusUTM(6075445*m, 446954*m, 1444*m, 19, 'H', e);
85  const Point centralCampus(centralCampusUTM.GetPoint());
86  checkOnePoint(centralCampus);
87 
88  const CoordinateSystemPtr cs =
89  AugerCoordinateSystem::Create(centralCampus, e, ecef);
90  const CoordinateSystemPtr csu =
91  AugerCoordinateSystem::Create(centralCampusUTM, ecef);
92 
93  CPPUNIT_ASSERT(Verify<CloseTo>(
94  cs->GetTransformation().Distance(csu->GetTransformation()), 0.));
95 
96  const UTMPoint malargueOriginUTM(6060000*m, 440000*m, 0*m, 19, 'H', e);
97  const Point malargueOrigin(malargueOriginUTM.GetPoint());
98  checkOnePoint(malargueOrigin);
99  }
100 
101  void
102  testSiteCS() // mimick the use of the auger site CS
103  {
104  const ReferenceEllipsoid e =
106  const CoordinateSystemPtr ecef = e.GetECEF();
107 
108  const UTMPoint malargueOriginUTM(6060000*m, 440000*m, 0*m, 19, 'H', e);
109  const Point malargueOrigin(malargueOriginUTM.GetPoint());
110 
111  const UTMPoint centralCampusUTM(6075445*m, 446954*m, 1444*m, 19, 'H', e);
112  const Point centralCampus(centralCampusUTM.GetPoint());
113 
114  // regular site CS is a base CS
115  const CoordinateSystemPtr siteCS =
116  AugerBaseCoordinateSystem::Create(malargueOriginUTM, ecef);
117 
118  CPPUNIT_ASSERT(Verify<CloseTo>(
119  malargueOrigin.GetCoordinates(siteCS), Triple(0,0,0)));
120 
121  const CoordinateSystemPtr localCS =
122  AugerCoordinateSystem::Create(centralCampus, e, siteCS);
123 
124  CPPUNIT_ASSERT(Verify<CloseTo>(
125  centralCampus.GetCoordinates(localCS), Triple(0,0,0)));
126 
127  // test again for regular (non-base) CS
128  const CoordinateSystemPtr siteCSnonBase =
129  AugerCoordinateSystem::Create(malargueOriginUTM, ecef);
130 
131  CPPUNIT_ASSERT(Verify<CloseTo>(
132  malargueOrigin.GetCoordinates(siteCSnonBase), Triple(0,0,0)));
133 
134  const CoordinateSystemPtr localCS2 =
135  AugerCoordinateSystem::Create(centralCampus, e, siteCSnonBase);
136 
137  CPPUNIT_ASSERT(Verify<CloseTo>(
138  centralCampus.GetCoordinates(localCS2), Triple(0,0,0)));
139 
140  // this should use the same reference system and transformation as
141  // localCS2 since localCS2 is relative to a non-base CS that uses
142  // the ecef as a reference system
143  const CoordinateSystemPtr localCSecef =
144  AugerCoordinateSystem::Create(centralCampus, e, ecef);
145 
146  CPPUNIT_ASSERT(Verify<Equal>(
147  localCS2->GetReferenceSystem(), localCSecef->GetReferenceSystem()));
148  CPPUNIT_ASSERT(Verify<CloseTo>(
149  localCS2->GetTransformation().Distance(localCSecef->GetTransformation()), 0.));
150 
151  // now remove the CS two levels of base systems from the ECEF
152  const CoordinateSystemPtr campusCS =
153  AugerBaseCoordinateSystem::Create(centralCampusUTM, siteCS);
154 
155  const UTMPoint losLeonesUTM(6071794*m, 459218*m, 1444*m, 19, 'H', e);
156  const Point losLeones = losLeonesUTM.GetPoint();
157 
158  const CoordinateSystemPtr llCS =
159  AugerCoordinateSystem::Create(losLeonesUTM, campusCS);
160 
161  CPPUNIT_ASSERT(Verify<CloseTo>(
162  losLeones.GetCoordinates(llCS), Triple(0,0,0)));
163 
164  const CoordinateSystemPtr llBaseCS =
165  AugerBaseCoordinateSystem::Create(losLeonesUTM, campusCS);
166 
167  CPPUNIT_ASSERT(Verify<CloseTo>(
168  losLeones.GetCoordinates(llBaseCS), Triple(0,0,0)));
169  }
170 
171 };
172 
173 
175 
176 
177 // Configure (x)emacs for this file ...
178 // Local Variables:
179 // mode:c++
180 // compile-command: "make -C .. -k testGeometry && ../testGeometry"
181 // End:
static Policy::type Create(const Point &theOrigin, const ReferenceEllipsoid &theEllipsoid, const CoordinateSystemPtr &theReferenceCS)
Point object.
Definition: Point.h:32
constexpr double km
Definition: AugerUnits.h:125
Class to hold and convert a point in geodetic coordinates.
Definition: UTMPoint.h:40
static const ReferenceEllipsoid & Get(const EllipsoidID theID)
Get known ellipsoid by registered ID.
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
constexpr double micrometer
Definition: AugerUnits.h:101
boost::tuple< double, double, double > Triple
Coordinate triple for easy getting or setting of coordinates.
Definition: Triple.h:15
Reference ellipsoids for UTM transformations.
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
const CoordinateSystemPtr GetECEF() const
Get the ECEF.
Point GetPoint(const CoordinateSystemPtr &theCS=CoordinateSystemPtr()) const
Get a cartesian point from an UTMPoint.
Definition: UTMPoint.cc:45
constexpr double m
Definition: AugerUnits.h:121

, generated on Tue Sep 26 2023.