76 double equatorialRadius;
82 double inverseFlattening;
92 double eccentricitySqr;
137 EarthShape(
const string& earthShape =
"WGS84") { setEarthShape(earthShape); }
166 shapeName = earthShape;
168 if (earthShape ==
"SPHERE")
170 equatorialRadius = 6371;
171 inverseFlattening = 1e99;
172 constantRadius =
true;
174 else if (earthShape ==
"GRS80")
176 equatorialRadius = 6378.137;
177 inverseFlattening = 298.257222101;
178 constantRadius =
false;
180 else if (earthShape ==
"GRS80_RCONST")
182 equatorialRadius = 6371.;
183 inverseFlattening = 298.257222101;
184 constantRadius =
true;
186 else if (earthShape ==
"WGS84")
188 equatorialRadius = 6378.137;;
189 inverseFlattening = 298.257223563;
190 constantRadius =
false;
192 else if (earthShape ==
"WGS84_RCONST")
194 equatorialRadius = 6371.;
195 inverseFlattening = 298.257223563;
196 constantRadius =
true;
198 else if (earthShape ==
"IERS2003")
200 equatorialRadius = 6378.1366;
201 inverseFlattening = 298.25642;
202 constantRadius =
false;
204 else if (earthShape ==
"IERS2003_RCONST")
206 equatorialRadius = 6371.;
207 inverseFlattening = 298.25642;
208 constantRadius =
true;
213 os << endl <<
"ERROR in EarthShape::setEarthShape" << endl
214 << earthShape <<
" is not a recognized EarthShape" << endl
215 <<
"Valid EarthShapes include SPHERE, GRS80, GRS80_RCONST, WGS84, WGS84_RCONST, IERS2003 and IERS2003_RCONST" << endl;
219 sphere = shapeName ==
"SPHERE";
220 eccentricitySqr = (2.- 1./inverseFlattening)/inverseFlattening;
221 e1 = 1.-eccentricitySqr;
222 e2 = eccentricitySqr/(1.-eccentricitySqr);
237 {
return "EarthShape"; }
255 return constantRadius ? equatorialRadius
256 : equatorialRadius / sqrt(1 + e2 * v[2] * v[2]);
269 return sphere ? lat : atan(tan(lat) * e1);
281 return sphere ? lat : atan(tan(lat) / e1);
293 return getGeoGraphicLatitude(asin(v[2]));
304 return CPPUtils::toDegrees(getLat(v));
315 return atan2(v[1], v[0]);
326 return CPPUtils::toDegrees(atan2(v[1], v[0]));
343 return getVector(CPPUtils::toRadians(lat), CPPUtils::toRadians(lon));
357 const double& lon,
double* v)
359 return getVector(CPPUtils::toRadians(lat), CPPUtils::toRadians(lon), v);
375 double* v =
new double[3];
376 getVector(lat, lon, v);
390 double*
getVector(
const double& lat,
const double& lon,
double* v)
393 double temp = getGeoCentricLatitude(lat);
402 v[0] = temp * cos(lon);
403 v[1] = temp * sin(lon);
415 string frmt(
"%9.5f %10.5f");
416 sprintf(s, frmt.c_str(), getLatDegrees(v), getLonDegrees(v));
437 #endif // EARTH_SHAPE_H
double getLon(const double *const v)
Definition: EarthShape.h:313
double getGeoCentricLatitude(const double &lat)
Definition: EarthShape.h:266
double getEarthRadius(const double *const v)
Definition: EarthShape.h:253
double getGeoGraphicLatitude(const double &lat)
Definition: EarthShape.h:279
double * getVector(const double &lat, const double &lon, double *v)
Definition: EarthShape.h:390
void setEarthShape(const string &earthShape)
Definition: EarthShape.h:164
const string & getShapeName() const
Definition: EarthShape.h:430
double * getVectorDegrees(const double &lat, const double &lon)
Definition: EarthShape.h:340
double getLatDegrees(const double *const v)
Definition: EarthShape.h:302
double getLonDegrees(const double *const v)
Definition: EarthShape.h:324
An exception class for all GeoTess objects.
Definition: GeoTessException.h:65
static string class_name()
Definition: EarthShape.h:236
virtual ~EarthShape()
Definition: EarthShape.h:228
double * getVector(const double &lat, const double &lon)
Definition: EarthShape.h:373
Definition: EarthShape.h:64
virtual int class_size() const
Definition: EarthShape.h:243
double getInverseFlattening() const
Definition: EarthShape.h:426
string getLatLonString(const double *const v)
Definition: EarthShape.h:412
bool isConstantRadius() const
Definition: EarthShape.h:420
bool isSphere() const
Definition: EarthShape.h:428
double getLat(const double *const v)
Definition: EarthShape.h:291
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
double * getVectorDegrees(const double &lat, const double &lon, double *v)
Definition: EarthShape.h:356
double getEquatorialRadius() const
Definition: EarthShape.h:424
double getEccentricitySqr() const
Definition: EarthShape.h:422
EarthShape(const string &earthShape="WGS84")
Definition: EarthShape.h:137