00001 #pragma ident "$Id: XYZ2NEU.cpp 1325 2008-07-29 14:33:43Z architest $"
00002
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "XYZ2NEU.hpp"
00033
00034
00035 namespace gpstk
00036 {
00037
00038
00039
00040 int XYZ2NEU::classIndex = 7200000;
00041
00042
00043
00044 int XYZ2NEU::getIndex() const
00045 { return index; }
00046
00047
00048
00049 std::string XYZ2NEU::getClassName() const
00050 { return "XYZ2NEU"; }
00051
00052
00053
00054
00055
00056
00057
00058 XYZ2NEU::XYZ2NEU(const Position& refPos)
00059 {
00060
00061 setLatLon( refPos.getGeodeticLatitude(),
00062 refPos.getLongitude() );
00063
00064 setIndex();
00065
00066 }
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 XYZ2NEU& XYZ2NEU::setLat(const double& lat)
00078 {
00079
00080 if ( (lat > 90.0) ||
00081 (lat < -90.0) )
00082 {
00083 refLat = 0.0;
00084 }
00085 else
00086 {
00087 refLat = (lat*DEG_TO_RAD);
00088 }
00089
00090 init();
00091
00092 return (*this);
00093
00094 }
00095
00096
00097
00098
00099
00100
00101
00102 XYZ2NEU& XYZ2NEU::setLon(const double& lon)
00103 {
00104
00105 refLon = (lon*DEG_TO_RAD);
00106
00107 init();
00108
00109 return (*this);
00110
00111 }
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 XYZ2NEU& XYZ2NEU::setLatLon( const double& lat,
00125 const double& lon )
00126 {
00127
00128
00129 if ( (lat > 90.0) ||
00130 (lat < -90.0) )
00131 {
00132 refLat = 0.0;
00133 }
00134 else
00135 {
00136 refLat = (lat*DEG_TO_RAD);
00137 }
00138
00139 refLon = (lon*DEG_TO_RAD);
00140
00141 init();
00142
00143 return (*this);
00144
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154 satTypeValueMap& XYZ2NEU::Process(satTypeValueMap& gData)
00155 throw(ProcessingException)
00156 {
00157
00158 try
00159 {
00160
00161 Matrix<double> neuMatrix;
00162
00163
00164 Matrix<double> dMatrix(gData.getMatrixOfTypes(inputSet));
00165
00166
00167
00168 neuMatrix = dMatrix*rotationMatrix;
00169
00170 gData.insertMatrix(outputSet, neuMatrix);
00171
00172 return gData;
00173
00174 }
00175 catch(Exception& u)
00176 {
00177
00178 ProcessingException e( getClassName() + ":"
00179 + StringUtils::asString( getIndex() ) + ":"
00180 + u.what() );
00181
00182 GPSTK_THROW(e);
00183
00184 }
00185
00186 }
00187
00188
00189
00190
00191
00192 void XYZ2NEU::init()
00193 {
00194
00195
00196 rotationMatrix.resize(3,3);
00197
00198
00199 rotationMatrix(0,0) = -std::sin(refLat)*std::cos(refLon);
00200 rotationMatrix(1,0) = -std::sin(refLat)*std::sin(refLon);
00201 rotationMatrix(2,0) = std::cos(refLat);
00202 rotationMatrix(0,1) = -std::sin(refLon);
00203 rotationMatrix(1,1) = std::cos(refLon);
00204 rotationMatrix(2,1) = 0.0;
00205 rotationMatrix(0,2) = std::cos(refLat)*std::cos(refLon);
00206 rotationMatrix(1,2) = std::cos(refLat)*std::sin(refLon);
00207 rotationMatrix(2,2) = std::sin(refLat);
00208
00209
00210 inputSet.clear();
00211 inputSet.insert(TypeID::dx);
00212 inputSet.insert(TypeID::dy);
00213 inputSet.insert(TypeID::dz);
00214
00215 outputSet.clear();
00216 outputSet.insert(TypeID::dLat);
00217 outputSet.insert(TypeID::dLon);
00218 outputSet.insert(TypeID::dH);
00219
00220 }
00221
00222
00223
00224 }