test_rinex.c

Go to the documentation of this file.
00001 /** 
00002 \file    test_rinex.c
00003 \brief   unit tests for test_rinex.c/.h
00004 \author  Glenn D. MacGougan (GDM)
00005 \date    2007-12-03
00006 \since   2007-12-03
00007 
00008 \b "LICENSE INFORMATION" \n
00009 Copyright (c) 2007, refer to 'author' doxygen tags \n
00010 All rights reserved. \n
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided the following conditions are met: \n
00014 
00015 - Redistributions of source code must retain the above copyright
00016   notice, this list of conditions and the following disclaimer. \n
00017 - Redistributions in binary form must reproduce the above copyright
00018   notice, this list of conditions and the following disclaimer in the
00019   documentation and/or other materials provided with the distribution. \n
00020 - The name(s) of the contributor(s) may not be used to endorse or promote 
00021   products derived from this software without specific prior written 
00022   permission. \n
00023 
00024 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 
00025 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00026 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027 DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00028 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00030 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00031 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00032 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00033 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
00034 SUCH DAMAGE.
00035 */
00036 #include <stdio.h>
00037 #include "Basic.h"     // CUnit/Basic.h
00038 #include "rinex.h"
00039 #include "time_conversion.h"
00040 #include "constants.h"
00041 
00042 
00043 typedef struct 
00044 {
00045   unsigned short year;
00046   unsigned char month;
00047   unsigned char day;
00048   unsigned char hour;
00049   unsigned char minute;
00050   float seconds;
00051 } struct_utc;
00052 
00053 
00054 int init_suite_RINEX(void)
00055 {
00056   return 0;
00057 }
00058 
00059 int clean_suite_RINEX(void)
00060 {
00061   return 0;
00062 }
00063 
00064 
00065 
00066 void test_RINEX_GetHeader(void)
00067 {
00068   BOOL result;
00069   char buffer[16384];
00070   unsigned buffer_size = 0;
00071   double version = 0.0;
00072   RINEX_enumFileType file_type = RINEX_FILE_TYPE_UNKNOWN;
00073   
00074   result = RINEX_GetHeader( 
00075     "aira0010.07o",
00076     //"rinex.07o",
00077     buffer,
00078     16384,
00079     &buffer_size,
00080     &version,
00081     &file_type
00082     );
00083 
00084   CU_ASSERT_FATAL( result );
00085   CU_ASSERT_DOUBLE_EQUAL( version, 2.1, 1e-02 );
00086   CU_ASSERT( file_type == RINEX_FILE_TYPE_OBS );
00087 }
00088 
00089 
00090 
00091 void test_RINEX_DecodeHeader_ObservationFile(void)
00092 {
00093   BOOL result;
00094   char buffer[16384];
00095   unsigned buffer_size = 0;
00096   double version = 0.0;
00097   RINEX_enumFileType file_type = RINEX_FILE_TYPE_UNKNOWN;
00098   RINEX_structDecodedHeader header;
00099 
00100   memset( &header, 0, sizeof(RINEX_structDecodedHeader) );
00101   
00102   result = RINEX_GetHeader( 
00103     "aira0010.07o",
00104     //"rinex.07o",
00105     buffer,
00106     16384,
00107     &buffer_size,
00108     &version,
00109     &file_type
00110     );
00111 
00112   CU_ASSERT_FATAL( result );
00113   CU_ASSERT_DOUBLE_EQUAL( version, 2.1, 1e-02 );
00114   CU_ASSERT_FATAL( file_type == RINEX_FILE_TYPE_OBS );
00115 
00116   
00117   result = RINEX_DecodeHeader_ObservationFile(
00118     buffer,
00119     buffer_size,  
00120     &header 
00121     );
00122 
00123   CU_ASSERT_DOUBLE_EQUAL( header.version, 2.1, 1E-02 );
00124   CU_ASSERT( header.type == RINEX_FILE_TYPE_OBS );
00125   CU_ASSERT( strcmp( header.marker_name, "AIRA" ) == 0 );
00126   CU_ASSERT_DOUBLE_EQUAL( header.x, -3530185.4892, 1e-04  );
00127   CU_ASSERT_DOUBLE_EQUAL( header.y, 4118797.3370, 1e-04  );
00128   CU_ASSERT_DOUBLE_EQUAL( header.z, 3344036.9313, 1e-04 );
00129   CU_ASSERT_DOUBLE_EQUAL( header.antenna_delta_h, 0.0, 1e-04 );
00130   CU_ASSERT_DOUBLE_EQUAL( header.antenna_ecc_e, 0.0, 1e-04 );
00131   CU_ASSERT_DOUBLE_EQUAL( header.antenna_ecc_n, 0.0, 1e-04 );
00132   CU_ASSERT_FATAL( header.nr_obs_types == 6 );
00133   CU_ASSERT( header.obs_types[0] == RINEX_OBS_TYPE_L1 );
00134   CU_ASSERT( header.obs_types[1] == RINEX_OBS_TYPE_L2 );
00135   CU_ASSERT( header.obs_types[2] == RINEX_OBS_TYPE_C1 );
00136   CU_ASSERT( header.obs_types[3] == RINEX_OBS_TYPE_P2 );
00137   CU_ASSERT( header.obs_types[4] == RINEX_OBS_TYPE_S1 );
00138   CU_ASSERT( header.obs_types[5] == RINEX_OBS_TYPE_S2 );
00139   CU_ASSERT( header.default_wavefactor_L1 == RINEX_WAVELENTH_FACTOR_FULL_AMB );
00140   CU_ASSERT( header.default_wavefactor_L2 == RINEX_WAVELENTH_FACTOR_FULL_AMB );
00141   CU_ASSERT( header.time_of_first_obs.year == 2007 );
00142   CU_ASSERT( header.time_of_first_obs.month == 1 );
00143   CU_ASSERT( header.time_of_first_obs.day == 1 );
00144   CU_ASSERT( header.time_of_first_obs.hour == 0 );
00145   CU_ASSERT( header.time_of_first_obs.minute == 0 );
00146   CU_ASSERT( header.time_of_first_obs.seconds == 0.0 );
00147   CU_ASSERT( header.time_of_first_obs.time_system == RINEX_TIME_SYSTEM_GPS );
00148 
00149 
00150   result = RINEX_GetHeader( 
00151     "www.ngs.noaa.gov_CORS_rinex210.txt",    
00152     buffer,
00153     16384,
00154     &buffer_size,
00155     &version,
00156     &file_type
00157     );
00158 
00159   CU_ASSERT_FATAL( result );
00160   CU_ASSERT_DOUBLE_EQUAL( version, 2.1, 1e-02 );
00161   CU_ASSERT_FATAL( file_type == RINEX_FILE_TYPE_OBS );
00162 
00163   
00164   result = RINEX_DecodeHeader_ObservationFile(
00165     buffer,
00166     buffer_size,  
00167     &header 
00168     );
00169 
00170   CU_ASSERT_DOUBLE_EQUAL( header.version, 2.1, 1E-02 );
00171   CU_ASSERT( header.type == RINEX_FILE_TYPE_OBS );
00172   CU_ASSERT( strcmp( header.marker_name, "A 9080" ) == 0 );
00173   CU_ASSERT_DOUBLE_EQUAL( header.x, 4375274.0, 1e-04  );
00174   CU_ASSERT_DOUBLE_EQUAL( header.y, 587466.0, 1e-04  );
00175   CU_ASSERT_DOUBLE_EQUAL( header.z, 4589095.0, 1e-04 );
00176   CU_ASSERT_DOUBLE_EQUAL( header.antenna_delta_h, 0.9030, 1e-04 );
00177   CU_ASSERT_DOUBLE_EQUAL( header.antenna_ecc_e, 0.0, 1e-04 );
00178   CU_ASSERT_DOUBLE_EQUAL( header.antenna_ecc_n, 0.0, 1e-04 );
00179   CU_ASSERT_FATAL( header.nr_obs_types == 4 );
00180   CU_ASSERT( header.obs_types[0] == RINEX_OBS_TYPE_P1 );
00181   CU_ASSERT( header.obs_types[1] == RINEX_OBS_TYPE_L1 );
00182   CU_ASSERT( header.obs_types[2] == RINEX_OBS_TYPE_L2 );
00183   CU_ASSERT( header.obs_types[3] == RINEX_OBS_TYPE_P2 );
00184   CU_ASSERT( header.default_wavefactor_L1 == RINEX_WAVELENTH_FACTOR_FULL_AMB );
00185   CU_ASSERT( header.default_wavefactor_L2 == RINEX_WAVELENTH_FACTOR_FULL_AMB );
00186   CU_ASSERT( header.time_of_first_obs.year == 2001 );
00187   CU_ASSERT( header.time_of_first_obs.month == 3 );
00188   CU_ASSERT( header.time_of_first_obs.day == 24 );
00189   CU_ASSERT( header.time_of_first_obs.hour == 13 );
00190   CU_ASSERT( header.time_of_first_obs.minute == 10 );
00191   CU_ASSERT( header.time_of_first_obs.seconds == 36.0 );
00192   CU_ASSERT( header.time_of_first_obs.time_system == RINEX_TIME_SYSTEM_GPS );
00193   
00194 }
00195 
00196 
00197 void test_RINEX_GetNextObservationSet(void)
00198 {
00199   BOOL result;
00200   char buffer[16384];
00201   unsigned buffer_size = 0;
00202   double version = 0.0;
00203   RINEX_enumFileType file_type = RINEX_FILE_TYPE_UNKNOWN;
00204   RINEX_structDecodedHeader header;
00205   unsigned i = 0;
00206 
00207   FILE* fid = NULL;
00208   BOOL wasEndOfFileReached;  // Has the end of the file been reached (output).
00209   BOOL wasObservationFound;  // Was a valid observation found (output).
00210   unsigned filePosition=0;   // The file position for the start of the 
00211   unsigned nrObs = 0;
00212   char linebuf[8192];
00213 
00214   GNSS_structMeasurement obsArray[24];
00215 
00216   struct_utc utc;
00217   
00218   result = RINEX_GetHeader( 
00219     "aira0010.07o",
00220     buffer,
00221     16384,
00222     &buffer_size,
00223     &version,
00224     &file_type
00225     );
00226 
00227   CU_ASSERT_FATAL( result );
00228   CU_ASSERT_DOUBLE_EQUAL( version, 2.1, 1e-02 );
00229   CU_ASSERT_FATAL( file_type == RINEX_FILE_TYPE_OBS );
00230 
00231   
00232   result = RINEX_DecodeHeader_ObservationFile(
00233     buffer,
00234     buffer_size,  
00235     &header 
00236     );
00237 
00238   CU_ASSERT_DOUBLE_EQUAL( header.version, 2.1, 1E-02 );
00239   CU_ASSERT( header.type == RINEX_FILE_TYPE_OBS );
00240   CU_ASSERT( strcmp( header.marker_name, "AIRA" ) == 0 );
00241   CU_ASSERT_DOUBLE_EQUAL( header.x, -3530185.4892, 1e-04  );
00242   CU_ASSERT_DOUBLE_EQUAL( header.y, 4118797.3370, 1e-04  );
00243   CU_ASSERT_DOUBLE_EQUAL( header.z, 3344036.9313, 1e-04 );
00244   CU_ASSERT_DOUBLE_EQUAL( header.antenna_delta_h, 0.0, 1e-04 );
00245   CU_ASSERT_DOUBLE_EQUAL( header.antenna_ecc_e, 0.0, 1e-04 );
00246   CU_ASSERT_DOUBLE_EQUAL( header.antenna_ecc_n, 0.0, 1e-04 );
00247   CU_ASSERT_FATAL( header.nr_obs_types == 6 );
00248   CU_ASSERT( header.obs_types[0] == RINEX_OBS_TYPE_L1 );
00249   CU_ASSERT( header.obs_types[1] == RINEX_OBS_TYPE_L2 );
00250   CU_ASSERT( header.obs_types[2] == RINEX_OBS_TYPE_C1 );
00251   CU_ASSERT( header.obs_types[3] == RINEX_OBS_TYPE_P2 );
00252   CU_ASSERT( header.obs_types[4] == RINEX_OBS_TYPE_S1 );
00253   CU_ASSERT( header.obs_types[5] == RINEX_OBS_TYPE_S2 );
00254   CU_ASSERT( header.default_wavefactor_L1 == RINEX_WAVELENTH_FACTOR_FULL_AMB );
00255   CU_ASSERT( header.default_wavefactor_L2 == RINEX_WAVELENTH_FACTOR_FULL_AMB );
00256   CU_ASSERT( header.time_of_first_obs.year == 2007 );
00257   CU_ASSERT( header.time_of_first_obs.month == 1 );
00258   CU_ASSERT( header.time_of_first_obs.day == 1 );
00259   CU_ASSERT( header.time_of_first_obs.hour == 0 );
00260   CU_ASSERT( header.time_of_first_obs.minute == 0 );
00261   CU_ASSERT( header.time_of_first_obs.seconds == 0.0 );
00262   CU_ASSERT( header.time_of_first_obs.time_system == RINEX_TIME_SYSTEM_GPS );
00263   
00264   { 
00265     // test "aira0010.07o"
00266     unsigned total_nr_epochs = 0;
00267 
00268     fid = fopen( "aira0010.07o", "r" );
00269     CU_ASSERT_FATAL( fid != NULL );
00270 
00271     while( !feof(fid) )
00272     {
00273       if( fgets( linebuf, 8192, fid ) == NULL )
00274         break;
00275       if( strstr( linebuf, "END OF HEADER" ) != NULL )
00276         break;
00277     }
00278 
00279     if( feof(fid) || ferror(fid) != 0 )
00280       return;
00281    
00282     result = RINEX_GetNextObservationSet(
00283       fid,
00284       &header,
00285       &wasEndOfFileReached,
00286       &wasObservationFound,
00287       &filePosition,
00288       obsArray,
00289       24,
00290       &nrObs
00291       );    
00292     CU_ASSERT_FATAL( result );
00293     CU_ASSERT_FATAL( nrObs == 14 ); // L1, and L2 for 7 satellites.
00294     total_nr_epochs++;
00295 
00296     for( i = 0; i < 14; i++ )    
00297     {
00298       CU_ASSERT( obsArray[i].system == GNSS_GPS );
00299       CU_ASSERT( obsArray[i].flags.isActive );
00300       CU_ASSERT( obsArray[i].flags.isCodeLocked );
00301       CU_ASSERT( obsArray[i].flags.isPhaseLocked );
00302       CU_ASSERT( obsArray[i].flags.isParityValid );
00303       CU_ASSERT( obsArray[i].flags.isPsrValid );
00304       CU_ASSERT( obsArray[i].flags.isAdrValid );
00305       CU_ASSERT( obsArray[i].flags.isDopplerValid == FALSE );
00306     }
00307 
00308     CU_ASSERT( obsArray[0].id == 13 );
00309     CU_ASSERT( obsArray[0].freqType == GNSS_GPSL1 );
00310     CU_ASSERT( obsArray[0].codeType == GNSS_CACode );
00311     CU_ASSERT_DOUBLE_EQUAL( obsArray[0].psr, 22845039.656, 1E-03 );
00312     CU_ASSERT_DOUBLE_EQUAL( obsArray[0].adr, -7244061.926, 1E-03 );
00313     CU_ASSERT_DOUBLE_EQUAL( obsArray[0].cno, 43.750, 1E-03 );
00314 
00315     CU_ASSERT( obsArray[1].id == 13 );
00316     CU_ASSERT( obsArray[1].freqType == GNSS_GPSL2 );
00317     CU_ASSERT( obsArray[1].codeType == GNSS_PCode );
00318     CU_ASSERT_DOUBLE_EQUAL( obsArray[1].psr, 22845035.492 , 1E-03 );
00319     CU_ASSERT_DOUBLE_EQUAL( obsArray[1].adr, -5627744.060, 1E-03 );
00320     CU_ASSERT_DOUBLE_EQUAL( obsArray[1].cno, 30.750, 1E-03 );
00321 
00322     CU_ASSERT( obsArray[2].id == 31 );
00323     CU_ASSERT( obsArray[2].freqType == GNSS_GPSL1 );
00324     CU_ASSERT( obsArray[2].codeType == GNSS_CACode );
00325     CU_ASSERT_DOUBLE_EQUAL( obsArray[2].psr, 23633146.703, 1E-03 );
00326     CU_ASSERT_DOUBLE_EQUAL( obsArray[2].adr, -2365861.250, 1E-03 );
00327     CU_ASSERT_DOUBLE_EQUAL( obsArray[2].cno, 39.750, 1E-03 );
00328 
00329     CU_ASSERT( obsArray[3].id == 31 );
00330     CU_ASSERT( obsArray[3].freqType == GNSS_GPSL2 );
00331     CU_ASSERT( obsArray[3].codeType == GNSS_PCode );
00332     CU_ASSERT_DOUBLE_EQUAL( obsArray[3].psr, 23633143.383, 1E-03 );
00333     CU_ASSERT_DOUBLE_EQUAL( obsArray[3].adr, -2855938.538, 1E-03 );
00334     CU_ASSERT_DOUBLE_EQUAL( obsArray[3].cno, 28.500, 1E-03 );
00335 
00336   
00337     CU_ASSERT( obsArray[4].id == 25 );
00338     CU_ASSERT( obsArray[4].freqType == GNSS_GPSL1 );
00339     CU_ASSERT( obsArray[4].codeType == GNSS_CACode );
00340     CU_ASSERT_DOUBLE_EQUAL( obsArray[4].psr, 22637559.453, 1E-03 );
00341     CU_ASSERT_DOUBLE_EQUAL( obsArray[4].adr, -7887817.801, 1E-03 );
00342     CU_ASSERT_DOUBLE_EQUAL( obsArray[4].cno, 47.000, 1E-03 );
00343 
00344     CU_ASSERT( obsArray[5].id == 25 );
00345     CU_ASSERT( obsArray[5].freqType == GNSS_GPSL2 );
00346     CU_ASSERT( obsArray[5].codeType == GNSS_PCode );
00347     CU_ASSERT_DOUBLE_EQUAL( obsArray[5].psr, 22637555.531, 1E-03 );
00348     CU_ASSERT_DOUBLE_EQUAL( obsArray[5].adr, -6613691.417, 1E-03 );
00349     CU_ASSERT_DOUBLE_EQUAL( obsArray[5].cno, 35.000, 1E-03 );
00350 
00351   
00352     CU_ASSERT( obsArray[6].id == 23 );
00353     CU_ASSERT( obsArray[6].freqType == GNSS_GPSL1 );
00354     CU_ASSERT( obsArray[6].codeType == GNSS_CACode );
00355     CU_ASSERT_DOUBLE_EQUAL( obsArray[6].psr, 22399110.750, 1E-03 );
00356     CU_ASSERT_DOUBLE_EQUAL( obsArray[6].adr, -10666567.867, 1E-03 );
00357     CU_ASSERT_DOUBLE_EQUAL( obsArray[6].cno, 47.000, 1E-03 );
00358 
00359     CU_ASSERT( obsArray[7].id == 23 );
00360     CU_ASSERT( obsArray[7].freqType == GNSS_GPSL2 );
00361     CU_ASSERT( obsArray[7].codeType == GNSS_PCode );
00362     CU_ASSERT_DOUBLE_EQUAL( obsArray[7].psr, 22399104.246, 1E-03 );
00363     CU_ASSERT_DOUBLE_EQUAL( obsArray[7].adr, -9429599.906, 1E-03 );
00364     CU_ASSERT_DOUBLE_EQUAL( obsArray[7].cno, 37.250, 1E-03 );
00365 
00366   
00367     CU_ASSERT( obsArray[8].id == 27 );
00368     CU_ASSERT( obsArray[8].freqType == GNSS_GPSL1 );
00369     CU_ASSERT( obsArray[8].codeType == GNSS_CACode );
00370     CU_ASSERT_DOUBLE_EQUAL( obsArray[8].psr, 24956414.750, 1E-03 );
00371     CU_ASSERT_DOUBLE_EQUAL( obsArray[8].adr, -1712409.000, 1E-03 );
00372     CU_ASSERT_DOUBLE_EQUAL( obsArray[8].cno, 36.750, 1E-03 );
00373 
00374     CU_ASSERT( obsArray[9].id == 27 );
00375     CU_ASSERT( obsArray[9].freqType == GNSS_GPSL2 );
00376     CU_ASSERT( obsArray[9].codeType == GNSS_PCode );
00377     CU_ASSERT_DOUBLE_EQUAL( obsArray[9].psr, 24956410.289, 1E-03 );
00378     CU_ASSERT_DOUBLE_EQUAL( obsArray[9].adr, -1190201.485, 1E-03 );
00379     CU_ASSERT_DOUBLE_EQUAL( obsArray[9].cno, 19.500, 1E-03 );
00380 
00381   
00382     CU_ASSERT( obsArray[10].id == 19 );
00383     CU_ASSERT( obsArray[10].freqType == GNSS_GPSL1 );
00384     CU_ASSERT( obsArray[10].codeType == GNSS_CACode );
00385     CU_ASSERT_DOUBLE_EQUAL( obsArray[10].psr, 20845187.570, 1E-03 );
00386     CU_ASSERT_DOUBLE_EQUAL( obsArray[10].adr, -14268620.926, 1E-03 );
00387     CU_ASSERT_DOUBLE_EQUAL( obsArray[10].cno, 51.000, 1E-03 );
00388 
00389     CU_ASSERT( obsArray[11].id == 19 );
00390     CU_ASSERT( obsArray[11].freqType == GNSS_GPSL2 );
00391     CU_ASSERT( obsArray[11].codeType == GNSS_PCode );
00392     CU_ASSERT_DOUBLE_EQUAL( obsArray[11].psr, 20845181.938, 1E-03 );
00393     CU_ASSERT_DOUBLE_EQUAL( obsArray[11].adr, -12449166.320, 1E-03 );
00394     CU_ASSERT_DOUBLE_EQUAL( obsArray[11].cno, 46.750, 1E-03 );
00395 
00396 
00397     CU_ASSERT( obsArray[12].id == 16 );
00398     CU_ASSERT( obsArray[12].freqType == GNSS_GPSL1 );
00399     CU_ASSERT( obsArray[12].codeType == GNSS_CACode );
00400     CU_ASSERT_DOUBLE_EQUAL( obsArray[12].psr, 21448404.508, 1E-03 );
00401     CU_ASSERT_DOUBLE_EQUAL( obsArray[12].adr, -15023921.164, 1E-03 );
00402     CU_ASSERT_DOUBLE_EQUAL( obsArray[12].cno, 51.500, 1E-03 );
00403 
00404     CU_ASSERT( obsArray[13].id == 16 );
00405     CU_ASSERT( obsArray[13].freqType == GNSS_GPSL2 );
00406     CU_ASSERT( obsArray[13].codeType == GNSS_PCode );
00407     CU_ASSERT_DOUBLE_EQUAL( obsArray[13].psr, 21448399.809, 1E-03 );
00408     CU_ASSERT_DOUBLE_EQUAL( obsArray[13].adr, -12087101.065, 1E-03 );
00409     CU_ASSERT_DOUBLE_EQUAL( obsArray[13].cno, 43.250, 1E-03 );
00410 
00411     while( wasObservationFound && !wasEndOfFileReached )
00412     {
00413       RINEX_GetNextObservationSet(
00414         fid,
00415         &header,
00416         &wasEndOfFileReached,
00417         &wasObservationFound,
00418         &filePosition,
00419         obsArray,
00420         24,
00421         &nrObs
00422         );
00423       if( wasObservationFound )
00424         total_nr_epochs++;
00425 
00426       if( total_nr_epochs == 2880 ) 
00427       {
00428         // the last record
00429         i = 0;
00430         CU_ASSERT( obsArray[i].id == 13 );
00431         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00432         CU_ASSERT( obsArray[i].codeType == GNSS_CACode );
00433         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 22849570.617, 1E-03 );
00434         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -7211395.695, 1E-03 );
00435         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 44.000, 1E-03 );
00436         i++;
00437         CU_ASSERT( obsArray[i].id == 13 );
00438         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00439         CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00440         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 22849566.484, 1E-03 );
00441         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -5610987.454, 1E-03 );
00442         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 31.000, 1E-03 );
00443         i++;
00444         CU_ASSERT( obsArray[i].id == 25 );
00445         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00446         CU_ASSERT( obsArray[i].codeType == GNSS_CACode );
00447         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 22756497.375, 1E-03 );
00448         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -6098094.969, 1E-03 );
00449         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 45.000, 1E-03 );
00450         i++;
00451         CU_ASSERT( obsArray[i].id == 25 );
00452         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00453         CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00454         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 22756494.617, 1E-03 );
00455         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -5877136.896, 1E-03 );
00456         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 34.000, 1E-03 );
00457         i++;
00458         CU_ASSERT( obsArray[i].id == 23 );
00459         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00460         CU_ASSERT( obsArray[i].codeType == GNSS_CACode );
00461         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 22475769.211, 1E-03 );
00462         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -10284321.602, 1E-03 );
00463         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 45.500, 1E-03 );
00464         i++;
00465         CU_ASSERT( obsArray[i].id == 23 );
00466         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00467         CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00468         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 22475762.820, 1E-03 );
00469         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -8789458.208, 1E-03 );
00470         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 34.250, 1E-03 );
00471         i++;
00472         CU_ASSERT( obsArray[i].id == 31 );
00473         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00474         CU_ASSERT( obsArray[i].codeType == GNSS_CACode );
00475         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23767808.828, 1E-03 );
00476         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -1142317.953, 1E-03 );
00477         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 34.750, 1E-03 );
00478         i++;
00479         CU_ASSERT( obsArray[i].id == 31 );
00480         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00481         CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00482         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23767805.035, 1E-03 );
00483         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -1850546.594, 1E-03 );
00484         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 21.500, 1E-03 );
00485         i++;
00486         CU_ASSERT( obsArray[i].id == 27 );
00487         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00488         CU_ASSERT( obsArray[i].codeType == GNSS_CACode );
00489         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 24827754.609, 1E-03 );
00490         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -2521640.309, 1E-03 );
00491         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 36.000, 1E-03 );
00492         i++;
00493         CU_ASSERT( obsArray[i].id == 27 );
00494         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00495         CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00496         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 24827751.324, 1E-03 );
00497         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -1849906.420, 1E-03 );
00498         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 19.000, 1E-03 );
00499         i++;
00500         CU_ASSERT( obsArray[i].id == 19 );
00501         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00502         CU_ASSERT( obsArray[i].codeType == GNSS_CACode );
00503         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20784715.734, 1E-03 );
00504         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -14615047.402, 1E-03 );
00505         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 50.750, 1E-03 );
00506         i++;
00507         CU_ASSERT( obsArray[i].id == 19 );
00508         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00509         CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00510         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20784710.168, 1E-03 );
00511         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -12203215.200, 1E-03 );
00512         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 47.000, 1E-03 );
00513         i++;
00514         CU_ASSERT( obsArray[i].id == 16 );
00515         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00516         CU_ASSERT( obsArray[i].codeType == GNSS_CACode );
00517         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21495162.945, 1E-03 );
00518         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -14601064.457, 1E-03 );
00519         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 51.000, 1E-03 );
00520         i++;
00521         CU_ASSERT( obsArray[i].id == 16 );
00522         CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00523         CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00524         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21495158.898, 1E-03 );
00525         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -11756509.901, 1E-03 );
00526         CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 42.750, 1E-03 );
00527       }
00528     }
00529 
00530     CU_ASSERT( total_nr_epochs == 2880 );
00531     
00532     fclose(fid);    
00533   }
00534 
00535 
00536   result = RINEX_GetHeader( 
00537     "www.ngs.noaa.gov_CORS_rinex210.txt",    
00538     buffer,
00539     16384,
00540     &buffer_size,
00541     &version,
00542     &file_type
00543     );
00544 
00545   CU_ASSERT_FATAL( result );
00546   CU_ASSERT_DOUBLE_EQUAL( version, 2.1, 1e-02 );
00547   CU_ASSERT_FATAL( file_type == RINEX_FILE_TYPE_OBS );
00548 
00549   
00550   result = RINEX_DecodeHeader_ObservationFile(
00551     buffer,
00552     buffer_size,  
00553     &header 
00554     );
00555 
00556   CU_ASSERT_DOUBLE_EQUAL( header.version, 2.1, 1E-02 );
00557   CU_ASSERT( header.type == RINEX_FILE_TYPE_OBS );
00558   CU_ASSERT( strcmp( header.marker_name, "A 9080" ) == 0 );
00559   CU_ASSERT_DOUBLE_EQUAL( header.x, 4375274.0, 1e-04  );
00560   CU_ASSERT_DOUBLE_EQUAL( header.y, 587466.0, 1e-04  );
00561   CU_ASSERT_DOUBLE_EQUAL( header.z, 4589095.0, 1e-04 );
00562   CU_ASSERT_DOUBLE_EQUAL( header.antenna_delta_h, 0.9030, 1e-04 );
00563   CU_ASSERT_DOUBLE_EQUAL( header.antenna_ecc_e, 0.0, 1e-04 );
00564   CU_ASSERT_DOUBLE_EQUAL( header.antenna_ecc_n, 0.0, 1e-04 );
00565   CU_ASSERT_FATAL( header.nr_obs_types == 4 );
00566   CU_ASSERT( header.obs_types[0] == RINEX_OBS_TYPE_P1 );
00567   CU_ASSERT( header.obs_types[1] == RINEX_OBS_TYPE_L1 );
00568   CU_ASSERT( header.obs_types[2] == RINEX_OBS_TYPE_L2 );
00569   CU_ASSERT( header.obs_types[3] == RINEX_OBS_TYPE_P2 );
00570   CU_ASSERT( header.default_wavefactor_L1 == RINEX_WAVELENTH_FACTOR_FULL_AMB );
00571   CU_ASSERT( header.default_wavefactor_L2 == RINEX_WAVELENTH_FACTOR_FULL_AMB );
00572   CU_ASSERT( header.time_of_first_obs.year == 2001 );
00573   CU_ASSERT( header.time_of_first_obs.month == 3 );
00574   CU_ASSERT( header.time_of_first_obs.day == 24 );
00575   CU_ASSERT( header.time_of_first_obs.hour == 13 );
00576   CU_ASSERT( header.time_of_first_obs.minute == 10 );
00577   CU_ASSERT( header.time_of_first_obs.seconds == 36.0 );
00578   CU_ASSERT( header.time_of_first_obs.time_system == RINEX_TIME_SYSTEM_GPS );
00579 
00580   { 
00581     fid = fopen( "www.ngs.noaa.gov_CORS_rinex210.txt", "r" );
00582     CU_ASSERT_FATAL( fid != NULL );
00583 
00584     while( !feof(fid) )
00585     {
00586       if( fgets( linebuf, 8192, fid ) == NULL )
00587         break;
00588       if( strstr( linebuf, "END OF HEADER" ) != NULL )
00589         break;
00590     }
00591 
00592     if( feof(fid) || ferror(fid) != 0 )
00593       return;
00594    
00595     // Get the first observation set.
00596     result = RINEX_GetNextObservationSet(
00597       fid,
00598       &header,
00599       &wasEndOfFileReached,
00600       &wasObservationFound,
00601       &filePosition,
00602       obsArray,
00603       24,
00604       &nrObs
00605       );
00606     CU_ASSERT_FATAL( result );
00607 
00608     
00609     CU_ASSERT_FATAL( nrObs == 6 ); // L1, and L2 for 3 satellites.
00610 
00611     for( i = 0; i < nrObs; i++ )
00612     {
00613       CU_ASSERT( obsArray[i].system == GNSS_GPS );
00614       CU_ASSERT( obsArray[i].codeType == GNSS_PCode );      
00615     }
00616     i = 0;
00617     CU_ASSERT( obsArray[i].id == 12 );
00618     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00619     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23629347.915, 1e-03 );
00620     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr,.300, 1e-03 );
00621     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 44.5, 1e-01 );
00622     i++;
00623     CU_ASSERT( obsArray[i].id == 12 );
00624     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00625     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23629364.158, 1e-03 );
00626     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr,-0.353, 1e-03 );
00627     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00628 
00629     i++;
00630     CU_ASSERT( obsArray[i].id == 9 );
00631     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00632     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20891534.648, 1e-03 );
00633     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -.120, 1e-03 );
00634     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 50.0, 1e-01 );
00635     i++;
00636     CU_ASSERT( obsArray[i].id == 9 );
00637     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00638     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20891541.292, 1e-03 );
00639     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -.358, 1e-03 );
00640     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00641 
00642     i++;
00643     CU_ASSERT( obsArray[i].id == 6 );
00644     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00645     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20607600.189, 1e-03 );
00646     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -.430, 1e-03 );
00647     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 50.0, 1e-01 );
00648     i++;
00649     CU_ASSERT( obsArray[i].id == 6 );
00650     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00651     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20607605.848, 1e-03 );
00652     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, .394, 1e-03 );
00653     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00654 
00655     result = TIMECONV_GetUTCTimeFromGPSTime( 
00656       obsArray[0].week, 
00657       obsArray[0].tow+23629347.915/LIGHTSPEED, 
00658       &utc.year,
00659       &utc.month,
00660       &utc.day,
00661       &utc.hour,
00662       &utc.minute,
00663       &utc.seconds
00664       );
00665     utc.seconds += 13; // no utc offset in RINEX time.
00666     CU_ASSERT_FATAL( result );
00667     CU_ASSERT( utc.year == 2001 );
00668     CU_ASSERT( utc.month == 3 );
00669     CU_ASSERT( utc.day == 24 );
00670     CU_ASSERT( utc.hour == 13 );
00671     CU_ASSERT( utc.minute == 10 );
00672     CU_ASSERT_DOUBLE_EQUAL( utc.seconds, 36.0, 1e-01 );
00673 
00674     result = TIMECONV_GetUTCTimeFromGPSTime( 
00675       obsArray[5].week, 
00676       obsArray[5].tow+20607605.848/LIGHTSPEED + 13,  // + 13 since there is no utc offset in RINEX time.
00677       &utc.year,
00678       &utc.month,
00679       &utc.day,
00680       &utc.hour,
00681       &utc.minute,
00682       &utc.seconds
00683       );
00684     CU_ASSERT_FATAL( result );
00685     CU_ASSERT( utc.year == 2001 );
00686     CU_ASSERT( utc.month == 3 );
00687     CU_ASSERT( utc.day == 24 );
00688     CU_ASSERT( utc.hour == 13 );
00689     CU_ASSERT( utc.minute == 10 );
00690     CU_ASSERT_DOUBLE_EQUAL( utc.seconds, 36.0, 1e-01 );
00691 
00692 
00693     // Get the next observation set.
00694     result = RINEX_GetNextObservationSet(
00695       fid,
00696       &header,
00697       &wasEndOfFileReached,
00698       &wasObservationFound,
00699       &filePosition,
00700       obsArray,
00701       24,
00702       &nrObs
00703       );
00704     CU_ASSERT_FATAL( result );
00705     
00706     CU_ASSERT_FATAL( nrObs == 8 ); // L1, and L2 for 3 satellites and two L1 for GLONASS.
00707 
00708     i = 0;
00709     CU_ASSERT( obsArray[i].id == 12 );
00710     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00711     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00712     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00713     CU_ASSERT( obsArray[i].channel == i );
00714     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23619095.450, 1e-03 );
00715     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -53875.632, 1e-03 );
00716     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 44.5, 1e-01 );
00717     i++;
00718     CU_ASSERT( obsArray[i].id == 12 );
00719     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00720     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00721     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00722     CU_ASSERT( obsArray[i].channel == i );
00723     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23619112.008, 1e-03 );
00724     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -41981.375, 1e-03 );
00725     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00726     i++;
00727     CU_ASSERT( obsArray[i].id == 9 );
00728     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00729     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00730     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00731     CU_ASSERT( obsArray[i].channel == i );
00732     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20886075.667, 1e-03 );
00733     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -28688.027, 1e-03 );
00734     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 50.0, 1e-01 );
00735     i++;
00736     CU_ASSERT( obsArray[i].id == 9 );
00737     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00738     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00739     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00740     CU_ASSERT( obsArray[i].channel == i );
00741     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20886082.101, 1e-03 );
00742     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -22354.535, 1e-03 );
00743     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00744     i++;
00745     CU_ASSERT( obsArray[i].id == 6 );
00746     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00747     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00748     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00749     CU_ASSERT( obsArray[i].channel == i );
00750     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20611072.689, 1e-03 );
00751     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 18247.789, 1e-03 );
00752     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 50.0, 1e-01 );
00753     i++;
00754     CU_ASSERT( obsArray[i].id == 6 );
00755     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00756     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00757     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00758     CU_ASSERT( obsArray[i].channel == i );
00759     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20611078.410, 1e-03 );
00760     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 14219.770, 1e-03 );
00761     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00762     i++;
00763     CU_ASSERT( obsArray[i].id == 21 );
00764     CU_ASSERT( obsArray[i].system == GNSS_GLONASS );
00765     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00766     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00767     CU_ASSERT( obsArray[i].channel == i );
00768     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21345678.576, 1e-03 );
00769     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 12345.567, 1e-03 );
00770     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 28.0, 1e-01 );
00771     i++;
00772     CU_ASSERT( obsArray[i].id == 22 );
00773     CU_ASSERT( obsArray[i].system == GNSS_GLONASS );
00774     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00775     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00776     CU_ASSERT( obsArray[i].channel == i );
00777     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 22123456.789, 1e-03 );
00778     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 23456.789, 1e-03 );
00779     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 28.0, 1e-01 );
00780 
00781 
00782     // Get the next observation set.
00783     result = RINEX_GetNextObservationSet(
00784       fid,
00785       &header,
00786       &wasEndOfFileReached,
00787       &wasObservationFound,
00788       &filePosition,
00789       obsArray,
00790       24,
00791       &nrObs
00792       );
00793     CU_ASSERT_FATAL( result );
00794     
00795     CU_ASSERT_FATAL( nrObs == 8 ); // L1, and L2 for 3 satellites and two L1 for GLONASS.
00796 
00797     i = 0;
00798     CU_ASSERT( obsArray[i].id == 16 );
00799     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00800     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00801     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00802     CU_ASSERT( obsArray[i].channel == i );
00803     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21110991.756, 1e-03 );
00804     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 16119.980, 1e-03 );
00805     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );
00806     i++;
00807     CU_ASSERT( obsArray[i].id == 16 );
00808     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00809     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00810     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00811     CU_ASSERT( obsArray[i].channel == i );
00812     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21110998.441, 1e-03 );
00813     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 12560.510, 1e-03 );
00814     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00815     i++;
00816     CU_ASSERT( obsArray[i].id == 12 );
00817     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00818     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00819     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00820     CU_ASSERT( obsArray[i].channel == i );
00821     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23588424.398, 1e-03 );
00822     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -215050.557, 1e-03 );
00823     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 33.5, 1e-01 );
00824     i++;
00825     CU_ASSERT( obsArray[i].id == 12 );
00826     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00827     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00828     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00829     CU_ASSERT( obsArray[i].channel == i );
00830     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23588439.570, 1e-03 );
00831     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -167571.734, 1e-03 );
00832     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00833     i++;
00834     CU_ASSERT( obsArray[i].id == 9 );
00835     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00836     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00837     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00838     CU_ASSERT( obsArray[i].channel == i );
00839     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20869878.790, 1e-03 );
00840     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -113803.187, 1e-03 );
00841     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 44.5, 1e-01 );
00842     i++;
00843     CU_ASSERT( obsArray[i].id == 9 );
00844     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00845     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00846     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00847     CU_ASSERT( obsArray[i].channel == i );
00848     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20869884.938, 1e-03 );
00849     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -88677.926, 1e-03 );
00850     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00851     i++;
00852     CU_ASSERT( obsArray[i].id == 6 );
00853     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00854     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00855     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00856     CU_ASSERT( obsArray[i].channel == i );
00857     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20621643.727, 1e-03 );
00858     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 73797.462, 1e-03 );
00859     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );
00860     i++;
00861     CU_ASSERT( obsArray[i].id == 6 );
00862     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00863     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00864     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00865     CU_ASSERT( obsArray[i].channel == i );
00866     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20621649.276, 1e-03 );
00867     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 57505.177, 1e-03 );
00868     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 32.0, 1e-01 );
00869     i++;
00870     
00871 
00872     // Get the next observation set.
00873     result = RINEX_GetNextObservationSet(
00874       fid,
00875       &header,
00876       &wasEndOfFileReached,
00877       &wasObservationFound,
00878       &filePosition,
00879       obsArray,
00880       24,
00881       &nrObs
00882       );
00883     CU_ASSERT_FATAL( result );
00884 
00885     // confirm that the marker name has changed
00886     CU_ASSERT( strcmp( header.marker_name, "A 9081" ) == 0 );
00887 
00888     // confirm that the antenna height has changed
00889     CU_ASSERT_DOUBLE_EQUAL( header.antenna_delta_h, 0.999, 1e-02 );
00890     
00891     CU_ASSERT_FATAL( nrObs == 8 ); // L1, and L2 for 3 satellites and two L1 for GLONASS.
00892 
00893     i = 0;
00894     CU_ASSERT( obsArray[i].id == 16 );
00895     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00896     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00897     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00898     CU_ASSERT( obsArray[i].channel == i );
00899     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21112589.384, 1e-03 );
00900     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 24515.877, 1e-03 );
00901     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 33.5, 1e-01 );
00902     i++;
00903     CU_ASSERT( obsArray[i].id == 16 );
00904     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00905     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00906     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00907     CU_ASSERT( obsArray[i].channel == i );
00908     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21112596.187, 1e-03 );
00909     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 19102.763, 1e-03 );
00910     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 17.0, 1e-01 );
00911     i++;
00912     CU_ASSERT( obsArray[i].id == 12 );
00913     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00914     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00915     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00916     CU_ASSERT( obsArray[i].channel == i );
00917     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23578228.338, 1e-03 );
00918     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -268624.234, 1e-03 );
00919     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );
00920     i++;
00921     CU_ASSERT( obsArray[i].id == 12 );
00922     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00923     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00924     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00925     CU_ASSERT( obsArray[i].channel == i );
00926     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23578244.398, 1e-03 );
00927     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -209317.284, 1e-03 );
00928     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 22.5, 1e-01 );
00929     i++;
00930     CU_ASSERT( obsArray[i].id == 6 );
00931     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00932     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00933     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00934     CU_ASSERT( obsArray[i].channel == i );
00935     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20625218.088, 1e-03 );
00936     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 92581.207, 1e-03 );
00937     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );
00938     i++;
00939     CU_ASSERT( obsArray[i].id == 6 );
00940     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00941     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00942     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00943     CU_ASSERT( obsArray[i].channel == i );
00944     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20625223.795, 1e-03 );
00945     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 72141.846, 1e-03 );
00946     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 22.5, 1e-01 );
00947     i++;
00948     CU_ASSERT( obsArray[i].id == 9 );
00949     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00950     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00951     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00952     CU_ASSERT( obsArray[i].channel == i );
00953     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20864539.693, 1e-03 );
00954     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -141858.836, 1e-03 );
00955     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 44.5, 1e-01 );
00956     i++;
00957     CU_ASSERT( obsArray[i].id == 9 );
00958     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00959     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00960     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00961     CU_ASSERT( obsArray[i].channel == i );
00962     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20864545.943, 1e-03 );
00963     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -110539.435, 1e-03 );
00964     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 28.0, 1e-01 );
00965     i++;
00966 
00967 
00968     // Get the next observation set.
00969     result = RINEX_GetNextObservationSet(
00970       fid,
00971       &header,
00972       &wasEndOfFileReached,
00973       &wasObservationFound,
00974       &filePosition,
00975       obsArray,
00976       24,
00977       &nrObs
00978       );
00979     CU_ASSERT_FATAL( result );
00980 
00981     CU_ASSERT_FATAL( nrObs == 8 ); // L1, and L2 for 3 satellites and two L1 for GLONASS.
00982 
00983     i = 0;
00984     CU_ASSERT( obsArray[i].id == 16 );
00985     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00986     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
00987     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00988     CU_ASSERT( obsArray[i].channel == i );
00989     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21124965.133, 1e-03 );
00990     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 89551.302, 1e-03 );
00991     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 33.5, 1e-01 );
00992     CU_ASSERT( obsArray[i].flags.isNoCycleSlipDetected == FALSE );
00993     i++;
00994     CU_ASSERT( obsArray[i].id == 16 );
00995     CU_ASSERT( obsArray[i].system == GNSS_GPS );
00996     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
00997     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
00998     CU_ASSERT( obsArray[i].channel == i );
00999     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21124972.275, 1e-03 );
01000     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 69779.626, 1e-03 );
01001     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 22.5, 1e-01 );
01002     CU_ASSERT( obsArray[i].flags.isNoCycleSlipDetected == FALSE );
01003     i++;
01004     CU_ASSERT( obsArray[i].id == 12 );
01005     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01006     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
01007     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01008     CU_ASSERT( obsArray[i].channel == i );
01009     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23507272.372, 1e-03 );
01010     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -212616.150, 1e-03 );
01011     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );    
01012     i++;
01013     CU_ASSERT( obsArray[i].id == 12 );
01014     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01015     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
01016     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01017     CU_ASSERT( obsArray[i].channel == i );
01018     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23507288.421, 1e-03 );
01019     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -165674.789, 1e-03 );
01020     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 28, 1e-01 );    
01021     i++;
01022     CU_ASSERT( obsArray[i].id == 9 );
01023     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01024     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
01025     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01026     CU_ASSERT( obsArray[i].channel == i );
01027     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20828010.354, 1e-03 );
01028     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -333820.093, 1e-03 );
01029     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 33.5, 1e-01 );    
01030     i++;
01031     CU_ASSERT( obsArray[i].id == 9 );
01032     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01033     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
01034     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01035     CU_ASSERT( obsArray[i].channel == i );
01036     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20828017.129, 1e-03 );
01037     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -260119.395, 1e-03 );
01038     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 28.0, 1e-01 );    
01039     i++;
01040     CU_ASSERT( obsArray[i].id == 6 );
01041     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01042     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
01043     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01044     CU_ASSERT( obsArray[i].channel == i );
01045     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20650944.902, 1e-03 );
01046     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 227775.130, 1e-03 );
01047     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );    
01048     i++;
01049     CU_ASSERT( obsArray[i].id == 6 );
01050     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01051     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
01052     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01053     CU_ASSERT( obsArray[i].channel == i );
01054     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20650950.363, 1e-03 );
01055     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 177487.651, 1e-03 );
01056     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 22.5, 1e-01 );    
01057     i++;    
01058 
01059 
01060     // Get the next observation set.
01061     result = RINEX_GetNextObservationSet(
01062       fid,
01063       &header,
01064       &wasEndOfFileReached,
01065       &wasObservationFound,
01066       &filePosition,
01067       obsArray,
01068       24,
01069       &nrObs
01070       );
01071     CU_ASSERT_FATAL( result );
01072 
01073     CU_ASSERT_FATAL( nrObs == 0 ); // Cycle slip observation records which are not processed yet.
01074 
01075 
01076     // Get the next observation set.
01077     result = RINEX_GetNextObservationSet(
01078       fid,
01079       &header,
01080       &wasEndOfFileReached,
01081       &wasObservationFound,
01082       &filePosition,
01083       obsArray,
01084       24,
01085       &nrObs
01086       );
01087     CU_ASSERT_FATAL( result );
01088 
01089     CU_ASSERT_FATAL( nrObs == 8 ); // L1 and L2 for 4 GPS satellites.
01090 
01091     result = TIMECONV_GetUTCTimeFromGPSTime( 
01092       obsArray[i].week, 
01093       obsArray[0].tow+obsArray[0].psr/LIGHTSPEED + 13, // +13 since there is no utc offset in RINEX time.
01094       &utc.year,
01095       &utc.month,
01096       &utc.day,
01097       &utc.hour,
01098       &utc.minute,
01099       &utc.seconds );
01100     CU_ASSERT_FATAL( result );
01101     CU_ASSERT( utc.year == 2001 );
01102     CU_ASSERT( utc.month == 3 );
01103     CU_ASSERT( utc.day == 24 );
01104     CU_ASSERT( utc.hour == 13 );
01105     CU_ASSERT( utc.minute == 14 );
01106     CU_ASSERT_DOUBLE_EQUAL( utc.seconds, 48.0, 1e-01 );
01107 
01108     i=0;
01109     CU_ASSERT( obsArray[i].id == 16 );
01110     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01111     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
01112     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01113     CU_ASSERT( obsArray[i].channel == i );
01114     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21128884.159, 1e-03 );
01115     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 110143.144, 1e-03 );
01116     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );    
01117     i++;    
01118     CU_ASSERT( obsArray[i].id == 16 );
01119     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01120     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
01121     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01122     CU_ASSERT( obsArray[i].channel == i );
01123     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 21128890.7764, 1e-03 );
01124     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 85825.18545, 1e-03 );
01125     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 28.0, 1e-01 );    
01126     i++;    
01127     CU_ASSERT( obsArray[i].id == 12 );
01128     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01129     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
01130     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01131     CU_ASSERT( obsArray[i].channel == i );
01132     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23487131.045, 1e-03 );
01133     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -318463.297, 1e-03 );
01134     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );    
01135     i++;    
01136     CU_ASSERT( obsArray[i].id == 12 );
01137     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01138     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
01139     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01140     CU_ASSERT( obsArray[i].channel == i );
01141     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 23487146.149, 1e-03 );
01142     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -248152.72824, 1e-03 );
01143     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 22.5, 1e-01 );    
01144     i++;    
01145     CU_ASSERT( obsArray[i].id == 9 );
01146     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01147     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
01148     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01149     CU_ASSERT( obsArray[i].channel == i );
01150     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20817844.743, 1e-03 );
01151     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -387242.571, 1e-03 );
01152     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 33.5, 1e-01 );    
01153     i++;    
01154     CU_ASSERT( obsArray[i].id == 9 );
01155     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01156     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
01157     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01158     CU_ASSERT( obsArray[i].channel == i );
01159     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20817851.322, 1e-03 );
01160     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, -301747.22925, 1e-03 );
01161     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 28.0, 1e-01 );    
01162     i++;    
01163     CU_ASSERT( obsArray[i].id == 6 );
01164     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01165     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL1 );
01166     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01167     CU_ASSERT( obsArray[i].channel == i );
01168     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20658519.895, 1e-03 );
01169     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 267583.67817, 1e-03 );
01170     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 39.0, 1e-01 );    
01171     CU_ASSERT( obsArray[i].flags.isNoCycleSlipDetected == FALSE );
01172     i++;    
01173     CU_ASSERT( obsArray[i].id == 6 );
01174     CU_ASSERT( obsArray[i].system == GNSS_GPS );
01175     CU_ASSERT( obsArray[i].freqType == GNSS_GPSL2 );
01176     CU_ASSERT( obsArray[i].codeType == GNSS_PCode );
01177     CU_ASSERT( obsArray[i].channel == i );
01178     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].psr, 20658525.869, 1e-03 );
01179     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].adr, 208507.26234, 1e-03 );
01180     CU_ASSERT_DOUBLE_EQUAL( obsArray[i].cno, 22.5, 1e-01 );    
01181     i++;    
01182 
01183     fclose(fid);
01184   }   
01185 }
01186 
01187 
01188 void test_RINEX_DecodeGPSNavigationFile(void)
01189 {
01190   BOOL result;
01191   GNSS_structKlobuchar iono_model;
01192   GPS_structEphemeris ephemeris_array[512];
01193   unsigned length_ephemeris_array = 0;
01194   unsigned i = 0;
01195 
01196   struct_utc utc;
01197 
01198   result = RINEX_DecodeGPSNavigationFile(
01199     "aira0010.07n",
01200     &iono_model,
01201     ephemeris_array,
01202     512,
01203     &length_ephemeris_array
01204     );
01205 
01206   CU_ASSERT_FATAL( result );
01207   CU_ASSERT_FATAL( length_ephemeris_array == 333 );
01208 
01209   CU_ASSERT( iono_model.isValid == TRUE );
01210   CU_ASSERT( iono_model.week == 1408 )
01211   CU_ASSERT( iono_model.tow == 233472 ); 
01212 
01213   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha0, 7.4506E-09, 1e-13 );
01214   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha1, -1.4901E-08, 1e-13 );
01215   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha2, -5.9605E-08, 1e-13 );
01216   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha3, 1.1921E-07, 1e-13 );
01217 
01218   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta0, 9.0112E+04, 1e-13 );
01219   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta1, -6.5536E+04, 1e-13 );
01220   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta2, -1.3107E+05, 1e-13 );
01221   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta3, 4.5875E+05, 1e-13 );
01222 
01223   // examine the first record
01224   /*
01225   13 07  1  1  0  0  0.0 1.281178556383E-04 3.979039320257E-12 0.000000000000E+00
01226     2.390000000000E+02-1.053750000000E+02 3.802301140610E-09 1.191964944844E+00
01227    -5.604699254036E-06 2.938966266811E-03 2.777203917503E-06 5.153674734116E+03
01228     8.640000000000E+04-9.499490261078E-08-1.452396007335E+00 1.117587089539E-08
01229     9.933681219067E-01 3.428125000000E+02 1.254085410171E+00-7.978189664470E-09
01230    -3.142988092009E-10 1.000000000000E+00 1.408000000000E+03 0.000000000000E+00
01231     2.000000000000E+00 0.000000000000E+00-1.117587089539E-08 2.390000000000E+02
01232     8.149800000000D+04 4.000000000000D+00
01233   */
01234 
01235   result = TIMECONV_GetUTCTimeFromGPSTime(
01236     ephemeris_array[0].week,
01237     ephemeris_array[0].toe+14, // no utc offset in RINEX time.
01238     &utc.year,
01239     &utc.month,
01240     &utc.day,
01241     &utc.hour,
01242     &utc.minute,
01243     &utc.seconds 
01244     );
01245   CU_ASSERT_FATAL( result );
01246   CU_ASSERT( utc.year == 2007 );
01247   CU_ASSERT( utc.month == 1 );
01248   CU_ASSERT( utc.day == 1 );
01249   CU_ASSERT( utc.hour == 0 );
01250   CU_ASSERT( utc.minute == 0 );
01251   CU_ASSERT_DOUBLE_EQUAL( utc.seconds, 0.0, 1e-2 );
01252 
01253   CU_ASSERT( ephemeris_array[0].prn == 13 );
01254   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].af0, 1.281178556383E-04, 1e-15 );
01255   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].af1, 3.979039320257E-12, 1e-23 );
01256   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].af2, 0.000000000000E+00, 1e-10 );
01257 
01258   CU_ASSERT( ephemeris_array[0].iode == 239 );
01259   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].crs, -1.053750000000E+02, 1e-07 );
01260   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].delta_n, 3.802301140610E-09, 1e-20 );
01261   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].m0, 1.191964944844E+00, 1e-12 );
01262 
01263   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].cuc, -5.604699254036E-06, 1e-17 );
01264   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].ecc, 2.938966266811E-03, 1e-15 );
01265   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].cus, 2.777203917503E-06, 1e-17 );
01266   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].sqrta, 5.153674734116E+03, 1e-09 );
01267 
01268   CU_ASSERT( ephemeris_array[0].toe == 86400 );
01269   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].cic, -9.499490261078E-08, 1e-19 );
01270   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].omega0, -1.452396007335E+00, 1e-12 );
01271   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].cis, 1.117587089539E-08, 1e-19 );
01272 
01273   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].i0, 9.933681219067E-01, 1e-13 );
01274   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].crc, 3.428125000000E+02, 1e-10 );
01275   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].w, 1.254085410171E+00, 1e-12 );
01276   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].omegadot, -7.978189664470E-09, 1e-20 );
01277 
01278   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].idot, -3.142988092009E-10, 1e-21 );
01279   CU_ASSERT( ephemeris_array[0].code_on_L2 == 1 );
01280   CU_ASSERT( ephemeris_array[0].week == 1408 );
01281   CU_ASSERT( ephemeris_array[0].L2_P_data_flag == 0 );
01282 
01283   CU_ASSERT( ephemeris_array[i].ura == 0 );
01284   CU_ASSERT( ephemeris_array[0].health == 0 );
01285   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[0].tgd, -1.117587089539E-08, 1e-19 );
01286   CU_ASSERT( ephemeris_array[0].iodc == 239 );
01287 
01288   CU_ASSERT( ephemeris_array[0].fit_interval_flag == 0 ); // four hours   
01289 
01290   // Test the very last record
01291   /*
01292   27 07  1  2  0  0  0.0 8.633267134428E-05 2.046363078989E-12 0.000000000000E+00
01293     1.630000000000E+02-1.581562500000E+02 3.835874284874E-09-3.001539225745E+00
01294    -8.240342140198E-06 2.041919447947E-02 9.946525096893E-06 5.153800029755E+03
01295     1.728000000000E+05 1.918524503708E-07-4.983656852855E-01-1.359730958939E-07
01296     9.620745223570E-01 1.831562500000E+02-1.862446808648E+00-7.336019791637E-09
01297     8.643217391802E-11 1.000000000000E+00 1.408000000000E+03 0.000000000000E+00
01298     2.800000000000E+00 0.000000000000E+00-4.190951585770E-09 4.190000000000E+02
01299     1.720680000000E+05 4.000000000000E+00
01300   */
01301 
01302   i = length_ephemeris_array-1;
01303   result = TIMECONV_GetUTCTimeFromGPSTime(
01304     ephemeris_array[i].week,
01305     ephemeris_array[i].toe+14, // no utc offset in RINEX time.
01306     &utc.year,
01307     &utc.month,
01308     &utc.day,
01309     &utc.hour,
01310     &utc.minute,
01311     &utc.seconds 
01312     );
01313   CU_ASSERT_FATAL( result );
01314   CU_ASSERT( utc.year == 2007 );
01315   CU_ASSERT( utc.month == 1 );
01316   CU_ASSERT( utc.day == 2 );
01317   CU_ASSERT( utc.hour == 0 );
01318   CU_ASSERT( utc.minute == 0 );
01319   CU_ASSERT_DOUBLE_EQUAL( utc.seconds, 0.0, 1e-2 );
01320 
01321   CU_ASSERT( ephemeris_array[i].prn == 27 );
01322   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af0, 8.633267134428E-05, 1e-15 );
01323   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af1, 2.046363078989E-12, 1e-23 );
01324   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af2, 0.000000000000E+00, 1e-10 );
01325 
01326    
01327   CU_ASSERT( ephemeris_array[i].iode == 163 );
01328   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].crs, -1.581562500000E+02, 1e-07 );
01329   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].delta_n, 3.835874284874E-09, 1e-20 );
01330   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].m0, -3.001539225745E+00, 1e-12 );
01331 
01332   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cuc, -8.240342140198E-06, 1e-17 );
01333   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].ecc, 2.041919447947E-02, 1e-15 );
01334   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cus, 9.946525096893E-06, 1e-17 );
01335   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].sqrta, 5.153800029755E+03, 1e-09 );
01336 
01337   CU_ASSERT( ephemeris_array[i].toe == 172800 );
01338   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cic, 1.918524503708E-07, 1e-19 );
01339   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].omega0, -4.983656852855E-01, 1e-12 );
01340   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cis, -1.359730958939E-07, 1e-19 );
01341 
01342   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].i0, 9.620745223570E-01, 1e-13 );
01343   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].crc, 1.831562500000E+02, 1e-10 );
01344   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].w, -1.862446808648, 1e-12 );
01345   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].omegadot, -7.336019791637E-09, 1e-20 );
01346 
01347   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].idot, 8.643217391802E-11, 1e-21 );
01348   CU_ASSERT( ephemeris_array[i].code_on_L2 == 1 );
01349   CU_ASSERT( ephemeris_array[i].week == 1408 );
01350   CU_ASSERT( ephemeris_array[i].L2_P_data_flag == 0 );
01351 
01352   CU_ASSERT( ephemeris_array[i].ura == 1 );
01353   CU_ASSERT( ephemeris_array[i].health == 0 );
01354   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].tgd, -4.190951585770E-09, 1e-19 );
01355   CU_ASSERT( ephemeris_array[i].iodc == 419 );
01356 
01357   CU_ASSERT( ephemeris_array[i].fit_interval_flag == 0 ); // four hours   
01358 
01359 
01360 
01361   result = RINEX_DecodeGPSNavigationFile(
01362     "AIUB2450.99n",
01363     &iono_model,
01364     ephemeris_array,
01365     512,
01366     &length_ephemeris_array
01367     );
01368 
01369   CU_ASSERT_FATAL( result );
01370   CU_ASSERT_FATAL( length_ephemeris_array == 2 );
01371 
01372   /*
01373   .1676E-07   .2235E-07  -.1192E-06  -.1192E-06          ION ALPHA
01374   .1208E+06   .1310E+06  -.1310E+06  -.1966E+06          ION BETA
01375   */
01376   CU_ASSERT( iono_model.isValid == TRUE );
01377   CU_ASSERT( iono_model.week == 1025 )
01378   CU_ASSERT( iono_model.tow == 552960 ); 
01379 
01380   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha0, .1676E-07, 1e-13 );
01381   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha1, .2235E-07, 1e-13 );
01382   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha2, -.1192E-06, 1e-13 );
01383   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha3, -.1192E-06, 1e-13 );
01384 
01385   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta0, .1208E+06, 1e-13 );
01386   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta1, .1310E+06, 1e-13 );
01387   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta2, -.1310E+06, 1e-13 );
01388   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta3, -.1966E+06, 1e-13 );
01389 
01390   /*
01391   6 99  9  2 17 51 44.0 -.839701388031E-03 -.165982783074E-10  .000000000000E+00
01392      .910000000000E+02  .934062500000E+02  .116040547840E-08  .162092304801E+00
01393      .484101474285E-05  .626740418375E-02  .652112066746E-05  .515365489006E+04
01394      .409904000000E+06 -.242143869400E-07  .329237003460E+00 -.596046447754E-07d
01395      .111541663136E+01  .326593750000E+03  .206958726335E+01 -.638312302555E-08d
01396      .307155651409E-09  .000000000000E+00  .102500000000E+04  .000000000000E+00d
01397      .000000000000E+00  .000000000000E+00  .000000000000E+00  .910000000000E+02
01398      .406800000000E+06  .000000000000E+00
01399      */
01400 
01401   i = 0;
01402   result = TIMECONV_GetUTCTimeFromGPSTime(
01403     ephemeris_array[i].week,
01404     ephemeris_array[i].toe+13, // no utc offset in RINEX time.
01405     &utc.year,
01406     &utc.month,
01407     &utc.day,
01408     &utc.hour,
01409     &utc.minute,
01410     &utc.seconds 
01411     );
01412   CU_ASSERT_FATAL( result );
01413   CU_ASSERT( utc.year == 1999 );
01414   CU_ASSERT( utc.month == 9 );
01415   CU_ASSERT( utc.day == 2 );
01416   CU_ASSERT( utc.hour == 17 );
01417   CU_ASSERT( utc.minute == 51 );
01418   CU_ASSERT_DOUBLE_EQUAL( utc.seconds, 44.0, 1e-2 );
01419 
01420   CU_ASSERT( ephemeris_array[i].prn == 6 );
01421   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af0, -.839701388031E-03, 1e-15 );
01422   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af1, -.165982783074E-10, 1e-23 );
01423   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af2, 0.000000000000E+00, 1e-10 );
01424 
01425   CU_ASSERT( ephemeris_array[i].iode == 91 );
01426   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].crs, .934062500000E+02, 1e-07 );
01427   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].delta_n, .116040547840E-08, 1e-20 );
01428   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].m0, .162092304801E+00, 1e-12 );
01429 
01430   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cuc, .484101474285E-05, 1e-17 );
01431   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].ecc, .626740418375E-02, 1e-15 );
01432   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cus, .652112066746E-05, 1e-17 );
01433   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].sqrta, .515365489006E+04, 1e-09 );
01434      
01435   CU_ASSERT( ephemeris_array[i].toe == 409904 );
01436   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cic, -.242143869400E-07, 1e-19 );
01437   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].omega0, .329237003460E+00, 1e-12 );
01438   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cis, -.596046447754E-07, 1e-19 );
01439 
01440   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].i0, .111541663136E+01, 1e-13 );
01441   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].crc, .326593750000E+03, 1e-10 );
01442   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].w, .206958726335E+01, 1e-12 );
01443   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].omegadot, -.638312302555E-08, 1e-20 );
01444 
01445   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].idot, .307155651409E-09, 1e-21 );
01446   CU_ASSERT( ephemeris_array[i].code_on_L2 == 0 );
01447   CU_ASSERT( ephemeris_array[i].week == 1025 );
01448   CU_ASSERT( ephemeris_array[i].L2_P_data_flag == 0 );
01449   
01450   CU_ASSERT( ephemeris_array[i].ura == 0 );
01451   CU_ASSERT( ephemeris_array[i].health == 0 );
01452   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].tgd, 0.0, 1e-12 );
01453   CU_ASSERT( ephemeris_array[i].iodc == 91 );
01454   
01455   CU_ASSERT( ephemeris_array[i].fit_interval_flag == 0 ); // four hours   
01456 
01457   /*
01458   13 99  9  2 19  0  0.0  .490025617182E-03  .204636307899E-11  .000000000000E+00
01459      .133000000000E+03 -.963125000000E+02  .146970407622E-08  .292961152146E+01
01460     -.498816370964E-05  .200239347760E-02  .928156077862E-05  .515328476143E+04
01461      .414000000000E+06 -.279396772385E-07  .243031939942E+01 -.558793544769E-07
01462      .110192796930E+01  .271187500000E+03 -.232757915425E+01 -.619632953057E-08
01463     -.785747015231E-11  .000000000000E+00  .102500000000E+04  .000000000000E+00
01464      .000000000000E+00  .000000000000E+00  .000000000000E+00  .389000000000E+03
01465      .410400000000E+06  .000000000000E+00
01466      */
01467 
01468   i = 1;
01469   result = TIMECONV_GetUTCTimeFromGPSTime(
01470     ephemeris_array[i].week,
01471     ephemeris_array[i].toe+13.00001, // no utc offset in RINEX time.
01472     &utc.year,
01473     &utc.month,
01474     &utc.day,
01475     &utc.hour,
01476     &utc.minute,
01477     &utc.seconds 
01478     );
01479   CU_ASSERT_FATAL( result );
01480   CU_ASSERT( utc.year == 1999 );
01481   CU_ASSERT( utc.month == 9 );
01482   CU_ASSERT( utc.day == 2 );
01483   CU_ASSERT( utc.hour == 19 );
01484   CU_ASSERT( utc.minute == 0 );
01485   CU_ASSERT_DOUBLE_EQUAL( utc.seconds, 0.0, 1e-2 );
01486 
01487   
01488   CU_ASSERT( ephemeris_array[i].prn == 13 );
01489   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af0, .490025617182E-03, 1e-15 );
01490   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af1, .204636307899E-11, 1e-23 );
01491   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].af2, 0.000000000000E+00, 1e-10 );
01492 
01493   CU_ASSERT( ephemeris_array[i].iode == 133 );
01494   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].crs, -.963125000000E+02, 1e-07 );
01495   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].delta_n, .146970407622E-08, 1e-20 );
01496   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].m0, .292961152146E+01, 1e-12 );
01497 
01498   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cuc, -.498816370964E-05, 1e-17 );
01499   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].ecc, .200239347760E-02, 1e-15 );
01500   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cus, .928156077862E-05, 1e-17 );
01501   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].sqrta, .515328476143E+04, 1e-09 );
01502      
01503   CU_ASSERT( ephemeris_array[i].toe == 414000 );
01504   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cic, -.279396772385E-07, 1e-19 );
01505   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].omega0, .243031939942E+01, 1e-12 );
01506   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].cis, -.558793544769E-07, 1e-19 );
01507 
01508   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].i0, .110192796930E+01, 1e-13 );
01509   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].crc, .271187500000E+03, 1e-10 );
01510   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].w, -.232757915425E+01, 1e-12 );
01511   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].omegadot, -.619632953057E-08, 1e-20 );
01512 
01513   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].idot, -.785747015231E-11, 1e-21 );
01514   CU_ASSERT( ephemeris_array[i].code_on_L2 == 0 );
01515   CU_ASSERT( ephemeris_array[i].week == 1025 );
01516   CU_ASSERT( ephemeris_array[i].L2_P_data_flag == 0 );
01517   
01518   CU_ASSERT( ephemeris_array[i].ura == 0 );
01519   CU_ASSERT( ephemeris_array[i].health == 0 );
01520   CU_ASSERT_DOUBLE_EQUAL( ephemeris_array[i].tgd, 0.0, 1e-12 );
01521   CU_ASSERT( ephemeris_array[i].iodc == 389 );
01522   
01523   CU_ASSERT( ephemeris_array[i].fit_interval_flag == 0 ); // four hours   
01524 }
01525 
01526 
01527 
01528 
01529 void test_RINEX_GetKlobucharIonoParametersFromNavFile(void)
01530 {
01531   BOOL result;
01532   GNSS_structKlobuchar iono_model;
01533 
01534   result = RINEX_GetKlobucharIonoParametersFromNavFile( "aira0010.07n", &iono_model );
01535 
01536   CU_ASSERT_FATAL( result );
01537 
01538   CU_ASSERT( iono_model.isValid == TRUE );
01539   CU_ASSERT( iono_model.week == 1408 )
01540   CU_ASSERT( iono_model.tow == 233472 ); 
01541 
01542   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha0, 7.4506E-09, 1e-13 );
01543   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha1, -1.4901E-08, 1e-13 );
01544   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha2, -5.9605E-08, 1e-13 );
01545   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha3, 1.1921E-07, 1e-13 );
01546 
01547   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta0, 9.0112E+04, 1e-13 );
01548   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta1, -6.5536E+04, 1e-13 );
01549   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta2, -1.3107E+05, 1e-13 );
01550   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta3, 4.5875E+05, 1e-13 );
01551 
01552   result = RINEX_GetKlobucharIonoParametersFromNavFile( "AIUB2450.99n", &iono_model );
01553 
01554   CU_ASSERT_FATAL( result );
01555 
01556   /*
01557   .1676E-07   .2235E-07  -.1192E-06  -.1192E-06          ION ALPHA
01558   .1208E+06   .1310E+06  -.1310E+06  -.1966E+06          ION BETA
01559   */
01560   CU_ASSERT( iono_model.isValid == TRUE );
01561   CU_ASSERT( iono_model.week == 1025 )
01562   CU_ASSERT( iono_model.tow == 552960 ); 
01563 
01564   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha0, .1676E-07, 1e-13 );
01565   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha1, .2235E-07, 1e-13 );
01566   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha2, -.1192E-06, 1e-13 );
01567   CU_ASSERT_DOUBLE_EQUAL( iono_model.alpha3, -.1192E-06, 1e-13 );
01568 
01569   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta0, .1208E+06, 1e-13 );
01570   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta1, .1310E+06, 1e-13 );
01571   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta2, -.1310E+06, 1e-13 );
01572   CU_ASSERT_DOUBLE_EQUAL( iono_model.beta3, -.1966E+06, 1e-13 );
01573 }
01574 
01575 
01576