Dumper.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Dumper.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 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2009, 2011
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "Dumper.hpp"
00032 
00033 
00034 namespace gpstk
00035 {
00036 
00037       // Returns a string identifying this object.
00038    std::string Dumper::getClassName() const
00039    { return "Dumper"; }
00040 
00041 
00042 
00043       /* Dumps data from a satTypeValueMap object.
00044        *
00045        * @param gData     Data object holding the data.
00046        */
00047    satTypeValueMap& Dumper::Process( satTypeValueMap& gData )
00048       throw(ProcessingException)
00049    {
00050 
00051       try
00052       {
00053 
00054             // Iterate through all items in the GNSS Data Structure
00055          for( satTypeValueMap::const_iterator it = gData.begin();
00056               it!= gData.end();
00057               it++ )
00058          {
00059 
00060                // First, print satellite (system and PRN)
00061             *outStr << (*it).first << " ";
00062 
00063                // Now, print TypeIDs
00064             printTypeID( (*it).second );
00065 
00066                // Print end of line
00067             *outStr << std::endl;
00068 
00069          }  // End of 'for( satTypeValueMap::const_iterator it = ...'
00070 
00071          return gData;
00072 
00073       }
00074       catch(Exception& u)
00075       {
00076             // Throw an exception if something unexpected happens
00077          ProcessingException e( getClassName() + ":"
00078                                 + u.what() );
00079 
00080          GPSTK_THROW(e);
00081 
00082       }
00083 
00084    }  // End of method 'Dumper::Process()'
00085 
00086 
00087 
00088       /* Dumps data from a gnnsRinex object.
00089        *
00090        * @param gData    Data object holding the data.
00091        */
00092    gnssRinex& Dumper::Process( gnssRinex& gData )
00093       throw(ProcessingException)
00094    {
00095 
00096       try
00097       {
00098 
00099             // Iterate through all items in the GNSS Data Structure
00100          for( satTypeValueMap::const_iterator it = gData.body.begin();
00101               it!= gData.body.end();
00102               it++ )
00103          {
00104 
00105                // First, print year, Day-Of-Year and Seconds of Day (if enabled)
00106             if( printTime )
00107             {
00108                   // Declare a 'YDSTime' object to ease printing
00109                YDSTime time( gData.header.epoch );
00110 
00111                *outStr << time.year << " "
00112                        << time.doy << " "
00113                        << time.sod << " ";
00114             }
00115 
00116                // Second, print SourceID information (if enabled)
00117             if( printStation )
00118             {
00119                *outStr << gData.header.source << " ";
00120             }
00121 
00122                // Then, print satellite (system and PRN)
00123             *outStr << (*it).first << " ";
00124 
00125                // Now, print TypeIDs
00126             printTypeID( (*it).second );
00127 
00128                // Print end of line
00129             *outStr << std::endl;
00130 
00131          }  // End of 'for( satTypeValueMap::const_iterator it = ...'
00132 
00133          return gData;
00134 
00135       }
00136       catch(Exception& u)
00137       {
00138             // Throw an exception if something unexpected happens
00139          ProcessingException e( getClassName() + ":"
00140                                 + u.what() );
00141 
00142          GPSTK_THROW(e);
00143 
00144       }
00145 
00146    }  // End of method 'Dumper::Process()'
00147 
00148 
00149 
00150       /* Method to add a set of TypeIDs to be printed.
00151        *
00152        * @param printSet      TypeIDSet of data values to be added to the
00153        *                      ones being printed.
00154        */
00155    Dumper& Dumper::addTypeSet( const TypeIDSet& printSet )
00156    {
00157 
00158          // Iterate over 'printSet' and add its components to 'printTypeSet'
00159       for( TypeIDSet::const_iterator pos = printSet.begin();
00160            pos != printSet.end();
00161            ++pos )
00162       {
00163          printTypeSet.insert(*pos);
00164       }
00165 
00166       return (*this);
00167 
00168    }  // End of method 'Dumper::addTypeSet()'
00169 
00170 
00171 
00172       // Print TypeIDs information.
00173    void Dumper::printTypeID( const typeValueMap& tvMap )
00174    {
00175 
00176          // Iterate through all 'tvMap'
00177       for( typeValueMap::const_iterator itObs = tvMap.begin();
00178            itObs != tvMap.end();
00179            itObs++ )
00180       {
00181 
00182             // Check if we have specific TypeIDs to be printed or not
00183          if( printTypeSet.size() > 0 )
00184          {
00185 
00186                // Check if current TypeID is in 'printTypeSet'
00187             if( printTypeSet.find((*itObs).first) != printTypeSet.end() )
00188             {
00189                if( printType )
00190                {
00191                   *outStr << (*itObs).first << " ";
00192                }
00193 
00194                *outStr << (*itObs).second << " ";
00195             }
00196 
00197          }
00198          else
00199          {
00200                // No specific TypeIDs, so lets print them all
00201             if( printType )
00202             {
00203                *outStr << (*itObs).first << " ";
00204             }
00205 
00206             *outStr << (*itObs).second << " ";
00207 
00208          }  // End of 'if( printTypeSet.size() > 0 )'
00209 
00210       }  // End of 'for( typeValueMap::const_iterator itObs = ... )'
00211 
00212       return;
00213 
00214    }  // End of method 'Dumper::printTypeID()'
00215 
00216 
00217 }  // End of namespace gpstk

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