📄 rinexobs.cpp
字号:
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "RinexObs.h"
#include "fstream.h"
#include "GlobleDefine.h"
#include "fstream.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
void READEPOOBSHEAD(ifstream inObsFile,ofstream outPosFile,OBSHEAD &head,int *obstype,int &TYPENUM)
{
char str[81];
CString s;
char *p;
do
{
inObsFile.getline(str,82,'\n');
if(p=strstr(str,"COMMENT"))
continue;
if(p=strstr(str,"MARKER NAME"))
{ head.Markername=new char[4];
p=strncpy(head.Markername,str,4);
head.Markername[4]=0;
}
if(p=strstr(str,"APPROX")){
s=str;
head.dapproxmiatexyz.lX=atof(s.Mid(0,14));
head.dapproxmiatexyz.lY=atof(s.Mid(14,14));
head.dapproxmiatexyz.lZ=atof(s.Mid(28,14));}
if(p=strstr(str,"ANTENNA"))
{
s=str;
head.dANTDELTA_H=(double)atof(s.Mid(0,14));
head.dANTDELTA_E=(double)atof(s.Mid(14,14));
head.dANTDELTA_N=(double)atof(s.Mid(28,14));
}
if(p=strstr(str,"TYPES OF OBSERV"))
{
s=str;
head.iTYPENUM=atoi(s.Mid(0,6));
int i;
TYPENUM= head.iTYPENUM;
CString mystring=s.Mid(9,50); // The default order is C1,L1,L2,P1,P2,D1,D2,S1,S2
if(i=SEATYPE(mystring,"C1"))
obstype[C1]=i-1;
if(i=SEATYPE(mystring,"L1"))
obstype[L1]=i-1;
if(i=SEATYPE(mystring,"L2"))
obstype[L2]=i-1;
if(i=SEATYPE(mystring,"P1"))
obstype[P1]=i-1;
if(i=SEATYPE(mystring,"P2"))
obstype[P2]=i-1;
if(i=SEATYPE(mystring,"D1"))
obstype[D1]=i-1;
if(i=SEATYPE(mystring,"D2"))
obstype[D2]=i-1;
if(i=SEATYPE(mystring,"S1"))
obstype[S1]=i-1;
if(i=SEATYPE(mystring,"S2"))
obstype[S2]=i-1;
}
if(p=strstr(str,"LEAP SECONDS"))
{
s=str;
head.iLEAPSECONDS=atoi(s.Mid(0,6));
}
if(p=strstr(str,"TIME OF FIRST OBS"))
{
s=str;
head.FIRSTTIME.iYEAR=atoi(s.Mid(0,6));
head.FIRSTTIME.iMONTH=atoi(s.Mid(6,6));
head.FIRSTTIME.iDAY=atoi(s.Mid(12,6));
head.FIRSTTIME.iHOUR=atoi(s.Mid(18,6));
head.FIRSTTIME.iMINUTE=atoi(s.Mid(24,6));
head.FIRSTTIME.dSECOND=atof(s.Mid(30,14));
}
}
while(!strstr(str,"END OF HEADER"));
}
void READEPOOBSREC(ifstream inObsFile,ofstream outPosFile,OBSRECEPOHEAD &epohead,OBSRECPERSAT eporec[15],int TYPENUM)
{ char *str;
str=new char[81];
CString s;
int i, t=0;
int SATNUM;
while(!t)
{ inObsFile.getline(str,81,'\n');
if(strstr(str,"COMMENT"))
continue;
if(strstr(str," 4 1"))
continue;
if(str[0]==' '&&str[1]!=' ')
{ t=1;
s=str;
epohead.TIME.iYEAR=atoi(s.Mid(0,3));
epohead.TIME.iMONTH=atoi(s.Mid(3,3));
epohead.TIME.iDAY=atoi(s.Mid(6,3));
epohead.TIME.iHOUR=atoi(s.Mid(9,3));
epohead.TIME.iMINUTE=atoi(s.Mid(12,3));
epohead.TIME.dSECOND=atof(s.Mid(15,11));
epohead.iTAG=atoi(s.Mid(26,3));
epohead.iSATNUM=atoi(s.Mid(29,3));
epohead.SatList=s.Mid(32,epohead.iSATNUM*3);
SATNUM=epohead.iSATNUM;
for(i=0;i<SATNUM;i++)
{
eporec[i].iPRN=atoi(s.Mid(33+i*3,2));
eporec[i].iCycleFlag=0;
//initialization
eporec[i].lAmbiguity =0;
eporec[i].iAmbSmoTime=1;
eporec[i].Cyslip =0;
}
for(i=0;i<SATNUM;i++)
{ int lLen;//the variable for judging the line is or not useful
inObsFile.getline(str,82,'\n');
if((lLen=strlen(str))<80)
CORRECTOBSLINE(str);
s=str;
eporec[i].lOBS[0]=atof(s.Mid(0,14));
eporec[i].lOBS[1]=atof(s.Mid(16,14));
eporec[i].lOBS[2]=atof(s.Mid(32,14));
eporec[i].lOBS[3]=atof(s.Mid(48,14));
eporec[i].lOBS[4]=atof(s.Mid(64,14));
if(TYPENUM>5)
{
inObsFile.getline(str,81,'\n');
if((lLen=strlen(str))<(TYPENUM-5)*16)
CORRECTOBSLINE(str);
s=str;
for(int k=5;k<TYPENUM;k++)
eporec[i].lOBS[k]=atof(s.Mid(16*(k-5),14));
}
/*
eporec[i].HEALTH=1;
if((!eporec[i].lOBS[0])&&(!eporec[i].lOBS[3])&&(!eporec[i].lOBS[2]))
{
eporec[i].HEALTH=0;
epohead.iSATNUM--;
i--;
}
*/
}
SATNUM=epohead.iSATNUM;
}
}
}
void CORRECTOBSLINE(char *str)
{ int k,
t=0;
if(str[0]==' ')
{
while((str[t]!=0)&&(t<79))
{t++;}
k=t;
for(t=k;t<80;t++)
{
str[t]=32;
}
str[80]=0;
}
if(str[0]==0)
{
for(t=0;t<80;t++)
{
str[t]=32;
}
str[80]=0;
}
}
int SEATYPE(CString strT,CString strS)
{
if (strT.Mid(0,2)==strS)
return 1;
for (int i = 1;i<50;i++)
if (strT.Mid(i,2)==strS)
return i/6+1;
return 1;
}
int SEAPRN(CString str,int PRN)
{ int maxcha=MAXCHA;
int t;
for(int i=0;i<maxcha;i++)
{
int Prn=atoi(str.Mid(3*i+1,2));
if(Prn==PRN)
{
t=i;break;
}
}
return t;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -