BrcKeplerOrbit.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: BrcKeplerOrbit.cpp 3140 2012-06-18 15:03:02Z susancummins $"
00002 
00003 //============================================================================
00004 //
00005 //  This file is part of GPSTk, the GPS Toolkit.
00006 //
00007 //  The GPSTk is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Lesser General Public License as published
00009 //  by the Free Software Foundation; either version 2.1 of the License, or
00010 //  any later version.
00011 //
00012 //  The GPSTk is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Lesser General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Lesser General Public
00018 //  License along with GPSTk; if not, write to the Free Software Foundation,
00019 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00020 //  
00021 //  Copyright 2004, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00025 //============================================================================
00026 //
00027 //This software developed by Applied Research Laboratories at the University of
00028 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00029 //Department of Defense. The U.S. Government retains all rights to use,
00030 //duplicate, distribute, disclose, or release this software. 
00031 //
00032 //Pursuant to DoD Directive 523024 
00033 //
00034 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00035 //                           release, distribution is unlimited.
00036 //
00037 //=============================================================================
00038 
00043 #include <stdio.h>
00044 #include "BrcKeplerOrbit.hpp"
00045 #include <cmath>
00046 
00047 namespace gpstk
00048 {
00049    using namespace std;
00050    using namespace gpstk;
00051 
00052    BrcKeplerOrbit::BrcKeplerOrbit()
00053       throw()
00054    {
00055       dataLoaded = false;
00056 
00057       PRNID = 0;
00058 
00059       satSys = "";
00060 
00061       healthy = false;     
00062      
00063       URAoe = -16;
00064 
00065       Cuc = Cus = Crc = Crs = Cic = Cis = M0 = dn = dndot = 
00066            ecc = A = Ahalf =Adot = OMEGA0 = i0 = w = OMEGAdot = idot = 0.0;
00067    }
00068 
00069    BrcKeplerOrbit::BrcKeplerOrbit(const std::string satSysArg, const ObsID obsIDArg,
00070                                   const short PRNIDArg, const CommonTime beginFitArg,
00071                                   const CommonTime endFitArg, const CommonTime ToeArg,
00072                                   const short URAoeArg, const bool healthyArg, 
00073                                   const double CucArg, const double CusArg, 
00074                                   const double CrcArg, const double CrsArg, 
00075                                   const double CicArg, const double CisArg, 
00076                                   const double M0Arg, const double dnArg, 
00077                                   const double dndotArg, const double eccArg, 
00078                                             const double AArg, const double AhalfArg, 
00079                                   const double AdotArg, const double OMEGA0Arg, 
00080                                   const double i0Arg, const double wArg, 
00081                                   const double OMEGAdotARg, const double idotArg )
00082    {
00083       loadData(satSysArg, obsIDArg, PRNIDArg, beginFitArg, endFitArg, ToeArg,
00084                URAoeArg, healthyArg, CucArg, CusArg, CrcArg,
00085                CrsArg, CicArg, CisArg, M0Arg, dnArg, dndotArg, eccArg, AArg,
00086                AhalfArg, AdotArg, OMEGA0Arg, i0Arg, wArg, OMEGAdotARg, idotArg );
00087    }
00088 
00090    BrcKeplerOrbit::BrcKeplerOrbit(const ObsID obsIDArg, const short PRNID,
00091                                   const short fullweeknum,
00092                                             const long subframe1[10],
00093                                             const long subframe2[10],
00094                                             const long subframe3[10] )
00095    {
00096       loadData(obsIDArg, PRNID,fullweeknum, subframe1, subframe2, subframe3 );
00097    }
00098 
00099 
00100 
00101    void BrcKeplerOrbit::loadData(const std::string satSysArg, const ObsID obsIDArg,
00102                                  const short PRNIDArg, const CommonTime beginFitArg,
00103                                  const CommonTime endFitArg, const CommonTime ToeArg,
00104                                  const short URAoeArg, const bool healthyArg, 
00105                                  const double CucArg, const double CusArg, 
00106                                  const double CrcArg, const double CrsArg, 
00107                                  const double CicArg, const double CisArg,  
00108                                  const double M0Arg, const double dnArg, 
00109                                  const double dndotArg, const double eccArg, 
00110                                            const double AArg, const double AhalfArg, 
00111                                  const double AdotArg, const double OMEGA0Arg, 
00112                                  const double i0Arg, const double wArg, 
00113                                  const double OMEGAdotARg, const double idotArg )
00114    {
00115            satSys      = satSysArg;
00116            obsID       = obsIDArg;
00117            PRNID       = PRNIDArg;
00118       beginFit    = beginFitArg;
00119       endFit      = endFitArg;
00120            Toe         = ToeArg;
00121            URAoe       = URAoeArg;
00122            healthy     = healthyArg;
00123            Cuc         = CucArg;
00124            Cus         = CusArg;
00125            Crc         = CrcArg;
00126            Crs         = CrsArg;
00127            Cic         = CicArg;
00128            Cis         = CisArg;
00129            M0          = M0Arg;
00130            dn          = dnArg;
00131            dndot       = dndotArg;
00132            ecc         = eccArg;
00133            A           = AArg;
00134       Ahalf       = AhalfArg;
00135            Adot        = AdotArg;
00136            OMEGA0      = OMEGA0Arg;
00137            i0          = i0Arg;
00138            w           = wArg;
00139            OMEGAdot    = OMEGAdotARg;
00140            idot        = idotArg;
00141            dataLoaded  = true;
00142    }
00143 
00144    void BrcKeplerOrbit::loadData(const ObsID obsIDArg, const short PRNIDArg,
00145                                  const short fullweeknum,
00146                                            const long subframe1[10],
00147                                            const long subframe2[10],
00148                                            const long subframe3[10])
00149            throw(InvalidParameter)
00150    {
00151       double ficked[60];
00152 
00153             //Load overhead members
00154            satSys = "G";
00155            obsID = obsIDArg;
00156            PRNID = PRNIDArg;
00157       short iodc = 0;
00158 
00159             //Convert Subframe 1
00160            if (!subframeConvert(subframe1, fullweeknum, ficked))
00161            {
00162               InvalidParameter exc("Subframe 1 not valid.");
00163               GPSTK_THROW(exc);
00164            }
00165 
00166            short weeknum = static_cast<short>( ficked[5] );
00167            short accFlag = static_cast<short>( ficked[7] );
00168            short health  = static_cast<short>( ficked[8] );
00169            URAoe = accFlag;
00170            healthy = false;
00171            if (health == 0)
00172            healthy = true;
00173       iodc = static_cast<short>( ldexp( ficked[9], -11 ) );
00174           
00175             //Convert Subframe 2
00176            if (!subframeConvert(subframe2, fullweeknum, ficked))
00177            {
00178               InvalidParameter exc("Subframe 2 not valid.");
00179               GPSTK_THROW(exc);
00180            }
00181 
00182       Crs    = ficked[6];
00183            dn     = ficked[7];
00184            M0     = ficked[8];
00185            Cuc    = ficked[9];
00186            ecc    = ficked[10];
00187            Cus    = ficked[11];
00188            Ahalf  = ficked[12];
00189            A      = Ahalf*Ahalf;
00190            double ToeSOW = ficked[13];
00191 /*
00192       double diff = Txmit - ToeSOW;
00193       if (diff > HALFWEEK)          // NOTE: This USED to be in DayTime, but DayTime is going away.  Where is it now?
00194          weeknum++;                 // Convert week # of transmission to week # of epoch time when Toc is forward across a week boundary
00195       else if (diff < -HALFWEEK)
00196          weeknum--;                 // Convert week # of transmission to week # of epoch time when Toc is back across a week boundary
00197 */
00198       Toe = GPSWeekSecond(weeknum, ToeSOW, TimeSystem::GPS);
00199       short fiti = static_cast<short>(ficked[14]);
00200       short fitHours = getLegacyFitInterval(iodc, fiti);
00201       long beginFitSOW = ToeSOW - (fitHours/2)*3600;
00202       long endFitSOW = ToeSOW + (fitHours/2)*3600;
00203       short beginFitWk = weeknum;
00204       short endFitWk = weeknum;
00205       if (beginFitSOW < 0)
00206       {
00207          beginFitSOW += FULLWEEK;
00208          beginFitWk--;
00209       }
00210       beginFit = GPSWeekSecond(beginFitWk, beginFitSOW, TimeSystem::GPS);
00211 
00212       if (endFitSOW >= FULLWEEK)
00213       {
00214          endFitSOW -= FULLWEEK;
00215          endFitWk++;
00216       }
00217       endFit = GPSWeekSecond(endFitWk, endFitSOW, TimeSystem::GPS);       
00218 
00219                //Convert Subframe 3
00220            if (!subframeConvert(subframe3, fullweeknum, ficked))
00221            {
00222               InvalidParameter exc("Subframe3 not valid.");
00223               GPSTK_THROW(exc);
00224            }
00225 
00226            Cic      = ficked[5];
00227            OMEGA0   = ficked[6];
00228            Cis      = ficked[7];
00229            i0       = ficked[8];
00230            Crc      = ficked[9];
00231            w        = ficked[10];
00232            OMEGAdot = ficked[11];
00233            idot     = ficked[13];
00234 
00235            dndot      = 0.0;
00236            Adot       = 0.0;
00237            dataLoaded = true;
00238          
00239            return;
00240    }
00241              
00242    bool BrcKeplerOrbit::hasData() const
00243    {
00244       return(dataLoaded);
00245    }
00246 
00247    bool BrcKeplerOrbit::isHealthy() const
00248       throw(InvalidRequest)
00249    {
00250       if (!dataLoaded)
00251       {   
00252          InvalidRequest exc("Required data not stored.");
00253          GPSTK_THROW(exc);
00254       }
00255       return(healthy);
00256    }
00257 
00258    bool BrcKeplerOrbit::withinFitInterval(const CommonTime ct) const
00259       throw(InvalidRequest)
00260    {
00261       if (!dataLoaded)
00262       {   
00263          InvalidRequest exc("Required data not stored.");
00264          GPSTK_THROW(exc);
00265       }
00266       if (ct >= beginFit && ct <= endFit) return(true);    
00267       return(false);
00268    }
00269 
00270    Xv BrcKeplerOrbit::svXv(const CommonTime& t) const
00271       throw(InvalidRequest)
00272    {
00273       Xv sv;
00274 
00275       GPSWeekSecond gpsws = (Toe);
00276       double ToeSOW = gpsws.sow;
00277       double ea;              // eccentric anomaly //
00278       double delea;           // delta eccentric anomaly during iteration */
00279       double elapte;          // elapsed time since Toe 
00280       double elaptc;          // elapsed time since Toc 
00281       double dtc,dtr,q,sinea,cosea;
00282       double GSTA,GCTA;
00283       double amm;
00284       double meana;           // mean anomaly 
00285       double F,G;             // temporary real variables 
00286       double alat,talat,c2al,s2al,du,dr,di,U,R,truea,AINC;
00287       double ANLON,cosu,sinu,xip,yip,can,san,cinc,sinc;
00288       double xef,yef,zef,dek,dlk,div,domk,duv,drv;
00289       double dxp,dyp,vxef,vyef,vzef;
00290       GPSEllipsoid ell;
00291 
00292       double sqrtgm = SQRT(ell.gm());
00293 
00294          // Check for ground transmitter
00295       double twoPI = 2.0e0 * PI;
00296       double lecc;               // eccentricity
00297       double tdrinc;            // dt inclination
00298 
00299       lecc = ecc;
00300       tdrinc = idot;
00301 
00302          // Compute time since ephemeris & clock epochs
00303       elapte = t - getOrbitEpoch();
00304       //CommonTime orbEp = getOrbitEpoch();
00305       //elapte = t - orbEp;
00306 
00307          // Compute mean motion
00308       amm  = (sqrtgm / (A*Ahalf)) + dn;
00309 
00310 
00311          // In-plane angles
00312          //     meana - Mean anomaly
00313          //     ea    - Eccentric anomaly
00314          //     truea - True anomaly
00315 
00316       meana = M0 + elapte * amm;
00317       meana = fmod(meana, twoPI);
00318    
00319       ea = meana + lecc * ::sin(meana);
00320 
00321       int loop_cnt = 1;
00322       do  {
00323          F = meana - ( ea - lecc * ::sin(ea));
00324          G = 1.0 - lecc * ::cos(ea);
00325          delea = F/G;
00326          ea = ea + delea;
00327          loop_cnt++;
00328       } while ( (fabs(delea) > 1.0e-11 ) && (loop_cnt <= 20) );
00329    
00330          // Compute true anomaly
00331       q     = SQRT( 1.0e0 - lecc*lecc);
00332       sinea = ::sin(ea);
00333       cosea = ::cos(ea);
00334       G     = 1.0e0 - lecc * cosea;
00335    
00336          //  G*SIN(TA) AND G*COS(TA)
00337       GSTA  = q * sinea;
00338       GCTA  = cosea - lecc;
00339 
00340          //  True anomaly
00341       truea = atan2 ( GSTA, GCTA );
00342 
00343          // Argument of lat and correction terms (2nd harmonic)
00344       alat  = truea + w;
00345       talat = 2.0e0 * alat;
00346       c2al  = ::cos( talat );
00347       s2al  = ::sin( talat );
00348 
00349       du  = c2al * Cuc +  s2al * Cus;
00350       dr  = c2al * Crc +  s2al * Crs;
00351       di  = c2al * Cic +  s2al * Cis;
00352 
00353          // U = updated argument of lat, R = radius, AINC = inclination
00354       U    = alat + du;
00355       R    = A*G  + dr;
00356       AINC = i0 + tdrinc * elapte  +  di;
00357 
00358          //  Longitude of ascending node (ANLON)
00359       ANLON = OMEGA0 + (OMEGAdot - ell.angVelocity()) *
00360               elapte - ell.angVelocity() * ToeSOW;
00361 
00362          // In plane location
00363       cosu = ::cos( U );
00364       sinu = ::sin( U );
00365 
00366       xip  = R * cosu;
00367       yip  = R * sinu;
00368 
00369          //  Angles for rotation to earth fixed
00370       can  = ::cos( ANLON );
00371       san  = ::sin( ANLON );
00372       cinc = ::cos( AINC  );
00373       sinc = ::sin( AINC  );
00374  
00375          // Earth fixed - meters
00376       xef  =  xip*can  -  yip*cinc*san;
00377       yef  =  xip*san  +  yip*cinc*can;
00378       zef  =              yip*sinc;
00379 
00380       sv.x[0] = xef;
00381       sv.x[1] = yef;
00382       sv.x[2] = zef;
00383 
00384          // Compute velocity of rotation coordinates
00385       dek = amm * A / R;
00386       dlk = Ahalf * q * sqrtgm / (R*R);
00387       div = tdrinc - 2.0e0 * dlk *
00388          ( Cic  * s2al - Cis * c2al );
00389       domk = OMEGAdot - ell.angVelocity();
00390       duv = dlk*(1.e0+ 2.e0 * (Cus*c2al - Cuc*s2al) );
00391       drv = A * lecc * dek * sinea - 2.e0 * dlk *
00392          ( Crc * s2al - Crs * c2al );
00393 
00394       dxp = drv*cosu - R*sinu*duv;
00395       dyp = drv*sinu + R*cosu*duv;
00396 
00397          // Calculate velocities
00398       vxef = dxp*can - xip*san*domk - dyp*cinc*san
00399          + yip*( sinc*san*div - cinc*can*domk);
00400       vyef = dxp*san + xip*can*domk + dyp*cinc*can
00401          - yip*( sinc*can*div + cinc*san*domk);
00402       vzef = dyp*sinc + yip*cinc*div;
00403 
00404          // Move results into output variables
00405       sv.v[0] = vxef;
00406       sv.v[1] = vyef;
00407       sv.v[2] = vzef;
00408 
00409       return sv;
00410    }
00411 
00412    double BrcKeplerOrbit::svRelativity(const CommonTime& t) const
00413       throw( InvalidRequest )
00414    {
00415       GPSEllipsoid ell;
00416       double twoPI  = 2.0e0 * PI;
00417       double sqrtgm = SQRT(ell.gm());
00418       double elapte = t - getOrbitEpoch();
00419       double amm    = (sqrtgm / (A*Ahalf)) + dn;
00420       double meana,F,G,delea;
00421       
00422       meana = M0 + elapte * amm; 
00423       meana = fmod(meana, twoPI);
00424       double ea = meana + ecc * ::sin(meana);
00425 
00426       int loop_cnt = 1;
00427       do {
00428          F     = meana - ( ea - ecc * ::sin(ea));
00429          G     = 1.0 - ecc * ::cos(ea);
00430          delea = F/G;
00431          ea    = ea + delea;
00432          loop_cnt++;
00433       } while ( (ABS(delea) > 1.0e-11 ) && (loop_cnt <= 20) );
00434       double dtr = REL_CONST * ecc * Ahalf * ::sin(ea);
00435       return dtr;
00436    }
00437 
00438    CommonTime BrcKeplerOrbit::getOrbitEpoch() const
00439       throw(InvalidRequest)
00440    {
00441       return Toe;
00442    }
00443    
00444    CommonTime BrcKeplerOrbit::getBeginningOfFitInterval() const
00445       throw(InvalidRequest)
00446    {
00447       if (!dataLoaded)
00448       {   
00449          InvalidRequest exc("Required data not stored.");
00450          GPSTK_THROW(exc);
00451       }
00452       return beginFit;
00453    }
00454 
00455    CommonTime BrcKeplerOrbit::getEndOfFitInterval() const
00456       throw(InvalidRequest)
00457    {
00458       if (!dataLoaded)
00459       {   
00460          InvalidRequest exc("Required data not stored.");
00461          GPSTK_THROW(exc);
00462       }
00463       return endFit;
00464    }
00465 
00466    short BrcKeplerOrbit::getPRNID() const
00467       throw(InvalidRequest)
00468    {
00469       if(!dataLoaded)
00470       {
00471          InvalidRequest exc("Required data not stored.");
00472          GPSTK_THROW(exc);
00473       }
00474       return PRNID;
00475    }   
00476   
00477    short BrcKeplerOrbit::getFullWeek()  const
00478       throw(InvalidRequest)
00479    {
00480       if (!dataLoaded)
00481       {
00482          InvalidRequest exc("Required data not stored.");
00483          GPSTK_THROW(exc);
00484       }
00485       GPSWeekSecond gpsws(Toe);
00486       return (gpsws.week);
00487    }   
00488   
00489    double BrcKeplerOrbit::getAccuracy()  const
00490       throw(InvalidRequest)
00491    {
00492       if (!dataLoaded)
00493       {
00494          InvalidRequest exc("Required data not stored.");
00495          GPSTK_THROW(exc);
00496       }
00497       double accuracy = ura2CNAVaccuracy(URAoe);
00498       return accuracy;
00499    }   
00500 
00501    void BrcKeplerOrbit::setAccuracy(const double& acc)
00502       throw(InvalidRequest)
00503    {
00504       if (!dataLoaded)
00505       {
00506          InvalidRequest exc("Required data not stored.");
00507          GPSTK_THROW(exc);
00508       }
00509       URAoe = accuracy2ura(acc);
00510    }
00511 
00512    short BrcKeplerOrbit::getURAoe() const
00513       throw(InvalidRequest)
00514    {
00515       if (!dataLoaded)
00516       {
00517          InvalidRequest exc("Required data not stored.");
00518          GPSTK_THROW(exc);
00519       }
00520       return URAoe;
00521    }
00522          
00523    double BrcKeplerOrbit::getCus() const
00524       throw(InvalidRequest)
00525    {
00526       if (!dataLoaded)
00527       {
00528          InvalidRequest exc("Required data not stored.");
00529          GPSTK_THROW(exc);
00530       }
00531       return Cus;
00532    }
00533    
00534    double BrcKeplerOrbit::getCrs() const
00535       throw(InvalidRequest)
00536    {
00537       if (!dataLoaded)
00538       {
00539          InvalidRequest exc("Required data not stored.");
00540          GPSTK_THROW(exc);
00541       }
00542       return Crs;
00543    }
00544    
00545    double BrcKeplerOrbit::getCis() const
00546       throw(InvalidRequest)
00547    {
00548       if (!dataLoaded)
00549       {
00550          InvalidRequest exc("Required data not stored.");
00551          GPSTK_THROW(exc);
00552       }
00553       return Cis;
00554    }
00555    
00556    double BrcKeplerOrbit::getCrc() const
00557       throw(InvalidRequest)
00558    {
00559       if (!dataLoaded)
00560       {
00561          InvalidRequest exc("Required data not stored.");
00562          GPSTK_THROW(exc);
00563       }
00564       return Crc;
00565    }
00566    
00567    double BrcKeplerOrbit::getCuc() const
00568       throw(InvalidRequest)
00569    {
00570       if (!dataLoaded)
00571       {
00572          InvalidRequest exc("Required data not stored.");
00573          GPSTK_THROW(exc);
00574       }
00575       return Cuc;
00576    }
00577   
00578    double BrcKeplerOrbit::getCic() const
00579       throw(InvalidRequest)
00580    {
00581       if (!dataLoaded)
00582       {
00583          InvalidRequest exc("Required data not stored.");
00584          GPSTK_THROW(exc);
00585       }
00586       return Cic;
00587    }
00588    
00589    double BrcKeplerOrbit::getToe() const
00590       throw(InvalidRequest)
00591    {
00592       if (!dataLoaded)
00593       {
00594          InvalidRequest exc("Required data not stored.");
00595          GPSTK_THROW(exc);
00596       }
00597       GPSWeekSecond gpsws(Toe);
00598       return gpsws.sow;
00599    }
00600    
00601    double BrcKeplerOrbit::getM0() const
00602       throw(InvalidRequest)
00603    {
00604       if (!dataLoaded)
00605       {
00606          InvalidRequest exc("Required data not stored.");
00607          GPSTK_THROW(exc);
00608       }
00609       return M0;
00610    }
00611    
00612    double BrcKeplerOrbit::getDn() const
00613       throw(InvalidRequest)
00614    {
00615       if (!dataLoaded)
00616       {
00617          InvalidRequest exc("Required data not stored.");
00618          GPSTK_THROW(exc);
00619       }
00620       return dn;
00621    }
00622    
00623    double BrcKeplerOrbit::getEcc() const
00624       throw(InvalidRequest)
00625    {
00626       if (!dataLoaded)
00627       {
00628          InvalidRequest exc("Required data not stored.");
00629          GPSTK_THROW(exc);
00630       }
00631       return ecc;
00632    }
00633       
00634    double BrcKeplerOrbit::getA() const
00635       throw(InvalidRequest)
00636    {
00637       if (!dataLoaded)
00638       {
00639          InvalidRequest exc("Required data not stored.");
00640          GPSTK_THROW(exc);
00641       }
00642       return A;
00643    }
00644 
00645    double BrcKeplerOrbit::getAhalf() const
00646       throw(InvalidRequest)
00647    {
00648       if (!dataLoaded)
00649       {
00650          InvalidRequest exc("Required data not stored.");
00651          GPSTK_THROW(exc);
00652       }
00653       return Ahalf;
00654    }
00655 
00656    double BrcKeplerOrbit::getAdot() const
00657       throw(InvalidRequest)
00658    {
00659       if (!dataLoaded)
00660       {
00661          InvalidRequest exc("Required data not stored.");
00662          GPSTK_THROW(exc);
00663       }
00664       return Adot;
00665    }
00666 
00667    double BrcKeplerOrbit::getDnDot() const
00668       throw(InvalidRequest)
00669    {
00670       if (!dataLoaded)
00671       {
00672          InvalidRequest exc("Required data not stored.");
00673          GPSTK_THROW(exc);
00674       }
00675       return dndot;
00676    }
00677    
00678    double BrcKeplerOrbit::getOmega0() const
00679       throw(InvalidRequest)
00680    {
00681       if (!dataLoaded)
00682       {
00683          InvalidRequest exc("Required data not stored.");
00684          GPSTK_THROW(exc);
00685       }
00686       return OMEGA0;
00687    }
00688    
00689    double BrcKeplerOrbit::getI0() const
00690       throw(InvalidRequest)
00691    {
00692       if (!dataLoaded)
00693       {
00694          InvalidRequest exc("Required data not stored.");
00695          GPSTK_THROW(exc);
00696       }
00697       return i0;
00698    }
00699    
00700    double BrcKeplerOrbit::getW() const
00701       throw(InvalidRequest)
00702    {
00703       if (!dataLoaded)
00704       {
00705          InvalidRequest exc("Required data not stored.");
00706          GPSTK_THROW(exc);
00707       }
00708       return w;
00709    }
00710    
00711    double BrcKeplerOrbit::getOmegaDot() const
00712       throw(InvalidRequest)
00713    {
00714       if (!dataLoaded)
00715       {
00716          InvalidRequest exc("Required data not stored.");
00717          GPSTK_THROW(exc);
00718       }
00719       return OMEGAdot;
00720    }
00721    
00722    double BrcKeplerOrbit::getIDot() const
00723       throw(InvalidRequest)
00724    {
00725       if (!dataLoaded)
00726       {
00727          InvalidRequest exc("Required data not stored.");
00728          GPSTK_THROW(exc);
00729       }
00730       return idot;
00731    }
00732 
00733    static void timeDisplay( ostream & os, const CommonTime& t )
00734    {
00735          // Convert to CommonTime struct from GPS wk,SOW to M/D/Y, H:M:S.
00736       GPSWeekSecond dummyTime;
00737       dummyTime = GPSWeekSecond(t);
00738       os << setw(4) << dummyTime.week << "(";
00739       os << setw(4) << (dummyTime.week & 0x03FF) << ")  ";
00740       os << setw(6) << setfill(' ') << dummyTime.sow << "   ";
00741 
00742       switch (dummyTime.getDayOfWeek())
00743       {
00744          case 0: os << "Sun-0"; break;
00745          case 1: os << "Mon-1"; break;
00746          case 2: os << "Tue-2"; break;
00747          case 3: os << "Wed-3"; break;
00748          case 4: os << "Thu-4"; break;
00749          case 5: os << "Fri-5"; break;
00750          case 6: os << "Sat-6"; break;
00751          default: break;
00752       }
00753       os << "   " << (static_cast<YDSTime>(t)).printf("%3j   %5.0s  ") 
00754          << (static_cast<CivilTime>(t)).printf("%02m/%02d/%04Y   %02H:%02M:%02S");
00755    }
00756 
00757    static void shortcut(ostream & os, const long HOW )
00758    {
00759       short DOW, hour, min, sec;
00760       long SOD, SOW;
00761       short SOH;
00762       
00763       SOW  = static_cast<long>( HOW );
00764       DOW  = static_cast<short>( SOW / SEC_PER_DAY );
00765       SOD  = SOW - static_cast<long>( DOW * SEC_PER_DAY );
00766       hour = static_cast<short>( SOD/3600 );
00767 
00768       SOH = static_cast<short>( SOD - (hour*3600) );
00769       min = SOH/60;
00770 
00771       sec = SOH - min * 60;
00772       switch (DOW)
00773       {
00774          case 0: os << "Sun-0"; break;
00775          case 1: os << "Mon-1"; break;
00776          case 2: os << "Tue-2"; break;
00777          case 3: os << "Wed-3"; break;
00778          case 4: os << "Thu-4"; break;
00779          case 5: os << "Fri-5"; break;
00780          case 6: os << "Sat-6"; break;
00781          default: break;
00782       }
00783 
00784       os << ":" << setfill('0')
00785          << setw(2) << hour
00786          << ":" << setw(2) << min
00787          << ":" << setw(2) << sec
00788          << setfill(' ');
00789    }
00790 
00791    void BrcKeplerOrbit::dump(ostream& s) const
00792       throw()
00793    {
00794       ios::fmtflags oldFlags = s.flags();
00795    
00796       s.setf(ios::fixed, ios::floatfield);
00797       s.setf(ios::right, ios::adjustfield);
00798       s.setf(ios::uppercase);
00799       s.precision(0);
00800       s.fill(' ');
00801       
00802       s << "****************************************************************"
00803         << "************" << endl
00804         << "Broadcast Ephemeris (Engineering Units)" << endl
00805         << endl
00806         << "PRN : " << setw(2) << PRNID << endl
00807         << endl;
00808   
00809       s << "              Week(10bt)     SOW     DOW   UTD     SOD"
00810         << "   MM/DD/YYYY   HH:MM:SS\n";
00811       
00812       s << endl;
00813       s << "Eph Epoch:    ";
00814       timeDisplay(s, getOrbitEpoch());
00815       s << endl;
00816 
00817       s.setf(ios::scientific, ios::floatfield);
00818       s.precision(8);
00819        
00820       s << endl
00821         << "           ORBIT PARAMETERS"
00822         << endl
00823         << endl
00824         << "Semi-major axis:       " << setw(16) << Ahalf  << " m**.5" << endl
00825         << "Motion correction:     " << setw(16) << dn     << " rad/sec"
00826         << endl
00827         << "Eccentricity:          " << setw(16) << ecc    << endl
00828         << "Arg of perigee:        " << setw(16) << w      << " rad" << endl
00829         << "Mean anomaly at epoch: " << setw(16) << M0     << " rad" << endl
00830         << "Right ascension:       " << setw(16) << OMEGA0 << " rad    "
00831         << setw(16) << OMEGAdot << " rad/sec" << endl
00832         << "Inclination:           " << setw(16) << i0     << " rad    "
00833         << setw(16) << idot     << " rad/sec" << endl;
00834       
00835       s << endl
00836         << "           HARMONIC CORRECTIONS"
00837         << endl
00838         << endl
00839         << "Radial        Sine: " << setw(16) << Crs << " m    Cosine: "
00840         << setw(16) << Crc << " m" << endl
00841         << "Inclination   Sine: " << setw(16) << Cis << " rad  Cosine: "
00842         << setw(16) << Cic << " rad" << endl
00843         << "In-track      Sine: " << setw(16) << Cus << " rad  Cosine: "
00844         << setw(16) << Cuc << " rad" << endl;    
00845       
00846       s << endl;
00847       
00848    } // end of BrcKeplerOrbit::dump()
00849    
00850    ostream& operator<<(ostream& s, const BrcKeplerOrbit& eph)
00851    {
00852       eph.dump(s);
00853       return s;
00854 
00855    } // end of operator<<
00856      
00857 } // namespace

Generated on Tue May 21 03:31:05 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1