DataStructures.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: DataStructures.cpp 3319 2012-09-19 16:58:10Z prestonherrmann $"
00002 
00008 //============================================================================
00009 //
00010 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00025 //
00026 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008, 2009, 2011
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 CommonTime, 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 CommonTime, 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 CommonTime& 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 'CommonTime' of the first element
01804          CommonTime 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 'CommonTime' of the first element
01838          CommonTime 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 'CommonTime' of the last element
01923          CommonTime 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 'CommonTime' of the last element
01957          CommonTime 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        * CommonTime, taking into account 'tolerance'.
01984        *
01985        * @param epoch         Epoch to be looked for.
01986        */
01987    gnssDataMap gnssDataMap::getDataFromEpoch( const CommonTime& epoch ) const
01988       throw( CommonTimeNotFound )
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(CommonTimeNotFound("Data map is empty"));
02020       }
02021 
02022          // Check if 'toReturn' is empty
02023       if( toReturn.empty() )
02024       {
02025          GPSTK_THROW(CommonTimeNotFound("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 CommonTime,
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 CommonTime& epoch,
02046                                  const SourceID& source,
02047                                  const SatID& satellite,
02048                                  const TypeID& type ) const
02049       throw( CommonTimeNotFound, ValueNotFound )
02050    {
02051 
02052          // Look for the epoch (CommonTime) 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 (CommonTime) 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 CommonTime, 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 CommonTime& epoch,
02156                                           const SourceID& source,
02157                                           const SatID& satellite,
02158                                           const TypeID& type,
02159                                           double value )
02160       throw( CommonTimeNotFound, 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 CommonTime with current tolerance
02222             GPSTK_THROW(CommonTimeNotFound("Epoch not found within tolerance"));
02223          }
02224 
02225       }
02226       else
02227       {
02228          GPSTK_THROW(CommonTimeNotFound("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                   // Declare a 'YDSTime' object to ease printing
02403                YDSTime time( (*it).first );
02404                   // First, print year, Day-Of-Year and Seconds of Day
02405                s << time.year << " "
02406                  << time.doy << " "
02407                  << time.sod << " ";
02408 
02409                   // Second, print SourceID information
02410                s << (*sdmIter).first << " ";
02411 
02412                   // Third, print satellite (system and PRN)
02413                s << (*stvmIter).first << " ";
02414 
02415                   // Fourth, print type descriptions and numerical values
02416                for( typeValueMap::const_iterator itObs =
02417                                                    (*stvmIter).second.begin();
02418                     itObs != (*stvmIter).second.end();
02419                     itObs++ )
02420                {
02421 
02422                   s << (*itObs).first << " "
02423                     << (*itObs).second << " ";
02424 
02425                }  // End of 'for( typeValueMap::const_iterator itObs = ...'
02426 
02427                   // Add end-of-line
02428                s << endl;
02429 
02430             }  // End of 'for( satTypeValueMap::const_iterator stvmIter = ...'
02431 
02432          }  // End of 'for( sourceDataMap::const_iterator sdmIter = ...'
02433 
02434       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02435 
02436          // Let's return the 'std::ostream'
02437       return s;
02438 
02439    }  // End of method 'gnssDataMap::dump()'
02440 
02441 
02442 
02443       // Returns a gnssDataMap with only this source.
02444       // @param source Source to be extracted.
02445    gnssDataMap gnssDataMap::extractSourceID(const SourceID& source)
02446    {
02447       SourceIDSet sourceSet;
02448       sourceSet.insert(source);
02449 
02450       return extractSourceID(sourceSet);
02451    
02452    }  // End of method 'gnssDataMap::extractSourceID()'
02453 
02454 
02455 
02459    gnssDataMap gnssDataMap::extractSourceID(const SourceIDSet& sourceSet)
02460    {
02461       gnssDataMap dataMap;
02462 
02463       // Iterate through all items in the gnssDataMap
02464       for( gnssDataMap::const_iterator it = this->begin();
02465            it != this->end();
02466            ++it )
02467       {
02468          const CommonTime& time(it->first);
02469          const sourceDataMap& sourceMap(it->second);
02470 
02471          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02472              itsrc != sourceMap.end();
02473              ++itsrc)
02474          {
02475             SourceIDSet::const_iterator itsrc2 = sourceSet.find(itsrc->first);
02476             if(itsrc2!=sourceSet.end())
02477             {
02478                gnssSatTypeValue gds;
02479                gds.header.epoch = time;
02480                gds.header.source = itsrc->first;
02481                gds.body = itsrc->second;
02482 
02483                dataMap.addGnssSatTypeValue(gds);
02484             }
02485 
02486          }  // loop in the sources
02487 
02488       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02489 
02490       return dataMap;
02491 
02492    }  // End of method 'gnssDataMap::extractSourceID()'
02493 
02494 
02495       // Modifies this object, keeping only this source.
02496       // @param source Source to be extracted.
02497    gnssDataMap& gnssDataMap::keepOnlySourceID(const SourceID& source)
02498    {
02499       (*this) = extractSourceID(source);
02500       return (*this);
02501    }
02502 
02503 
02504       // Modifies this object, keeping only these sources.
02505       // @param sourceSet Set(SourceIDSet) containing the sources 
02506       //                  to be extracted.
02507    gnssDataMap& gnssDataMap::keepOnlySourceID(const SourceIDSet& sourceSet)
02508    {
02509       (*this) = extractSourceID(sourceSet);
02510       return (*this);
02511    }
02512 
02513 
02514       // Modifies this object, removing this source.
02515       // @param source Source to be removed.
02516    gnssDataMap& gnssDataMap::removeSourceID(const SourceID& source)
02517    {
02518       SourceIDSet sourceSet;
02519       sourceSet.insert(source);
02520 
02521       return removeSourceID(sourceSet);
02522    }
02523 
02524 
02525       // Modifies this object, keeping only these sources.
02526       // @param sourceSet Set(SourceIDSet) containing the sources 
02527       //                  to be removed.
02528    gnssDataMap& gnssDataMap::removeSourceID(const SourceIDSet& sourceSet)
02529    {
02530       gnssDataMap dataMap;
02531 
02532       // Iterate through all items in the gnssDataMap
02533       for( gnssDataMap::const_iterator it = this->begin();
02534            it != this->end();
02535            ++it )
02536       {
02537          const CommonTime& time(it->first);
02538          const sourceDataMap& sourceMap(it->second);
02539 
02540          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02541             itsrc != sourceMap.end();
02542             ++itsrc)
02543          {
02544             SourceIDSet::const_iterator itsrc2 = sourceSet.find(itsrc->first);
02545             if(itsrc2==sourceSet.end())
02546             {
02547                gnssSatTypeValue gds;
02548                gds.header.epoch = time;
02549                gds.header.source = itsrc->first;
02550                gds.body = itsrc->second;
02551 
02552                dataMap.addGnssSatTypeValue(gds);
02553             }
02554 
02555          }  // loop in the sources
02556 
02557       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02558       
02559       (*this) = dataMap;
02560 
02561       return (*this);
02562 
02563    }  // End of method 'gnssDataMap::removeSourceID()'
02564 
02565 
02566       // Returns a gnssDataMap with only this satellite.
02567       // @param sat Satellite to be extracted.
02568    gnssDataMap gnssDataMap::extractSatID(const SatID& sat)
02569    {
02570       SatIDSet satSet;
02571       satSet.insert(sat);
02572 
02573       return extractSatID(satSet);
02574    }
02575 
02576 
02577       // Returns a gnssDataMap with only these satellites.
02578       // @param satSet Set(SatIDSet) containing the satellite 
02579       //               to be extracted.
02580    gnssDataMap gnssDataMap::extractSatID(const SatIDSet& satSet)
02581    {
02582       gnssDataMap dataMap;
02583 
02584       // Iterate through all items in the gnssDataMap
02585       for( gnssDataMap::const_iterator it = this->begin();
02586            it != this->end();
02587            ++it )
02588       {
02589          const CommonTime& time(it->first);
02590          const sourceDataMap& sourceMap(it->second);
02591 
02592          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02593              itsrc != sourceMap.end();
02594              ++itsrc)
02595          {
02596             gnssSatTypeValue gds;
02597             gds.header.epoch = time;
02598             gds.header.source = itsrc->first;
02599             gds.body = itsrc->second;
02600 
02601             gds.body.keepOnlySatID(satSet);
02602 
02603             dataMap.addGnssSatTypeValue(gds);
02604 
02605          }  // loop in the sources
02606 
02607       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02608 
02609       return dataMap;
02610 
02611    }  // End of method 'gnssDataMap::extractSatID()'
02612 
02613 
02614       // Modifies this object, keeping only this satellite.
02615       // @param sat Satellite to be extracted.
02616    gnssDataMap& gnssDataMap::keepOnlySatID(const SatID& sat)
02617    {
02618       (*this) = extractSatID(sat);
02619       return (*this);
02620    } 
02621 
02622 
02623       // Modifies this object, keeping only these satellites.
02624       // @param satSet Set(SatIDSet) containing the satellite 
02625       //                  to be extracted.
02626    gnssDataMap& gnssDataMap::keepOnlySatID(const SatIDSet& satSet)
02627    {
02628       (*this) = extractSatID(satSet);
02629       return (*this);
02630    }  
02631 
02632       // Modifies this object, removing this satellite.
02633       // @param sat Satellite to be removed.
02634    gnssDataMap& gnssDataMap::removeSatID(const SatID& sat)
02635    {
02636       SatIDSet satSet;
02637       satSet.insert(sat);
02638 
02639       return removeSatID(satSet);
02640    }
02641 
02642 
02643       // Modifies this object, keeping only these satellites.
02644       // @param satSet Set(SatIDSet) containing the satellites 
02645       //               to be removed.
02646    gnssDataMap& gnssDataMap::removeSatID(const SatIDSet& satSet)
02647    {
02648       gnssDataMap dataMap;
02649 
02650       // Iterate through all items in the gnssDataMap
02651       for( gnssDataMap::const_iterator it = this->begin();
02652            it != this->end();
02653            ++it )
02654       {
02655          const CommonTime& time(it->first);
02656          const sourceDataMap& sourceMap(it->second);
02657 
02658          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02659              itsrc != sourceMap.end();
02660              ++itsrc)
02661          {
02662             gnssSatTypeValue gds;
02663             gds.header.epoch = time;
02664             gds.header.source = itsrc->first;
02665             gds.body = itsrc->second;
02666 
02667             gds.body.removeSatID(satSet);
02668 
02669             dataMap.addGnssSatTypeValue(gds);
02670 
02671          }  // loop in the sources
02672 
02673       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02674 
02675       (*this) = dataMap;
02676 
02677       return (*this);
02678 
02679    }  // End of method 'gnssDataMap::removeSatID()'
02680 
02681 
02682 
02685    gnssDataMap gnssDataMap::extractTypeID(const TypeID& type)
02686    {
02687       TypeIDSet typeSet;
02688       typeSet.insert(type);
02689 
02690       return extractTypeID(typeSet);
02691    }
02692 
02693 
02694       // Returns a gnssDataMap with only these satellites.
02695       // @param typeSet Set(TypeIDSet) containing the types 
02696       //               to be extracted.
02697    gnssDataMap gnssDataMap::extractTypeID(const TypeIDSet& typeSet)
02698    {
02699       gnssDataMap dataMap;
02700 
02701       // Iterate through all items in the gnssDataMap
02702       for( gnssDataMap::const_iterator it = this->begin();
02703            it != this->end();
02704            ++it )
02705       {
02706          const CommonTime& time(it->first);
02707          const sourceDataMap& sourceMap(it->second);
02708 
02709          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02710              itsrc != sourceMap.end();
02711              ++itsrc)
02712          {
02713             gnssSatTypeValue gds;
02714             gds.header.epoch = time;
02715             gds.header.source = itsrc->first;
02716             gds.body = itsrc->second;
02717 
02718             gds.body.keepOnlyTypeID(typeSet);
02719 
02720             dataMap.addGnssSatTypeValue(gds);
02721 
02722          }  // loop in the sources
02723 
02724       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02725 
02726       return dataMap;
02727    }
02728 
02729 
02730       // Modifies this object, keeping only this type.
02731       // @param type Type to be extracted.
02732    gnssDataMap& gnssDataMap::keepOnlyTypeID(const TypeID& type)
02733    {
02734       (*this) = extractTypeID(type);
02735       return (*this);
02736    }
02737 
02738 
02739       // Modifies this object, keeping only these types.
02740       // @param typeSet Set(TypeIDSet) containing the type 
02741       //                  to be extracted.
02742    gnssDataMap& gnssDataMap::keepOnlyTypeID(const TypeIDSet& typeSet)
02743    {
02744       (*this) = extractTypeID(typeSet);
02745       return (*this);
02746    }
02747 
02748 
02749       // Modifies this object, removing this type.
02750       // @param type Type to be removed.
02751    gnssDataMap& gnssDataMap::removeTypeID(const TypeID& type)
02752    {
02753       TypeIDSet typeSet;
02754       typeSet.insert(type);
02755 
02756       return removeTypeID(typeSet);
02757    }
02758 
02759 
02760       // Modifies this object, keeping only these types.
02761       // @param typeSet Set(TypeIDSet) containing the types 
02762       //               to be removed.
02763    gnssDataMap& gnssDataMap::removeTypeID(const TypeIDSet& typeSet)
02764    {
02765       gnssDataMap dataMap;
02766 
02767       // Iterate through all items in the gnssDataMap
02768       for( gnssDataMap::const_iterator it = this->begin();
02769            it != this->end();
02770            ++it )
02771       {
02772          const CommonTime& time(it->first);
02773          const sourceDataMap& sourceMap(it->second);
02774 
02775          for(sourceDataMap::const_iterator itsrc = sourceMap.begin();
02776              itsrc != sourceMap.end();
02777              ++itsrc)
02778          {
02779             gnssSatTypeValue gds;
02780             gds.header.epoch = time;
02781             gds.header.source = itsrc->first;
02782             gds.body = itsrc->second;
02783 
02784             gds.body.removeTypeID(typeSet);
02785 
02786             dataMap.addGnssSatTypeValue(gds);
02787 
02788          }  // loop in the sources
02789 
02790       }  // End of 'for( gnssDataMap::const_iterator it = gdMap.begin(); ...'
02791 
02792       (*this) = dataMap;
02793 
02794       return (*this);
02795 
02796    }  // End of method 'gnssDataMap::removeTypeID()'
02797 
02798 
02799       /* Edit the dataset, removing data outside the indicated time
02800        *  interval.
02801        *
02802        * @param[in] tmin defines the beginning of the time interval
02803        * @param[in] tmax defines the end of the time interval
02804        */
02805    gnssDataMap& gnssDataMap::edit(CommonTime tmin, CommonTime tmax )
02806    {
02807       gnssDataMap dataMap;
02808 
02809       while(!this->empty())
02810       {
02811          gnssDataMap gds = this->frontEpoch();
02812 
02813          CommonTime time(gds.begin()->first);
02814          if( (time>=tmin) && (time<=tmax) ) dataMap.addGnssDataMap(gds);
02815 
02816          this->pop_front_epoch();
02817       }
02818 
02819       (*this) = dataMap;
02820 
02821       return (*this);
02822    }
02823 
02824       // Load data from a rinex observation file
02825    void gnssDataMap::loadObsFile(std::string obsFile)
02826    {
02827       try
02828       {
02829          RinexObsStream rin(obsFile);
02830          rin.exceptions(ios::failbit);
02831 
02832          gnssRinex gRin;
02833          while( rin >> gRin )
02834          {
02835             this->addGnssRinex(gRin);
02836          }
02837          
02838          rin.close();
02839       }
02840       catch(...)
02841       {
02842          Exception e("Failed to load obs file '"+obsFile+"'.");
02843          GPSTK_THROW(e);
02844       }
02845 
02846    }  // End of method 'gnssDataMap::loadObsFile()'
02847 
02848 
02850 
02851 
02852 
02853       // Convenience output method for structure satTypeValueMap
02854    std::ostream& satTypeValueMap::dump( std::ostream& s,
02855                                         int mode ) const
02856    {
02857 
02858       for( satTypeValueMap::const_iterator it = (*this).begin();
02859            it!= (*this).end();
02860            it++ )
02861       {
02862 
02863             // First, print satellite (system and PRN)
02864          s << (*it).first << " ";
02865 
02866          for( typeValueMap::const_iterator itObs = (*it).second.begin();
02867               itObs != (*it).second.end();
02868               itObs++ )
02869          {
02870 
02871             if (mode==1)
02872             {
02873                s << (*itObs).first << " ";
02874             }
02875 
02876             s << (*itObs).second << " ";
02877 
02878          }  // End of 'for( typeValueMap::const_iterator itObs = ...'
02879 
02880          s << endl;
02881 
02882       }  // End of 'for( satTypeValueMap::const_iterator it = ...'
02883 
02884          // Let's return the 'std::ostream'
02885       return s;
02886 
02887    }  // End of method 'satTypeValueMap::dump()'
02888 
02889 
02890 
02891       // stream output for satTypeValueMap
02892    std::ostream& operator<<( std::ostream& s,
02893                              const satTypeValueMap& stvMap )
02894    {
02895 
02896       stvMap.dump(s);
02897       return s;
02898 
02899    }  // End of 'operator<<'
02900 
02901 
02902 
02903       // stream output for gnssDataMap
02904    std::ostream& operator<<( std::ostream& s,
02905                              const gnssDataMap& gdsMap)
02906    {
02907 
02908       gdsMap.dump(s);
02909       return s;
02910 
02911    }  // End of 'operator<<'
02912 
02913 
02914       // Stream input for gnssRinex
02915    std::istream& operator>>( std::istream& i, gnssRinex& f )
02916    {
02917 
02918       if( RinexObsStream::IsRinexObsStream(i) )    // Rinex2
02919       {
02920          try
02921          {
02922             RinexObsStream& strm = dynamic_cast<RinexObsStream&>(i);
02923 
02924             // If the header hasn't been read, read it...
02925             if(!strm.headerRead) strm >> strm.header;
02926 
02927             // Clear out this object
02928             RinexObsHeader& roh = strm.header;
02929 
02930             RinexObsData rod;
02931             strm >> rod;
02932 
02933             // Fill data
02934             f.header.source.type = SatIDsystem2SourceIDtype(roh.system);
02935             f.header.source.sourceName = roh.markerName;
02936             f.header.antennaType = roh.antType;
02937             f.header.antennaPosition = roh.antennaPosition;
02938             f.header.epochFlag = rod.epochFlag;
02939             f.header.epoch = rod.time;
02940 
02941             f.body = satTypeValueMapFromRinexObsData(roh, rod);
02942 
02943             return i;
02944          }  
02945          catch (...)
02946          {
02947             return i;
02948          }
02949       }
02950       if( Rinex3ObsStream::IsRinex3ObsStream(i) )     // Rinex3
02951       {
02952          Rinex3ObsStream& strm = dynamic_cast<Rinex3ObsStream&>(i);
02953 
02954          // If the header hasn't been read, read it...
02955          if(!strm.headerRead) strm >> strm.header;
02956 
02957          // Clear out this object
02958          Rinex3ObsHeader& roh = strm.header;
02959 
02960          Rinex3ObsData rod;
02961          strm >> rod;
02962 
02963          // Fill data
02964          f.header.source.type = SatIDsystem2SourceIDtype(roh.fileSysSat);
02965          f.header.source.sourceName = roh.markerName;
02966          f.header.antennaType = roh.antType;
02967          f.header.antennaPosition = roh.antennaPosition;
02968          f.header.epochFlag = rod.epochFlag;
02969          f.header.epoch = rod.time;
02970 
02971          f.body = satTypeValueMapFromRinex3ObsData(roh, rod);
02972 
02973          return i;
02974       }
02975       
02976       return i;
02977 
02978    }  // End of stream input for gnssRinex
02979 
02980 
02981    // Stream output for gnssRinex
02982    std::ostream& operator<<( std::ostream& s,
02983                              gnssRinex& f )
02984       throw(FFStreamError, gpstk::StringUtils::StringException)
02985    {
02986       FFStream* ffs = dynamic_cast<FFStream*>(&s);
02987       if(ffs)
02988       {
02989          try
02990          {
02991             RinexObsStream& strm = dynamic_cast<RinexObsStream&>(*ffs);
02992 
02993             // Clear out this object
02994             RinexObsHeader& hdr = strm.header;
02995             
02996             RinexObsData rod;
02997             
02998             rod.time = f.header.epoch;
02999             rod.epochFlag = f.header.epochFlag; 
03000             rod.numSvs = f.numSats();
03001             rod.clockOffset = 0.0;
03002             rod.auxHeader = hdr;
03003                         
03004             SatIDSet satSet = f.getSatID();
03005             for(SatIDSet::iterator itSat = satSet.begin();
03006                itSat != satSet.end();
03007                ++itSat)
03008             {
03009                vector<RinexObsHeader::RinexObsType>::iterator obsTypeItr = 
03010                   hdr.obsTypeList.begin();
03011 
03012                while (obsTypeItr != strm.header.obsTypeList.end())
03013                {
03014                   TypeID type = ConvertToTypeID( *obsTypeItr,
03015                      RinexSatID(itSat->id,itSat->system));
03016                   
03017                   RinexObsData::RinexDatum data;
03018                   data.data = f.body[*itSat][type];
03019                   data.ssi = 0;
03020                   data.lli = 0;
03021                   
03022                   if( (type == TypeID::P1) || (type == TypeID::L1) )
03023                   {
03024                      if(type == TypeID::L1)
03025                      {
03026                         data.data /= L1_WAVELENGTH_GAL;
03027                         data.ssi = f.body[*itSat][TypeID::SSI1];
03028                      }
03029  
03030                      data.lli = f.body[*itSat][TypeID::LLI1];
03031                   }
03032 
03033                   if( (type == TypeID::P2) || (type == TypeID::L2))
03034                   {
03035                      if(type == TypeID::L2)
03036                      {
03037                         data.data /= L2_WAVELENGTH_GPS;
03038                         data.ssi = f.body[*itSat][TypeID::SSI2];
03039                      }
03040 
03041                      data.lli = f.body[*itSat][TypeID::LLI2];
03042                   }
03043 
03044                   if( (type == TypeID::C5) || (type == TypeID::L5))
03045                   {
03046                      if(type == TypeID::L5)
03047                      {
03048                         data.data /= L5_WAVELENGTH_GAL;
03049                         data.ssi = f.body[*itSat][TypeID::SSI5];
03050                      }
03051 
03052                      data.lli = f.body[*itSat][TypeID::LLI5];
03053                   }
03054 
03055                   if( (type == TypeID::C6) || (type == TypeID::L6) )
03056                   {
03057                      if(type == TypeID::L6)
03058                      {
03059                         data.data /= L6_WAVELENGTH_GAL;
03060                         data.ssi = f.body[*itSat][TypeID::SSI6];
03061                      }
03062 
03063                      data.lli = f.body[*itSat][TypeID::LLI6];
03064                   }
03065 
03066                   if( (type == TypeID::C7) || (type == TypeID::L7) )
03067                   {
03068                      if(type == TypeID::L7)
03069                      {
03070                         data.data /= L7_WAVELENGTH_GAL;
03071                         data.ssi = f.body[*itSat][TypeID::SSI7];
03072                      }
03073 
03074                      data.lli = f.body[*itSat][TypeID::LLI7];
03075                   }
03076 
03077                   if( (type == TypeID::C8) || (type == TypeID::L8))
03078                   {
03079                      if(type == TypeID::L8)
03080                      {
03081                         data.data /= L8_WAVELENGTH_GAL;
03082                         data.ssi = f.body[*itSat][TypeID::SSI8];
03083                      }
03084 
03085                      data.lli = f.body[*itSat][TypeID::LLI8];
03086                   }
03087 
03088                   if( (type == TypeID::D1) || 
03089                       (type == TypeID::S1) ||
03090                       (type == TypeID::C1) )
03091                   {
03092                      data.lli = f.body[*itSat][TypeID::LLI1];
03093                   }
03094 
03095                   if( (type == TypeID::D2) || (type == TypeID::S2) )
03096                   {
03097                      data.lli = f.body[*itSat][TypeID::LLI2];
03098                   }
03099 
03100 
03101                   rod.obs[*itSat][*obsTypeItr] = data;
03102                
03103                   obsTypeItr++;
03104                }
03105             }
03106 
03107             strm << rod;
03108 
03109             return s;
03110 
03111          }  // End of "try" block
03118          // EOF - do nothing - eof causes fail() to be set which
03119          // is handled by std::fstream
03120          catch (EndOfFile& e)
03121          {
03122             return s;
03123          }
03124          catch (...)
03125          {
03126             return s;
03127          }
03128 
03129       }  // End of block: "if (ffs)..."
03130       else
03131       {
03132          FFStreamError e("operator<< stream argument must be an FFStream");
03133          GPSTK_THROW(e);
03134       }
03135 
03136    }   // End of stream input for gnssRinex
03137 
03138 
03139       // Convenience function to convert from SatID system to SourceID type.
03140       // @param sid Satellite ID.
03141    SourceID::SourceType SatIDsystem2SourceIDtype(const SatID& sid)
03142    {
03143 
03144          // Select the right system the data came from
03145       switch(sid.system)
03146       {
03147          case SatID::systemGPS:
03148             return SourceID::GPS;
03149             break;
03150          case SatID::systemGalileo:
03151             return SourceID::Galileo;
03152             break;
03153          case SatID::systemGlonass:
03154             return SourceID::Glonass;
03155             break;
03156          case SatID::systemGeosync:
03157             return SourceID::Geosync;
03158             break;
03159          case SatID::systemLEO:
03160             return SourceID::LEO;
03161             break;
03162          case SatID::systemTransit:
03163             return SourceID::Transit;
03164             break;
03165          case SatID::systemMixed:
03166             return SourceID::Mixed;
03167             break;
03168          default:
03169             return SourceID::Unknown;
03170       }
03171 
03172    } // End SatIDsystem2SourceIDtype(const SatID& sid)
03173 
03174 
03175 
03176       // Convenience function to fill a satTypeValueMap with data
03177       // from RinexObsData.
03179       // @param rod RinexObsData holding the data.
03180    satTypeValueMap satTypeValueMapFromRinexObsData(
03181                             const RinexObsHeader& roh, const RinexObsData& rod)
03182    {
03183 
03184          // We need to declare a satTypeValueMap
03185       satTypeValueMap theMap;
03186 
03187          // Let's define the "it" iterator to visit the observations PRN map
03188          // RinexSatMap is a map from SatID to RinexObsTypeMap:
03189          //      std::map<SatID, RinexObsTypeMap>
03190       for( RinexObsData::RinexSatMap::const_iterator it = rod.obs.begin();
03191            it!= rod.obs.end();
03192            ++it )
03193       {
03194             // RinexObsTypeMap is a map from RinexObsType to RinexDatum:
03195             //   std::map<RinexObsHeader::RinexObsType, RinexDatum>
03196             // The "second" field of a RinexSatMap (it) is a
03197             // RinexObsTypeMap (otmap)
03198          RinexObsData::RinexObsTypeMap otmap = (*it).second;
03199          SatID sat = (*it).first;
03200 
03201          typeValueMap tvMap;
03202 
03203          // Let's visit the RinexObsTypeMap (RinexObsType -> RinexDatum)
03204          for( RinexObsData::RinexObsTypeMap::const_iterator itObs = otmap.begin();
03205             itObs!= otmap.end();
03206             ++itObs )
03207          {
03208 
03209             RinexSatID rsat(sat.id,sat.system);
03210 
03211             TypeID type = ConvertToTypeID( itObs->first, rsat);
03212 
03213             const bool isPhase = IsCarrierPhase(itObs->first);
03214             const int n = GetCarrierBand(itObs->first);
03215 
03216             if(isPhase)
03217             {
03218                // TODO:: handle glonass data later(yanweigps)
03219                tvMap[ type ] = (*itObs).second.data*getWavelength(rsat,n);
03220 
03221                // n=1 2 5 6 7 8
03222                if(n==1)
03223                {
03224                   tvMap[TypeID::LLI1] = (*itObs).second.lli;
03225                   tvMap[TypeID::SSI1] = (*itObs).second.ssi;
03226                }
03227                else if(n==2)
03228                {
03229                   tvMap[TypeID::LLI2] = (*itObs).second.lli;
03230                   tvMap[TypeID::SSI2] = (*itObs).second.ssi;
03231                }
03232                else if(n==5)
03233                {
03234                   tvMap[TypeID::LLI5] = (*itObs).second.lli;
03235                   tvMap[TypeID::SSI5] = (*itObs).second.ssi;
03236                }
03237                else if(n==6)
03238                {
03239                   tvMap[TypeID::LLI6] = (*itObs).second.lli;
03240                   tvMap[TypeID::SSI6] = (*itObs).second.ssi;
03241                }
03242                else if(n==7)
03243                {
03244                   tvMap[TypeID::LLI7] = (*itObs).second.lli;
03245                   tvMap[TypeID::SSI7] = (*itObs).second.ssi;
03246                }
03247                else if(n==8)
03248                {
03249                   tvMap[TypeID::LLI8] = (*itObs).second.lli;
03250                   tvMap[TypeID::SSI8] = (*itObs).second.ssi;
03251                }
03252             }
03253             else
03254             {
03255                tvMap[ type ] = (*itObs).second.data;
03256             }
03257 
03258          }  // End of "for( itObs = otmap.
03259 
03260          theMap[sat] = tvMap;
03261       }
03262 
03263       return theMap;
03264 
03265    } // End FillsatTypeValueMapwithRinexObsData(const RinexObsData& rod)
03266 
03267 
03268       // Convenience function to fill a satTypeValueMap with data
03269       // from Rinex3ObsData.
03270       // @param roh Rinex3ObsHeader holding the data
03271       // @param rod Rinex3ObsData holding the data.
03272    satTypeValueMap satTypeValueMapFromRinex3ObsData(
03273                          const Rinex3ObsHeader& roh, const Rinex3ObsData& rod )
03274    {
03275       // We need to declare a satTypeValueMap
03276       satTypeValueMap theMap;
03277 
03278       Rinex3ObsData::DataMap::const_iterator it;
03279       for(it=rod.obs.begin(); it != rod.obs.end(); it++) 
03280       {
03281          RinexSatID sat(it->first);
03282  
03283          typeValueMap tvMap;
03284 
03285          map<std::string,std::vector<RinexObsID> > mapObsTypes(roh.mapObsTypes);
03286          const vector<RinexObsID> types = mapObsTypes[sat.toString().substr(0,1)];
03287          for(int i=0; i<types.size(); i++)
03288          {
03289             TypeID type = ConvertToTypeID(types[i],sat);
03290 
03291             const int n = GetCarrierBand(types[i]);
03292 
03293             if(types[i].type==ObsID::otPhase)   // Phase
03294             {
03295                // TODO:: handle glonass data later(yanweigps)
03296                tvMap[type] = it->second[i].data*getWavelength(sat,n);
03297 
03298                // n=1 2 5 6 7 8
03299                if(n==1)
03300                {
03301                   tvMap[TypeID::LLI1] = it->second[i].lli;
03302                   tvMap[TypeID::SSI1] = it->second[i].ssi;
03303                }
03304                else if(n==2)
03305                {
03306                   tvMap[TypeID::LLI2] = it->second[i].lli;
03307                   tvMap[TypeID::SSI2] = it->second[i].ssi;
03308                }
03309                else if(n==5)
03310                {
03311                   tvMap[TypeID::LLI5] = it->second[i].lli;
03312                   tvMap[TypeID::SSI5] = it->second[i].ssi;
03313                }
03314                else if(n==6)
03315                {
03316                   tvMap[TypeID::LLI6] = it->second[i].lli;
03317                   tvMap[TypeID::SSI6] = it->second[i].ssi;
03318                }
03319                else if(n==7)
03320                {
03321                   tvMap[TypeID::LLI7] = it->second[i].lli;
03322                   tvMap[TypeID::SSI7] = it->second[i].ssi;
03323                }
03324                else if(n==8)
03325                {
03326                   tvMap[TypeID::LLI8] = it->second[i].lli;
03327                   tvMap[TypeID::SSI8] = it->second[i].ssi;
03328                }
03329             }
03330             else
03331             {
03332                tvMap[ type ] = it->second[i].data;
03333             }
03334          }
03335 
03336          theMap[sat] = tvMap;
03337       }   // End loop over all the satellite
03338 
03339       return theMap;
03340    }
03341 
03342 }  // End of namespace gpstk

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