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

📄 crx2rnx.c

📁 一个可以将gps原始rinex格式文件压缩成d文件的小程序
💻 C
📖 第 1 页 / 共 3 页
字号:
                    p_buff += sprintf(p_buff,"              %c%c",flag[i][j*2],flag[i][j*2+1]);                }            }            if((j+1) == ntype || (rinex_version==2 && (j+1)%5 == 0 ) ){                while(*--p_buff == ' '); p_buff++;  /*** cut spaces ***/                *p_buff++ = '\n';            }        }    }}/*---------------------------------------------------------------------*/void repair(char *s, char *ds){    for(; *s != '\0' && *ds != '\0' ; ds++,s++){        if(*ds == ' ')continue;        if(*ds == '&')            *s = ' ';        else            *s = *ds;    }    if(*ds != '\0') {        sprintf(s,"%s",ds);        for(; *s != '\0' ;s++) {            if(*s == '&') *s = ' ';        }    }}/*---------------------------------------------------------------------*/int  getdiff(data_format *y, data_format *y0, int i0, char *dflag){    int j,length;    char *s,*s1,*s2,line[MAXCLM];    /******************************************/    /****  separate the fields with '\0'   ****/    /******************************************/    if(read_chk_line(line)!=0) return 1;    for(j=0,s=line; j<ntype; s++){        if(*s == '\0') {            j++;            *(s+1) = '\0';        }else if(*s == ' '){            j++;            *s = '\0';        }    }    strcpy(dflag,s);    /************************************/    /*     read the differenced data    */    /************************************/    s1=line;    for(j=0;j<ntype;j++,y++,y0++){        if(*s1 == '\0'){            y->arc_order = -1;      /**** arc_order < 0 means that the feild is blank ****/            y->order = -1;            s1++;        }else{            if(*(s1+1) == '&'){     /**** arc initialization ****/                y->order = -1;                y->arc_order = atoi(s1);                s1 += 2;                if(y->arc_order > MAX_DIFF_ORDER) error_exit(7,line);            }else if(i0 < 0){                if( ! skip ) error_exit(11,line);                fprintf(stderr,"WARNING : New satellite, but data arc is not initialized.\n");                return 1;            }else if(y0->arc_order < 0){                if( ! skip ) error_exit(12,line);                fprintf(stderr,"WARNING : New data sequence but without initialization.\n");                return 1;            }else{                y->order = y0->order;                y->arc_order = y0->arc_order;            }            length=(s2=strchr(s1,'\0'))-s1;            if(*s1 == '-') length--;            if(length < 6){                 y->u[0] = 0;                y->l[0] = atol(s1);            }else{                s = s2-5;                y->l[0] = atol(s); *s = '\0';                y->u[0] = atol(s1);                if(y->u[0] < 0) y->l[0] = -y->l[0];            }            s1 = s2+1;        }    }    return 0;}/*---------------------------------------------------------------------*/void putfield(data_format *y, char *flag){    int  i;    i=y->order;    if(y->u[i]<0 && y->l[i]>0){        y->u[i]++ ; y->l[i] -= 100000 ;    }else if(y->u[i]>0 && y->l[i]<0){        y->u[i]-- ; y->l[i] += 100000 ;    }    if(y->u[i]!=0){                                    /* ex) 123.456  -123.456 */       p_buff += sprintf(p_buff,"%8ld %05.5ld%c%c",y->u[i],labs(y->l[i]),*flag,*(flag+1));       p_buff[-8] = p_buff[-7];       p_buff[-7] = p_buff[-6];    }else{       p_buff += sprintf(p_buff,"         %05.5ld%c%c",labs(y->l[i]),*flag,*(flag+1));       if (p_buff[-7] != '0' ){                        /* ex)  12.345    -2.345 */           p_buff[-8] = p_buff[-7];           p_buff[-7] = p_buff[-6];           if(y->l[i] <0) p_buff[-9]='-';       }else if (p_buff[-6] != '0' ){                  /* ex)   1.234    -1.234 */           p_buff[-7] = p_buff[-6];           p_buff[-8] = (y->l[i] <0)? '-':' ';       }else{                                          /* ex)    .123     -.123 */           p_buff[-7] = (y->l[i] <0)? '-':' ';       }    }    p_buff[-6] = '.';}/*---------------------------------------------------------------------*/void print_clock(long yu, long yl, int shift_clk){    char tmp[8],*p_tmp,*p;    int n,sgn;    if(yu<0 && yl>0){        yu++ ; yl -= 100000000;    }else if(yu>0 && yl<0){        yu-- ; yl += 100000000;    }    /** add ond more digit to handle '-0'(RINEX2) or '-0000'(RINEX3) **/    sgn = (yl<0) ? -1:1;    n=sprintf(tmp,"%0.*ld",shift_clk+1,yu*10+sgn); /** AT LEAST fractional parts are filled with 0 **/    n--;                           /** n: number of digits excluding the additional digit **/    p_tmp=&tmp[n];    *p_tmp='\0';    p_tmp-=shift_clk;       /** pointer to the top of last "shift_clk" digits **/    p_buff += sprintf(p_buff,"  .%s",p_tmp);  /** print last "shift_clk" digits.  **/    if( n > shift_clk ){        p_tmp--;        p=p_buff-shift_clk-2;        *p=*p_tmp;        if( n > shift_clk+1 ){ *(p-1)=*(p_tmp-1); }    }    p_buff += sprintf(p_buff,"%08.8ld\n",labs(yl));}/*---------------------------------------------------------------------*/int  read_chk_line(char *line){    char *p;     nl_count++;    if( fgets(line,MAXCLM,stdin) == NULL ) error_exit(8,line);    if( (p = strchr(line,'\n')) == NULL) {        if( fgetc(stdin) == EOF ) {     /** check if EOF is there **/            error_exit(8,line);        }else{            if( ! skip ) error_exit(13,line);            return 1;        }    }    if( *(p-1) == '\n' )p--;    if( *(p-1) == '\r' )p--;   /*** check DOS CR/LF ***/    *p = '\0';    return 0;}/*---------------------------------------------------------------------*/void error_exit(int error_no, char *string){    if(error_no == 1 ){        fprintf(stderr,"Usage: %s input file [-o output file] [-f] [-s] [-h]\n",string);        fprintf(stderr,"    output file name can be omitted if input file name is *.[yy]d\n");    }else if(error_no == 2 ){        fprintf(stderr,"Usage: %s [file] [-] [-f] [-s] [-h]\n",string);        fprintf(stderr,"    stdin and stdout are used if input file name is not given.\n");    }    if(error_no == 1 || error_no == 2){        fprintf(stderr,"    -  : output to stdout\n");        fprintf(stderr,"    -f : force overwrite of output file\n");        fprintf(stderr,"    -s : skip strange epochs (default:stop with error)\n");        fprintf(stderr,"           This option may be used for salvaging usable data when middle of\n");        fprintf(stderr,"           the Compact RINEX file is missing. The data after the missing part,\n");        fprintf(stderr,"           are, however, useless until the compression operation of all data\n");        fprintf(stderr,"           are initialized at some epoch. Combination with use of -e option\n");        fprintf(stderr,"           of RNX2CRX (ver.4.0 or after) may be effective.\n");        fprintf(stderr,"           Caution : It is assumed that no change in # of data types\n");        fprintf(stderr,"                     happens in the lost part of the data.\n");        fprintf(stderr,"    -h : display help message\n\n");        fprintf(stderr,"    exit code = %d (success)\n",EXIT_SUCCESS);        fprintf(stderr,"              = %d (error)\n",  EXIT_FAILURE);        fprintf(stderr,"              = %d (warning)\n",EXIT_WARNING);        fprintf(stderr,"    [version : %s]\n",VERSION);        exit(EXIT_FAILURE);    }    if(error_no == 3 ){        fprintf(stderr,"ERROR : invalid file name  %s\n",string);        fprintf(stderr,"The extention of the input file name should be [.xxd].\n");        fprintf(stderr,"If the file name doesn't obey this naming convention, use this program as a filter. \n");        fprintf(stderr,"    for example)  cat file.in | %s - > file.out\n",PROGNAME);        exit(EXIT_FAILURE);    }    if(error_no == 4 ){        fprintf(stderr,"ERROR : can't open %s\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 5 ){        fprintf(stderr,"ERROR : The file format is not Compact RINEX or the version of\n");        fprintf(stderr,"        the format is not valid. This software can deal with\n");        fprintf(stderr,"        only Compact RINEX format ver.%s.\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 6 ){        fprintf(stderr,"ERROR at line %ld : exceed maximum number of satellites(%d)\n",nl_count,MAXSAT);        fprintf(stderr,"      start>%s<end\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 7 ){        fprintf(stderr,"ERROR at line %ld : exceed maximum order of difference (%d)\n",nl_count,MAX_DIFF_ORDER);        fprintf(stderr,"      start>%s<end\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 8 ){        fprintf(stderr,"ERROR : The file seems to be trancated in the middle.\n");        fprintf(stderr,"        The conversion is interrupted after reading the line %ld :\n",nl_count);        fprintf(stderr,"      start>%s<end\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 9 ){        fprintf(stderr,"ERROR at line %ld : The arc should be initialized, but not.\n",nl_count);        fprintf(stderr,"      start>%s<end\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 11){        fprintf(stderr,"ERROR at line %ld : New satellite, but data arc is not initialized.\n",nl_count);        fprintf(stderr,"      start>%s<end\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 12){        fprintf(stderr,"ERROR at line %ld : The data feild in previous epoch is blank, but the arc is not initialized.\n",nl_count);        fprintf(stderr,"      start>%s<end\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 13){        fprintf(stderr,"ERROR at line %ld : null character is found in the line or the line is too long (>%d) at line.\n",nl_count,MAXCLM);        fprintf(stderr,"      start>%s<end\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 15 ){        fprintf(stderr,"ERROR : The format version of the original RINEX file is not valid.\n");        fprintf(stderr,"         This software can deal with only (compressed) RINEX format ver.%s.\n",string);        exit(EXIT_FAILURE);    }    if(error_no == 20 ){        fprintf(stderr,"ERROR at line %ld. : A GNSS type not defined in the header is found.\n",nl_count);        fprintf(stderr,"     start>%s<end\n",string);        exit(EXIT_FAILURE);    }}

⌨️ 快捷键说明

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