ConvertC1ToP1.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ConvertC1ToP1.cpp 2552 2011-04-12 06:09:42Z yanweignss $"
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 //  Wei Yan - Chinese Academy of Sciences . 2009, 2010, 2011
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "ConvertC1ToP1.hpp"
00032 
00033 namespace gpstk
00034 {
00035       // Index initially assigned to this class
00036    int ConvertC1ToP1::classIndex = 4800000;
00037 
00038       // Returns an index identifying this object.
00039    int ConvertC1ToP1::getIndex() const
00040    { return index; }
00041 
00042 
00043       // Returns a string identifying this object.
00044    std::string ConvertC1ToP1::getClassName() const
00045    { return "ConvertC1ToP1"; }
00046 
00047       /* Sets name of file containing DCBs data.
00048        * @param name      Name of the file containing DCB(P1-C1)
00049        */
00050    ConvertC1ToP1& ConvertC1ToP1::setDCBFile(const string& fileP1C1)
00051    {
00052       dcbP1C1.open(fileP1C1);
00053       
00054       return (*this);
00055    }
00056 
00057       /* Returns a satTypeValueMap object, adding the new data generated
00058        *  when calling this object.
00059        *
00060        * @param time      Epoch corresponding to the data.
00061        * @param gData     Data object holding the data.
00062        */
00063    satTypeValueMap& ConvertC1ToP1::Process( const DayTime& time,
00064                                                 satTypeValueMap& gData )
00065       throw(ProcessingException)
00066    {
00067       
00068       try
00069       {
00070          static const double minLimit(15000000.0);
00071          static const double maxLimit(30000000.0);
00072 
00073          SatIDSet satRejectedSet;
00074 
00075          // Loop through all the satellites
00076          satTypeValueMap::iterator it;
00077          for (it = gData.begin(); it != gData.end(); ++it)
00078          {
00079             SatID sat = it->first;
00080             
00081             typeValueMap::iterator ittC1 = it->second.find(TypeID::C1);
00082             typeValueMap::iterator ittP1 = it->second.find(TypeID::P1);
00083 
00084             bool hasC1( ittC1 != it->second.end() );
00085             bool hasP1( ittP1 != it->second.end() );
00086 
00087             // filter out C1 and P1
00088             if(hasC1)
00089             {
00090                if( it->second[TypeID::C1]<minLimit || 
00091                    it->second[TypeID::C1]>maxLimit      ) { hasC1 = false;}
00092             }
00093             if(hasP1)
00094             {
00095                if( it->second[TypeID::P1]<minLimit || 
00096                    it->second[TypeID::P1]>maxLimit      ) { hasP1 = false;}
00097             }
00098 
00099                // If no desirable data, then schedule this satellite for removal
00100             if( !hasC1 && !hasP1)
00101             {
00102                satRejectedSet.insert(it->first);
00103             }
00104 
00105             if( hasC1 && !hasP1 )
00106             {
00107                double Bp1c1(0.0);      // in ns
00108                try
00109                {
00110                   Bp1c1 = dcbP1C1.getDCB(sat);
00111                }
00112                catch(...)
00113                {
00114                   Bp1c1 = 0.0;
00115                }
00116 
00117                it->second[TypeID::P1] = it->second[TypeID::C1] 
00118                                        +Bp1c1*(C_GPS_M * 1.0e-9);
00119             }
00120 
00121          }  // End of 'for (it = gData.begin(); it != gData.end(); ++it)'
00122 
00123          gData.removeSatID(satRejectedSet);
00124 
00125          return gData;
00126             
00127       }
00128       catch(Exception& u)
00129       {
00130 
00131          // Throw an exception if something unexpected happens
00132          ProcessingException e( getClassName() + ":"
00133             + StringUtils::asString( getIndex() ) + ":"
00134             + u.what() );
00135 
00136          GPSTK_THROW(e);
00137 
00138       }
00139 
00140    }  // End of method 'ConvertC1ToP1::Process()'
00141 
00142 
00143 }  // End of namespace gpstk
00144 
00145 
00146 

Generated on Tue May 22 03:30:57 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1