/* cl /AL thinraw.c proj1 filter track 1 /c 100 /b filters 'track.raw' and makes 'tracka.raw' with no vector longer than 100 points. and '/b' means brief. No status will be printed and it will run faster. */ #include #include #include #include "proj1.h" #include "nomouse.h" #define NUM_TYPE 5 #define DEG_RAD 0.01745329251 /* converts degrees to radians */ #define MAX_VAL 15000 #define MAX_DIST 10000.00 FILE *Fpin,*FpV,*FpTxt; double huge Lat[MAX_VAL],huge Lon[MAX_VAL]; struct filetype { char *id; double scale; }F[NUM_TYPE]= { {"0",100.0}, {"A",10.0}, {"B",1.0}, {"C",0.1}, {"D",0.01} }; int Type=0; int CutLong=0; int Count=0; float Thin=1.0; long Num=0,Tnum=0,Limit=13000; /* proj1 */ struct control Constant; char String[10][80]; extern struct projection *Proj; /* end proj1 */ main(argc,argv) int argc; char *argv[]; { int i,j,k,n,il,m; char string1[100],string2[100],filename[40],file[40],string0[100]; int num,segs=0,len,numread,print=0,end_of_file=0; double dist,mindist,coslat,sum=0.0,used=0.0; int pnum; char string[100],cr=0xd,outfile[50],infile[50]; double zscale,lat,lon,x,y,dval; long count=0,lthin=0; float thin=0.0; FILE *fptmp; if(argc<2) { printf("Command Line to Count Points Only:\n"); printf("\n"); printf(" thinraw [raw_name]\n"); printf("\n"); printf("Command Line Process Points:\n"); printf("\n"); printf( " thinraw [in_file] [out_file] [thin_number] \n"); printf(" \n"); printf(" where:\n"); printf(" \n"); printf( " in_file -- input '.raw' file name without file type\n"); printf( " out_file -- name of output file ( type will be made '.v' )\n"); printf( " thin_number -- floating point number of ratio of points to save\n"); printf(" ( must be 1.0 or greater)\n"); printf( " max_pts -- optional resetting of maximum number of points\n"); printf(" ( default is 14,000 )\n"); printf("\n"); exit(0); } else strcpy(file,argv[1]); strcpy(filename,file); strcat(filename,".raw"); Fpin=fopen(filename,"rt"); if(!Fpin) { printf("Could not open file '%s'.\n",filename); exit(0); } strcpy(infile,filename); if(argc<3) { Count=1; printf("Counting points\n"); } if(Count==0) { strcpy(filename,argv[2]); for(k=0;k3) sscanf(argv[3],"%f",&Thin); else { printf("Give thinning value (2 is every other point)\n\n"); scanf("%f",&Thin); } if(argc>4) sscanf(argv[4],"%ld",&Limit); if(Thin<1.0) Thin=1.0; printf("Thinning rate = 1%/%0.2f\n",Thin); } if(Count==0) { fprintf(FpTxt,"# %s converted to %s by program 'thinraw.c'\n", infile,outfile); fptmp=fopen("temp.txt","w+t"); if(!fptmp) { printf("Could not open 'temp.txt' to write projection data.\n"); exit(0); } pnum=choose_projection(&Constant,fptmp); get_constants(&Constant,fptmp); rewind(fptmp); while(fgets(string1,100,fptmp)) fprintf(FpTxt,"# %s",string1); fclose(fptmp); unlink("temp.txt"); printf("Give vertical exaggeration (negative for bathimetry)\n\n"); scanf("%lf",&zscale); } if(Count==0) printf("Thinning rate = 1%/%0.2f or %0.3f%%\n",Thin,1.0/Thin*100.0); if(Count==0) { for(k=0;k100) { printf("String too long.\n"); exit(0); } if(i>=MAX_VAL) { printf("Too many entries in segment %d\n",segs); printf("1st Lat = %lf Lon = %lf\n",Lat[0],Lon[0]); if(print==1) { printf("Too many entries in segment %d\n",segs); printf("1st Lat = %lf Lon = %lf\n",Lat[0],Lon[0]); } exit(0); } sscanf(string1,"%lf",Lat+i); sscanf(string2,"%lf",Lon+i); i+=1; }while(string2[strlen(string2)-1]!='/'&&end_of_file==0); num=i; Num+=num; sum+=num; if(Count==0) { for(i=0;i