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

📄 tide_cor.c

📁 GPS详尽的代码
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <graphics.h>
#include <math.h>
#include <string.h>
#include <process.h>
main ()
{
char filname[30],*kch,*start,*end,line[90];
char filname1[30],kcc,kcd,gap[4];
char filname2[30],filename3[30],filename4[30];
FILE *fin,*fin1,*fin2;
int i,th,tm,ts,ii,iii,ii1,ii4,ii5,ii6,ii7,ii8,ii9,wang,ii2,scale;
double ttt,jj,j,x[1000],y[1000],h[1000],h1[1000],t[1000],tt[1000],hh[1000],hhh,dist[1000],pids[1000],tth,ttm,tts,liht;
int driver,mode;
driver=DETECT;
wang=0;mode=0;kcd=' ';
initgraph(&driver,&mode,"");
cleardevice();
printf ("\n         ***** Correct Hydrographic Data by Tide *****\n \n");
printf ("Please Input Tide Depth filename: ");
q:scanf("%s",&filname1);
if ((fin1=fopen(filname1,"r"))==NULL)
{printf("NOT EXIST,AGAIN: ");goto q;}
printf ("Please Input OUTPUT  filename: ");
qq:scanf("%s",&filname2);
if((fin2=fopen(filname2,"r"))==NULL) goto qqq;
{printf("EXIST OVERWRITE?(Y/N):");
 kcc=getch();
 kcc=toupper(kcc);printf("%c\n",kcc);
 if (kcc=='N') goto qq;}
qqq:if((fin2=fopen(filname2,"w"))==NULL)
{printf("CAN NOT OPEN,AGAIN:");goto qq;}
printf ("Please select relative height or absolute height(R/A) ");
kcd=getch();
kcd=toupper(kcd);
printf("%c\n",kcd);
      i=1;
      while(!feof(fin1))
      {if(fgets(line,80,fin1))
      {
      end=line;
      j=strtod(line,&end);
      start=end;
      hh[i]=strtod(start,&end);
      th=j/10000.0;
      tm=(j-th*10000.0)/100.0;
      ts=j-th*10000.0-tm*100.0;
      tt[i]=th*3600.0+tm*60.0+ts;
      i++;}}
      ii=i-1;
      fclose(fin1);
      i=1;

wee:  printf ("Please input GPS/Depth filename: ");
weee:      scanf("%s",&filname);
      if ((fin=fopen(filname,"r"))==NULL)
      {printf("NOT EXIST,AGAIN: ");goto weee;}
      i=1;
      printf ("Please input Gap number: ");
      scanf("%s",&gap);
      ii5=atoi(gap);
      if (ii5==0) ii8=2;
      if (ii5!=0) ii8=ii5+3;
      while(!feof(fin))
      {ab: for (ii4=1;ii4<ii8;ii4++)
      {if(fgets(line,80,fin))
      { end=line;
      kch=strchr(line,':');
      if (kch!=0)
      {start=strstr(line,":")+1;
      end=line;
      jj=strtod(start,&end);
      ii1=jj;
      fgets(line,80,fin);
      {if (wang==0) {printf ("Please Input Mapscale Factor : ");
      scanf("%s",&filename3);scale=atoi(filename3);
      wang=1;}
     /* fprintf(fin2,"   LINE: %4i \n",ii1);ii2=1,i=1;
      fprintf(fin2,"   NO       X          Y           H\n");
      printf("LINE %4i \n",ii1);*/

      goto ab;}}
      j=strtod(line,&end);
      start=end;
      ttt=strtod(start,&end);
      start=end;
      x[ii4]=strtod(start,&end)/scale;
      start=end;
      y[ii4]=strtod(start,&end)/scale;
      start=end;
      h[ii4]=strtod(start,&end);
      start=end;
      dist[ii4]=strtod(start,&end);
      start=end;
      pids[ii4]=strtod(start,&end);
      h1[ii4]=h[ii4];
      th=ttt/10000.0;
      tm=(ttt-th*10000.0)/100.0;
      ts=ttt-th*10000.0-tm*100.0;
      t[ii4]=th*3600.0+tm*60.0+ts;
      for (iii=1;iii<ii;iii++)
      {hhh=0;
       if((t[ii4]>=tt[iii])&&(t[ii4]<=tt[iii+1]))
       {hhh=(hh[iii+1]-hh[iii])/(tt[iii+1]-tt[iii]);
       liht=hh[iii]+(t[ii4]-tt[iii])*hhh;
       h[ii4]=-h1[ii4]+liht;
       if (kcd=='R') h[ii4]=-h[ii4];
       }}}}


      {ii4=1;
      fprintf(fin2," %3i%12.3f%12.3f%10.2f\n",i,x[ii4],y[ii4],h[ii4]);
      printf("%5i %10.1f %11.1f%7.2f\n", i,x[ii4],y[ii4],h[ii4]);
      i++; }

      if (ii5>0)
      {ii7=2;
      for (ii6=2;ii6<ii5+2;ii6++)
      {if (h[ii6]>h[ii7]) ii7=ii6;}
       ii9=2;
       for (ii6=2;ii6<ii5+2;ii6++)
      {if (h[ii6]<h[ii9]) ii9=ii6;}
      tth=h[1];
      ttm=h[ii5+2];
      tts=h[ii7];
      if((tts<tth)&&(tts<ttm))
      {ii4=ii7;
      fprintf(fin2," %3i%12.3f%12.3f%10.2f\n",i,x[ii4],y[ii4],
      h[ii4]);
      printf("%5i %10.1f %11.1f%7.2f\n", i,x[ii4],y[ii4],
      h[ii4]);
      i++;}
      tth=h[1];
      ttm=h[ii5+2];
      tts=h[ii9];
      if((tts>tth)&&(tts>ttm))
      {ii4=ii9;
      fprintf(fin2," %3i%12.3f%12.3f%10.2f\n",i,x[ii4],y[ii4],
      h[ii4]);
      printf("%5i %10.1f %11.1f%7.2f\n", i,x[ii4],y[ii4],
      h[ii4]);
      i++;}
      ii4=ii5+2;
      fprintf(fin2," %3i%12.3f%12.3f%10.2f\n",i,x[ii4],y[ii4],
      h1[ii4]);
      printf("%5i %10.1f %11.1f%7.2f\n", i,x[ii4],y[ii4],
      h1[ii4]);
      i++;}
      }

end:  printf("Continue (Y/N)? ");
      kcc=getch();
      kcc=toupper(kcc);printf("%c\n",kcc);
      if (kcc=='Y') goto wee;
 fg:  fclose(fin);
      fclose(fin2);
      restorecrtmode();
}



⌨️ 快捷键说明

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