DataStructures.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: DataStructures.cpp 2960 2011-11-02 05:01:16Z 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 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008, 2009
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "DataStructures.hpp"
00032 
00033 using namespace gpstk::StringUtils;
00034 using namespace std;
00035 
00036 
00037 namespace gpstk
00038 {
00039 
00040 
00042 
00043 
00044       // Returns a TypeIDSet with all the data types present in
00045       // this object.
00046    TypeIDSet typeValueMap::getTypeID() const
00047    {
00048 
00049       TypeIDSet typeSet;
00050 
00051       for( typeValueMap::const_iterator pos = (*this).begin();
00052            pos != (*this).end();
00053            ++pos )
00054       {
00055          typeSet.insert( (*pos).first );
00056       }
00057 
00058       return typeSet;
00059 
00060    }  // End of method 'typeValueMap::getTypeID()'
00061 
00062 
00063 
00064       // Returns a typeValueMap with only this type of data.
00065       // @param type Type of value to be extracted.
00066    typeValueMap typeValueMap::extractTypeID(const TypeID& type) const
00067    {
00068 
00069       TypeIDSet typeSet;
00070       typeSet.insert(type);
00071 
00072       return extractTypeID(typeSet);
00073 
00074    }  // End of method 'typeValueMap::extractTypeID()'
00075 
00076 
00077 
00078       // Returns a typeValueMap with only these types of data.
00079       // @param typeSet Set (TypeIDSet) containing the types of data to
00080       //                be extracted.
00081    typeValueMap typeValueMap::extractTypeID(const TypeIDSet& typeSet) const
00082    {
00083 
00084       typeValueMap tvMap;
00085 
00086       for( TypeIDSet::const_iterator pos = typeSet.begin();
00087            pos != typeSet.end();
00088            ++pos )
00089       {
00090 
00091          typeValueMap::const_iterator itObs( (*this).find(*pos) );
00092          if( itObs != (*this).end() )
00093          {
00094             tvMap[ (*itObs).first ] = (*itObs).second;
00095          };
00096       }
00097 
00098       return tvMap;
00099 
00100    }  // End of method 'typeValueMap::extractTypeID()'
00101 
00102 
00103 
00104       // Modifies this object, keeping only this type of data.
00105       // @param type Type of value to be kept.
00106    typeValueMap& typeValueMap::keepOnlyTypeID(const TypeID& type)
00107    {
00108 
00109       TypeIDSet typeSet;
00110       typeSet.insert(type);
00111 
00112       return (keepOnlyTypeID(typeSet));
00113 
00114    }  // End of method 'typeValueMap::keepOnlyTypeID()'
00115 
00116 
00117 
00118       // Modifies this object, keeping only these types of data.
00119       // @param typeSet Set (TypeIDSet) containing the types of data
00120       //                to be kept.
00121    typeValueMap& typeValueMap::keepOnlyTypeID(const TypeIDSet& typeSet)
00122    {
00123 
00124       typeValueMap tvMap( (*this).extractTypeID(typeSet) );
00125       (*this) = tvMap;
00126 
00127       return (*this);
00128 
00129    }  // End of method 'typeValueMap::keepOnlyTypeID()'
00130 
00131 
00132 
00133       // Modifies this object, removing these types of data.
00134       // @param typeSet Set (TypeIDSet) containing the types of data
00135       //                to be kept.
00136    typeValueMap& typeValueMap::removeTypeID(const TypeIDSet& typeSet)
00137    {
00138 
00139       for( TypeIDSet::const_iterator pos = typeSet.begin();
00140            pos != typeSet.end();
00141            ++pos )
00142       {
00143          (*this).erase(*pos);
00144       }
00145 
00146       return (*this);
00147 
00148    }  // End of method 'typeValueMap::removeTypeID()'
00149 
00150 
00151 
00152       /* Returns the data value (double) corresponding to provided type.
00153        *
00154        * @param type       Type of value to be looked for.
00155        */
00156    double typeValueMap::getValue(const TypeID& type) const
00157       throw(TypeIDNotFound)
00158    {
00159 
00160       typeValueMap::const_iterator itObs( (*this).find(type) );
00161       if ( itObs != (*this).end() )
00162       {
00163          return (*itObs).second;
00164       }
00165       else
00166       {
00167          GPSTK_THROW(TypeIDNotFound("TypeID not found in map"));
00168       }
00169 
00170    }  // End of method 'typeValueMap::getValue()'
00171 
00172 
00173 
00174       // Returns a reference to the data value (double) with
00175       // corresponding type.
00176       // @param type Type of value to be looked for.
00177    double& typeValueMap::operator()(const TypeID& type)
00178       throw(TypeIDNotFound)
00179    {
00180 
00181       typeValueMap::iterator itObs ( (*this).find(type) );
00182 
00183       if ( itObs != (*this).end() )
00184       {
00185          return (*itObs).second;
00186       }
00187       else
00188       {
00189          GPSTK_THROW(TypeIDNotFound("TypeID not found in map"));
00190       }
00191 
00192    }  // End of method 'typeValueMap::operator()'
00193 
00194 
00195 
00197 
00198 
00199       // Returns a SatIDSet with all the satellites present in this object.
00200    SatIDSet satValueMap::getSatID() const
00201    {
00202 
00203       SatIDSet satSet;
00204 
00205       for( satValueMap::const_iterator pos = (*this).begin();
00206            pos != (*this).end();
00207            ++pos )
00208       {
00209          satSet.insert( (*pos).first );
00210       }
00211 
00212       return satSet;
00213 
00214    }  // End of method 'satValueMap::getSatID()'
00215 
00216 
00217 
00218       // Returns a Vector with all the satellites present in this object.
00219    Vector<SatID> satValueMap::getVectorOfSatID() const
00220    {
00221 
00222       std::vector<SatID> temp;
00223 
00224       for( satValueMap::const_iterator pos = (*this).begin();
00225            pos != (*this).end();
00226            ++pos )
00227       {
00228          temp.push_back( (*pos).first );
00229       }
00230 
00231       Vector<SatID> result;
00232       result = temp;
00233 
00234       return result;
00235 
00236    }  // End of method 'satValueMap::getVectorOfSatID()'
00237 
00238 
00239 
00240       // Returns a satValueMap with only this satellite.
00241       // @param satellite Satellite to be extracted.
00242    satValueMap satValueMap::extractSatID(const SatID& satellite) const
00243    {
00244 
00245       SatIDSet satSet;
00246       satSet.insert(satellite);
00247 
00248       return extractSatID(satSet);
00249 
00250    }  // End of method 'satValueMap::extractSatID()'
00251 
00252 
00253 
00254       // Returns a satValueMap with only one satellite, identified by
00255       // the given parameters.
00256       // @param p Satellite PRN number.
00257       // @param p System the satellite belongs to.
00258    satValueMap satValueMap::extractSatID( const int& p,
00259                                      const SatID::SatelliteSystem& s ) const
00260    {
00261 
00262       SatID tempSatellite(p, s);  // We build a temporary SatID object
00263 
00264       return extractSatID(tempSatellite);
00265 
00266    }  // End of method 'satValueMap::extractSatID()'
00267 
00268 
00269 
00270       // Returns a satValueMap with only these satellites.
00271       // @param satSet Set (SatIDSet) containing the satellites to
00272       //               be extracted.
00273    satValueMap satValueMap::extractSatID(const SatIDSet& satSet) const
00274    {
00275 
00276       satValueMap svMap;
00277 
00278       for( SatIDSet::const_iterator pos = satSet.begin();
00279            pos != satSet.end();
00280            ++pos )
00281       {
00282          satValueMap::const_iterator itObs( (*this).find(*pos) );
00283 
00284          if( itObs != (*this).end() )
00285          {
00286             svMap[ (*itObs).first ] = (*itObs).second;
00287          };
00288       }
00289 
00290       return svMap;
00291 
00292    }  // End of method 'satValueMap::extractSatID()'
00293 
00294 
00295 
00296       // Modifies this object, keeping only this satellite.
00297       // @param satellite Satellite to be kept.
00298    satValueMap& satValueMap::keepOnlySatID(const SatID& satellite)
00299    {
00300 
00301       SatIDSet satSet;
00302       satSet.insert(satellite);
00303 
00304       return keepOnlySatID(satSet);
00305 
00306    }  // End of method 'satValueMap::keepOnlySatID()'
00307 
00308 
00309 
00310       // Modifies this object, keeping only this satellite.
00311       // @param p Satellite PRN number.
00312       // @param p System the satellite belongs to.
00313    satValueMap& satValueMap::keepOnlySatID( const int& p,
00314                                             const SatID::SatelliteSystem& s )
00315    {
00316 
00317       SatID tempSatellite(p, s);  // We build a temporary SatID object
00318 
00319       return keepOnlySatID(tempSatellite);
00320 
00321    }  // End of method 'satValueMap::keepOnlySatID()'
00322 
00323 
00324 
00325       // Modifies this object, keeping only these satellites.
00326       // @param satSet Set (SatIDSet) containing the satellites to be kept.
00327    satValueMap& satValueMap::keepOnlySatID(const SatIDSet& satSet)
00328    {
00329 
00330       satValueMap svMap = extractSatID(satSet);
00331       (*this) = svMap;
00332 
00333       return (*this);
00334 
00335    }  // End of method 'satValueMap::keepOnlySatID()'
00336 
00337 
00338 
00339       // Modifies this object, removing these satellites.
00340       // @param satSet Set (SatIDSet) containing the satellites to
00341       //               be removed.
00342    satValueMap& satValueMap::removeSatID(const SatIDSet& satSet)
00343    {
00344 
00345       for( SatIDSet::const_iterator pos = satSet.begin();
00346            pos != satSet.end();
00347            ++pos )
00348       {
00349          (*this).erase(*pos);
00350       }
00351 
00352       return (*this);
00353 
00354    }  // End of method 'satValueMap::removeSatID()'
00355 
00356 
00357 
00358       /* Returns the data value (double) corresponding to provided SatID.
00359        *
00360        * @param satellite     Satellite to be looked for.
00361        */
00362    double satValueMap::getValue(const SatID& satellite) const
00363       throw(SatIDNotFound)
00364    {
00365 
00366       satValueMap::const_iterator itObs( (*this).find(satellite) );
00367       if ( itObs != (*this).end() )
00368       {
00369          return (*itObs).second;
00370       }
00371       else
00372       {
00373          GPSTK_THROW(SatIDNotFound("SatID not found in map"));
00374       }
00375 
00376    }  // End of method 'satValueMap::getValue()'
00377 
00378 
00379 
00380       // Returns a reference to the data value (double) with
00381       // corresponding SatID.
00382       // @param satellite Satellite to be looked for.
00383    double& satValueMap::operator()(const SatID& satellite)
00384       throw(SatIDNotFound)
00385    {
00386 
00387       satValueMap::iterator itObs( (*this).find(satellite) );
00388 
00389       if ( itObs != (*this).end() )
00390       {
00391          return (*itObs).second;
00392       }
00393       else
00394       {
00395          GPSTK_THROW(SatIDNotFound("SatID not found in map"));
00396       }
00397 
00398    }  // End of method 'satValueMap::operator()'
00399 
00400 
00401 
00403 
00404 
00405       /* Returns the total number of data elements in the map.
00406        * This method DOES NOT suppose that all the satellites have
00407        * the same number of type values.
00408        */
00409    size_t satTypeValueMap::numElements() const
00410    {
00411 
00412       size_t numEle(0);
00413 
00414       for( satTypeValueMap::const_iterator it = (*this).begin();
00415            it != (*this).end();
00416            ++it )
00417       {
00418          numEle = numEle + (*it).second.size();
00419       }
00420 
00421       return numEle;
00422 
00423    }  // End of method 'satTypeValueMap::numElements()'
00424 
00425 
00426 
00427       // Returns a SatIDSet with all the satellites present in this object.
00428    SatIDSet satTypeValueMap::getSatID() const
00429    {
00430 
00431       SatIDSet satSet;
00432 
00433       for( satTypeValueMap::const_iterator pos = (*this).begin();
00434            pos != (*this).end();
00435            ++pos )
00436       {
00437          satSet.insert( (*pos).first );
00438       }
00439 
00440       return satSet;
00441 
00442    }  // End of method 'satTypeValueMap::getSatID()'
00443 
00444 
00445 
00446       // Returns a Vector with all the satellites present in this object.
00447    Vector<SatID> satTypeValueMap::getVectorOfSatID() const
00448    {
00449 
00450       std::vector<SatID> temp;
00451 
00452       for( satTypeValueMap::const_iterator pos = (*this).begin();
00453            pos != (*this).end();
00454            ++pos )
00455       {
00456          temp.push_back( (*pos).first );
00457       }
00458 
00459       Vector<SatID> result;
00460       result = temp;
00461 
00462       return result;
00463 
00464    }  // End of method 'satTypeValueMap::getVectorOfSatID()'
00465 
00466 
00467 
00468       // Returns a TypeIDSet with all the data types present in
00469       // this object. This does not imply that all satellites have these types.
00470    TypeIDSet satTypeValueMap::getTypeID() const
00471    {
00472 
00473       TypeIDSet typeSet;
00474 
00475       for( satTypeValueMap::const_iterator pos = (*this).begin();
00476            pos != (*this).end();
00477            ++pos )
00478       {
00479 
00480          for( typeValueMap::const_iterator it = (*pos).second.begin();
00481               it != (*pos).second.end();
00482               ++it )
00483          {
00484             typeSet.insert( (*it).first );
00485          }
00486 
00487       }
00488 
00489       return typeSet;
00490 
00491    }  // End of method 'satTypeValueMap::getTypeID()'
00492 
00493 
00494 
00495       // Returns a satTypeValueMap with only this satellite.
00496       // @param satellite Satellite to be extracted.
00497    satTypeValueMap satTypeValueMap::extractSatID(const SatID& satellite) const
00498    {
00499 
00500       SatIDSet satSet;
00501       satSet.insert(satellite);
00502 
00503       return extractSatID(satSet);
00504 
00505    }  // End of method 'satTypeValueMap::extractSatID()'
00506 
00507 
00508 
00509       // Returns a satTypeValueMap with only one satellite, identified
00510       // by the given parameters.
00511       // @param p Satellite PRN number.
00512       // @param p System the satellite belongs to.
00513    satTypeValueMap satTypeValueMap::extractSatID( const int& p,
00514                                         const SatID::SatelliteSystem& s) const
00515    {
00516 
00517       SatID tempSatellite(p, s);  // We build a temporary SatID object
00518 
00519       return extractSatID(tempSatellite);
00520 
00521    }  // End of method 'satTypeValueMap::extractSatID()'
00522 
00523 
00524 
00525       // Returns a satTypeValueMap with only these satellites.
00526       // @param satSet Set (SatIDSet) containing the satellites to
00527       //               be extracted.
00528    satTypeValueMap satTypeValueMap::extractSatID(const SatIDSet& satSet) const
00529    {
00530 
00531       satTypeValueMap stvMap;
00532 
00533       for( SatIDSet::const_iterator pos = satSet.begin();
00534            pos != satSet.end();
00535            ++pos )
00536       {
00537          satTypeValueMap::const_iterator itObs( (*this).find(*pos) );
00538          if( itObs != (*this).end() )
00539          {
00540             stvMap[ (*itObs).first ] = (*itObs).second;
00541          };
00542       }
00543 
00544       return stvMap;
00545 
00546    }  // End of method 'satTypeValueMap::extractSatID()'
00547 
00548 
00549 
00550       // Modifies this object, keeping only this satellite.
00551       // @param satellite Satellite to be kept.
00552    satTypeValueMap& satTypeValueMap::keepOnlySatID(const SatID& satellite)
00553    {
00554 
00555       SatIDSet satSet;
00556       satSet.insert(satellite);
00557 
00558       return keepOnlySatID(satSet);
00559 
00560    }  // End of method 'satTypeValueMap::keepOnlySatID()'
00561 
00562 
00563 
00564       // Modifies this object, keeping only this satellite.
00565       // @param p Satellite PRN number.
00566       // @param p System the satellite belongs to.
00567    satTypeValueMap& satTypeValueMap::keepOnlySatID( const int& p,
00568                                              const SatID::SatelliteSystem& s )
00569    {
00570 
00571       SatID tempSatellite(p, s);  // We build a temporary SatID object
00572 
00573       return keepOnlySatID(tempSatellite);
00574 
00575    }  // End of method 'satTypeValueMap::keepOnlySatID()'
00576 
00577 
00578 
00579       // Modifies this object, keeping only these satellites.
00580       // @param satSet Set (SatIDSet) containing the satellites to be kept.
00581    satTypeValueMap& satTypeValueMap::keepOnlySatID(const SatIDSet& satSet)
00582    {
00583 
00584       satTypeValueMap stvMap( extractSatID(satSet) );
00585       (*this) = stvMap;
00586 
00587       return (*this);
00588 
00589    }  // End of method 'satTypeValueMap::keepOnlySatID()'
00590 
00591 
00592 
00593       // Returns a satTypeValueMap with only this type of value.
00594       // @param type Type of value to be extracted.
00595    satTypeValueMap satTypeValueMap::extractTypeID(const TypeID& type) const
00596    {
00597 
00598       TypeIDSet typeSet;
00599       typeSet.insert(type);
00600 
00601       return extractTypeID(typeSet);
00602 
00603    }  // End of method 'satTypeValueMap::extractTypeID()'
00604 
00605 
00606 
00607       // Returns a satTypeValueMap with only these types of data.
00608       // @param typeSet Set (TypeIDSet) containing the types of data
00609       //                to be extracted.
00610    satTypeValueMap satTypeValueMap::extractTypeID(const TypeIDSet& typeSet)
00611       const
00612    {
00613 
00614       satTypeValueMap theMap;
00615 
00616       for( satTypeValueMap::const_iterator it = (*this).begin();
00617            it != (*this).end();
00618            ++it )
00619       {
00620 
00621          typeValueMap tvMap( (*it).second.extractTypeID(typeSet) );
00622          if( tvMap.size() > 0 )
00623          {
00624             theMap[(*it).first] = tvMap;
00625          };
00626 
00627       };
00628 
00629       return theMap;
00630 
00631    }  // End of method 'satTypeValueMap::extractTypeID()'
00632 
00633 
00634 
00635       // Modifies this object, keeping only this type of data.
00636       // @param type Type of value to be kept.
00637    satTypeValueMap& satTypeValueMap::keepOnlyTypeID(const TypeID& type)
00638    {
00639 
00640       TypeIDSet typeSet;
00641       typeSet.insert(type);
00642 
00643       return keepOnlyTypeID(typeSet);
00644 
00645    }  // End of method 'satTypeValueMap::keepOnlyTypeID()'
00646 
00647 
00648 
00649       // Modifies this object, keeping only these types of data.
00650       // @param typeSet Set (TypeIDSet) containing the types of data
00651       //                to be kept.
00652    satTypeValueMap& satTypeValueMap::keepOnlyTypeID(const TypeIDSet& typeSet)
00653    {
00654 
00655       satTypeValueMap stvMap( extractTypeID(typeSet) );
00656       (*this) = stvMap;
00657 
00658       return (*this);
00659 
00660    }  // End of method 'satTypeValueMap::keepOnlyTypeID()'
00661 
00662 
00663 
00664       // Modifies this object, removing these satellites.
00665       // @param satSet Set (SatIDSet) containing the satellites
00666       //               to be removed.
00667    satTypeValueMap& satTypeValueMap::removeSatID(const SatIDSet& satSet)
00668    {
00669 
00670       for( SatIDSet::const_iterator pos = satSet.begin();
00671            pos != satSet.end();
00672            ++pos )
00673       {
00674          (*this).erase(*pos);
00675       }
00676 
00677       return (*this);
00678 
00679    }  // End of method 'satTypeValueMap::removeSatID()'
00680 
00681 
00682 
00683       // Modifies this object, removing this type of data.
00684       // @param type Type of value to be removed.
00685    satTypeValueMap& satTypeValueMap::removeTypeID(const TypeID& type)
00686    {
00687 
00688       for( satTypeValueMap::iterator it = (*this).begin();
00689            it != (*this).end();
00690            ++it )
00691       {
00692          (*it).second.removeTypeID(type);
00693       }
00694 
00695       return (*this);
00696 
00697    }  // End of method 'satTypeValueMap::removeTypeID()'
00698 
00699 
00700 
00701       // Modifies this object, removing these types of data.
00702       // @param typeSet Set (TypeIDSet) containing the types of data
00703       //                to be kept.
00704    satTypeValueMap& satTypeValueMap::removeTypeID(const TypeIDSet& typeSet)
00705    {
00706 
00707       for( TypeIDSet::const_iterator pos = typeSet.begin();
00708            pos != typeSet.end();
00709            ++pos )
00710       {
00711          removeTypeID(*pos);
00712       }
00713 
00714       return (*this);
00715 
00716    }  // End of method 'satTypeValueMap::removeTypeID()'
00717 
00718 
00719 
00720       // Returns a GPSTk::Vector containing the data values with this type.
00721       // @param type Type of value to be returned.
00722       // This method returns zero if a given satellite does not have this type.
00723    Vector<double> satTypeValueMap::getVectorOfTypeID(const TypeID& type) const
00724    {
00725 
00726          // Let's declare a STL vector
00727       std::vector<double> temp;
00728 
00729       for( satTypeValueMap::const_iterator it = (*this).begin();
00730            it != (*this).end();
00731            ++it )
00732       {
00733 
00734          typeValueMap::const_iterator itObs( (*it).second.find(type) );
00735          if ( itObs != (*it).second.end() )
00736          {
00737             temp.push_back( (*itObs).second );
00738          }
00739          else
00740          {
00741             temp.push_back( 0.0 );
00742          }
00743 
00744       }
00745 
00746          // Let's declare a GPSTk Vector
00747       Vector<double> result;
00748 
00749          // Transform STL vector into GPSTk Vector
00750       result = temp;
00751 
00752       return result;
00753 
00754    }  // End of method 'satTypeValueMap::getVectorOfTypeID()'
00755 
00756 
00757 
00758       // Returns a GPSTk::Matrix containing the data values in this set.
00759       // @param typeSet  TypeIDSet of values to be returned.
00760    Matrix<double> satTypeValueMap::getMatrixOfTypes(const TypeIDSet& typeSet)
00761       const
00762    {
00763 
00764          // First, let's create a Matrix<double> of the proper size
00765       Matrix<double> tempMat( (*this).numSats(), typeSet.size(), 0.0 );
00766 
00767       size_t numRow(0), numCol(0);
00768 
00769       for( satTypeValueMap::const_iterator it = (*this).begin();
00770            it != (*this).end();
00771            ++it )
00772       {
00773          numCol=0;
00774 
00775          for( TypeIDSet::const_iterator pos = typeSet.begin();
00776               pos != typeSet.end();
00777               ++pos )
00778          {
00779 
00780             typeValueMap::const_iterator itObs( (*it).second.find(*pos) );
00781             if( itObs != (*it).second.end() )
00782             {
00783                tempMat(numRow, numCol) = (*itObs).second;
00784             }
00785 
00786             ++numCol;
00787          }
00788 
00789          ++numRow;
00790 
00791       }
00792 
00793       return tempMat;
00794 
00795    }  // End of method 'satTypeValueMap::getMatrixOfTypes()'
00796 
00797 
00798 
00799       /* Modifies this object, adding one vector of data with this type,
00800        * one value per satellite.
00801        *
00802        * If type already exists, data is overwritten. If the number of
00803        * values does not match with the number of satellites, a
00804        * NumberOfSatsMismatch exception is thrown.
00805        *
00806        * Given that dataVector does not store information about the
00807        * satellites the values correspond to, the user is held responsible
00808        * for having the data values stored in dataVector in the proper
00809        * order regarding the SatIDs in this object.
00810        *
00811        * @param type          Type of data to be added.
00812        * @param dataVector    GPSTk Vector containing the data to be added.
00813        */
00814    satTypeValueMap& satTypeValueMap::insertTypeIDVector( const TypeID& type,
00815                                            const Vector<double> dataVector )
00816       throw(NumberOfSatsMismatch)
00817    {
00818 
00819       if( dataVector.size() == (*this).numSats() )
00820       {
00821          size_t pos = 0;
00822 
00823          for( satTypeValueMap::iterator it = (*this).begin();
00824               it != (*this).end();
00825               ++it )
00826          {
00827             (*it).second[type] = dataVector[pos];
00828             ++pos;
00829          }
00830 
00831          return (*this);
00832 
00833       }
00834       else
00835       {
00836          GPSTK_THROW( NumberOfSatsMismatch(" Number of data values in vector \
00837 and number of satellites do not match") );
00838       }
00839 
00840    }  // End of method 'satTypeValueMap::insertTypeIDVector()'
00841 
00842 
00843 
00844       /* Modifies this object, adding a matrix of data, one vector
00845        * per satellite.
00846        *
00847        * If types already exists, data is overwritten. If the number of
00848        * rows in matrix does not match with the number of satellites, a
00849        * NumberOfSatsMismatch exception is thrown. If the number of columns
00850        * in matrix does not match with the number of types in typeSet, a
00851        * NumberOfTypesMismatch exception is thrown.
00852        *
00853        * Given that dataMatrix does not store information about the
00854        * satellites and types the values correspond to, the user is held
00855        * responsible for having those data values stored in dataMatrix in
00856        * the proper order regarding the SatIDs in this object and the
00857        * provided typeSet.
00858        *
00859        * @param typeSet       Set (TypeIDSet) containing the types of data
00860        *                      to be added.
00861        * @param dataMatrix    GPSTk Matrix containing the data to be added.
00862        */
00863    satTypeValueMap& satTypeValueMap::insertMatrix( const TypeIDSet& typeSet,
00864                                              const Matrix<double> dataMatrix )
00865       throw(NumberOfSatsMismatch, NumberOfTypesMismatch)
00866    {
00867 
00868       if( dataMatrix.rows() != (*this).numSats() )
00869       {
00870          GPSTK_THROW( NumberOfSatsMismatch("Number of rows in matrix and \
00871 number of satellites do not match") );
00872       }
00873 
00874       if( dataMatrix.cols() == typeSet.size() )
00875       {
00876 
00877          size_t pos(0);
00878 
00879          for( satTypeValueMap::iterator it = (*this).begin();
00880               it != (*this).end();
00881               ++it )
00882          {
00883 
00884             size_t idx(0);
00885 
00886             for( TypeIDSet::const_iterator itSet = typeSet.begin();
00887                  itSet != typeSet.end();
00888                  ++itSet )
00889             {
00890                (*it).second[(*itSet)] = dataMatrix(pos,idx);
00891                ++idx;
00892             }
00893 
00894             ++pos;
00895 
00896          }
00897 
00898          return (*this);
00899 
00900       }
00901       else
00902       {
00903          GPSTK_THROW( NumberOfTypesMismatch("Number of data values per row \
00904 in matrix and number of types do not match") );
00905       }
00906 
00907    }  // End of method 'satTypeValueMap::insertMatrix()'
00908 
00909 
00910 
00911       /* Returns the data value (double) corresponding to provided SatID
00912        * and TypeID.
00913        *
00914        * @param satellite     Satellite to be looked for.
00915        * @param type          Type to be looked for.
00916        */
00917    double satTypeValueMap::getValue( const SatID& satellite,
00918                                      const TypeID& type ) const
00919       throw( SatIDNotFound, TypeIDNotFound )
00920    {
00921 
00922       satTypeValueMap::const_iterator itObs( (*this).find(satellite) );
00923       if( itObs != (*this).end() )
00924       {
00925          return (*itObs).second.getValue( type );
00926       }
00927       else
00928       {
00929          GPSTK_THROW(SatIDNotFound("SatID not found in map"));
00930       }
00931 
00932    }  // End of method 'satTypeValueMap::getValue()'
00933 
00934 
00935 
00936       // Returns a reference to the typeValueMap with corresponding SatID.
00937       // @param type Type of value to be looked for.
00938    typeValueMap& satTypeValueMap::operator()(const SatID& satellite)
00939       throw(SatIDNotFound)
00940    {
00941 
00942       satTypeValueMap::iterator itObs( (*this).find(satellite) );
00943       if( itObs != (*this).end() )
00944       {
00945          return (*itObs).second;
00946       }
00947       else
00948       {
00949          GPSTK_THROW(SatIDNotFound("SatID not found in map"));
00950       }
00951 
00952    }  // End of method 'satTypeValueMap::operator()'
00953 
00954 
00955 
00956 
00958 
00959 
00960       // Returns a gnssSatValue with only this satellite.
00961       // @param satellite Satellite to be extracted.
00962    gnssSatValue gnssSatValue::extractSatID(const SatID& satellite) const
00963    {
00964 
00965       gnssSatValue result;
00966       result.header = (*this).header;
00967       result.body = (*this).body.extractSatID(satellite);
00968 
00969       return result;
00970 
00971    }  // End of method 'gnssSatValue::extractSatID()'
00972 
00973 
00974 
00975       // Returns a gnssSatValue with only one satellite, identified by
00976       // the given parameters.
00977       // @param p Satellite PRN number.
00978       // @param p System the satellite belongs to.
00979    gnssSatValue gnssSatValue::extractSatID( const int& p,
00980                                        const SatID::SatelliteSystem& s ) const
00981    {
00982 
00983       SatID tempSatellite(p, s);  // We build a temporary SatID object
00984 
00985       return extractSatID(tempSatellite);
00986 
00987    }  // End of method 'gnssSatValue::extractSatID()'
00988 
00989 
00990 
00991       // Returns a gnssSatValue with only these satellites.
00992       // @param satSet Set (SatIDSet) containing the satellites
00993       //               to be extracted.
00994    gnssSatValue gnssSatValue::extractSatID(const SatIDSet& satSet) const
00995    {
00996 
00997       gnssSatValue result;
00998       result.header = (*this).header;
00999       result.body = (*this).body.extractSatID(satSet);
01000 
01001       return result;
01002 
01003    }  // End of method 'gnssSatValue::extractSatID()'
01004 
01005 
01006 
01007       // Modifies this object, keeping only this satellite.
01008       // @param satellite Satellite to be kept.
01009    gnssSatValue& gnssSatValue::keepOnlySatID(const SatID& satellite)
01010    {
01011 
01012       SatIDSet satSet;
01013       satSet.insert(satellite);
01014 
01015       return keepOnlySatID(satSet);
01016 
01017    }  // End of method 'gnssSatValue::keepOnlySatID()'
01018 
01019 
01020 
01021       // Modifies this object, keeping only this satellite.
01022       // @param p Satellite PRN number.
01023       // @param p System the satellite belongs to.
01024    gnssSatValue& gnssSatValue::keepOnlySatID( const int& p,
01025                                               const SatID::SatelliteSystem& s )
01026    {
01027 
01028       SatID tempSatellite(p, s);  // We build a temporary SatID object
01029 
01030       return keepOnlySatID(tempSatellite);
01031 
01032    }  // End of method 'gnssSatValue::keepOnlySatID()'
01033 
01034 
01035 
01036       // Modifies this object, keeping only these satellites.
01037       // @param satSet Set (SatIDSet) containing the satellites to be kept.
01038    gnssSatValue& gnssSatValue::keepOnlySatID(const SatIDSet& satSet)
01039    {
01040 
01041       satValueMap svMap ( (*this).body.extractSatID(satSet) );
01042       (*this).body = svMap;
01043 
01044       return (*this);
01045 
01046    }  // End of method 'gnssSatValue::keepOnlySatID()'
01047 
01048 
01049 
01050       // Modifies this object, removing these satellites.
01051       // @param satSet Set (SatIDSet) containing the satellites
01052       //               to be removed.
01053    gnssSatValue& gnssSatValue::removeSatID(const SatIDSet& satSet)
01054    {
01055 
01056       for( SatIDSet::const_iterator pos = satSet.begin();
01057            pos != satSet.end();
01058            ++pos )
01059       {
01060          (*this).body.erase(*pos);
01061       }
01062 
01063          return (*this);
01064 
01065    }  // End of method 'gnssSatValue::removeSatID()'
01066 
01067 
01068 
01069 
01071 
01072 
01073       // Returns a gnssTypeValue with only this type of data.
01074       // @param type Type of value to be extracted.
01075    gnssTypeValue gnssTypeValue::extractTypeID(const TypeID& type) const
01076    {
01077 
01078       gnssTypeValue result;
01079       result.header = (*this).header;
01080       result.body = (*this).body.extractTypeID(type);
01081 
01082       return result;
01083 
01084    }  // End of method 'gnssTypeValue::extractTypeID()'
01085 
01086 
01087 
01088       // Returns a gnssTypeValue with only these types of data.
01089       // @param typeSet Set (TypeIDSet) containing the types of data
01090       //                to be extracted.
01091    gnssTypeValue gnssTypeValue::extractTypeID(const TypeIDSet& typeSet) const
01092    {
01093 
01094       gnssTypeValue result;
01095       result.header = (*this).header;
01096       result.body = (*this).body.extractTypeID(typeSet);
01097 
01098       return result;
01099 
01100    }  // End of method 'gnssTypeValue::extractTypeID()'
01101 
01102 
01103 
01104       // Modifies this object, keeping only this type of data.
01105       // @param type Type of value to be kept.
01106    gnssTypeValue& gnssTypeValue::keepOnlyTypeID(const TypeID& type)
01107    {
01108 
01109       TypeIDSet typeSet;
01110       typeSet.insert(type);
01111 
01112       return keepOnlyTypeID(typeSet);
01113 
01114    }  // End of method 'gnssTypeValue::keepOnlyTypeID()'
01115 
01116 
01117 
01118       // Modifies this object, keeping only these types of data.
01119       // @param typeSet Set (TypeIDSet) containing the types of data
01120       //                to be kept.
01121    gnssTypeValue& gnssTypeValue::keepOnlyTypeID(const TypeIDSet& typeSet)
01122    {
01123 
01124       typeValueMap tvMap( (*this).body.extractTypeID(typeSet) );
01125       (*this).body = tvMap;
01126 
01127       return (*this);
01128 
01129    }  // End of method 'gnssTypeValue::keepOnlyTypeID()'
01130 
01131 
01132 
01133       // Modifies this object, removing these types of data.
01134       // @param typeSet Set (TypeIDSet) containing the types of data
01135       //                to be kept.
01136    gnssTypeValue& gnssTypeValue::removeTypeID(const TypeIDSet& typeSet)
01137    {
01138 
01139       for( TypeIDSet::const_iterator pos = typeSet.begin();
01140            pos != typeSet.end();
01141            ++pos )
01142       {
01143          (*this).body.erase(*pos);
01144       }
01145 
01146       return (*this);
01147 
01148    }  // End of method 'gnssTypeValue::removeTypeID()'
01149 
01150 
01151 
01152 
01154 
01155 
01156       // Returns a gnssSatTypeValue with only this satellite.
01157       // @param satellite Satellite to be extracted.
01158    gnssSatTypeValue gnssSatTypeValue::extractSatID(const SatID& satellite)
01159       const
01160    {
01161 
01162       gnssSatTypeValue result;
01163       result.header = (*this).header;
01164       result.body = (*this).body.extractSatID(satellite);
01165 
01166       return result;
01167 
01168    }  // End of method 'gnssSatTypeValue::extractSatID()'
01169 
01170 
01171 
01172       // Returns a gnssSatTypeValue with only one satellite, identified
01173       // by the given parameters.
01174       // @param p Satellite PRN number.
01175       // @param p System the satellite belongs to.
01176    gnssSatTypeValue gnssSatTypeValue::extractSatID( const int& p,
01177                                        const SatID::SatelliteSystem& s ) const
01178    {
01179 
01180       SatID tempSatellite(p, s);  // We build a temporary SatID object
01181 
01182       return extractSatID(tempSatellite);
01183 
01184    }  // End of method 'gnssSatTypeValue::extractSatID()'
01185 
01186 
01187 
01188       // Returns a gnssSatTypeValue with only these satellites.
01189       // @param satSet Set (SatIDSet) containing the satellites
01190       //               to be extracted.
01191    gnssSatTypeValue gnssSatTypeValue::extractSatID(const SatIDSet& satSet) const
01192    {
01193 
01194       gnssSatTypeValue result;
01195       result.header = (*this).header;
01196       result.body = (*this).body.extractSatID(satSet);
01197 
01198       return result;
01199 
01200    }  // End of method 'gnssSatTypeValue::extractSatID()'
01201 
01202 
01203 
01204       // Modifies this object, keeping only this satellite.
01205       // @param satellite Satellite to be kept.
01206    gnssSatTypeValue& gnssSatTypeValue::keepOnlySatID(const SatID& satellite)
01207    {
01208 
01209       SatIDSet satSet;
01210       satSet.insert(satellite);
01211 
01212       return keepOnlySatID(satSet);
01213 
01214    }  // End of method 'gnssSatTypeValue::keepOnlySatID()'
01215 
01216 
01217 
01218       // Modifies this object, keeping only this satellite.
01219       // @param p Satellite PRN number.
01220       // @param p System the satellite belongs to.
01221    gnssSatTypeValue& gnssSatTypeValue::keepOnlySatID( const int& p,
01222                                              const SatID::SatelliteSystem& s )
01223    {
01224 
01225       SatID tempSatellite(p, s);  // We build a temporary SatID object
01226 
01227       return keepOnlySatID(tempSatellite);
01228 
01229    }  // End of method 'gnssSatTypeValue::keepOnlySatID()'
01230 
01231 
01232 
01233       // Modifies this object, keeping only these satellites.
01234       // @param satSet Set (SatIDSet) containing the satellites to be kept.
01235    gnssSatTypeValue& gnssSatTypeValue::keepOnlySatID(const SatIDSet& satSet)
01236    {
01237 
01238       satTypeValueMap stvMap( (*this).body.extractSatID(satSet) );
01239       (*this).body = stvMap;
01240 
01241       return (*this);
01242 
01243    }  // End of method 'gnssSatTypeValue::keepOnlySatID()'
01244 
01245 
01246 
01247       // Returns a gnssSatTypeValue with only this type of data.
01248       // @param type Type of value to be extracted.
01249    gnssSatTypeValue gnssSatTypeValue::extractTypeID(const TypeID& type) const
01250    {
01251 
01252       gnssSatTypeValue result;
01253       result.header = (*this).header;
01254       result.body = (*this).body.extractTypeID(type);
01255 
01256       return result;
01257 
01258    }  // End of method 'gnssSatTypeValue::extractTypeID()'
01259 
01260 
01261 
01262       // Returns a gnssSatTypeValue with only these types of data.
01263       // @param typeSet Set (TypeIDSet) containing the types of data
01264       //                to be extracted.
01265    gnssSatTypeValue gnssSatTypeValue::extractTypeID(const TypeIDSet& typeSet)
01266       const
01267    {
01268 
01269       gnssSatTypeValue result;
01270       result.header = (*this).header;
01271       result.body = (*this).body.extractTypeID(typeSet);
01272 
01273       return result;
01274 
01275    }  // End of method 'gnssSatTypeValue::extractTypeID()'
01276 
01277 
01278 
01279       // Modifies this object, keeping only this type of data.
01280       // @param type Type of value to be kept.
01281    gnssSatTypeValue& gnssSatTypeValue::keepOnlyTypeID(const TypeID& type)
01282    {
01283 
01284       TypeIDSet typeSet;
01285       typeSet.insert(type);
01286 
01287       return keepOnlyTypeID(typeSet);
01288 
01289    }  // End of method 'gnssSatTypeValue::keepOnlyTypeID()'
01290 
01291 
01292 
01293       // Modifies this object, keeping only these types of data.
01294       // @param typeSet Set (TypeIDSet) containing the types of data
01295       //                to be kept.
01296    gnssSatTypeValue& gnssSatTypeValue::keepOnlyTypeID(const TypeIDSet& typeSet)
01297    {
01298 
01299       satTypeValueMap stvMap( (*this).body.extractTypeID(typeSet) );
01300       (*this).body = stvMap;
01301 
01302       return (*this);
01303 
01304    }  // End of method 'gnssSatTypeValue::keepOnlyTypeID()'
01305 
01306 
01307 
01308       // Modifies this object, removing these satellites.
01309       // @param satSet Set (SatIDSet) containing the satellites
01310       //               to be removed.
01311    gnssSatTypeValue& gnssSatTypeValue::removeSatID(const SatIDSet& satSet)
01312    {
01313 
01314       for( SatIDSet::const_iterator pos = satSet.begin();
01315            pos != satSet.end();
01316            ++pos )
01317       {
01318          (*this).body.erase(*pos);
01319       }
01320 
01321       return (*this);
01322 
01323    }  // End of method 'gnssSatTypeValue::removeSatID()'
01324 
01325 
01326 
01327       // Modifies this object, removing these types of data
01328       // @param typeSet Set (TypeIDSet) containing the types of data
01329       //                to be kept.
01330    gnssSatTypeValue& gnssSatTypeValue::removeTypeID(const TypeIDSet& typeSet)
01331    {
01332 
01333       for( TypeIDSet::const_iterator pos = typeSet.begin();
01334            pos != typeSet.end();
01335            ++pos )
01336       {
01337          (*this).body.removeTypeID(*pos);
01338       }
01339 
01340       return (*this);
01341 
01342    }  // End of method 'gnssSatTypeValue::removeTypeID()'
01343 
01344 
01345 
01346 
01348 
01349 
01350       // Returns a gnssRinex with only this satellite.
01351       // @param satellite Satellite to be extracted.
01352    gnssRinex gnssRinex::extractSatID(const SatID& satellite) const
01353    {
01354 
01355       gnssRinex result;
01356       result.header = (*this).header;
01357       result.body = (*this).body.extractSatID(satellite);
01358 
01359       return result;
01360 
01361    }  // End of method 'gnssRinex::extractSatID()'
01362 
01363 
01364 
01365       // Returns a gnssRinex with only one satellite, identified by
01366       // the given parameters.
01367       // @param p Satellite PRN number.
01368       // @param p System the satellite belongs to.
01369    gnssRinex gnssRinex::extractSatID( const int& p,
01370                                       const SatID::SatelliteSystem& s ) const
01371    {
01372 
01373       SatID tempSatellite(p, s);  // We build a temporary SatID object
01374 
01375       return extractSatID(tempSatellite);
01376 
01377    }  // End of method 'gnssRinex::extractSatID()'
01378 
01379 
01380 
01381       // Returns a gnssRinex with only these satellites.
01382       // @param satSet Set (SatIDSet) containing the satellites
01383       //               to be extracted.
01384    gnssRinex gnssRinex::extractSatID(const SatIDSet& satSet) const
01385    {
01386 
01387       gnssRinex result;
01388       result.header = (*this).header;
01389       result.body = (*this).body.extractSatID(satSet);
01390 
01391       return result;
01392 
01393    }  // End of method 'gnssRinex::extractSatID()'
01394 
01395 
01396 
01397       // Modifies this object, keeping only this satellite.
01398       // @param satellite Satellite to be kept.
01399    gnssRinex& gnssRinex::keepOnlySatID(const SatID& satellite)
01400    {
01401 
01402       SatIDSet satSet;
01403       satSet.insert(satellite);
01404 
01405       return keepOnlySatID(satSet);
01406 
01407    }  // End of method 'gnssRinex::keepOnlySatID()'
01408 
01409 
01410 
01411       // Modifies this object, keeping only this satellite.
01412       // @param p Satellite PRN number.
01413       // @param p System the satellite belongs to.
01414    gnssRinex& gnssRinex::keepOnlySatID( const int& p,
01415                                         const SatID::SatelliteSystem& s )
01416    {
01417 
01418       SatID tempSatellite(p, s);  // We build a temporary SatID object
01419 
01420       return keepOnlySatID(tempSatellite);
01421 
01422    }  // End of method 'gnssRinex::keepOnlySatID()'
01423 
01424 
01425 
01426       // Modifies this object, keeping only these satellites.
01427       // @param satSet Set (SatIDSet) containing the satellites to be kept.
01428    gnssRinex& gnssRinex::keepOnlySatID(const SatIDSet& satSet)
01429    {
01430 
01431       satTypeValueMap stvMap( (*this).body.extractSatID(satSet) );
01432       (*this).body = stvMap;
01433 
01434       return (*this);
01435 
01436    }  // End of method 'gnssRinex::keepOnlySatID()'
01437 
01438 
01439 
01440       // Returns a gnssRinex with only this type of data.
01441       // @param type Type of value to be extracted.
01442    gnssRinex gnssRinex::extractTypeID(const TypeID& type) const
01443    {
01444 
01445       gnssRinex result;
01446       result.header = (*this).header;
01447       result.body = (*this).body.extractTypeID(type);
01448 
01449       return result;
01450 
01451    }  // End of method 'gnssRinex::extractTypeID()'
01452 
01453 
01454 
01455       // Returns a gnssRinex with only these types of data.
01456       // @param typeSet Set (TypeIDSet) containing the types of data
01457       //                to be extracted.
01458    gnssRinex gnssRinex::extractTypeID(const TypeIDSet& typeSet) const
01459    {
01460 
01461       gnssRinex result;
01462       result.header = (*this).header;
01463       result.body = (*this).body.extractTypeID(typeSet);
01464 
01465       return result;
01466 
01467    }  // End of method 'gnssRinex::extractTypeID()'
01468 
01469 
01470 
01471       // Modifies this object, keeping only this type of data.
01472       // @param type Type of value to be kept.
01473    gnssRinex& gnssRinex::keepOnlyTypeID(const TypeID& type)
01474    {
01475 
01476       TypeIDSet typeSet;
01477       typeSet.insert(type);
01478 
01479       return keepOnlyTypeID(typeSet);
01480 
01481    }  // End of method 'gnssRinex::keepOnlyTypeID()'
01482 
01483 
01484 
01485       // Modifies this object, keeping only these types of data.
01486       // @param typeSet Set (TypeIDSet) containing the types of data
01487       //                to be kept.
01488    gnssRinex& gnssRinex::keepOnlyTypeID(const TypeIDSet& typeSet)
01489    {
01490 
01491       satTypeValueMap stvMap( (*this).body.extractTypeID(typeSet) );
01492       (*this).body = stvMap;
01493 
01494       return (*this);
01495 
01496    }  // End of method 'gnssRinex::keepOnlyTypeID()'
01497 
01498 
01499 
01500       // Returns a gnssRinex with only these types of data.
01501       // @param satSys Satellite System value to be kept. 
01502    gnssRinex& gnssRinex::keepOnlySatSystem(const SatID::SatelliteSystem satSys)
01503    {
01504        satTypeValueMap stvMap( (*this).body );
01505        
01506        SatIDSet satRejectedSet;
01507        for(satTypeValueMap::iterator it = stvMap.begin();
01508            it != stvMap.end();
01509            ++it)
01510        {
01511            if( it->first.system != satSys ) satRejectedSet.insert( it->first );
01512        }
01513        stvMap.removeSatID(satRejectedSet);
01514 
01515 
01516        (*this).body = stvMap;
01517 
01518        return (*this);
01519    }  // End of method 'gnssRinex::keepOnlySatSystem()'
01520 
01521 
01522 
01524 
01525 
01526 
01527       /* Returns the data value (double) corresponding to provided SourceID,
01528        * SatID and TypeID.
01529        *
01530        * @param source        Source to be looked for.
01531        * @param satellite     Satellite to be looked for.
01532        * @param type          Type to be looked for.
01533        */
01534    double sourceDataMap::getValue( const SourceID& source,
01535                                    const SatID& satellite,
01536                                    const TypeID& type ) const
01537       throw( SourceIDNotFound, SatIDNotFound, TypeIDNotFound )
01538    {
01539 
01540          // Look for the SourceID
01541       sourceDataMap::const_iterator itObs( (*this).find(source) );
01542       if( itObs != (*this).end() )
01543       {
01544          return (*itObs).second.getValue( satellite, type );
01545       }
01546       else
01547       {
01548          GPSTK_THROW(SourceIDNotFound("SourceID not found in map"));
01549       }
01550 
01551    }  // End of method 'sourceDataMap::getValue()'
01552 
01553 
01554 
01555       /* Get a set with all the SourceID's in this data structure.
01556        *
01557        * @warning If current 'sourceDataMap' is big, this could be a very
01558        * costly operation.
01559        */
01560    SourceIDSet sourceDataMap::getSourceIDSet( void ) const
01561    {
01562 
01563          // SourceID set to be returned
01564       SourceIDSet toReturn;
01565 
01566          // Then, iterate through corresponding 'sourceDataMap'
01567       for( sourceDataMap::const_iterator sdmIter = (*this).begin();
01568            sdmIter != (*this).end();
01569            ++sdmIter )
01570       {
01571 
01572             // Add current SourceID to 'toReturn'
01573          toReturn.insert( (*sdmIter).first );
01574 
01575       }  // End of 'for( sourceDataMap::const_iterator sdmIter = ...'
01576 
01577       return toReturn;
01578 
01579    }  // End of method 'sourceDataMap::getSourceIDSet()'
01580 
01581 
01582 
01583       /* Get a set with all the SatID's in this data structure.
01584        *
01585        * @warning If current 'sourceDataMap' is big, this could be a very
01586        * costly operation.
01587        */
01588    SatIDSet sourceDataMap::getSatIDSet( void ) const
01589    {
01590 
01591          // SatID set to be returned
01592       SatIDSet toReturn;
01593 
01594          // Then, iterate through corresponding 'sourceDataMap'
01595       for( sourceDataMap::const_iterator sdmIter = (*this).begin();
01596            sdmIter != (*this).end();
01597            ++sdmIter )
01598       {
01599 
01600             // Finally, iterate through corresponding 'satTypeValueMap'
01601          for( satTypeValueMap::const_iterator stvmIter =
01602                                                    (*sdmIter).second.begin();
01603               stvmIter != (*sdmIter).second.end();
01604               stvmIter++ )
01605          {
01606 
01607                // Add current SatID to 'toReturn'
01608             toReturn.insert( (*stvmIter).first );
01609 
01610          }  // End of 'for( satTypeValueMap::const_iterator stvmIter = ...'
01611 
01612       }  // End of 'for( sourceDataMap::const_iterator sdmIter = ...'
01613 
01614       return toReturn;
01615 
01616    }  // End of method 'sourceDataMap::getSatIDSet()'
01617 
01618 
01619 
01620       /* Adds 'gnssSatTypeValue' object data to this structure.
01621        *
01622        * @param gds     gnssSatTypeValue object containing data to be added.
01623        */
01624    gnssDataMap& gnssDataMap::addGnssSatTypeValue( const gnssSatTypeValue& gds )
01625    {
01626 
01627          // Declare an object for temporal storage of data
01628       sourceDataMap sdMap;
01629 
01630          // Fill with data
01631       sdMap[ gds.header.source ] = gds.body;
01632 
01633          // Introduce data into this GDS
01634       (*this).insert( pair<const DayTime, sourceDataMap>( gds.header.epoch, sdMap ) );
01635 
01636          // Return curren GDS.
01637       return (*this);
01638 
01639    }  // End of method 'gnssDataMap::addGnssSatTypeValue()'
01640 
01641 
01642 
01643       /* Adds 'gnssRinex' object data to this structure.
01644        *
01645        * @param gds     gnssRinex object containing data to be added.
01646        */
01647    gnssDataMap& gnssDataMap::addGnssRinex( const gnssRinex& gds )
01648    {
01649 
01650          // Declare an object for temporal storage of data
01651       sourceDataMap sdMap;
01652 
01653          // Fill with data
01654       sdMap[ gds.header.source ] = gds.body;
01655 
01656          // Introduce data into this GDS
01657       (*this).insert( pair<const DayTime, sourceDataMap>( gds.header.epoch, sdMap ) );
01658 
01659          // Return current GDS.
01660       return (*this);
01661 
01662    }  // End of method 'gnssDataMap::addGnssRinex()'
01663 
01664 
01665 
01666       /* Returns a 'gnssRinex' object corresponding to given SourceID.
01667        *
01668        * @param source     SourceID object.
01669        *
01670        * @warning Returned data will correspond to first matching SourceID,
01671        * if it exists.
01672        */
01673    gnssRinex gnssDataMap::getGnssRinex( const SourceID& source ) const
01674    {
01675 
01676          // Get first data set
01677       gnssDataMap gdMap( (*this).frontEpoch() );
01678 
01679          // Declare a gnssRinex object to be returned
01680       gnssRinex toReturn;
01681 
01682          // We'll need a flag
01683       bool found(false);
01684 
01685          // Look into the data structure
01686       for( gnssDataMap::const_iterator it = gdMap.begin();
01687            it != gdMap.end() && !found;
01688            ++it )
01689       {
01690 
01691             // Look for SourceID
01692          sourceDataMap::const_iterator iter( (*it).second.find( source ) );
01693          if( iter != (*it).second.end() )
01694          {
01695             toReturn.body = (*iter).second;
01696             toReturn.header.source = (*iter).first;
01697             toReturn.header.epoch = (*it).first;
01698             toReturn.header.epochFlag = 0;
01699             found = true;
01700          }
01701 
01702       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
01703 
01704          // Return GDS
01705       return toReturn;
01706 
01707    }  // End of method 'gnssDataMap::addGnssRinex()'
01708 
01709 
01710 
01711       /* Adds 'gnssDataMap' object data to this structure.
01712        *
01713        * @param gds     gnssDataMap object containing data to be added.
01714        */
01715    gnssDataMap& gnssDataMap::addGnssDataMap( const gnssDataMap& gds )
01716    {
01717          // Iterate through all items in the gnssDataMap
01718       for( gnssDataMap::const_iterator it = gds.begin();
01719            it != gds.end();
01720            ++it )
01721       {
01722          const DayTime& time(it->first);
01723          const sourceDataMap& sourceMap(it->second);
01724 
01725          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
01726              itsrc != sourceMap.end();
01727              ++itsrc)
01728          {
01729             gnssSatTypeValue stv;
01730             stv.header.epoch = time;
01731             stv.header.source = itsrc->first;
01732             stv.body = itsrc->second;
01733 
01734             addGnssSatTypeValue(stv);
01735 
01736          }  // loop in the sources
01737 
01738       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
01739 
01740       return (*this);
01741    }
01742 
01743 
01744       // Returns a copy of the first element in the map.
01745    gnssDataMap gnssDataMap::front( void ) const
01746    {
01747 
01748          // Object to be returned
01749       gnssDataMap toReturn;
01750 
01751          // First check that structure isn't empty
01752       if( !( (*this).empty() ) )
01753       {
01754 
01755             // Get first element
01756          gnssDataMap::const_iterator firstIt( (*this).begin() );
01757 
01758             // Insert first element in 'toReturn' object
01759          toReturn.insert(*firstIt);
01760 
01761       }
01762 
01763       return toReturn;
01764 
01765    }  // End of method 'gnssDataMap::front()'
01766 
01767 
01768 
01769       // Removes the first element in the map.
01770    void gnssDataMap::pop_front( void )
01771    {
01772 
01773          // First check that structure isn't empty
01774       if( !( (*this).empty() ) )
01775       {
01776 
01777             // Define an iterator pointing to the beginning of this map
01778          gnssDataMap::iterator pos( (*this).begin() );
01779 
01780             // It is advisable to avoid sawing off the branch we are sitting on
01781          (*this).erase( pos++ );
01782 
01783       }
01784 
01785       return;
01786 
01787    }  // End of method 'gnssDataMap::pop_front()'
01788 
01789 
01790 
01791       // Returns the data corresponding to the first epoch in the map,
01792       // taking into account the 'tolerance' value.
01793    gnssDataMap gnssDataMap::frontEpoch( void ) const
01794    {
01795 
01796          // Declare structure to be returned
01797       gnssDataMap toReturn;
01798 
01799          // First check that structure isn't empty
01800       if( !( (*this).empty() ) )
01801       {
01802 
01803             // Get the 'DayTime' of the first element
01804          DayTime firstEpoch( (*(*this).begin()).first );
01805 
01806             // Find the position of the first element PAST
01807             // 'firstEpoch+tolerance'
01808          gnssDataMap::const_iterator endPos(
01809                                  (*this).upper_bound(firstEpoch+tolerance) );
01810 
01811             // Add values to 'toReturn'
01812          for( gnssDataMap::const_iterator it = (*this).begin();
01813               it != endPos;
01814               ++it )
01815          {
01816             toReturn.insert( (*it) );
01817          }
01818 
01819       }
01820 
01821       return toReturn;
01822 
01823    }  // End of method 'gnssDataMap::frontEpoch()'
01824 
01825 
01826 
01827       // Removes the first epoch in the map. Be aware that this method
01828       // takes into account 'tolerance', so more than just one epoch may be
01829       // removed if they are within 'tolerance' margin.
01830    void gnssDataMap::pop_front_epoch( void )
01831    {
01832 
01833          // First check that structure isn't empty
01834       if( !( (*this).empty() ) )
01835       {
01836 
01837             // Get the 'DayTime' of the first element
01838          DayTime firstEpoch( (*(*this).begin()).first );
01839 
01840             // Find the position of the first element PAST
01841             // 'firstEpoch+tolerance'
01842          gnssDataMap::iterator endPos(
01843                                  (*this).upper_bound(firstEpoch+tolerance) );
01844 
01845             // Remove values
01846          for( gnssDataMap::iterator pos = (*this).begin();
01847               pos != endPos; )
01848          {
01849 
01850                // It is advisable to avoid sawing off the branch we are
01851                // sitting on
01852             (*this).erase( pos++ );
01853          }
01854 
01855       }
01856 
01857       return;
01858 
01859    }  // End of method 'gnssDataMap::pop_front_epoch()'
01860 
01861 
01862 
01863       // Returns a copy of the last element in the map.
01864    gnssDataMap gnssDataMap::back( void ) const
01865    {
01866 
01867          // Object to be returned
01868       gnssDataMap toReturn;
01869 
01870          // First check that structure isn't empty
01871       if( !( (*this).empty() ) )
01872       {
01873 
01874             // Get last element
01875          gnssDataMap::const_reverse_iterator lastIt( (*this).rbegin() );
01876 
01877             // Insert the last element in 'toReturn' object
01878          toReturn.insert(*lastIt);
01879 
01880       }
01881 
01882       return toReturn;
01883 
01884    }  // End of method 'gnssDataMap::back()'
01885 
01886 
01887 
01888       // Removes the last element in the map.
01889    void gnssDataMap::pop_back( void )
01890    {
01891 
01892          // First check that structure isn't empty
01893       if( !( (*this).empty() ) )
01894       {
01895 
01896             // Define an iterator pointing to the end of this map
01897          gnssDataMap::iterator pos( (*this).end() );
01898 
01899             // Delete element
01900          (*this).erase( --pos );
01901 
01902       }
01903 
01904       return;
01905 
01906    }  // End of method 'gnssDataMap::pop_back()'
01907 
01908 
01909 
01910       // Returns the data corresponding to the last epoch in the map,
01911       // taking into account the 'tolerance' value.
01912    gnssDataMap gnssDataMap::backEpoch( void ) const
01913    {
01914 
01915          // Declare structure to be returned
01916       gnssDataMap toReturn;
01917 
01918          // First check that structure isn't empty
01919       if( !( (*this).empty() ) )
01920       {
01921 
01922             // Get the 'DayTime' of the last element
01923          DayTime lastEpoch( (*(--(*this).end())).first );
01924 
01925             // Find the position of the last element PAST
01926             // 'lastEpoch-tolerance'
01927          gnssDataMap::const_iterator beginPos(
01928                                  (*this).lower_bound(lastEpoch-tolerance) );
01929 
01930             // Add values to 'toReturn'
01931          for( gnssDataMap::const_iterator it = beginPos;
01932               it != (*this).end();
01933               ++it )
01934          {
01935             toReturn.insert( (*it) );
01936          }
01937 
01938       }
01939 
01940       return toReturn;
01941 
01942    }  // End of method 'gnssDataMap::backEpoch()'
01943 
01944 
01945 
01946       // Removes the last epoch in the map. Be aware that this method
01947       // takes into account 'tolerance', so more than just one epoch may be
01948       // removed if they are within 'tolerance' margin.
01949    void gnssDataMap::pop_back_epoch( void )
01950    {
01951 
01952          // First check that structure isn't empty
01953       if( !( (*this).empty() ) )
01954       {
01955 
01956             // Get the 'DayTime' of the last element
01957          DayTime lastEpoch( (*(--(*this).end())).first );
01958 
01959             // Find the position of the last element PAST
01960             // 'lastEpoch-tolerance'
01961          gnssDataMap::iterator beginPos(
01962                                  (*this).lower_bound(lastEpoch-tolerance) );
01963 
01964             // Remove values
01965          for( gnssDataMap::iterator pos = beginPos;
01966               pos != (*this).end(); )
01967          {
01968 
01969                // It is advisable to avoid sawing off the branch we are
01970                // sitting on
01971             (*this).erase( pos++ );
01972          }
01973 
01974       }
01975 
01976       return;
01977 
01978    }  // End of method 'gnssDataMap::pop_back_epoch()'
01979 
01980 
01981 
01982       /* Returns a 'gnssDataMap' with the data corresponding to provided
01983        * DayTime, taking into account 'tolerance'.
01984        *
01985        * @param epoch         Epoch to be looked for.
01986        */
01987    gnssDataMap gnssDataMap::getDataFromEpoch( const DayTime& epoch ) const
01988       throw( DayTimeNotFound )
01989    {
01990 
01991          // Declare structure to be returned
01992       gnssDataMap toReturn;
01993 
01994          // First check that structure isn't empty
01995       if( !( (*this).empty() ) )
01996       {
01997 
01998             // Find the position of the first element whose key is not less than
01999             // 'epoch-tolerance'
02000          gnssDataMap::const_iterator beginPos(
02001                                  (*this).lower_bound(epoch-tolerance) );
02002 
02003             // Find the position of the first element PAST
02004             // 'epoch+tolerance'
02005          gnssDataMap::const_iterator endPos(
02006                                  (*this).upper_bound(epoch+tolerance) );
02007 
02008             // Add values to 'toReturn'
02009          for( gnssDataMap::const_iterator it = beginPos;
02010               it != endPos;
02011               ++it )
02012          {
02013             toReturn.insert( (*it) );
02014          }
02015 
02016       }
02017       else
02018       {
02019          GPSTK_THROW(DayTimeNotFound("Data map is empty"));
02020       }
02021 
02022          // Check if 'toReturn' is empty
02023       if( toReturn.empty() )
02024       {
02025          GPSTK_THROW(DayTimeNotFound("Epoch not found"));
02026       }
02027 
02028       return toReturn;
02029 
02030    }  // End of method 'gnssDataMap::getDataFromEpoch()'
02031 
02032 
02033 
02034       /* Returns the data value (double) corresponding to provided DayTime,
02035        * SourceID, SatID and TypeID.
02036        *
02037        * @param epoch         Epoch to be looked for.
02038        * @param source        Source to be looked for.
02039        * @param satellite     Satellite to be looked for.
02040        * @param type          Type to be looked for.
02041        *
02042        * @warning If within (epoch +/- tolerance) more than one match exists,
02043        * then only the first one is returned.
02044        */
02045    double gnssDataMap::getValue( const DayTime& epoch,
02046                                  const SourceID& source,
02047                                  const SatID& satellite,
02048                                  const TypeID& type ) const
02049       throw( DayTimeNotFound, ValueNotFound )
02050    {
02051 
02052          // Look for the epoch (DayTime) data
02053       gnssDataMap gdMap( getDataFromEpoch(epoch) );
02054 
02055          // Value to be returned
02056       double toReturn;
02057 
02058          // We'll need a flag
02059       bool found(false);
02060 
02061          // Look into the data structure
02062       for( gnssDataMap::const_iterator it = gdMap.begin();
02063            it != gdMap.end() && !found;
02064            ++it )
02065       {
02066 
02067          try
02068          {
02069             toReturn = (*it).second.getValue( source, satellite, type );
02070             found = true;
02071          }
02072          catch(...)
02073          {
02074             continue;
02075          }
02076 
02077       }
02078 
02079          // Check if value was found
02080       if( !found )
02081       {
02082          GPSTK_THROW(ValueNotFound("Value not found"));
02083       }
02084 
02085       return toReturn;
02086 
02087    }  // End of method 'gnssDataMap::getValue()'
02088 
02089 
02090 
02091       /* Returns the data value (double) corresponding to the first epoch
02092        * in the data structure, given SourceID, SatID and TypeID.
02093        *
02094        * @param source        Source to be looked for.
02095        * @param satellite     Satellite to be looked for.
02096        * @param type          Type to be looked for.
02097        *
02098        * @warning If within first epoch (epoch +/- tolerance) more than one
02099        * match exists, then only the first one is returned.
02100        */
02101    double gnssDataMap::getValue( const SourceID& source,
02102                                  const SatID& satellite,
02103                                  const TypeID& type ) const
02104       throw( ValueNotFound )
02105    {
02106 
02107          // Look for the epoch (DayTime) data
02108       gnssDataMap gdMap( frontEpoch() );
02109 
02110          // Value to be returned
02111       double toReturn;
02112 
02113          // We'll need a flag
02114       bool found(false);
02115 
02116          // Look into the data structure
02117       for( gnssDataMap::const_iterator it = gdMap.begin();
02118            it != gdMap.end() && !found;
02119            ++it )
02120       {
02121 
02122          try
02123          {
02124             toReturn = (*it).second.getValue( source, satellite, type );
02125             found = true;
02126          }
02127          catch(...)
02128          {
02129             continue;
02130          }
02131 
02132       }
02133 
02134          // Check if value was found
02135       if( !found )
02136       {
02137          GPSTK_THROW(ValueNotFound("Value not found"));
02138       }
02139 
02140       return toReturn;
02141 
02142    }  // End of method 'gnssDataMap::getValue()'
02143 
02144 
02145 
02146       /* Inserts a data value (double) at the provided DayTime, SourceID,
02147        * SatID and TypeID, taking into account 'tolerance'.
02148        *
02149        * @param epoch         Epoch to be looked for.
02150        * @param source        Source to be looked for.
02151        * @param satellite     Satellite to be looked for.
02152        * @param type          Type of the new data.
02153        * @param value         Value to be inserted.
02154        */
02155    gnssDataMap& gnssDataMap::insertValue( const DayTime& epoch,
02156                                           const SourceID& source,
02157                                           const SatID& satellite,
02158                                           const TypeID& type,
02159                                           double value )
02160       throw( DayTimeNotFound, ValueNotFound )
02161    {
02162 
02163          // First check that structure isn't empty
02164       if( !( (*this).empty() ) )
02165       {
02166 
02167             // Find the position of the first element whose key is not less than
02168             // 'epoch-tolerance'
02169          gnssDataMap::iterator beginPos( (*this).lower_bound(epoch-tolerance) );
02170 
02171             // Find the position of the first element PAST
02172             // 'epoch+tolerance'
02173          gnssDataMap::iterator endPos( (*this).upper_bound(epoch+tolerance) );
02174 
02175             // Check if we found some match within current tolerance
02176          if( beginPos != endPos )
02177          {
02178 
02179                // We'll need a flag
02180             bool found(false);
02181 
02182                // Look into the range
02183             for( gnssDataMap::iterator it = beginPos;
02184                  it != endPos && !found;
02185                  ++it )
02186             {
02187 
02188                   // Look for the source
02189                sourceDataMap::iterator it2( (*it).second.find(source) );
02190 
02191                if( it2 != (*it).second.end() )
02192                {
02193 
02194                      // Look for the satellite
02195                   satTypeValueMap::iterator it3((*it2).second.find(satellite));
02196 
02197                   if( it3 != (*it2).second.end() )
02198                   {
02199 
02200                         // Insert type and value
02201                      (*it3).second[ type ] = value;
02202 
02203                         // Work is done, let's get out
02204                      found = true;
02205 
02206                   }  // End of 'if( it3 != (*it2).second.end() )'
02207 
02208                }  // End of 'if( it2 != (*it).second.end() )'
02209 
02210             }  // End of 'for( gnssDataMap::iterator it = beginPos ...'
02211 
02212                // Check if we found a proper place to insert value
02213             if( !found )
02214             {
02215                GPSTK_THROW( ValueNotFound("No proper place to insert value"));
02216             }
02217 
02218          }
02219          else
02220          {
02221                // No match found for DayTime with current tolerance
02222             GPSTK_THROW(DayTimeNotFound("Epoch not found within tolerance"));
02223          }
02224 
02225       }
02226       else
02227       {
02228          GPSTK_THROW(DayTimeNotFound("Data map is empty"));
02229       }
02230 
02231       return (*this);
02232 
02233    }  // End of method 'gnssDataMap::insertValue()'
02234 
02235 
02236 
02237       /* Inserts a data value (double) in the first epoch of the data
02238        * structure with the given SourceID, SatID and TypeID.
02239        *
02240        * @param source        Source to be looked for.
02241        * @param satellite     Satellite to be looked for.
02242        * @param type          Type of the new data.
02243        * @param value         Value to be inserted.
02244        */
02245    gnssDataMap& gnssDataMap::insertValue( const SourceID& source,
02246                                           const SatID& satellite,
02247                                           const TypeID& type,
02248                                           double value )
02249       throw( ValueNotFound )
02250    {
02251 
02252          // We'll need a flag
02253       bool found(false);
02254 
02255          // Look into the data structure
02256       for( gnssDataMap::iterator it = (*this).begin();
02257            it != (*this).end() && !found;
02258            ++it )
02259       {
02260 
02261             // Look for the source
02262          sourceDataMap::iterator it2( (*it).second.find(source) );
02263 
02264          if( it2 != (*it).second.end() )
02265          {
02266 
02267                // Look for the satellite
02268             satTypeValueMap::iterator it3( (*it2).second.find(satellite) );
02269 
02270             if( it3 != (*it2).second.end() )
02271             {
02272 
02273                   // Insert type and value
02274                (*it3).second[ type ] = value;
02275 
02276                   // Work is done, let's get out
02277                found = true;
02278 
02279             }  // End of 'if( it3 != (*it2).second.end() )'
02280 
02281          }  // End of 'if( it2 != (*it).second.end() )'
02282 
02283       }  // End of 'for( gnssDataMap::iterator it = (*this).begin(); ...'
02284 
02285          // Check if we found a proper place to insert value
02286       if( !found )
02287       {
02288          GPSTK_THROW( ValueNotFound("No proper place to insert value"));
02289       }
02290 
02291       return (*this);
02292 
02293    }  // End of method 'gnssDataMap::insertValue()'
02294 
02295 
02296 
02297       /* Get a set with all the SourceID's in this data structure.
02298        *
02299        * @warning If current 'gnssDataMap' is big, this could be a very
02300        * costly operation.
02301        */
02302    SourceIDSet gnssDataMap::getSourceIDSet( void ) const
02303    {
02304 
02305          // SourceID set to be returned
02306       SourceIDSet toReturn;
02307 
02308          // Iterate through all items in the gnssDataMap
02309       for( gnssDataMap::const_iterator it = (*this).begin();
02310            it != (*this).end();
02311            ++it )
02312       {
02313 
02314             // Then, iterate through corresponding 'sourceDataMap'
02315          for( sourceDataMap::const_iterator sdmIter = (*it).second.begin();
02316               sdmIter != (*it).second.end();
02317               ++sdmIter )
02318          {
02319 
02320                // Add current SourceID to 'toReturn'
02321             toReturn.insert( (*sdmIter).first );
02322 
02323          }  // End of 'for( sourceDataMap::const_iterator sdmIter = ...'
02324 
02325       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02326 
02327       return toReturn;
02328 
02329    }  // End of method 'gnssDataMap::getSourceIDSet()'
02330 
02331 
02332 
02333       /* Get a set with all the SatID's in this data structure.
02334        *
02335        * @warning If current 'gnssDataMap' is big, this could be a very
02336        * costly operation.
02337        */
02338    SatIDSet gnssDataMap::getSatIDSet( void ) const
02339    {
02340 
02341          // SatID set to be returned
02342       SatIDSet toReturn;
02343 
02344          // Iterate through all items in the gnssDataMap
02345       for( gnssDataMap::const_iterator it = (*this).begin();
02346            it != (*this).end();
02347            ++it )
02348       {
02349 
02350             // Then, iterate through corresponding 'sourceDataMap'
02351          for( sourceDataMap::const_iterator sdmIter = (*it).second.begin();
02352               sdmIter != (*it).second.end();
02353               ++sdmIter )
02354          {
02355 
02356                // Finally, iterate through corresponding 'satTypeValueMap'
02357             for( satTypeValueMap::const_iterator stvmIter =
02358                                                       (*sdmIter).second.begin();
02359                  stvmIter != (*sdmIter).second.end();
02360                  stvmIter++ )
02361             {
02362 
02363                   // Add current SatID to 'toReturn'
02364                toReturn.insert( (*stvmIter).first );
02365 
02366             }  // End of 'for( satTypeValueMap::const_iterator stvmIter = ...'
02367 
02368          }  // End of 'for( sourceDataMap::const_iterator sdmIter = ...'
02369 
02370       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02371 
02372       return toReturn;
02373 
02374    }  // End of method 'gnssDataMap::getSatIDSet()'
02375 
02376 
02377 
02378       // Convenience output method
02379    std::ostream& gnssDataMap::dump( std::ostream& s,
02380                                     int mode ) const
02381    {
02382 
02383          // Iterate through all items in the gnssDataMap
02384       for( gnssDataMap::const_iterator it = (*this).begin();
02385            it != (*this).end();
02386            ++it )
02387       {
02388 
02389             // Then, iterate through corresponding 'sourceDataMap'
02390          for( sourceDataMap::const_iterator sdmIter = (*it).second.begin();
02391               sdmIter != (*it).second.end();
02392               ++sdmIter )
02393          {
02394 
02395                // Finally, iterate through corresponding 'satTypeValueMap'
02396             for( satTypeValueMap::const_iterator stvmIter =
02397                                                       (*sdmIter).second.begin();
02398                  stvmIter != (*sdmIter).second.end();
02399                  stvmIter++ )
02400             {
02401 
02402                   // First, print year, Day-Of-Year and Seconds of Day
02403                s << (*it).first.year() << " "
02404                  << (*it).first.DOY() << " "
02405                  << (*it).first.DOYsecond() << " ";
02406 
02407                   // Second, print SourceID information
02408                s << (*sdmIter).first << " ";
02409 
02410                   // Third, print satellite (system and PRN)
02411                s << (*stvmIter).first << " ";
02412 
02413                   // Fourth, print type descriptions and numerical values
02414                for( typeValueMap::const_iterator itObs =
02415                                                    (*stvmIter).second.begin();
02416                     itObs != (*stvmIter).second.end();
02417                     itObs++ )
02418                {
02419 
02420                   s << (*itObs).first << " "
02421                     << (*itObs).second << " ";
02422 
02423                }  // End of 'for( typeValueMap::const_iterator itObs = ...'
02424 
02425                   // Add end-of-line
02426                s << endl;
02427 
02428             }  // End of 'for( satTypeValueMap::const_iterator stvmIter = ...'
02429 
02430          }  // End of 'for( sourceDataMap::const_iterator sdmIter = ...'
02431 
02432       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02433 
02434          // Let's return the 'std::ostream'
02435       return s;
02436 
02437    }  // End of method 'gnssDataMap::dump()'
02438 
02439 
02440 
02441       // Returns a gnssDataMap with only this source.
02442       // @param source Source to be extracted.
02443    gnssDataMap gnssDataMap::extractSourceID(const SourceID& source)
02444    {
02445       SourceIDSet sourceSet;
02446       sourceSet.insert(source);
02447 
02448       return extractSourceID(sourceSet);
02449    
02450    }  // End of method 'gnssDataMap::extractSourceID()'
02451 
02452 
02453 
02457    gnssDataMap gnssDataMap::extractSourceID(const SourceIDSet& sourceSet)
02458    {
02459       gnssDataMap dataMap;
02460 
02461       // Iterate through all items in the gnssDataMap
02462       for( gnssDataMap::const_iterator it = this->begin();
02463            it != this->end();
02464            ++it )
02465       {
02466          const DayTime& time(it->first);
02467          const sourceDataMap& sourceMap(it->second);
02468 
02469          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02470              itsrc != sourceMap.end();
02471              ++itsrc)
02472          {
02473             SourceIDSet::const_iterator itsrc2 = sourceSet.find(itsrc->first);
02474             if(itsrc2!=sourceSet.end())
02475             {
02476                gnssSatTypeValue gds;
02477                gds.header.epoch = time;
02478                gds.header.source = itsrc->first;
02479                gds.body = itsrc->second;
02480 
02481                dataMap.addGnssSatTypeValue(gds);
02482             }
02483 
02484          }  // loop in the sources
02485 
02486       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02487 
02488       return dataMap;
02489 
02490    }  // End of method 'gnssDataMap::extractSourceID()'
02491 
02492 
02493       // Modifies this object, keeping only this source.
02494       // @param source Source to be extracted.
02495    gnssDataMap& gnssDataMap::keepOnlySourceID(const SourceID& source)
02496    {
02497       (*this) = extractSourceID(source);
02498       return (*this);
02499    }
02500 
02501 
02502       // Modifies this object, keeping only these sources.
02503       // @param sourceSet Set(SourceIDSet) containing the sources 
02504       //                  to be extracted.
02505    gnssDataMap& gnssDataMap::keepOnlySourceID(const SourceIDSet& sourceSet)
02506    {
02507       (*this) = extractSourceID(sourceSet);
02508       return (*this);
02509    }
02510 
02511 
02512       // Modifies this object, removing this source.
02513       // @param source Source to be removed.
02514    gnssDataMap& gnssDataMap::removeSourceID(const SourceID& source)
02515    {
02516       SourceIDSet sourceSet;
02517       sourceSet.insert(source);
02518 
02519       return removeSourceID(sourceSet);
02520    }
02521 
02522 
02523       // Modifies this object, keeping only these sources.
02524       // @param sourceSet Set(SourceIDSet) containing the sources 
02525       //                  to be removed.
02526    gnssDataMap& gnssDataMap::removeSourceID(const SourceIDSet& sourceSet)
02527    {
02528       gnssDataMap dataMap;
02529 
02530       // Iterate through all items in the gnssDataMap
02531       for( gnssDataMap::const_iterator it = this->begin();
02532            it != this->end();
02533            ++it )
02534       {
02535          const DayTime& time(it->first);
02536          const sourceDataMap& sourceMap(it->second);
02537 
02538          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02539             itsrc != sourceMap.end();
02540             ++itsrc)
02541          {
02542             SourceIDSet::const_iterator itsrc2 = sourceSet.find(itsrc->first);
02543             if(itsrc2==sourceSet.end())
02544             {
02545                gnssSatTypeValue gds;
02546                gds.header.epoch = time;
02547                gds.header.source = itsrc->first;
02548                gds.body = itsrc->second;
02549 
02550                dataMap.addGnssSatTypeValue(gds);
02551             }
02552 
02553          }  // loop in the sources
02554 
02555       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02556       
02557       (*this) = dataMap;
02558 
02559       return (*this);
02560 
02561    }  // End of method 'gnssDataMap::removeSourceID()'
02562 
02563 
02564       // Returns a gnssDataMap with only this satellite.
02565       // @param sat Satellite to be extracted.
02566    gnssDataMap gnssDataMap::extractSatID(const SatID& sat)
02567    {
02568       SatIDSet satSet;
02569       satSet.insert(sat);
02570 
02571       return extractSatID(satSet);
02572    }
02573 
02574 
02575       // Returns a gnssDataMap with only these satellites.
02576       // @param satSet Set(SatIDSet) containing the satellite 
02577       //               to be extracted.
02578    gnssDataMap gnssDataMap::extractSatID(const SatIDSet& satSet)
02579    {
02580       gnssDataMap dataMap;
02581 
02582       // Iterate through all items in the gnssDataMap
02583       for( gnssDataMap::const_iterator it = this->begin();
02584            it != this->end();
02585            ++it )
02586       {
02587          const DayTime& time(it->first);
02588          const sourceDataMap& sourceMap(it->second);
02589 
02590          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02591              itsrc != sourceMap.end();
02592              ++itsrc)
02593          {
02594             gnssSatTypeValue gds;
02595             gds.header.epoch = time;
02596             gds.header.source = itsrc->first;
02597             gds.body = itsrc->second;
02598 
02599             gds.body.keepOnlySatID(satSet);
02600 
02601             dataMap.addGnssSatTypeValue(gds);
02602 
02603          }  // loop in the sources
02604 
02605       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02606 
02607       return dataMap;
02608 
02609    }  // End of method 'gnssDataMap::extractSatID()'
02610 
02611 
02612       // Modifies this object, keeping only this satellite.
02613       // @param sat Satellite to be extracted.
02614    gnssDataMap& gnssDataMap::keepOnlySatID(const SatID& sat)
02615    {
02616       (*this) = extractSatID(sat);
02617       return (*this);
02618    } 
02619 
02620 
02621       // Modifies this object, keeping only these satellites.
02622       // @param satSet Set(SatIDSet) containing the satellite 
02623       //                  to be extracted.
02624    gnssDataMap& gnssDataMap::keepOnlySatID(const SatIDSet& satSet)
02625    {
02626       (*this) = extractSatID(satSet);
02627       return (*this);
02628    }  
02629 
02630       // Modifies this object, removing this satellite.
02631       // @param sat Satellite to be removed.
02632    gnssDataMap& gnssDataMap::removeSatID(const SatID& sat)
02633    {
02634       SatIDSet satSet;
02635       satSet.insert(sat);
02636 
02637       return removeSatID(satSet);
02638    }
02639 
02640 
02641       // Modifies this object, keeping only these satellites.
02642       // @param satSet Set(SatIDSet) containing the satellites 
02643       //               to be removed.
02644    gnssDataMap& gnssDataMap::removeSatID(const SatIDSet& satSet)
02645    {
02646       gnssDataMap dataMap;
02647 
02648       // Iterate through all items in the gnssDataMap
02649       for( gnssDataMap::const_iterator it = this->begin();
02650            it != this->end();
02651            ++it )
02652       {
02653          const DayTime& time(it->first);
02654          const sourceDataMap& sourceMap(it->second);
02655 
02656          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02657              itsrc != sourceMap.end();
02658              ++itsrc)
02659          {
02660             gnssSatTypeValue gds;
02661             gds.header.epoch = time;
02662             gds.header.source = itsrc->first;
02663             gds.body = itsrc->second;
02664 
02665             gds.body.removeSatID(satSet);
02666 
02667             dataMap.addGnssSatTypeValue(gds);
02668 
02669          }  // loop in the sources
02670 
02671       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02672 
02673       (*this) = dataMap;
02674 
02675       return (*this);
02676 
02677    }  // End of method 'gnssDataMap::removeSatID()'
02678 
02679 
02680 
02683    gnssDataMap gnssDataMap::extractTypeID(const TypeID& type)
02684    {
02685       TypeIDSet typeSet;
02686       typeSet.insert(type);
02687 
02688       return extractTypeID(typeSet);
02689    }
02690 
02691 
02692       // Returns a gnssDataMap with only these satellites.
02693       // @param typeSet Set(TypeIDSet) containing the types 
02694       //               to be extracted.
02695    gnssDataMap gnssDataMap::extractTypeID(const TypeIDSet& typeSet)
02696    {
02697       gnssDataMap dataMap;
02698 
02699       // Iterate through all items in the gnssDataMap
02700       for( gnssDataMap::const_iterator it = this->begin();
02701            it != this->end();
02702            ++it )
02703       {
02704          const DayTime& time(it->first);
02705          const sourceDataMap& sourceMap(it->second);
02706 
02707          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02708              itsrc != sourceMap.end();
02709              ++itsrc)
02710          {
02711             gnssSatTypeValue gds;
02712             gds.header.epoch = time;
02713             gds.header.source = itsrc->first;
02714             gds.body = itsrc->second;
02715 
02716             gds.body.keepOnlyTypeID(typeSet);
02717 
02718             dataMap.addGnssSatTypeValue(gds);
02719 
02720          }  // loop in the sources
02721 
02722       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02723 
02724       return dataMap;
02725    }
02726 
02727 
02728       // Modifies this object, keeping only this type.
02729       // @param type Type to be extracted.
02730    gnssDataMap& gnssDataMap::keepOnlyTypeID(const TypeID& type)
02731    {
02732       (*this) = extractTypeID(type);
02733       return (*this);
02734    }
02735 
02736 
02737       // Modifies this object, keeping only these types.
02738       // @param typeSet Set(TypeIDSet) containing the type 
02739       //                  to be extracted.
02740    gnssDataMap& gnssDataMap::keepOnlyTypeID(const TypeIDSet& typeSet)
02741    {
02742       (*this) = extractTypeID(typeSet);
02743       return (*this);
02744    }
02745 
02746 
02747       // Modifies this object, removing this type.
02748       // @param type Type to be removed.
02749    gnssDataMap& gnssDataMap::removeTypeID(const TypeID& type)
02750    {
02751       TypeIDSet typeSet;
02752       typeSet.insert(type);
02753 
02754       return removeTypeID(typeSet);
02755    }
02756 
02757 
02758       // Modifies this object, keeping only these types.
02759       // @param typeSet Set(TypeIDSet) containing the types 
02760       //               to be removed.
02761    gnssDataMap& gnssDataMap::removeTypeID(const TypeIDSet& typeSet)
02762    {
02763       gnssDataMap dataMap;
02764 
02765       // Iterate through all items in the gnssDataMap
02766       for( gnssDataMap::const_iterator it = this->begin();
02767            it != this->end();
02768            ++it )
02769       {
02770          const DayTime& time(it->first);
02771          const sourceDataMap& sourceMap(it->second);
02772 
02773          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02774              itsrc != sourceMap.end();
02775              ++itsrc)
02776          {
02777             gnssSatTypeValue gds;
02778             gds.header.epoch = time;
02779             gds.header.source = itsrc->first;
02780             gds.body = itsrc->second;
02781 
02782             gds.body.removeTypeID(typeSet);
02783 
02784             dataMap.addGnssSatTypeValue(gds);
02785 
02786          }  // loop in the sources
02787 
02788       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02789 
02790       (*this) = dataMap;
02791 
02792       return (*this);
02793 
02794    }  // End of method 'gnssDataMap::removeTypeID()'
02795 
02796 
02797       /* Edit the dataset, removing data outside the indicated time
02798        *  interval.
02799        *
02800        * @param[in] tmin defines the beginning of the time interval
02801        * @param[in] tmax defines the end of the time interval
02802        */
02803    gnssDataMap& gnssDataMap::edit(DayTime tmin, DayTime tmax )
02804    {
02805       gnssDataMap dataMap;
02806 
02807       while(!this->empty())
02808       {
02809          gnssDataMap gds = this->frontEpoch();
02810 
02811          DayTime time(gds.begin()->first);
02812          if( (time>=tmin) && (time<=tmax) ) dataMap.addGnssDataMap(gds);
02813 
02814          this->pop_front_epoch();
02815       }
02816 
02817       (*this) = dataMap;
02818 
02819       return (*this);
02820    }
02821 
02822       // Load data from a rinex observation file
02823    void gnssDataMap::loadObsFile(std::string obsFile)
02824    {
02825       try
02826       {
02827          RinexObsStream rin(obsFile);
02828          rin.exceptions(ios::failbit);
02829 
02830          gnssRinex gRin;
02831          while( rin >> gRin )
02832          {
02833             this->addGnssRinex(gRin);
02834          }
02835          
02836          rin.close();
02837       }
02838       catch(...)
02839       {
02840          Exception e("Failed to load obs file '"+obsFile+"'.");
02841          GPSTK_THROW(e);
02842       }
02843 
02844    }  // End of method 'gnssDataMap::loadObsFile()'
02845 
02846 
02848 
02849 
02850 
02851       // Convenience output method for structure satTypeValueMap
02852    std::ostream& satTypeValueMap::dump( std::ostream& s,
02853                                         int mode ) const
02854    {
02855 
02856       for( satTypeValueMap::const_iterator it = (*this).begin();
02857            it!= (*this).end();
02858            it++ )
02859       {
02860 
02861             // First, print satellite (system and PRN)
02862          s << (*it).first << " ";
02863 
02864          for( typeValueMap::const_iterator itObs = (*it).second.begin();
02865               itObs != (*it).second.end();
02866               itObs++ )
02867          {
02868 
02869             if (mode==1)
02870             {
02871                s << (*itObs).first << " ";
02872             }
02873 
02874             s << (*itObs).second << " ";
02875 
02876          }  // End of 'for( typeValueMap::const_iterator itObs = ...'
02877 
02878          s << endl;
02879 
02880       }  // End of 'for( satTypeValueMap::const_iterator it = ...'
02881 
02882          // Let's return the 'std::ostream'
02883       return s;
02884 
02885    }  // End of method 'satTypeValueMap::dump()'
02886 
02887 
02888 
02889       // stream output for satTypeValueMap
02890    std::ostream& operator<<( std::ostream& s,
02891                              const satTypeValueMap& stvMap )
02892    {
02893 
02894       stvMap.dump(s);
02895       return s;
02896 
02897    }  // End of 'operator<<'
02898 
02899 
02900 
02901       // stream output for gnssDataMap
02902    std::ostream& operator<<( std::ostream& s,
02903                              const gnssDataMap& gdsMap)
02904    {
02905 
02906       gdsMap.dump(s);
02907       return s;
02908 
02909    }  // End of 'operator<<'
02910 
02911 
02912 
02913       // Input for gnssSatTypeValue from RinexObsHeader
02914    gnssSatTypeValue& operator>>( const RinexObsHeader& roh,
02915                                  gnssSatTypeValue& f )
02916    {
02917 
02918          // First, select the right system the data came from
02919       f.header.source.type = SatIDsystem2SourceIDtype(roh.system);
02920 
02921          // Set the proper name for the receiver
02922       f.header.source.sourceName = roh.markerName;
02923 
02924       return f;
02925 
02926    }  // End of 'operator>>'
02927 
02928 
02929 
02930       // Input for gnssRinex from RinexObsHeader
02931    gnssRinex& operator>>( const RinexObsHeader& roh,
02932                           gnssRinex& f )
02933    {
02934 
02935          // First, select the right system the data came from
02936       f.header.source.type = SatIDsystem2SourceIDtype(roh.system);
02937 
02938          // Set the proper name for the receiver
02939       f.header.source.sourceName = roh.markerName;
02940 
02941          // Set the proper antenna type for the receiver
02942       f.header.antennaType = roh.antType;
02943 
02944          // Set the proper antenna position
02945       f.header.antennaPosition = roh.antennaPosition;
02946 
02947       return f;
02948 
02949    }  // End of 'operator>>'
02950 
02951 
02952 
02953       // Input for gnssSatTypeValue from RinexObsData
02954    gnssSatTypeValue& operator>>( const RinexObsData& rod,
02955                                  gnssSatTypeValue& f )
02956    {
02957 
02958          // Fill header epoch with the proper value
02959       f.header.epoch = rod.time;
02960 
02961          // Extract the observations map and store it in the body
02962       f.body = FillsatTypeValueMapwithRinexObsData(rod);
02963 
02964       return f;
02965 
02966    }  // End of 'operator>>'
02967 
02968 
02969 
02970       // Input for gnssRinex from RinexObsData
02971    gnssRinex& operator>>( const RinexObsData& rod,
02972                           gnssRinex& f )
02973    {
02974 
02975          // Fill header epoch with the proper value
02976       f.header.epoch = rod.time;
02977 
02978          // Fill header epoch with the proper value
02979       f.header.epochFlag = rod.epochFlag;
02980 
02981          // Extract the observations map and store it in the body
02982       f.body = FillsatTypeValueMapwithRinexObsData(rod);
02983 
02984       return f;
02985 
02986    }  // End of 'operator>>'
02987 
02988 
02989 
02990       // Stream input for gnssSatTypeValue
02991    std::istream& operator>>( std::istream& i,
02992                              gnssSatTypeValue& f )
02993       throw(FFStreamError, gpstk::StringUtils::StringException)
02994    {
02995 
02996       FFStream* ffs = dynamic_cast<FFStream*>(&i);
02997       if(ffs)
02998       {
02999          try
03000          {
03001             RinexObsStream& strm = dynamic_cast<RinexObsStream&>(*ffs);
03002 
03003                // If the header hasn't been read, read it...
03004             if(!strm.headerRead) strm >> strm.header;
03005 
03006                // Clear out this object
03007             RinexObsHeader& hdr = strm.header;
03008             hdr >> f;
03009 
03010             RinexObsData rod;
03011             strm >> rod;
03012 
03013             f.header.epoch = rod.time;
03014             
03015             f.body = FillsatTypeValueMapwithRinexObsData(rod);
03016 
03017             return i;
03018 
03019          }  // End of "try" block
03026          // EOF - do nothing - eof causes fail() to be set which
03027          // is handled by std::fstream
03028          catch (EndOfFile& e)
03029          {
03030             return i;
03031          }
03032          catch (...)
03033          {
03034             return i;
03035          }
03036 
03037       }  // End of block: "if(ffs) ..."
03038       else
03039       {
03040          FFStreamError e("operator<< stream argument must be an FFStream");
03041          GPSTK_THROW(e);
03042       }
03043 
03044    }  // End of stream input for gnssSatTypeValue
03045 
03046 
03047 
03048       // Stream input for gnssRinex
03049    std::istream& operator>>( std::istream& i,
03050                              gnssRinex& f )
03051       throw(FFStreamError, gpstk::StringUtils::StringException)
03052    {
03053 
03054       FFStream* ffs = dynamic_cast<FFStream*>(&i);
03055       if(ffs)
03056       {
03057          try
03058          {
03059             RinexObsStream& strm = dynamic_cast<RinexObsStream&>(*ffs);
03060 
03061                // If the header hasn't been read, read it...
03062             if(!strm.headerRead) strm >> strm.header;
03063 
03064                // Clear out this object
03065             RinexObsHeader& hdr = strm.header;
03066             hdr >> f;
03067             
03068             RinexObsData rod;
03069             strm >> rod;
03070             
03071             f.header.epochFlag = rod.epochFlag;
03072             f.header.epoch = rod.time;
03073 
03074             f.body = FillsatTypeValueMapwithRinexObsData(rod);
03075 
03076             return i;
03077          }  // End of "try" block
03084          // EOF - do nothing - eof causes fail() to be set which
03085          // is handled by std::fstream
03086          catch (EndOfFile& e)
03087          {
03088             return i;
03089          }
03090          catch (...)
03091          {
03092             return i;
03093          }
03094 
03095       }  // End of block: "if (ffs)..."
03096       else
03097       {
03098          FFStreamError e("operator<< stream argument must be an FFStream");
03099          GPSTK_THROW(e);
03100       }
03101 
03102    }  // End of stream input for gnssRinex
03103 
03104 
03105    // Stream output for gnssRinex
03106    std::ostream& operator<<( std::ostream& s,
03107            gnssRinex& f )
03108            throw(FFStreamError, gpstk::StringUtils::StringException)
03109    {
03110       FFStream* ffs = dynamic_cast<FFStream*>(&s);
03111       if(ffs)
03112       {
03113          try
03114          {
03115             RinexObsStream& strm = dynamic_cast<RinexObsStream&>(*ffs);
03116 
03117             // Clear out this object
03118             RinexObsHeader& hdr = strm.header;
03119             
03120             RinexObsData rod;
03121             
03122             rod.time = f.header.epoch;
03123             rod.epochFlag = f.header.epochFlag; 
03124             rod.numSvs = f.numSats();
03125             rod.clockOffset = 0.0;
03126             rod.auxHeader = hdr;
03127                         
03128             SatIDSet satSet = f.getSatID();
03129             for(SatIDSet::iterator itSat = satSet.begin();
03130                itSat != satSet.end();
03131                ++itSat)
03132             {
03133                vector<RinexObsHeader::RinexObsType>::iterator obsTypeItr = 
03134                   hdr.obsTypeList.begin();
03135 
03136                while (obsTypeItr != strm.header.obsTypeList.end())
03137                {
03138                   TypeID type( RinexType2TypeID( *obsTypeItr ) );
03139                   
03140                   RinexObsData::RinexDatum data;
03141                   data.data = f.body[*itSat][type];
03142                   data.ssi = 0;
03143                   data.lli = 0;
03144                   
03145                   if( (type == TypeID::P1) || (type == TypeID::L1) )
03146                   {
03147                      if(type == TypeID::L1)
03148                      {
03149                         data.data /= L1_WAVELENGTH;
03150                         data.ssi = f.body[*itSat][TypeID::SSI1];
03151                      }
03152  
03153                      data.lli = f.body[*itSat][TypeID::LLI1];
03154                   }
03155 
03156                   if( (type == TypeID::P2) || (type == TypeID::L2))
03157                   {
03158                      if(type == TypeID::L2)
03159                      {
03160                         data.data /= L2_WAVELENGTH;
03161                         data.ssi = f.body[*itSat][TypeID::SSI2];
03162                      }
03163 
03164                      data.lli = f.body[*itSat][TypeID::LLI2];
03165                   }
03166 
03167                   if( (type == TypeID::C5) || (type == TypeID::L5))
03168                   {
03169                      if(type == TypeID::L5)
03170                      {
03171                         data.data /= L5_WAVELENGTH;
03172                         data.ssi = f.body[*itSat][TypeID::SSI5];
03173                      }
03174 
03175                      data.lli = f.body[*itSat][TypeID::LLI5];
03176                   }
03177 
03178                   if( (type == TypeID::C6) || (type == TypeID::L6) )
03179                   {
03180                      if(type == TypeID::L6)
03181                      {
03182                         data.data /= L6_WAVELENGTH;
03183                         data.ssi = f.body[*itSat][TypeID::SSI6];
03184                      }
03185 
03186                      data.lli = f.body[*itSat][TypeID::LLI6];
03187                   }
03188 
03189                   if( (type == TypeID::C7) || (type == TypeID::L7) )
03190                   {
03191                      if(type == TypeID::L7)
03192                      {
03193                         data.data /= L7_WAVELENGTH;
03194                         data.ssi = f.body[*itSat][TypeID::SSI7];
03195                      }
03196 
03197                      data.lli = f.body[*itSat][TypeID::LLI7];
03198                   }
03199 
03200                   if( (type == TypeID::C8) || (type == TypeID::L8))
03201                   {
03202                      if(type == TypeID::L8)
03203                      {
03204                         data.data /= L8_WAVELENGTH;
03205                         data.ssi = f.body[*itSat][TypeID::SSI8];
03206                      }
03207 
03208                      data.lli = f.body[*itSat][TypeID::LLI8];
03209                   }
03210 
03211                   if( (type == TypeID::D1) || 
03212                       (type == TypeID::S1) ||
03213                       (type == TypeID::C1) )
03214                   {
03215                      data.lli = f.body[*itSat][TypeID::LLI1];
03216                   }
03217 
03218                   if( (type == TypeID::D2) || (type == TypeID::S2) )
03219                   {
03220                      data.lli = f.body[*itSat][TypeID::LLI2];
03221                   }
03222 
03223 
03224                   rod.obs[*itSat][*obsTypeItr] = data;
03225                
03226                   obsTypeItr++;
03227                }
03228             }
03229 
03230             strm << rod;
03231 
03232             return s;
03233 
03234          }  // End of "try" block
03241          // EOF - do nothing - eof causes fail() to be set which
03242          // is handled by std::fstream
03243          catch (EndOfFile& e)
03244          {
03245             return s;
03246          }
03247          catch (...)
03248          {
03249             return s;
03250          }
03251 
03252       }  // End of block: "if (ffs)..."
03253       else
03254       {
03255          FFStreamError e("operator<< stream argument must be an FFStream");
03256          GPSTK_THROW(e);
03257       }
03258 
03259    }   // End of stream input for gnssRinex
03260 
03261 
03262       // Convenience function to convert from SatID system to SourceID type.
03263       // @param sid Satellite ID.
03264    SourceID::SourceType SatIDsystem2SourceIDtype(const SatID& sid)
03265    {
03266 
03267          // Select the right system the data came from
03268       switch(sid.system)
03269       {
03270          case SatID::systemGPS:
03271             return SourceID::GPS;
03272             break;
03273          case SatID::systemGalileo:
03274             return SourceID::Galileo;
03275             break;
03276          case SatID::systemGlonass:
03277             return SourceID::Glonass;
03278             break;
03279          case SatID::systemGeosync:
03280             return SourceID::Geosync;
03281             break;
03282          case SatID::systemLEO:
03283             return SourceID::LEO;
03284             break;
03285          case SatID::systemTransit:
03286             return SourceID::Transit;
03287             break;
03288          case SatID::systemMixed:
03289             return SourceID::Mixed;
03290             break;
03291          default:
03292             return SourceID::Unknown;
03293       }
03294 
03295    } // End SatIDsystem2SourceIDtype(const SatID& sid)
03296 
03297 
03298 
03299       // Convenience function to fill a typeValueMap with data
03300       // from RinexObsTypeMap.
03301    typeValueMap FilltypeValueMapwithRinexObsTypeMap(
03302                                  const RinexObsData::RinexObsTypeMap& otmap )
03303    {
03304 
03305          // RinexObsTypeMap is a map from RinexObsType to RinexDatum:
03306          //   std::map<RinexObsHeader::RinexObsType, RinexDatum>
03307 
03308          // We will need a typeValueMap
03309       typeValueMap tvMap;
03310 
03311          // Let's visit the RinexObsTypeMap (RinexObsType -> RinexDatum)
03312       for( RinexObsData::RinexObsTypeMap::const_iterator itObs = otmap.begin();
03313            itObs!= otmap.end();
03314            ++itObs )
03315       {
03316 
03317          TypeID type( RinexType2TypeID( (*itObs).first ) );
03318          tvMap[ type ] = (*itObs).second.data;
03319 
03320             // If this is a phase measurement, let's store corresponding
03321             // LLI and SSI for this SV and frequency
03322             // Also, the values for phase measurements will be given in meters
03323          if( type == TypeID::L1 )
03324          {
03325             tvMap[TypeID::LLI1] = (*itObs).second.lli;
03326             tvMap[TypeID::SSI1] = (*itObs).second.ssi;
03327             tvMap[ type ] = tvMap[ type ] * L1_WAVELENGTH;
03328          }
03329          if( type == TypeID::L2 )
03330          {
03331             tvMap[TypeID::LLI2] = (*itObs).second.lli;
03332             tvMap[TypeID::SSI2] = (*itObs).second.ssi;
03333             tvMap[ type ] = tvMap[ type ] * L2_WAVELENGTH;
03334          }
03335          if( type == TypeID::L5 )
03336          {
03337             tvMap[TypeID::LLI5] = (*itObs).second.lli;
03338             tvMap[TypeID::SSI5] = (*itObs).second.ssi;
03339             tvMap[ type ] = tvMap[ type ] * L5_WAVELENGTH;
03340          }
03341          if( type == TypeID::L6 )
03342          {
03343             tvMap[TypeID::LLI6] = (*itObs).second.lli;
03344             tvMap[TypeID::SSI6] = (*itObs).second.ssi;
03345             tvMap[ type ] = tvMap[ type ] * L6_WAVELENGTH;
03346          }
03347          if( type == TypeID::L7 )
03348          {
03349             tvMap[TypeID::LLI7] = (*itObs).second.lli;
03350             tvMap[TypeID::SSI7] = (*itObs).second.ssi;
03351             tvMap[ type ] = tvMap[ type ] * L7_WAVELENGTH;
03352          }
03353          if( type == TypeID::L8 )
03354          {
03355             tvMap[TypeID::LLI8] = (*itObs).second.lli;
03356             tvMap[TypeID::SSI8] = (*itObs).second.ssi;
03357             tvMap[ type ] = tvMap[ type ] * L8_WAVELENGTH;
03358          }
03359 
03360       }  // End of "for( itObs = otmap.begin(); ..."
03361 
03362       return tvMap;
03363 
03364    } // End FilltypeValueMapwithRinexObsTypeMap()
03365 
03366 
03367 
03368       // Convenience function to fill a satTypeValueMap with data
03369       // from RinexObsData.
03370       // @param rod RinexObsData holding the data.
03371    satTypeValueMap FillsatTypeValueMapwithRinexObsData(const RinexObsData& rod)
03372    {
03373 
03374          // We need to declare a satTypeValueMap
03375       satTypeValueMap theMap;
03376 
03377          // Let's define the "it" iterator to visit the observations PRN map
03378          // RinexSatMap is a map from SatID to RinexObsTypeMap:
03379          //      std::map<SatID, RinexObsTypeMap>
03380       for( RinexObsData::RinexSatMap::const_iterator it = rod.obs.begin();
03381            it!= rod.obs.end();
03382            ++it )
03383       {
03384             // RinexObsTypeMap is a map from RinexObsType to RinexDatum:
03385             //   std::map<RinexObsHeader::RinexObsType, RinexDatum>
03386             // The "second" field of a RinexSatMap (it) is a
03387             // RinexObsTypeMap (otmap)
03388          RinexObsData::RinexObsTypeMap otmap = (*it).second;
03389 
03390          theMap[(*it).first] = FilltypeValueMapwithRinexObsTypeMap(otmap);
03391 
03392       }
03393 
03394       return theMap;
03395 
03396    } // End FillsatTypeValueMapwithRinexObsData(const RinexObsData& rod)
03397 
03398 
03399 
03400       /* This function constructs a DayTime object from the given parameters.
03401        *
03402        * @param line    the encoded time string found in the RINEX record.
03403        * @param hdr     the RINEX Observation Header object for the current
03404        *                RINEX file.
03405        */
03406    DayTime parseTime( const std::string& line,
03407                       const RinexObsHeader& hdr )
03408       throw(FFStreamError)
03409    {
03410 
03411       try
03412       {
03413             // check if the spaces are in the right place - an easy
03414             // way to check if there's corruption in the file
03415          if ( (line[0] != ' ')  ||
03416               (line[3] != ' ')  ||
03417               (line[6] != ' ')  ||
03418               (line[9] != ' ')  ||
03419               (line[12] != ' ') ||
03420               (line[15] != ' ') )
03421          {
03422             FFStreamError e("Invalid time format");
03423             GPSTK_THROW(e);
03424          }
03425 
03426             // if there's no time, just return a bad time
03427          if (line.substr(0,26) == std::string(26, ' '))
03428          {
03429             return DayTime(DayTime::BEGINNING_OF_TIME);
03430          }
03431 
03432          int year, month, day, hour, min;
03433          double sec;
03434          int yy = hdr.firstObs.year()/100;
03435          yy *= 100;
03436 
03437          year  = StringUtils::asInt(   line.substr(1,  2 ));
03438          month = StringUtils::asInt(   line.substr(4,  2 ));
03439          day   = StringUtils::asInt(   line.substr(7,  2 ));
03440          hour  = StringUtils::asInt(   line.substr(10, 2 ));
03441          min   = StringUtils::asInt(   line.substr(13, 2 ));
03442          sec   = StringUtils::asDouble(line.substr(15, 11));
03443 
03444             // Real Rinex has epochs 'yy mm dd hr 59 60.0'
03445             // surprisingly often....
03446          double ds=0;
03447          if(sec >= 60.) { ds=sec; sec=0.0; }
03448          DayTime rv(yy+year, month, day, hour, min, sec);
03449          if(ds != 0) rv += ds;
03450 
03451          return rv;
03452       }
03453          // string exceptions for substr are caught here
03454       catch (std::exception &e)
03455       {
03456          FFStreamError err("std::exception: " + std::string(e.what()));
03457          GPSTK_THROW(err);
03458       }
03459       catch (gpstk::Exception& e)
03460       {
03461          std::string text;
03462          for(int i=0; i<(int)e.getTextCount(); i++) text += e.getText(i);
03463          FFStreamError err("gpstk::Exception in parseTime(): " + text);
03464          GPSTK_THROW(err);
03465       }
03466 
03467    }  // End of parseTime()
03468 
03469 
03470 }  // End of namespace gpstk

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