ModeledPR.cpp

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

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