📄 sck_dule.c
字号:
#include "sv.h"
#include <graphics.h>
#include <conio.h>
#define MaxSats 32
char err_str[64];
static int dinmth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int prn[MaxSats];
double r[MaxSats][24],elev[MaxSats][24],azi[MaxSats][24];
int SatNum, BadSatNum,wn,year,month,day,hour, minute, LatD, LonD;
int DrawPicture(void);
float LatM,LonM, Lat,Lon,H;
double second,gpstime, Get_atan(double z,double y);
void GetElev(double SatX0,double SatY0,double SatZ0,double ObsB,
double ObsL,double ObsH,double *r,double *elev,double *azi);
int GetGPSTime(int year,int month,int day,
int hour,int minute,double second,double *gpstime);
void GetSVPos(SVText *Text,double t,double *X,double *Y,double *Z);
int GetGPSTime(int year,int month,int day,
int hour,int minute,double second,double *gpstime);
int read_RinexEPP( FILE *RinexEPP_file,SVText *snv,
int *year, int *month,int *day,int *hour,int *minute,
double *second,double *gpstime,int *wn);
int main()
{ SVText snv;
FILE *f;
char temp[300];
int flag;
double SatX0,SatY0,SatZ0;
double PAI=3.1415926535898;
double P0=PAI/180.0;
int wn1,year1,month1,day1,hour1, minute1,i,j;
double second1,gpstime1;
printf("Please Input Date(yyyy mm dd):");
scanf("%4i %2i %i",&year,&month,&day);
printf("Please Input local Lat(dd mm.mmmm):");
scanf("%i %f",&LatD,&LatM);
Lat = ((float)LatD + LatM/60.0)*P0;
printf("Please Input local Lon(ddd mm.mmmm):");
scanf("%i %f",&LonD,&LonM);
Lon = ((float)LonD + LonM/60.0)*P0;
printf("Please Input local Height(meter):");
scanf("%f",&H);
/* 读RINEX格式的观测文件 */
if( ( f=fopen("a.98n","ra"))==NULL )
{ printf("cannot open almance.alm file \n"); return 1; }
wn=GetGPSTime(year,month,day,0,0,0.0, &gpstime);
SatNum=0;
rewind(f); for(i=0;i<3;i++) { fgets(temp,200,f); }
for(i=0;i<MaxSats;i++)
{ prn[i]=0;
for(j=0;j<24;j++) { r[i][j]=0.0; elev[i][j]=0.0; azi[i][j]=0.0;} }
do
{ flag=read_RinexEPP(f,&snv,
&year1,&month1,&day1,&hour1,&minute1,&second1,&gpstime1,&wn1);
if(flag==0
{ prn[SatNum] = snv.prn;
for(i=0;i<24;i++) /* 24 小时*/
{ GetSVPos(&snv,(gpstime+i*3600),&SatX0,&SatY0,&SatZ0);
GetElev(SatX0,SatY0,SatZ0, Lat,Lon,H,
&r[SatNum][i], &elev[SatNum][i], &azi[SatNum][i]);}
SatNum++; }
}while(flag!= 1);
DrawPicture();
fclose( f ); return 0;}
int DrawPicture(void)
{ int gdriver = DETECT, gmode, errorcode;
struct linesettingstype lineinfo;
struct textsettingstype textinfo;
int txwd, txht, gridx, gridy,startx, endx, starty, endy, i,j;
char PRN[10],time[10],text[50];
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:"); getch();
exit(1); }
gotoxy(0,0);
getlinesettings(&lineinfo);
gettextsettings(&textinfo);
txht = textheight("W"); txwd = textwidth("W");
startx = txwd * (5+1) +20; gridx =(int) ( getmaxx() - startx - 10 )/24;
endx = startx + 24 * gridx;
starty = txht + 20 + 10; gridy = (int)( getmaxy() - starty - 20) /MaxSats;
endy = starty + 24 * gridy;
setlinestyle(SOLID_LINE,1,NORM_WIDTH);
rectangle(startx,starty,endx,endy);
setlinestyle(CENTER_LINE,1,NORM_WIDTH);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
/* 显示信息 */
settextjustify(RIGHT_TEXT, BOTTOM_TEXT);
for(i=0;i<24;i++)
{ sprintf(PRN,"prn%2i",prn[i]); outtextxy(startx ,starty+i*gridy, PRN);}
settextjustify(LEFT_TEXT, BOTTOM_TEXT);
for(i=0;i<24;i++)
{ sprintf(time,"%i",i); outtextxy(startx+i*gridx, endy+gridy, time);}
sprintf(text,"%4i %2i %2i %2i %7.4f %3i %7.4f %7.4f",
year,month,day,LatD,LatM,LonD,LonM,H);
outtextxy(startx+20, starty-5, text);
setlinestyle(SOLID_LINE,1,THICK_WIDTH);
setcolor(RED);
for(i=0;i<SatNum;i++)
{for(j=0;j<24;j++)
{ if( (elev[i][j] >= 5.0) &&(elev[i][j] <= 90.0) )
{ line(startx + j*gridx, starty + i*gridy,
startx + (j+1)*gridx, starty + i*gridy); } } }
getch(); closegraph(); return 0;}
void GetElev(double SatX0,double SatY0,double SatZ0,double ObsB,double ObsL,
double ObsH,double *r,double *elev,double *azi)
{ double a=6378245.0;
double e2=0.00669342162297;
double N,DeltaX,DeltaY,DeltaZ,ObsX0,ObsY0,ObsZ0,X_Obs,Y_Obs,Z_Obs;
N = a / sqrt(1.0-e2*sin(ObsB) * sin(ObsB));
ObsX0 = (N + ObsH) * cos(ObsB) * cos(ObsL);
ObsY0 = (N + ObsH) * cos(ObsB) * sin(ObsL);
ObsZ0 = (N * (1.0-e2) + ObsH ) * sin(ObsB);
DeltaX=SatX0 - ObsX0;
DeltaY=SatY0 - ObsY0;
DeltaZ=SatZ0 - ObsZ0;
X_Obs = - sin(ObsB)*cos(ObsL)*DeltaX
- sin(ObsB)*sin(ObsL)*DeltaY
+ cos(ObsB)*DeltaZ;
Y_Obs = - sin(ObsL)*DeltaX + cos(ObsL)*DeltaY;
Z_Obs = cos(ObsB)*cos(ObsL)*DeltaX
+ cos(ObsB)*sin(ObsL)*DeltaY
+ sin(ObsB)*DeltaZ;
*r = sqrt(X_Obs * X_Obs +Y_Obs * Y_Obs +Z_Obs * Z_Obs );
*azi = Get_atan(Y_Obs,X_Obs) * 180.0/M_PI;
*elev =Get_atan(Z_Obs, sqrt(X_Obs * X_Obs + Y_Obs * Y_Obs))* 180.0/M_PI;
} /* End of Function */
/* 参见附3 */
/* 读RINEX星历文件 */
/* 应用卫星导航星历计算卫星地心坐标 */
/* 转换日期和时间为GPS时间 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -