📄 main.cpp
字号:
#include <list>
#include "iostream.h"
#include "Time.h"
#include "Rinex.h"
#include "Substr.h"
#include "Coordinate.h"
#include "GetGMN.h"
#include "GetGMO.h"
#include "GetPosition.h"
#include "stdio.h"
#include "math.h"
#include <fstream>
//using namespace std;
void main()
{
FILE *fp;
if((fp=fopen("Result.dat","w"))==NULL)
{
printf("失败\n");
exit(0);
}
fputs(">>>>>>>>>>>>>>>>>>>>>>>>>>单点定位解算>>>>>>>>>>>>>>>>>>>>>",fp);
fprintf(fp,"\n\n");
//测试导航电文头
cout<<"读取导航电文头"<<endl;
GMNHDR gmnh;
gmnh=GetGMNHDR("GPS NAVIGATION MESSAGE FILE.txt");
// cout<<"RINEX VERSION / TYPE "<<" "<<gmnh.ver_major<<"."<<gmnh.ver_minor<<endl<<endl;
//测试导航电文数据
cout<<"读取导航电文数据"<<endl;
list<PGMNREC> RecList;
list<PGMNREC>::iterator pRecList;
GetGMNREC("GPS NAVIGATION MESSAGE FILE.txt", RecList);
// for(pRecList=RecList.begin();pRecList!=RecList.end();++pRecList)
// {
// cout<<(*pRecList)->PRN<<" "<<(*pRecList)->TOC.year<<" "<<(*pRecList)->TOC.month<<" "<<(*pRecList)->TOC.day
// <<" "<<(*pRecList)->TOC.hour<<" "<<(*pRecList)->TOC.minute<<" "<<(*pRecList)->TOC.second<<endl<<endl;
// }
//测试观测数据头
cout<<"读取观测数据头"<<endl;
GMOHDR gmoh;
gmoh=GetGMOHDR("GPS OBSERVATION DATA FILE.txt");
// cout<<"TIME OF FIRST OBS "<<gmoh.start.year<<" "<<gmoh.start.month<<" "<<gmoh.start.day<<" "
// <<gmoh.start.hour<<" "<<gmoh.start.minute<<" "<<gmoh.start.second<<" "<<endl<<endl;
//测试观测数据
cout<<"读取观测数据"<<endl<<endl;
list<PGMOREC> List;
list<PGMOREC>::iterator pList;
GetGMOREC("GPS OBSERVATION DATA FILE.txt", List);
/* for(pList=List.begin();pList!=List.end();++pList)
{
if((*pList)->sign_of_use==0)
{
cout<<(*pList)->epoch.year<<" "<<(*pList)->epoch.month<<" "<<(*pList)->epoch.day
<<" "<<(*pList)->epoch.hour<<" "<<(*pList)->epoch.minute<<" "<<(*pList)->epoch.second<<" "
<<(*pList)->sign_of_use<<" "<<(*pList)->num_sat<<" "<<(*pList)->rcvr_clk_bias<<" "<<endl;
cout<<"卫星列表:"<<endl;
for (int i=0;i<(*pList)->num_sat;i++)
cout<<(*pList)->prn_lst[i]<<" ";//卫星号 卫星都是GPS卫星
cout<<endl<<endl;
}
else
cout<<"此行无效"<<endl<<endl;
}
*/
int count=0;//统计历元数
cout<<"解算卫星在笛卡尔坐标系下的位置"<<endl<<endl<<endl;
for(pList=List.begin();pList!=List.end();++pList)
{
if((*pList)->sign_of_use==0)
{
count++;
// cout<<(*pList)->epoch.year<<" "<<(*pList)->epoch.month<<" "<<(*pList)->epoch.day<<" " //输出历元
// <<(*pList)->epoch.hour<<" "<<(*pList)->epoch.minute<<" "<<(*pList)->epoch.second<<endl;
fprintf(fp,"%8s %4d,%2d,%2d,%2d,%2d,%6.3lf\n","历元时刻(年月日时分秒)",(*pList)->epoch.year, //输出历元
(*pList)->epoch.month,(*pList)->epoch.day,(*pList)->epoch.hour,
(*pList)->epoch.minute,(*pList)->epoch.second);
PCRDCARTESIAN pcrdOrb=new CRDCARTESIAN; //存放卫星在 笛卡尔 坐标下的位置
PSatVel psatv=new SatVel; //卫星速度
PPPONERESULT presult=new PPONERESULT; // 地面点坐标 及相关数据
for(int i=0;i<(*pList)->num_sat;i++)
{
// cout<<"卫星号"<<(*pList)->prn_lst[i]<<" ";
fprintf(fp," %2d%s ",(*pList)->prn_lst[i], " 号卫星的坐标(XYZ):");
GetOrbNClk(RecList, (*pList)->prn_lst[i], &(*pList)->epoch, pcrdOrb);//笛卡尔 计算卫星坐标
GetSatVelocity(RecList,(*pList)->prn_lst[i],&(*pList)->epoch, psatv);//笛卡尔 计算卫星速度
PPOne(gmoh,pList,RecList,presult); //// 地面点坐标 及相关数据
// cout<<pcrdOrb->x<<pcrdOrb->y<<pcrdOrb->z<<endl;
// cout<<psatv->xv<<psatv->yv<<psatv->zv<<endl;
fprintf(fp,"%17.7f, %17.7f, %17.7f %s %14.7f, %14.7f, %14.7f\n",pcrdOrb->x,pcrdOrb->y,pcrdOrb->z," 速度(Vx,Vy,Vz):",psatv->xv,psatv->yv,psatv->zv);
}
fprintf(fp,"%s %17.7f, %17.7f, %17.7f\n\n\n"," 测站坐标(XYZ): ",(*presult).crd.x,(*presult).crd.y,(*presult).crd.z);
}
else
cout<<"此行无效"<<endl<<endl;
}
cout<<"计算完毕! 共计 "<<count<<" 个历元....."<<endl;
// 测试时间转换函数
/* COMMONTIME x1={2008,10,13,5,25,45.1234},x3;
PCOMMONTIME px1=&x1,px3=&x3;
JULIANDAY x2,x5;
PJULIANDAY px2=&x2,px5=&x5;
GPSTIME x4;
PGPSTIME px4=&x4;
CommonTimeToJulianDay(px1,px2);////////////// 1
JulianDayToCommonTime(px2,px3);
cout<<"CommonTimeToJulianDay......"<<endl;
cout<<px2->day<<endl;
cout<<px2->tod.sn<<" "<<px2->tod.tos<<endl;
cout<<"JulianDayToCommonTime......"<<endl;
cout<<px3->year<<" "<<int(px3->month)<<" "<<int(px3->day)<<" "<<int(px3->hour)<<" "<<int(px3->minute)<<" "<<px3->second<<endl<<endl;
JulianDayToGPSTime(px2,px4);/////////////// 2
GPSTimeToJulianDay(px4,px5);
cout<<"JulianDayToGPSTime......"<<endl;
cout<<px4->wn<<endl;
cout<<px4->tow.sn<<" "<<px4->tow.tos<<endl;
cout<<"GPSTimeToJulianDay......"<<endl;
cout<<px5->day<<endl;
cout<<px5->tod.sn<<" "<<px5->tod.tos<<endl<<endl;
CommonTimeToGPSTime(px1,px4);/////////////// 3
cout<<"CommonTimeToGPSTime......"<<endl;
cout<<px4->wn<<endl;
cout<<px4->tow.sn<<" "<<px4->tow.tos<<endl;
GPSTimeToCommonTime(px4,px3);
cout<<"GPSTimeToCommonTime......"<<endl;
cout<<px3->year<<" "<<int(px3->month)<<" "<<int(px3->day)<<" "<<int(px3->hour)<<" "<<int(px3->minute)<<" "<<px3->second<<endl;
*/
/*
COMMONTIME x1={2001,3,4,0,1,0.0},x3;
PCOMMONTIME px1=&x1,px3=&x3;
JULIANDAY x2,x5;
PJULIANDAY px2=&x2,px5=&x5;
GPSTIME x4;
PGPSTIME px4=&x4;
x4.wn=1104;
x4.tow.sn=0;
x4.tow.tos=0;
CommonTimeToJulianDay(px1,px2);
GPSTimeToJulianDay(px4,px5);
cout<<px2->day<<" "<<px2->tod.sn<<" "<<px2->tod.tos<<endl;
cout<<px5->day<<" "<<px5->tod.sn<<" "<<px5->tod.tos<<endl;
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -