您的位置:首页 > 其它

GPS时间系统的转换

2018-01-30 17:07 429 查看
 GPS所采用的是原子时秒长,起点为1980年1月6日的UTC0时。

 在GPS应用中,时常需要采用GPS时间,格式为GPS周+GPS周内秒,从RINEX格式文件中读取的时间均为

格里高利时,所以需要进行时间从格里高利时-儒略日-GPS时间转换的过程。

 代码如下:

 

long YMDHMStoJD(YMDHMS time1);
GPSTime JDtoGPSTime(long time2);

typedef struct{
long         year;
long         month;
long         day;
long         hour;
long         min;
double       sec;
}  YMDHMS;

typedef struct{
long        GPSWeek;
double      secsOfWeek;
}  GPSTime;

long YMDHMStoJD(YMDHMS time1)
{
int m,y;
long JD;
if(time1.month<=2)
{
y=time1.year+1;
m=time1.month+12;
}
else if(time1.month>2)
{
y=time1.year;
m=time1.month;
}
JD=365.25*y+30.6001*(m+1)+time1.day+1720981.5+time1.hour/24+time1.min/1440+time1.sec/86400;
return JD;
}

GPSTime JDtoGPSTime(long time2)
{
GPSTime gpst;
gpst.GPSWeek=(time2-2444244.5)/7;
gpst.secsOfWeek=((time2-2453736.5)/7-gpst.GPSWeek)*604800;
return gpst;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: