ModelObs.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ModelObs.cpp 1325 2008-07-29 14:33:43Z architest $"
00002 
00009 //============================================================================
00010 //
00011 //  This file is part of GPSTk, the GPS Toolkit.
00012 //
00013 //  The GPSTk is free software; you can redistribute it and/or modify
00014 //  it under the terms of the GNU Lesser General Public License as published
00015 //  by the Free Software Foundation; either version 2.1 of the License, or
00016 //  any later version.
00017 //
00018 //  The GPSTk is distributed in the hope that it will be useful,
00019 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //  GNU Lesser General Public License for more details.
00022 //
00023 //  You should have received a copy of the GNU Lesser General Public
00024 //  License along with GPSTk; if not, write to the Free Software Foundation,
00025 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 //
00027 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008
00028 //
00029 //============================================================================
00030 
00031 
00032 #include "ModelObs.hpp"
00033 
00034 
00035 namespace gpstk
00036 {
00037 
00038 
00039       // Index initially assigned to this class
00040    int ModelObs::classIndex = 4200000;
00041 
00042 
00043       // Returns an index identifying this object.
00044    int ModelObs::getIndex() const
00045    { return index; }
00046 
00047 
00048       // Returns a string identifying this object.
00049    std::string ModelObs::getClassName() const
00050    { return "ModelObs"; }
00051 
00052 
00053 
00054       /* Explicit constructor, taking as input initial receiver
00055        * coordinates, default ionospheric and tropospheric models,
00056        * ephemeris to be used, default observable and whether TGD will
00057        * be computed or not.
00058        *
00059        * @param RxCoordinates Initial receiver coordinates.
00060        * @param dIonoModel    Ionospheric model to be used by default.
00061        * @param dTropoModel   Tropospheric model to be used by default.
00062        * @param dEphemeris    XvtStore<SatID> object to be used by default.
00063        * @param dObservable   Observable type to be used by default.
00064        * @param usetgd        Whether TGD will be used by default or not.
00065        *
00066        */
00067    ModelObs::ModelObs( const Position& RxCoordinates,
00068                        IonoModelStore& dIonoModel,
00069                        TropModel& dTropoModel,
00070                        XvtStore<SatID>& dEphemeris,
00071                        const TypeID& dObservable,
00072                        bool usetgd )
00073    {
00074 
00075       InitializeValues();
00076       Prepare(RxCoordinates);
00077       setDefaultIonoModel(dIonoModel);
00078       setDefaultTropoModel(dTropoModel);
00079       setDefaultObservable(dObservable);
00080       setDefaultEphemeris(dEphemeris);
00081       useTGD = usetgd;
00082       setIndex();
00083 
00084    }  // End of 'ModelObs::ModelObs()'
00085 
00086 
00087 
00088       /* Explicit constructor, taking as input initial receiver
00089        * coordinates, default ionospheric model, ephemeris to be used,
00090        * default observable and whether TGD will be computed or not.
00091        *
00092        * The default tropospheric model will be set to NULL.
00093        *
00094        * @param RxCoordinates Initial receiver coordinates.
00095        * @param dIonoModel    Ionospheric model to be used by default.
00096        * @param dEphemeris    XvtStore<SatID> object to be used by default.
00097        * @param dObservable   Observable type to be used by default.
00098        * @param usetgd        Whether TGD will be used by default or not.
00099        *
00100        */
00101    ModelObs::ModelObs( const Position& RxCoordinates,
00102                        IonoModelStore& dIonoModel,
00103                        XvtStore<SatID>& dEphemeris,
00104                        const TypeID& dObservable,
00105                        bool usetgd )
00106    {
00107 
00108       InitializeValues();
00109       Prepare(RxCoordinates);
00110       setDefaultIonoModel(dIonoModel);
00111       pDefaultTropoModel = NULL;
00112       setDefaultObservable(dObservable);
00113       setDefaultEphemeris(dEphemeris);
00114       useTGD = usetgd;
00115       setIndex();
00116 
00117    }  // End of 'ModelObs::ModelObs()'
00118 
00119 
00120 
00121       /* Explicit constructor, taking as input initial receiver
00122        * coordinates, default tropospheric model, ephemeris to be used,
00123        * default observable and whether TGD will be computed or not.
00124        *
00125        * The default ionospheric model will be set to NULL.
00126        *
00127        * @param RxCoordinates Initial receiver coordinates.
00128        * @param dTropoModel   Tropospheric model to be used by default.
00129        * @param dEphemeris    XvtStore<SatID> object to be used by default.
00130        * @param dObservable   Observable type to be used by default.
00131        * @param usetgd        Whether TGD will be used by default or not.
00132        *
00133        */
00134    ModelObs::ModelObs( const Position& RxCoordinates,
00135                        TropModel& dTropoModel,
00136                        XvtStore<SatID>& dEphemeris,
00137                        const TypeID& dObservable,
00138                        bool usetgd )
00139    {
00140 
00141       InitializeValues();
00142       Prepare(RxCoordinates);
00143       pDefaultIonoModel = NULL;
00144       setDefaultTropoModel(dTropoModel);
00145       setDefaultObservable(dObservable);
00146       setDefaultEphemeris(dEphemeris);
00147       useTGD = usetgd;
00148       setIndex();
00149 
00150    }  // End of 'ModelObs::ModelObs()'
00151 
00152 
00153 
00154       /* Explicit constructor, taking as input initial receiver
00155        * coordinates, ephemeris to be used, default observable and
00156        * whether TGD will be computed or not.
00157        *
00158        * Both the tropospheric and ionospheric models will be set to NULL.
00159        *
00160        * @param RxCoordinates Initial receiver coordinates.
00161        * @param dEphemeris    XvtStore<SatID> object to be used by default.
00162        * @param dObservable   Observable type to be used by default.
00163        * @param usetgd        Whether TGD will be used by default or not.
00164        *
00165        */
00166    ModelObs::ModelObs( const Position& RxCoordinates,
00167                        XvtStore<SatID>& dEphemeris,
00168                        const TypeID& dObservable,
00169                        bool usetgd )
00170    {
00171 
00172       InitializeValues();
00173       Prepare(RxCoordinates);
00174       pDefaultIonoModel = NULL;
00175       pDefaultTropoModel = NULL;
00176       setDefaultObservable(dObservable);
00177       setDefaultEphemeris(dEphemeris);
00178       useTGD = usetgd;
00179       setIndex();
00180 
00181    }  // End of 'ModelObs::ModelObs()'
00182 
00183 
00184 
00185       /* Explicit constructor, taking as input default ionospheric and
00186        * tropospheric models, ephemeris to be used, default observable
00187        * and whether TGD will be computed or not.
00188        *
00189        * @param dIonoModel    Ionospheric model to be used by default.
00190        * @param dTropoModel   Tropospheric model to be used by default.
00191        * @param dObservable   Observable type to be used by default.
00192        * @param dEphemeris    XvtStore<SatID> object to be used by default.
00193        * @param usetgd        Whether TGD will be used by default or not.
00194        *
00195        */
00196    ModelObs::ModelObs( IonoModelStore& dIonoModel,
00197                        TropModel& dTropoModel,
00198                        XvtStore<SatID>& dEphemeris,
00199                        const TypeID& dObservable,
00200                        bool usetgd )
00201    {
00202 
00203       InitializeValues();
00204       setDefaultIonoModel(dIonoModel);
00205       setDefaultTropoModel(dTropoModel);
00206       setDefaultObservable(dObservable);
00207       setDefaultEphemeris(dEphemeris);
00208       useTGD = usetgd;
00209       setIndex();
00210 
00211    }  // End of 'ModelObs::ModelObs()'
00212 
00213 
00214 
00215       /* Explicit constructor, taking as input default ionospheric model,
00216        * ephemeris to be used, default observable and whether TGD will be
00217        * computed or not.
00218        *
00219        * @param dIonoModel    Ionospheric model to be used by default.
00220        * @param dObservable   Observable type to be used by default.
00221        * @param dEphemeris    XvtStore<SatID> object to be used by default.
00222        * @param usetgd        Whether TGD will be used by default or not.
00223        * @sa DataStructures.hpp.
00224        */
00225    ModelObs::ModelObs( IonoModelStore& dIonoModel,
00226                        XvtStore<SatID>& dEphemeris,
00227                        const TypeID& dObservable,
00228                        bool usetgd )
00229    {
00230 
00231       InitializeValues();
00232       setDefaultIonoModel(dIonoModel);
00233       pDefaultTropoModel = NULL;
00234       setDefaultObservable(dObservable);
00235       setDefaultEphemeris(dEphemeris);
00236       useTGD = usetgd;
00237       setIndex();
00238 
00239    }  // End of 'ModelObs::ModelObs()'
00240 
00241 
00242 
00243       /* Explicit constructor, taking as input default tropospheric model,
00244        * ephemeris to be used, default observable and whether TGD will be
00245        * computed or not.
00246        *
00247        * @param dTropoModel   Tropospheric model to be used by default.
00248        * @param dObservable   Observable type to be used by default.
00249        * @param dEphemeris    XvtStore<SatID> object to be used by default.
00250        * @param usetgd        Whether TGD will be used by default or not.
00251        *
00252        */
00253    ModelObs::ModelObs( TropModel& dTropoModel,
00254                        XvtStore<SatID>& dEphemeris,
00255                        const TypeID& dObservable,
00256                        bool usetgd )
00257    {
00258 
00259       InitializeValues();
00260       pDefaultIonoModel = NULL;
00261       setDefaultTropoModel(dTropoModel);
00262       setDefaultObservable(dObservable);
00263       setDefaultEphemeris(dEphemeris);
00264       useTGD = usetgd;
00265       setIndex();
00266 
00267    }  // End of 'ModelObs::ModelObs()'
00268 
00269 
00270 
00271       /* Method to set an a priori position of receiver using
00272        * Bancroft's method.
00273        *
00274        * @param Tr            Time of observation
00275        * @param Satellite     std::vector of satellites in view
00276        * @param Pseudorange   std::vector of pseudoranges measured from mobile
00277        *                      station to satellites
00278        * @param Eph           Satellites Ephemeris
00279        *
00280        * @return
00281        *  0 if OK
00282        *  -1 if problems arose
00283        */
00284    int ModelObs::Prepare( const DayTime& Tr,
00285                           std::vector<SatID>& Satellite,
00286                           std::vector<double>& Pseudorange,
00287                           const XvtStore<SatID>& Eph )
00288    {
00289 
00290       Matrix<double> SVP;
00291       Bancroft Ban;
00292       Vector<double> vPos;
00293       PRSolution raimObj;
00294 
00295       try
00296       {
00297          raimObj.PrepareAutonomousSolution(Tr, Satellite, Pseudorange, Eph, SVP);
00298          if( Ban.Compute(SVP, vPos) < 0 )
00299          {
00300             return -1;
00301          }
00302       }
00303       catch(...)
00304       {
00305          return -1;
00306       }
00307 
00308       return Prepare(vPos(0), vPos(1), vPos(2));
00309 
00310    }  // End of method 'ModelObs::Prepare()'
00311 
00312 
00313 
00314       /* Method to set an a priori position of receiver using
00315        * Bancroft's method.
00316        *
00317        * @param time      DayTime object for this epoch
00318        * @param data      A satTypeValueMap data structure holding the data
00319        *
00320        * @return
00321        *  0 if OK
00322        *  -1 if problems arose
00323        */
00324    int ModelObs::Prepare( const DayTime& time,
00325                           const satTypeValueMap& data )
00326    {
00327 
00328       int i;
00329       std::vector<SatID> vSat;
00330       std::vector<double> vPR;
00331       Vector<SatID> Satellite( data.getVectorOfSatID() );
00332       Vector<double> Pseudorange(
00333                            data.getVectorOfTypeID( getDefaultObservable() ) );
00334 
00335          // Convert from gpstk::Vector to std::vector
00336       for(i = 0; i < (int)Satellite.size(); i++)
00337       {
00338          vSat.push_back(Satellite[i]);
00339       }
00340 
00341       for(i = 0; i < (int)Pseudorange.size(); i++)
00342       {
00343          vPR.push_back(Pseudorange[i]);
00344       }
00345 
00346       return Prepare(time, vSat, vPR, (*(getDefaultEphemeris())) );
00347 
00348    }  // End of method 'ModelObs::Prepare()'
00349 
00350 
00351 
00352       /* Method to set the initial (a priori) position of receiver before
00353        * Compute() method.
00354        * @return
00355        *  0 if OK
00356        *  -1 if problems arose
00357        */
00358    int ModelObs::Prepare( const double& aRx,
00359                           const double& bRx,
00360                           const double& cRx,
00361                           Position::CoordinateSystem s,
00362                           GeoidModel *geoid )
00363    {
00364 
00365       int result = setInitialRxPosition(aRx, bRx, cRx, s, geoid);
00366 
00367          // If everything is OK, the model is prepared
00368       if( result ==0 )
00369       {
00370          modelPrepared = true;
00371       }
00372       else
00373       {
00374          modelPrepared = false;
00375       }
00376 
00377       return result;
00378 
00379    }  // End of method 'ModelObs::Prepare()'
00380 
00381 
00382 
00383       /* Method to set the initial (a priori) position of receiver before
00384        * Compute() method.
00385        * @return
00386        *  0 if OK
00387        *  -1 if problems arose
00388        */
00389    int ModelObs::Prepare(const Position& RxCoordinates)
00390    {
00391 
00392       int result = setInitialRxPosition(RxCoordinates);
00393 
00394          // If everything is OK, the model is prepared
00395       if( result ==0 )
00396       {
00397          modelPrepared = true;
00398       }
00399       else
00400       {
00401          modelPrepared = false;
00402       }
00403 
00404       return result;
00405 
00406    }  // End of method 'ModelObs::Prepare()'
00407 
00408 
00409 
00410       /* Returns a satTypeValueMap object, adding the new data generated
00411        * when calling a modeling object.
00412        *
00413        * @param time      Epoch.
00414        * @param gData     Data object holding the data.
00415        */
00416    satTypeValueMap& ModelObs::Process( const DayTime& time,
00417                                        satTypeValueMap& gData )
00418       throw(ProcessingException)
00419    {
00420 
00421       try
00422       {
00423 
00424             // First, if the model is not prepared let's take care of it
00425          if( !getModelPrepared() )
00426          {
00427             Prepare(time, gData);
00428          }
00429 
00430          ModelObsFixedStation::Process(time, gData);
00431 
00432          return gData;
00433 
00434       }
00435       catch(Exception& u)
00436       {
00437             // Throw an exception if something unexpected happens
00438          ProcessingException e( getClassName() + ":"
00439                                 + StringUtils::asString( getIndex() ) + ":"
00440                                 + u.what() );
00441 
00442          GPSTK_THROW(e);
00443 
00444       }
00445 
00446    }   // End of method 'ModelObs::Process()'
00447 
00448 
00449 
00450 }  // End of namespace gpstk

Generated on Wed Feb 8 03:31:00 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1