SP3EphemerisStore.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SP3EphemerisStore.cpp 2741 2011-06-22 16:37:02Z nwu $"
00002 
00003 
00010 //============================================================================
00011 //
00012 //  This file is part of GPSTk, the GPS Toolkit.
00013 //
00014 //  The GPSTk is free software; you can redistribute it and/or modify
00015 //  it under the terms of the GNU Lesser General Public License as published
00016 //  by the Free Software Foundation; either version 2.1 of the License, or
00017 //  any later version.
00018 //
00019 //  The GPSTk is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU Lesser General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU Lesser General Public
00025 //  License along with GPSTk; if not, write to the Free Software Foundation,
00026 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 //
00028 //  Copyright 2004, The University of Texas at Austin
00029 //
00030 //============================================================================
00031 
00032 //============================================================================
00033 //
00034 //This software developed by Applied Research Laboratories at the University of
00035 //Texas at Austin, under contract to an agency or agencies within the U.S.
00036 //Department of Defense. The U.S. Government retains all rights to use,
00037 //duplicate, distribute, disclose, or release this software.
00038 //
00039 //Pursuant to DoD Directive 523024
00040 //
00041 // DISTRIBUTION STATEMENT A: This software has been approved for public
00042 //                           release, distribution is unlimited.
00043 //
00044 //=============================================================================
00045 
00046 
00047 
00048 #include "SP3EphemerisStore.hpp"
00049 #include "MiscMath.hpp"
00050 #include "ECEF.hpp"
00051 #include "icd_200_constants.hpp"
00052 
00053 using namespace gpstk::StringUtils;
00054 
00055 namespace gpstk
00056 {
00057 
00058       // Load the given SP3 file
00059    void SP3EphemerisStore::loadFile(const std::string& filename)
00060       throw(FileMissingException)
00061    {
00062 
00063       try
00064       {
00065 
00066          SP3Stream strm(filename.c_str());
00067          if (!strm)
00068          {
00069             FileMissingException e("File " +filename+ " could not be opened.");
00070             GPSTK_THROW(e);
00071          }
00072 
00073          SP3Header header;
00074          strm >> header;
00075 
00076          addFile(filename, header);
00077 
00078             // If any file doesn't have the velocity data, clear the
00079             // the flag indicating that there is any velocity data
00080          if (tolower(header.pvFlag) != 'v')
00081          {
00082             haveVelocity = false;
00083          }
00084 
00085          SP3Data rec;
00086          while(strm >> rec)
00087          {
00088 
00089                // If there is a bad or absent clock value, and
00090                // corresponding flag is set, then continue
00091             if( (rec.clk == 999999.999999) &&
00092                 ( rejectBadClockFlag ) )
00093             {
00094                continue;
00095             }
00096 
00097                // If there are bad or absent positional values, and
00098                // corresponding flag is set, then continue
00099             if( ( (rec.x[0] == 0.0)    ||
00100                   (rec.x[1] == 0.0)    ||
00101                   (rec.x[2] == 0.0) )  &&
00102                 ( rejectBadPosFlag ) )
00103             {
00104                continue;
00105             }
00106 
00107                // Ephemeris and clock are valid, then add them
00108             rec.version = header.version;
00109             addEphemeris(rec);
00110 
00111          }  // end of 'while(strm >> rec)'
00112 
00113       }
00114       catch (gpstk::Exception& e)
00115       {
00116          GPSTK_RETHROW(e);
00117       }
00118 
00119    }  // End of method 'SP3EphemerisStore::loadFile()'
00120 
00121 
00122 
00123       /* Dump the store to cout.
00124        * @param detail determines how much detail to include in the output
00125        *   0 list of filenames with their start, stop times.
00126        *   1 list of filenames with their start, stop times,
00127        *     other header information and prns/accuracy.
00128        *   2 above, plus dump all the PVT data (use judiciously).
00129        */
00130    void SP3EphemerisStore::dump( std::ostream& s,
00131                                  short detail )
00132       const throw()
00133    {
00134 
00135       s << "Dump of SP3EphemerisStore:" << std::endl;
00136       std::vector<std::string> fileNames = getFileNames();
00137       std::vector<std::string>::const_iterator f=fileNames.begin();
00138       for (f=fileNames.begin(); f!=fileNames.end(); f++)
00139          s << *f << std::endl;
00140 
00141 /*
00142   Add this back in when/if we add header info to the file store.
00143       while(fmi != fm.end()) {
00144          s << " File " << fmi->first << ", Times: " << fmi->second.time
00145             << " to " << (fmi->second.time+fmi->second.epochInterval*fmi->second.numberOfEpochs)
00146             << ", (" << fmi->second.numberOfEpochs
00147             << "  " << fmi->second.epochInterval << "sec intervals)." << std::endl;
00148          if(detail > 0) {
00149             s << "  Data used as input : " << fmi->second.dataUsed
00150                << "  Coordinate system : " << fmi->second.coordSystem << std::endl;
00151             s << "  Orbit estimate type : " << fmi->second.orbitType
00152                << "  Agency : " << fmi->second.agency << std::endl;
00153             s << "  List of satellite PRN/acc (" << fmi->second.svList.size()
00154                << " total) :\n";
00155             int i=0;
00156             std::map<short,short>::const_iterator it=fmi->second.svList.begin();
00157             while(it != fmi->second.svList.end()) {
00158                s << "  " << std::setw(2) << it->first << "/" << it->second;
00159                if(!(++i % 8)) s << std::endl;
00160                it++;
00161             }
00162             if(++i % 8) s << std::endl;
00163             s << "  Comments:\n";
00164             for(i=0; i<fmi->second.comments.size(); i++)
00165                s << "    " << fmi->second.comments[i] << std::endl;
00166             s << std::endl;
00167          }
00168          fmi++;
00169       }
00170 */
00171 
00172       TabularEphemerisStore::dump(s, detail);
00173 
00174    }  // End of method 'SP3EphemerisStore::dump()'
00175 
00176 
00177 
00178 }  // End of namespace gpstk

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