⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rinex2.c

📁 GPS导航定位程序
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "includes.h"

/****************************************************************************    
* RINEX-2 file update and manipulation routines.  For further information
* about the Receiver Independent Exchange Format version 2, consult the
* "Proceedings of the Second International Symposium on Precise Positioning
* with the Global Positioning System", Ottawa, Canada, Sept. 3-7, 1990,
* p. 977, "The RINEX format: Current status, future developments", by
* W. Gurtner and G. Mader.  See also the RINEX article in the July 1994
* issue of GPS World.
****************************************************************************/

static char prbuff[90];
static char buff[90];

/****************************************************************************    
* Function: void InsertIntoString(char *Destination, char *Source)
*
* Copy characters from a source string to a destination string, not including 
* the terminating null character.
*
* Input: Destination - pointer to the destination string.
*        Source - pointer to the source string.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void InsertIntoString(char *Dest, char *Src)
{
    while(*Src)
        *Dest++ = *Src++;
}

/****************************************************************************    
* Function: void Rx2IU(void)
*
* If the data is valid, this routine records the currently stored ionospheric 
* model and UTC conversion coefficients to the RINEX navigation file (.N).
*
* Input: None.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void Rx2IU(void)
{
    Checkpoint("Rx2IU",1);

    if(Rx2N==NULL)
        return;                         /* If Rinex2 output is not active. */

    if(ionoutc.vflg)
    {
        PROTECT++;
        memset(prbuff,' ',80);
        prbuff[80]=0;
        sprintf(buff,"  %12.4lE%12.4lE%12.4lE%12.4lE",
                ionoutc.a0,ionoutc.a1,ionoutc.a2,ionoutc.a3);
        InsertIntoString(prbuff,buff);
        strcpy(&prbuff[60],"ION ALPHA");
        fprintf(Rx2N,"%s\n",prbuff);
        Rx2NRecs++;
        memset(prbuff,' ',80);
        prbuff[80]=0;
        sprintf(buff,"  %12.4lE%12.4lE%12.4lE%12.4lE",
                ionoutc.b0,ionoutc.b1,ionoutc.b2,ionoutc.b3);
        InsertIntoString(prbuff,buff);
        strcpy(&prbuff[60],"ION BETA");
        fprintf(Rx2N,"%s\n",prbuff);
        Rx2NRecs++;

        memset(prbuff,' ',80);
        prbuff[80]=0;
        sprintf(buff,"   %19.12lE%19.12lE%9lu%9u",
                ionoutc.A0,ionoutc.A1,ionoutc.tot,ionoutc.wnt);
        InsertIntoString(prbuff,buff);
        strcpy(&prbuff[60],"DELTA-UTC: A0,A1,T,W");
        fprintf(Rx2N,"%s\n",prbuff);
        Rx2NRecs++;

        memset(prbuff,' ',80);
        prbuff[80]=0;
        sprintf(buff,"%6d",ionoutc.dtls);
        InsertIntoString(prbuff,buff);
        strcpy(&prbuff[60],"LEAP SECONDS");
        fprintf(Rx2N,"%s\n",prbuff);
        Rx2NRecs++;

        PROTECT--;
    }
}

/****************************************************************************    
* Function: void Rx2EPH(int prn)
*
* Record the currently stored ephemeris data for a specified satellite to the
* RINEX navigation (.N) file.
*
* Input: prn - the satellite PRN number (1-32).
*
* Output: None.
*
* Return Value: None.
****************************************************************************/
void Rx2EPH(int prn)
{
    int year;                                       /* The ephemeris year. */
    int month;                                     /* The ephemeris month. */
    int day;                                         /* The ephemeris day. */
    int hour;                                       /* The ephemeris hour. */
    int minute;                                   /* The ephemeris minute. */
    int ephem_index ;             /* Index into ephemeris structure array. */

    double second;                                /* The ephemeris second. */

    Checkpoint("Rx2EPH",1);

    if(Rx2N==NULL)
        return;                         /* If Rinex2 output is not active. */

    PROTECT++;

    memset(prbuff,' ',80);
    prbuff[80]=0;
    ephem_index = prn - 1;
    GpsTimeToGregorianDate(ephs[ephem_index].tocwk,ephs[ephem_index].toc,
                           &year,&month,&day,&hour,&minute,&second);
    sprintf(buff,"%2d %02d%3d%3d%3d%3d%5.1lf%19.12lE%19.12lE%19.12lE",
            prn,year%100,month,day,hour,minute,second,ephs[ephem_index].af0,
            ephs[ephem_index].af1,ephs[ephem_index].af2);
    strcpy(prbuff,buff);
    fprintf(Rx2N,"%s\n",prbuff);
    Rx2NRecs++;

    memset(prbuff,' ',80);
    prbuff[80]=0;
    sprintf(buff,"   %19.12lE%19.12lE%19.12lE%19.12lE",
            (double)ephs[ephem_index].iode,ephs[ephem_index].crs,
            ephs[ephem_index].deltan,ephs[ephem_index].m0);
    strcpy(prbuff,buff);
    fprintf(Rx2N,"%s\n",prbuff);
    Rx2NRecs++;

    memset(prbuff,' ',80);
    prbuff[80]=0;
    sprintf(buff,"   %19.12lE%19.12lE%19.12lE%19.12lE",
            ephs[ephem_index].cuc,ephs[ephem_index].ecc,
            ephs[ephem_index].cus,ephs[ephem_index].sqrta);
    strcpy(prbuff,buff);
    fprintf(Rx2N,"%s\n",prbuff);
    Rx2NRecs++;

    memset(prbuff,' ',80);
    prbuff[80]=0;
    sprintf(buff,"   %19.12lE%19.12lE%19.12lE%19.12lE",
            ephs[ephem_index].toe,ephs[ephem_index].cic,
            ephs[ephem_index].om0,ephs[ephem_index].cis);
    strcpy(prbuff,buff);
    fprintf(Rx2N,"%s\n",prbuff);
    Rx2NRecs++;

    memset(prbuff,' ',80);
    prbuff[80]=0;
    sprintf(buff,"   %19.12lE%19.12lE%19.12lE%19.12lE",
            ephs[ephem_index].in0,ephs[ephem_index].crc,
            ephs[ephem_index].olc,ephs[ephem_index].omd);
    strcpy(prbuff,buff);
    fprintf(Rx2N,"%s\n",prbuff);
    Rx2NRecs++;

    memset(prbuff,' ',80);
    prbuff[80]=0;
    sprintf(buff,"   %19.12lE%19.12lE%19.12lE%19.12lE",
            ephs[ephem_index].idot,(double)ephs[ephem_index].codeL2,
            (double)ephs[ephem_index].wkn,(double)ephs[ephem_index].L2Pdata);
    strcpy(prbuff,buff);
    fprintf(Rx2N,"%s\n",prbuff);
    Rx2NRecs++;

    memset(prbuff,' ',80); 
    prbuff[80]=0;
    sprintf(buff,"   %19.12lE%19.12lE%19.12lE%19.12lE",
            (double)ephs[ephem_index].ura,(double)ephs[ephem_index].s1hlth,
            ephs[ephem_index].tgd,(double)ephs[ephem_index].iodc);
    strcpy(prbuff,buff);
    fprintf(Rx2N,"%s\n",prbuff);
    Rx2NRecs++;

    memset(prbuff,' ',80);
    prbuff[80]=0;
    sprintf(buff,"   %19.12lE",(double)ephs[ephem_index].TofXmission);
    strcpy(prbuff,buff);
    fprintf(Rx2N,"%s\n",prbuff);
    Rx2NRecs++;
  
    PROTECT--;
}

/****************************************************************************    
* Function: void Rx2OBS(int y,int m,int d,int hh,int mm,double second,
*                       int EpochFlag,int Nsvs,int obspresent[],int svs[],
*                       double rco,int NObsPerSV,double obs[],int lli[],
*                       int sigstr[])
*
* Record the specified observations in the RINEX observation (.O) file.
*
* Input: int y - Observation (epoch) time, year.
*        int m - Observation (epoch) time, month.
*        int d - Observation (epoch) time, day.
*        int hh - Observation (epoch) time, hour.
*        int mm - Observation (epoch) time, minute.
*        double second - Observation (epoch) time, second.
*        int EpochFlag - 0=OK, 1=power fail, >1=event.
*        int Nsvs - not used (GPS Builder historic).
*        int obspresent[] - Observation present on this channel.
*        int svs[] - PRN numbers for the SV's.
*        double rco - rco = GPS time - epoch time.
*        int NObsPerSV - How many observations per SV.
*        double obs[] - Observations by SV's.
*        int lli[] - Loss of lock indicator, each obs.
*        int sigstr[] - Signal strength, each obs.
*
* Output: None.
*
* Return Value: None.
****************************************************************************/

#pragma warn -par                   /* Suppress variable not used warning. */

void Rx2OBS(int y,int m,int d,int hh,int mm,double second,int EpochFlag,
            int Nsvs,int obspresent[],int svs[],double rco,int NObsPerSV,              
            double obs[],int lli[],int sigstr[])
{
    int observations;                           /* Number of observations. */
    int channel;                                  /* Channel loop counter. */

    Checkpoint("Rx2OBS",1);

    if(Rx2O==NULL)
        return;                         /* If Rinex2 output is not active. */

    PROTECT++;

    memset(prbuff,' ',80);
    prbuff[80]=0;
    observations = 0;
    for(channel=0;channel<MAXCHANNELS;channel++)
    {
        if(obspresent[channel]==TRUE)
        {
            sprintf(buff,"G%2d",svs[channel]);
            InsertIntoString(&prbuff[32+observations*3],buff);
            observations++;
        }
    }
    sprintf(buff,"%3d%3d%3d%3d%3d%11.7lf%3d%3d",y%100,m,d,hh,mm,second,
            EpochFlag,observations);
    InsertIntoString(prbuff,buff);

    sprintf(buff,"%12.9lf",rco);
    strcpy(&prbuff[68],buff);
    fprintf(Rx2O,"%s\n",prbuff);
    Rx2ORecs++;

    for(channel=0;channel<MAXCHANNELS;channel++)
    {
        if(obspresent[channel]==TRUE)
        {
            memset(prbuff,' ',80);
            prbuff[80]=0;
            for(observations=0;observations<NObsPerSV;observations++)
            {
                sprintf(buff,"%14.3lf%d%d",
                        obs[channel*NObsPerSV+observations],
                        lli[channel*NObsPerSV+observations],
                        sigstr[channel*NObsPerSV+observations]);
                strcpy(&prbuff[observations*16],buff);
            }
            prbuff[NObsPerSV*16] = 0;
            fprintf(Rx2O,"%s\n",prbuff);
            Rx2ORecs++;
        }
    }

    PROTECT--;
}
#pragma warn .par                     /* Enable variable not used warning. */

/****************************************************************************    
* Function: void Rx2Comment(char *ch)
*
* Record the specified comment in both the navigation (.N) and observation
* (.O) file.
*
* Input: ch - pointer to the comment string.
*
* Output: None.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -