⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 一个解读gps
💻 C
字号:
#include "ha_rinex.h"

main()
{
	char RinexNameFo[100] ;

	FILE *RinexFo ;


	char temp[81] ;

	int year, month, day, hour, minute, epochFlag, satNum = 0 ;

	double second ;

	
	printf("Please Input Rinex Nav File Name");
	scanf("%s",RinexNameFo) ;

	if( ( RinexFo = fopen(RinexNameFo,"rt") ) == NULL )
	{
		fprintf ( stderr,"Cannot open input file.\n" ) ;
		exit(1) ;
	}


	Read_RinexO_header( RinexFo, temp, 81 ) ; 

	Read_Rinex_ObFile( RinexFo, &year, &month, &day, &hour, &minute, &second, &satNum,
					  &epochFlag, rinexObsdata, 12 ) ;
			

	fclose ( RinexFo ) ;

}


//-------------Read_RinexO_header用来读取rinex格式观测文件的头文件,当检测到END OF HEADER时结束--------------//

void Read_RinexO_header( FILE *RinexFo, char *temp, int tempN )
{
	int i ;
	int headIndex ;
	char TypesOfObserv[] = "# / TYPES OF OBSERV " ;
	char endOfHeader[] =   "END OF HEADER       " ;

	rewind ( RinexFo ) ;

	headIndex = 0 ;
	while( headIndex == 0 )
	{
		fgets ( temp, 81, RinexFo ) ;
		for( i=0; i<19;  )
		{
			if( *( temp+60+i ) == *( TypesOfObserv+i ) )
				i++ ;
			else break ;
		}
		if( i == 19 )
			headIndex = 1 ;
			
	}


	headIndex = 0 ;
	while( headIndex == 0 )
	{
		fgets ( temp, 81, RinexFo ) ;
		for( i=0; i<13;  )
		{
			if( *( temp+60+i ) == *( endOfHeader+i ) )
				i++ ;
			else break ;
		}
		if( i == 13 )
			headIndex = 1 ;
			
	}
}


//---------------Read_Rinex_ObFile用来读取每一帧的数据-------------------------------------------------------------------//

int Read_Rinex_ObFile( FILE*RinexFo, int*year, int *month, int *day, int *hour, int *minute, double *second, int *satNum,
					  int *epochFlag, OBSERVDATA *rinexObsdata, int strRON )
{
	int i ;
	char t1[30], t2[30], t3[30], t4[30], t5[30], t6[30] ;

	if( fscanf ( RinexFo," %d %d %d %d %d %s %d %d ",
		year, month, day, hour, minute, t1, epochFlag, satNum ) == EOF )
		return 1 ;

	*second = atof( t1 ) ;


	for( i=0; i<strRON; i++ )
	{
		if( i < *satNum )
		{
			if( fscanf ( RinexFo," %d ", &( ( rinexObsdata+i ) -> prnNum ) ) == EOF )
			return 1 ;
		
			
		}
		else
			i = strRON ;
	}

//	if( fscanf ( RinexFo," \n ") == EOF )
//		exit(1) ;

	for( i=0; i<strRON; i++ )
	{
		if( i < *satNum )
		{
			if( fscanf ( RinexFo," %s %s %s %s %s %s ",
				t1, t2, t3, t4, t5, t6 ) == EOF )
			return 1 ;
		

			( rinexObsdata+i )->C1 = atof( t1 ) ;
			( rinexObsdata+i )->P2 = atof( t2 ) ; 
			( rinexObsdata+i )->L1 = atof( t3 ) ;
			( rinexObsdata+i )->L2 = atof( t4 ) ;
			( rinexObsdata+i )->D1 = atof( t5 ) ;
			( rinexObsdata+i )->D2 = atof( t6 ) ;

		}
		else
			i = strRON ;
	}

	return (0) ;
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -