99 double equatorialRadius;
105 double inverseFlattening;
115 double eccentricitySqr;
160 EarthShape(
const string& earthShape =
"WGS84") { setEarthShape(earthShape); }
189 shapeName = earthShape;
191 if (earthShape ==
"SPHERE")
193 equatorialRadius = 6371;
194 inverseFlattening = 1e99;
195 constantRadius =
true;
197 else if (earthShape ==
"GRS80")
199 equatorialRadius = 6378.137;
200 inverseFlattening = 298.257222101;
201 constantRadius =
false;
203 else if (earthShape ==
"GRS80_RCONST")
205 equatorialRadius = 6371.;
206 inverseFlattening = 298.257222101;
207 constantRadius =
true;
209 else if (earthShape ==
"WGS84")
211 equatorialRadius = 6378.137;;
212 inverseFlattening = 298.257223563;
213 constantRadius =
false;
215 else if (earthShape ==
"WGS84_RCONST")
217 equatorialRadius = 6371.;
218 inverseFlattening = 298.257223563;
219 constantRadius =
true;
221 else if (earthShape ==
"IERS2003")
223 equatorialRadius = 6378.1366;
224 inverseFlattening = 298.25642;
225 constantRadius =
false;
227 else if (earthShape ==
"IERS2003_RCONST")
229 equatorialRadius = 6371.;
230 inverseFlattening = 298.25642;
231 constantRadius =
true;
236 os << endl <<
"ERROR in EarthShape::setEarthShape" << endl
237 << earthShape <<
" is not a recognized EarthShape" << endl
238 <<
"Valid EarthShapes include SPHERE, GRS80, GRS80_RCONST, WGS84, WGS84_RCONST, IERS2003 and IERS2003_RCONST" << endl;
242 sphere = shapeName ==
"SPHERE";
243 eccentricitySqr = (2.- 1./inverseFlattening)/inverseFlattening;
244 e1 = 1.-eccentricitySqr;
245 e2 = eccentricitySqr/(1.-eccentricitySqr);
260 {
return "EarthShape"; }
277 {
return constantRadius ? equatorialRadius : equatorialRadius / sqrt(1 + e2 * v[2] * v[2]); }
287 {
return sphere ? lat : atan(tan(lat) * e1); }
297 {
return sphere ? lat : atan(tan(lat) / e1); }
307 {
return sphere ? lat : CPPUtils::toDegrees(atan(tan(CPPUtils::toRadians(lat)) * e1)); }
317 {
return sphere ? lat : CPPUtils::toDegrees(atan(tan(CPPUtils::toRadians(lat)) / e1)); }
326 {
return getGeographicLat(asin(v[2])); }
335 {
return CPPUtils::toDegrees(getLat(v)); }
344 {
return atan2(v[1], v[0]); }
353 {
return CPPUtils::toDegrees(atan2(v[1], v[0])); }
366 { getVector(CPPUtils::toRadians(lat), CPPUtils::toRadians(lon), v); }
379 {
return getVector(CPPUtils::toRadians(lat), CPPUtils::toRadians(lon)); }
394 double* v =
new double[3];
395 getVector(lat, lon, v);
409 double*
getVector(
const double& lat,
const double& lon,
double* v)
412 double temp = getGeocentricLat(lat);
421 v[0] = temp * cos(lon);
422 v[1] = temp * sin(lon);
434 string frmt(
"%9.5f %10.5f");
435 sprintf(s, frmt.c_str(), getLatDegrees(v), getLonDegrees(v));
456 #endif // EARTH_SHAPE_H