FFIdentifier.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: FFIdentifier.cpp 2468 2010-09-15 13:25:46Z snelsen $"
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 
00039 #include <string>
00040 #include <iostream>
00041 #include <iomanip>
00042 
00043 #include "FileUtils.hpp"
00044 
00045 #include "FFIdentifier.hpp"
00046 
00047 #include "SP3EphemerisStore.hpp"
00048 #include "RinexEphemerisStore.hpp"
00049 #include "YumaAlmanacStore.hpp"
00050 #include "GPSGeoid.hpp"
00051 
00052 #include "RinexObsStream.hpp"
00053 #include "RinexObsData.hpp"
00054 
00055 #include "RinexNavStream.hpp"
00056 #include "RinexNavData.hpp"
00057 #include "RinexMetStream.hpp"
00058 #include "RinexMetData.hpp"
00059 
00060 #include "FICStream.hpp"
00061 #include "FICData.hpp"
00062 
00063 #include "SMODFStream.hpp"
00064 #include "SMODFData.hpp"
00065 
00066 #include "MSCData.hpp"
00067 #include "MSCStream.hpp"
00068 
00069 #include "MDPObsEpoch.hpp"
00070 #include "MDPPVTSolution.hpp"
00071 #include "MDPNavSubframe.hpp"
00072 #include "MDPSelftestStatus.hpp"
00073 #include "MDPStream.hpp"
00074 
00075 #include "YumaData.hpp"
00076 #include "YumaStream.hpp"
00077 
00078 #include "SEMData.hpp"
00079 #include "SEMStream.hpp"
00080 
00081 #include "NovatelData.hpp"
00082 #include "NovatelStream.hpp"
00083 
00084 #include "AshtechData.hpp"
00085 #include "AshtechStream.hpp"
00086 
00087 namespace gpstk
00088 {
00089    int FFIdentifier::debugLevel = 0;
00090 
00091    FFIdentifier::FFIdentifier(const std::string& fn)
00092       throw(FileMissingException)
00093    {
00094 
00095       if (!FileUtils::fileAccessCheck(fn))
00096       {
00097          FileMissingException e("Cannot open " + fn);
00098          GPSTK_THROW(e);
00099       }
00100 
00101       using namespace std;
00102       fileType=tUnknown;
00103 
00104       {
00105          if (debugLevel>2)
00106             cout << "Trying " << fn << " as RINEX obs."<< endl;
00107          RinexObsStream s(fn.c_str(), ios::in);
00108       
00109          RinexObsHeader temp_roh;
00110          s >> temp_roh;
00111          RinexObsData rod;
00112          s >> rod;
00113          if (s)
00114          {
00115             fileType = tRinexObs;
00116             return;
00117          } 
00118       }
00119 
00120       {
00121          if (debugLevel>2)
00122             cout << "Trying " << fn << " as SMODF."<< endl;
00123          SMODFStream s(fn.c_str(), ios::in);
00124          
00125          SMODFData smodata;       
00126          s >> smodata;
00127          s >> smodata;
00128          if (s)
00129          {
00130             fileType = tSMODF;
00131             return;
00132          }
00133       }
00134 
00135       {
00136          if (debugLevel>2)
00137             cout << "Trying " << fn << " as MDP."<< endl;
00138          MDPStream s(fn.c_str(), ios::in);
00139 
00140          MDPHeader header;
00141          s >> header;
00142          string body = header.readBody(s);
00143          if (s.rawHeader.size() && body.size())
00144          {
00145             header.setstate(crcbit);
00146             header.checkCRC(s.rawHeader+body);
00147             if (!header.crcerr())
00148             {
00149                fileType = tMDP;
00150                return;
00151             }
00152          }
00153       }
00154 
00155       {
00156          if (debugLevel>2)
00157             cout << "Trying " << fn << " as RINEX nav."<< endl;
00158          RinexNavStream s(fn.c_str(), ios::in);
00159 
00160          RinexNavData rnd;
00161          RinexNavHeader rnh;
00162          s >> rnh;
00163          s >> rnd;
00164          if (s)
00165          {
00166             fileType = tRinexNav;
00167             return;
00168          }
00169       }
00170       
00171       {
00172          if (debugLevel>2)
00173             cout << "Trying " << fn << " as FIC nav."<< endl;
00174          FICStream s(fn.c_str(), ios::in);
00175          
00176          FICData data;
00177          s >> data;
00178          if (s)
00179          {
00180             fileType = tFIC;
00181             return;
00182          }
00183       }
00184 
00185       {
00186          if (debugLevel>2)
00187             cout << "Trying " << fn << " as SP3 ephemeris."<< endl;
00188          SP3Stream s(fn.c_str(), ios::in);
00189          
00190          SP3Header header;
00191          s >> header;
00192          SP3Data data;
00193          s >> data;
00194          if (s)
00195          {
00196             fileType = tSP3;
00197             return;
00198          }
00199       }
00200 
00201       {
00202          if (debugLevel>2)
00203             cout << "Trying " << fn << " as Yuma elmanac."<< endl;
00204          YumaStream s(fn.c_str(), ios::in);
00205          
00206          YumaHeader header;
00207          s >> header;
00208          YumaData data;
00209          s >> data;
00210          if (s)
00211          {
00212             fileType = tYuma;
00213             return;
00214          }
00215       }
00216 
00217       {
00218          if (debugLevel>2)
00219             cout << "Trying " << fn << " as SEM almanac."<< endl;
00220          SEMStream s(fn.c_str(), ios::in);
00221          
00222          SEMHeader header;
00223          s >> header;
00224          SEMData data;
00225          s >> data;
00226          if (s)
00227          {
00228             fileType = tSEM;
00229             return;
00230          }
00231       }
00232 
00233       {
00234          if (debugLevel>2)
00235             cout << "Trying " << fn << " as MSC."<< endl;
00236          MSCStream s(fn.c_str(), ios::in);
00237 
00238          MSCData mscd;
00239          s >> mscd;
00240          if (s)
00241          {
00242             fileType = tMSC;
00243             return;
00244          }
00245       }
00246 
00247 
00248       {
00249          if (debugLevel>2)
00250             cout << "Trying " << fn << " as Novatel OEM." << endl;
00251          NovatelStream s(fn.c_str(), ios::in);
00252          NovatelData nd;
00253          s >> nd;
00254          if (s)
00255          {
00256             fileType = tNovatelOem;
00257             return;
00258          }
00259       }
00260 
00261       {
00262          if (debugLevel>2)
00263             cout << "Trying " << fn << " as Ashtech serial." << endl;
00264          AshtechStream s(fn.c_str(), ios::in);
00265          AshtechData nd;
00266          s >> nd;
00267          if (s)
00268          {
00269             fileType = tAshtechSerial;
00270             return;
00271          }
00272       }
00273 
00274    }
00275 
00276    std::string FFIdentifier::describe(FFIdentifier::FFType type)
00277    {
00278       std::string desc("Unknown");
00279 
00280       switch (type)
00281       {
00282          case FFIdentifier::tRinexObs : 
00283             desc="RINEX obs"; 
00284             break;
00285 
00286          case FFIdentifier::tMDP :      
00287             desc="Measurement Data Protocol";  
00288             break;
00289 
00290          case FFIdentifier::tSMODF :
00291            desc="Smoothed measurement";
00292            break;
00293       }
00294       return desc;
00295    }
00296 
00297 }

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