97 double equatorialRadius;
103 double inverseFlattening;
113 double eccentricitySqr;
158 EarthShape(
const string& earthShape =
"WGS84") { setEarthShape(earthShape); }
187 shapeName = earthShape;
189 if (earthShape ==
"SPHERE")
191 equatorialRadius = 6371;
192 inverseFlattening = 1e99;
193 constantRadius =
true;
195 else if (earthShape ==
"GRS80")
197 equatorialRadius = 6378.137;
198 inverseFlattening = 298.257222101;
199 constantRadius =
false;
201 else if (earthShape ==
"GRS80_RCONST")
203 equatorialRadius = 6371.;
204 inverseFlattening = 298.257222101;
205 constantRadius =
true;
207 else if (earthShape ==
"WGS84")
209 equatorialRadius = 6378.137;;
210 inverseFlattening = 298.257223563;
211 constantRadius =
false;
213 else if (earthShape ==
"WGS84_RCONST")
215 equatorialRadius = 6371.;
216 inverseFlattening = 298.257223563;
217 constantRadius =
true;
219 else if (earthShape ==
"IERS2003")
221 equatorialRadius = 6378.1366;
222 inverseFlattening = 298.25642;
223 constantRadius =
false;
225 else if (earthShape ==
"IERS2003_RCONST")
227 equatorialRadius = 6371.;
228 inverseFlattening = 298.25642;
229 constantRadius =
true;
234 os << endl <<
"ERROR in EarthShape::setEarthShape" << endl
235 << earthShape <<
" is not a recognized EarthShape" << endl
236 <<
"Valid EarthShapes include SPHERE, GRS80, GRS80_RCONST, WGS84, WGS84_RCONST, IERS2003 and IERS2003_RCONST" << endl;
240 sphere = shapeName ==
"SPHERE";
241 eccentricitySqr = (2.- 1./inverseFlattening)/inverseFlattening;
242 e1 = 1.-eccentricitySqr;
243 e2 = eccentricitySqr/(1.-eccentricitySqr);
258 {
return "EarthShape"; }
275 {
return constantRadius ? equatorialRadius : equatorialRadius / sqrt(1 + e2 * v[2] * v[2]); }
285 {
return sphere ? lat : atan(tan(lat) * e1); }
295 {
return sphere ? lat : atan(tan(lat) / e1); }
305 {
return sphere ? lat : CPPUtils::toDegrees(atan(tan(CPPUtils::toRadians(lat)) * e1)); }
315 {
return sphere ? lat : CPPUtils::toDegrees(atan(tan(CPPUtils::toRadians(lat)) / e1)); }
324 {
return getGeographicLat(asin(v[2])); }
333 {
return CPPUtils::toDegrees(getLat(v)); }
342 {
return atan2(v[1], v[0]); }
351 {
return CPPUtils::toDegrees(atan2(v[1], v[0])); }
364 { getVector(CPPUtils::toRadians(lat), CPPUtils::toRadians(lon), v); }
376 {
return getVector(CPPUtils::toRadians(lat), CPPUtils::toRadians(lon)); }
391 double* v =
new double[3];
392 getVector(lat, lon, v);
406 double*
getVector(
const double& lat,
const double& lon,
double* v)
409 double temp = getGeocentricLat(lat);
418 v[0] = temp * cos(lon);
419 v[1] = temp * sin(lon);
431 string frmt(
"%9.5f %10.5f");
432 sprintf(s, frmt.c_str(), getLatDegrees(v), getLonDegrees(v));
Defines the ellipsoid that is to be used to convert between geocentric and geographic latitude and be...
bool isConstantRadius() const
double getLat(const double *const v)
double * getVectorDegrees(const double &lat, const double &lon)
double getGeographicLatDegrees(const double &lat)
double getInverseFlattening() const
double getGeocentricLatDegrees(const double &lat)
double getLatDegrees(const double *const v)
double * getVector(const double &lat, const double &lon, double *v)
double getEccentricitySqr() const
double getLonDegrees(const double *const v)
double getLon(const double *const v)
double getGeocentricLat(const double &lat)
void getVectorDegrees(const double &lat, const double &lon, double *v)
EarthShape(const string &earthShape="WGS84")
double getEquatorialRadius() const
double getEarthRadius(const double *const v)
double * getVector(const double &lat, const double &lon)
double getGeographicLat(const double &lat)
string getLatLonString(const double *const v)
static string class_name()
virtual int class_size() const
void setEarthShape(const string &earthShape)
const string & getShapeName() const
An exception class for all GeoTess objects.