DCBDataReader.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: DCBDataReader.cpp 3140 2012-06-18 15:03:02Z susancummins $"
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00025 //
00026 //  Wei Yan - Chinese Academy of Sciences  2009, 2010
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "DCBDataReader.hpp"
00032 
00033 using namespace std;
00034 
00035 namespace gpstk
00036 {
00037    
00038       // Method to store load ocean tide harmonics data in this class'
00039       // data map
00040    void DCBDataReader::loadData()
00041       throw( FFStreamError, gpstk::StringUtils::StringException )
00042    {
00043 
00044       try
00045       {
00046          allDCB.satDCB.clear();
00047          allDCB.gpsDCB.clear();
00048          allDCB.glonassDCB.clear();
00049 
00050             // a buffer
00051          string line;
00052          
00053             // read first line 
00054          formattedGetLine(line, true);
00055                   
00056             // Let's skip 6 lines
00057          for(int i=0; i<6; i++) formattedGetLine(line, true);
00058          
00059          
00060             // Now, let's read data
00061          while(1)
00062          {
00063             formattedGetLine(line, true);
00064 
00065             if(line.length() < 46) continue;
00066             
00067             string sysFlag = line.substr(0,1);
00068             
00069             int satPRN = StringUtils::asInt(line.substr(1,2));
00070             
00071             string station = StringUtils::strip(line.substr(6,4));
00072             
00073             double dcbVal = StringUtils::asDouble(line.substr(26,9));      
00074             double dcbRMS = StringUtils::asDouble(line.substr(38,9));
00075 
00076             if(station.length() < 4)       // this is satellite DCB data
00077             {
00078 
00079                SatID sat;
00080                if(sysFlag == "G")
00081                {
00082                   sat = SatID(satPRN,SatID::systemGPS);
00083                }
00084                else if(sysFlag == "R")
00085                {
00086                   sat = SatID(satPRN,SatID::systemGlonass);
00087                }
00088                else
00089                {
00090                   // Unexpected and we do nothing here
00091                   
00092 
00093                }
00094                
00095                allDCB.satDCB[sat] = dcbVal;
00096                
00097             }
00098             else                           // this is receiver DCB data
00099             {
00100                if(sysFlag == "G")
00101                {
00102                   allDCB.gpsDCB[station] = dcbVal;
00103                }
00104                else if(sysFlag == "R")
00105                {
00106                   allDCB.glonassDCB[station] = dcbVal;
00107                }
00108                else
00109                {
00110                   // Unexpected and we do nothing here
00111 
00112                }
00113             }
00114 
00115          }  // End of 'while(1)'
00116 
00117       }  // End of try block
00118       catch (EndOfFile& e)
00119       {
00120        
00121             // We should close this data stream before returning
00122          (*this).close();
00123 
00124          return;
00125       }
00126       catch (...)
00127       {
00128 
00129          // We should close this data stream before returning
00130          (*this).close();
00131 
00132          return;
00133 
00134       }
00135 
00136 
00137    }  // End of 'DCBDataReader::loadData()'
00138 
00139 
00140 
00141       // Method to open AND load DCB data file. 
00142    void DCBDataReader::open(const char* fn)
00143    {
00144 
00145       // We need to be sure current data stream is closed
00146       (*this).close();
00147 
00148       // Open data stream
00149       FFTextStream::open(fn, std::ios::in);
00150       loadData();
00151 
00152       return;
00153 
00154    }  // End of method 'DCBDataReader::open()'
00155 
00156 
00157 
00158       // Method to open AND load DCB data file. It doesn't
00159       // clear data previously loaded.
00160    void DCBDataReader::open(const string& fn)
00161    {
00162 
00163       // We need to be sure current data stream is closed
00164       (*this).close();
00165 
00166       // Open data stream
00167       FFTextStream::open(fn.c_str(), std::ios::in);
00168       loadData();
00169 
00170       return;
00171    }  // End of method 'DCBDataReader::open()'
00172 
00173       // return P1-P2 or P1-C1 depend what you have loaded
00174    double DCBDataReader::getDCB(const SatID& sat)
00175    {
00176       return allDCB.satDCB[sat];     
00177    }
00178 
00179       // Get DCB data of a satellite
00180       // return P1-P2 or P1-C1 depend what you have loaded
00181    double DCBDataReader::getDCB(const int& prn,
00182       const SatID::SatelliteSystem& system)
00183    {
00184       SatID sat(prn,system);
00185       return allDCB.satDCB[sat];
00186    }
00187 
00188       // Get DCB data of aReceiver
00189       // it return P1-P2 
00190    double DCBDataReader::getDCB(const string& station,
00191       const SatID::SatelliteSystem& system)
00192    {
00193 
00194       if(system == SatID::systemGPS)
00195       {
00196          return allDCB.gpsDCB[station];
00197       }
00198       else if(system == SatID::systemGlonass)
00199       {
00200          return allDCB.glonassDCB[station];
00201       }
00202       else 
00203       {
00204             // Unexpected and return 0
00205          return 0.0;
00206       }
00207 
00208    }  // End of 'double DCBDataReader::getDCB(const string& station...'
00209 
00210 
00211 
00212 }  // End of namespace gpstk
00213 

Generated on Thu May 23 03:31:06 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1