4 #include <utl/ReferenceEllipsoid.h>
5 #include <utl/CoordinateSystem.h>
6 #include <utl/AugerUnits.h>
7 #include <utl/ErrorLogger.h>
8 #include <utl/AugerException.h>
10 #include <utl/StringCompare.h>
21 return 1 -
sqrt(1-fEccentricity2);
29 return fEquatorialRadius * (1 - GetFlattening());
39 const double&
a = fEquatorialRadius;
40 const double& e2 = fEccentricity2;
41 const double sinPhi = sin(phi);
43 return a /
sqrt(1 - e2*sinPhi*sinPhi);
66 boost::tie(x, y, z) = pt.GetCoordinates(fECEF);
68 const double& e2 = fEccentricity2;
70 double p =
sqrt(x*x + y*y);
72 double longitude = atan2(y, x);
75 double latitude = atan(z/
p);
79 height =
abs(z) - GetPolarRadius();
82 const int iterations = 4;
83 for (
int i = 0; i < iterations; ++i) {
84 double Rn = GetRn(latitude);
85 height =
p / cos(latitude) - Rn;
86 latitude = atan(z/
p/(1 - e2*(Rn / (Rn+height) ) ) );
90 return boost::make_tuple(latitude, longitude, height);
101 double const longitude,
107 const double& e2 = fEccentricity2;
109 double Rn = GetRn(latitude);
111 double x = (Rn + height) * cos(latitude) * cos(longitude);
112 double y = (Rn + height) * cos(latitude) * sin(longitude);
113 double z = (Rn*(1-e2) + height) * sin(latitude);
115 return Point(x, y, z, fECEF);
124 return LatitudeLongitudeHeightToPoint(theGeodeticCoordinates.get<0>(),
125 theGeodeticCoordinates.get<1>(),
126 theGeodeticCoordinates.get<2>());
144 boost::tuple<TransformationMatrix, TransformationMatrix>
150 double latitude, longitude, height;
151 boost::tie(latitude, longitude, height) =
152 PointToLatitudeLongitudeHeight(theOrigin);
154 boost::tie(x, y, z) =
Point(theOrigin).GetCoordinates(fECEF);
156 const double cosLat = cos(latitude);
157 const double sinLat = sin(latitude);
158 const double cosLon = cos(longitude);
159 const double sinLon = sin(longitude);
163 -sinLon, -sinLat*cosLon, cosLat*cosLon,
164 cosLon, -sinLat*sinLon, cosLat*sinLon,
170 return boost::make_tuple(trans, rot);
189 InitWithECEF(CoordinateSystem::GetRootCoordinateSystem());
191 Registry::iterator i = gfRegistry->find(theID);
192 if (i == gfRegistry->end()) {
194 msg <<
"Ellipsoid with id " << theID <<
" not existent.";
218 string msg(
"Calling InitWithECEF, "
219 "but ReferenceEllipsoidRegistry already initialised.");
225 RegisterOneEllipsoid(eWGS84, 6378137.*
m, 0.00669437999013, theCS);
246 string msg(
"Unknown reference ellipsoid ");
255 double theEquatorialRadius,
256 double theEccentricity,
260 bool ok = gfRegistry->insert(make_pair(theID, e)).second;
263 msg <<
"Double insertion of ellipsoid with id" << theID;
Point LatitudeLongitudeHeightToPoint(double const latitude, double const longitude, double const height) const
Convert Lat/Long/Height to Point.
static const ReferenceEllipsoid & Get(const EllipsoidID theID)
Get known ellipsoid by registered ID.
bool StringEquivalent(const std::string &a, const std::string &b, Predicate p)
Utility to compare strings for equivalence. It takes a predicate to determine the equivalence of indi...
static void RegisterOneEllipsoid(const EllipsoidID theID, double theEquatorialRadius, double theEccentricity, const CoordinateSystemPtr &theECEF)
boost::tuple< TransformationMatrix, TransformationMatrix > TransformECEFToLocalSystem(const Point &theOrigin) const
Translation and rotation to go to local coordinate system.
Exception to use if sequence of initialisations violated.
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
static Registry * gfRegistry
Reference ellipsoids for UTM transformations.
double abs(const SVector< n, T > &v)
double GetFlattening() const
Get flattening.
Triple PointToLatitudeLongitudeHeight(const Point &thePoint) const
Convert Point to Lat/Long/Height.
Report request for non-existent ellipsoid.
boost::tuple< double, double, double > Triple
Coordinate triple.
double GetPolarRadius() const
Get Polar radius ( )
#define WARNING(message)
Macro for logging warning messages.
std::map< EllipsoidID, const ReferenceEllipsoid > Registry
static void InitWithECEF(const CoordinateSystemPtr &theECEF)
Initialise the registry specifying the ECEF (instead of the Root CS)
EllipsoidID
ID's of known reference ellipsoid's.
#define ERROR(message)
Macro for logging error messages.
static EllipsoidID GetEllipsoidIDFromString(const std::string &str)
Get EllipsoidID from string.
double GetRn(const double phi) const