| 90 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 91 | |
| 92 | bool FGInertial::Load(Element* el) |
| 93 | { |
| 94 | if (!Upload(el, true)) return false; |
| 95 | |
| 96 | Name = el->GetAttributeValue("name"); |
| 97 | |
| 98 | if (el->FindElement("semimajor_axis")) |
| 99 | a = el->FindElementValueAsNumberConvertTo("semimajor_axis", "FT"); |
| 100 | else if (el->FindElement("equatorial_radius")) |
| 101 | a = el->FindElementValueAsNumberConvertTo("equatorial_radius", "FT"); |
| 102 | if (el->FindElement("semiminor_axis")) |
| 103 | b = el->FindElementValueAsNumberConvertTo("semiminor_axis", "FT"); |
| 104 | else if (el->FindElement("polar_radius")) |
| 105 | b = el->FindElementValueAsNumberConvertTo("polar_radius", "FT"); |
| 106 | // Trigger GeographicLib exceptions if the equatorial or polar radii are |
| 107 | // ill-defined. |
| 108 | // This intercepts the exception before being thrown by a destructor. |
| 109 | GeographicLib::Geodesic geod(a, 1.-b/a); |
| 110 | |
| 111 | if (el->FindElement("rotation_rate")) { |
| 112 | double RotationRate = el->FindElementValueAsNumberConvertTo("rotation_rate", "RAD/SEC"); |
| 113 | vOmegaPlanet = {0., 0., RotationRate}; |
| 114 | } |
| 115 | if (el->FindElement("GM")) |
| 116 | GM = el->FindElementValueAsNumberConvertTo("GM", "FT3/SEC2"); |
| 117 | if (el->FindElement("J2")) |
| 118 | J2 = el->FindElementValueAsNumber("J2"); // Dimensionless |
| 119 | |
| 120 | GroundCallback->SetEllipse(a, b); |
| 121 | |
| 122 | // Messages to warn the user about possible inconsistencies. |
| 123 | if (debug_lvl > 0) { |
| 124 | FGLogging log(LogLevel::WARN); |
| 125 | if (a != b && J2 == 0.0) |
| 126 | log << "Gravitational constant J2 is null for a non-spherical planet." << endl; |
| 127 | if (a == b && J2 != 0.0) |
| 128 | log << "Gravitational constant J2 is non-zero for a spherical planet." << endl; |
| 129 | } |
| 130 | |
| 131 | Debug(2); |
| 132 | |
| 133 | return true; |
| 134 | } |
| 135 | |
| 136 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 137 |
nothing calls this directly
no test coverage detected