Example #1
0
/* outrneobsh() */
void utest3(void)
{
    nav_t nav={0};
    
    outrnxobsh(stdout,&opt1,&nav);
    outrnxobsh(stdout,&opt2,&nav);
    
    printf("%s utest3 : OK\n",__FILE__);
}
Example #2
0
/* open output files ---------------------------------------------------------*/
static int openfile(FILE **ofp, char *files[], const char *file,
                    const rnxopt_t *opt, nav_t *nav)
{
    char path[1024];
    int i;
    
    trace(3,"openfile:\n");
    
    for (i=0;i<NOUTFILE;i++) {
        
        if (!*files[i]) continue;
        
        strcpy(path,files[i]);
        
        /* check overwrite input file and modify output file */
        if (!strcmp(path,file)) strcat(path,"_");
        
        /* create directory if not exist */
        createdir(path);
        
        if (!(ofp[i]=fopen(path,"w"))) {
            showmsg("file open error: %s",path);
            for (i--;i>=0;i--) if (ofp[i]) fclose(ofp[i]);
            return 0;
        }
        /* write header to file */
        switch (i) {
            case 0: outrnxobsh (ofp[0],opt,nav); break;
            case 1: outrnxnavh (ofp[1],opt,nav); break;
            case 2: outrnxgnavh(ofp[2],opt,nav); break;
            case 3: outrnxhnavh(ofp[3],opt,nav); break;
            case 4: outrnxqnavh(ofp[4],opt,nav); break;
            case 5: outrnxlnavh(ofp[5],opt,nav); break;
            case 6: outrnxcnavh(ofp[6],opt,nav); break;
        }
    }
    return 1;
}
Example #3
0
/* close output files --------------------------------------------------------*/
static void closefile(FILE **ofp, const rnxopt_t *opt, nav_t *nav)
{
    int i;
    
    trace(3,"closefile:\n");
    
    for (i=0;i<NOUTFILE;i++) {
        
        if (!ofp[i]) continue;
        
        /* rewrite header to file */
        rewind(ofp[i]);
        switch (i) {
            case 0: outrnxobsh (ofp[0],opt,nav); break;
            case 1: outrnxnavh (ofp[1],opt,nav); break;
            case 2: outrnxgnavh(ofp[2],opt,nav); break;
            case 3: outrnxhnavh(ofp[3],opt,nav); break;
            case 4: outrnxqnavh(ofp[4],opt,nav); break;
            case 5: outrnxlnavh(ofp[5],opt,nav); break;
        }
        fclose(ofp[i]);
    }
}
Example #4
0
/* simgal main ---------------------------------------------------------------*/
int main(int argc, char **argv)
{
    FILE *fp;
    rnxopt_t rnxopt={{0}};
    obs_t obs={0};
    nav_t nav={0};
    gtime_t ts={0},te={0};
    double es[]={2000,1,1,0,0,0},ee[]={2000,1,1,0,0,0},tint=30.0;
    double pos[3]={0},rr[3];
    char *infile[16]={0},*outfile="";
    int i,j,n=0,opt=0;
    
    for (i=1;i<argc;i++) {
        if      (!strcmp(argv[i],"-o")&&i+1<argc) outfile=argv[++i];
        else if (!strcmp(argv[i],"-ts")&&i+1<argc) {
            sscanf(argv[++i],"%lf/%lf/%lf %lf:%lf:%lf",es,es+1,es+2,es+3,es+4,es+5);
            ts=epoch2time(es);
        }
        else if (!strcmp(argv[i],"-te")&&i+1<argc) {
            sscanf(argv[++i],"%lf/%lf/%lf %lf:%lf:%lf",ee,ee+1,ee+2,ee+3,ee+4,ee+5);
            te=epoch2time(ee);
        }
        else if (!strcmp(argv[i],"-ti")&&i+1<argc) tint=atof(argv[++i]);
        else if (!strcmp(argv[i],"-r")&&i+3<argc) {
            for (j=0;j<3;j++) pos[j]=atof(argv[++i]); /* lat,lon,hgt */
        }
        else infile[n++]=argv[i];
    }
    if (n<=0) {
        fprintf(stderr,"no input file\n");
        return -1;
    }
    if (!*outfile) {
        fprintf(stderr,"no output file\n");
        return -1;
    }
    if (norm(pos,3)<=0.0) {
        fprintf(stderr,"no receiver pos\n");
        return -1;
    }
    pos[0]*=D2R; pos[1]*=D2R; pos2ecef(pos,rr);
    
    /* read simulated/real rinex nav files */
    readrnx(infile,n,&obs,&nav);
    
    if (nav.n<=0) {
        fprintf(stderr,"no nav data\n");
        return -1;
    }
    /* generate simulated observation data */
    if (!simobs(ts,te,tint,rr,&nav,&obs,opt)) return -1;
    
    /* output rinex obs file */
    if (!(fp=fopen(outfile,"w"))) {
        fprintf(stderr,"error : outfile open %s\n",outfile);
        return -1;
    }
    fprintf(stderr,"saving...: %s\n",outfile);
    strcpy(rnxopt.prog,PROGNAME);
    strcpy(rnxopt.comment[0],"SIMULATED OBS DATA");
    rnxopt.tstart=ts;
    rnxopt.tstart=te;
    rnxopt.navsys=SYS_ALL;
    rnxopt.obstype=OBSTYPE_PR|OBSTYPE_CP|OBSTYPE_SNR;
    rnxopt.freqtype=FREQTYPE_L1|FREQTYPE_L2|FREQTYPE_L5|FREQTYPE_L7;
    for (i=0;i<3;i++) rnxopt.apppos[i]=rr[i];
    
    outrnxobsh(fp,&rnxopt);
    
    for (i=0;i<obs.n;i=j) {
        for (j=i;j<obs.n;j++) {
            if (timediff(obs.data[j].time,obs.data[i].time)>0.001) break;
        }
        outrnxobsb(fp,&rnxopt,obs.data+i,j-i,0);
    }
    fclose(fp);
    return 0;
}