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

📄 typhooncls.cpp

📁 解析中央气象局下发的台风报文
💻 CPP
📖 第 1 页 / 共 3 页
字号:
								strLine.TrimRight ();
								strLine.TrimLeft ();
								if(strLine=="")
									continue;
								if(strLine.Find ("NNNN")>=0||strLine.Find ("FORECAST")>=0)
									break;

								if(strLine.Find ("HF")==2)
								{
									pTd->AddForcast (pTf);
									goto NEXTFORCAST_RJTD;

								}
								
								if(strLine.Find ("MOVE")>=0)
								{
									CParam::Split (strLine," ",vecOut);
									pTf->Direction=vecOut[1];
									I=vecOut[2].Find("KT");
									pTf->Move_Speed=atof(vecOut[2].Left(I))*1.852;
								}
								else if(strLine.Find ("PRES")>=0)
								{
									CParam::Split (strLine," ",vecOut);
									I=vecOut[1].Find("HPA");
									pTf->Pressure=atof(vecOut[1].Left(I));
								}
								else if(strLine.Find ("MXWD")>=0)
								{
									CParam::Split (strLine," ",vecOut);
									I=vecOut[1].Find("KT");
									pTf->Wind_Power=atof(vecOut[1].Left(I))*1.852/3.6;

								}
							}
							pTd->AddForcast (pTf);

						}

					}
					this->m_tdArray.Add (pTd);
				}
			}
			catch(...)
			{
			}
		
			//香港
			try
			{
				if(strLine.Find ("WTPQ20 VHHH")>=0)
				{
					pTd=new TYPHOONDATA;
					pTd->Station_Name ="香港";
					while(file.ReadString (strLine))
					{
						strLine.TrimRight ();
						strLine.TrimLeft ();
						if(strLine=="")
							continue;
						if(strLine.Find ("NNNN")>=0)
							break;
						if(strLine.Find ("AT")==0)
						{
							
							//台风类型
							CParam::Split (strLine," ",vecOut);
							pTd->Date_Time =ChackDateTime (dtFile.GetYear (),dtFile.GetMonth (),atoi(vecOut[1].Mid (0,2)),atoi(vecOut[1].Mid (2,2)),atoi(vecOut[1].Mid (4,2)),0,dtFile);
							
						}
						if(strLine.Find (") WITH")>0)
						{
							I=strLine.Find ("(");
							J=strLine.Find (")");
							pTd->Typhoon_ID =strLine.Mid (I+1,J-I-1);
							strLine=strLine.Left (I);
							strLine.Trim ();
							for(I=strLine.GetLength ()-1;I>=0;I--)
							{
								if(strLine.GetAt (I)==' ')
									break;

							}
							pTd->Title_EN =strLine.Mid (I+1);
						
							
						}
						else if(strLine.Find ("FORECAST POSITION")>=0)
						{
							
	NEXTFORCAST_WTPQ20VHHH:
							TYPHOONFORCAST *pTf=new TYPHOONFORCAST();
							I=strLine.Find ("AT");
							J=strLine.Find ("UTC");
							strtemp=strLine.Mid (I+2,J-I-2);
							strtemp.TrimLeft ();
							strtemp.TrimRight ();
							pTf->Predict_Time =ChackDateTime (dtFile.GetYear (),dtFile.GetMonth (),atoi(strtemp.Mid (0,2)),atoi(strtemp.Mid (2,2)),atoi(strtemp.Mid (4,2)),0,dtFile);
								
							while(file.ReadString (strLine))
							{
								strLine.TrimRight ();
								strLine.TrimLeft ();
								if(strLine=="")
									continue;
								if(strLine.Find ("N)")>0)
								{
									I=strLine.Find ("(");
									J=strLine.Find ("N)");
									pTf->Latitude=atof(strLine.Mid (I+1,J-I-1));
								}
								if(strLine.Find ("E)")>0)
								{
									I=strLine.Find ("(");
									J=strLine.Find ("E)");
									pTf->Longitude=atof(strLine.Mid (I+1,J-I-1));
								}
								if(strLine.Find ("WINDS")>=0)
								{
									I=strLine.Find ("WINDS");
									J=strLine.Find ("KNOTS");
									pTf->Wind_Power=atof(strLine.Mid (I+5,J-I-5))/3.6;

								}
								if(strLine.Find ("NNNN")>=0)
								{
									break;
								}
								if(strLine.Find ("FORECAST POSITION")>=0)
								{
									pTd->AddForcast (pTf);
									goto NEXTFORCAST_WTPQ20VHHH;

								}

								
							}
							pTd->AddForcast (pTf);
						}
						
					}
					this->m_tdArray.Add (pTd);
				
					
				}
			}
			catch(...)
			{
			}
		
		
			//广州
			try
			{
				if(strLine.Find ("WOCI41 BCGZ")>=0)
				{
					
					pTd=new TYPHOONDATA;
					pTd->Station_Name ="广州";
					int nType=-1;
					while(file.ReadString (strLine))
					{
						strLine.TrimRight ();
						strLine.TrimLeft ();
						if(strLine=="")
							continue;
						if(strLine.Find ("NNNN")>=0)
							break;
						if(strLine.Find ("GMT")>=0)
						{
							
							nType=0;
							//台风类型
							strtemp=strLine;
							//台风名称
							I=strLine.Find ("GMT");
							strLine=strLine.Left (I);
							strLine.Trim();
							strtemp=strLine.Right (6);
							strLine=strLine.Left(strLine.GetLength ()-6);
							strLine.Trim ();
							pTd->Date_Time =ChackDateTime (dtFile.GetYear (),dtFile.GetMonth (),atoi(strtemp.Mid (0,2)),atoi(strtemp.Mid (2,2)),atoi(strtemp.Mid (4,2)),0,dtFile);
							pTd->Typhoon_ID =strLine.Right(4);

							
						}
						if(strLine.Find ("AT")==0)
						{
								
							nType=1;
							//台风类型
							strLine=strLine.Mid (2);
							strLine.TrimLeft ();
							pTd->Date_Time =ChackDateTime (dtFile.GetYear (),dtFile.GetMonth (),atoi(strLine.Mid (0,2)),atoi(strLine.Mid (2,2)),atoi(strLine.Mid (4,2)),0,dtFile);
							//台风名称
							I=strLine.Find ("Z");
							strLine=strLine.Mid (I+1);
							strLine.TrimLeft ();
							pTd->Typhoon_ID =strLine.Left (4);
							
						}
						else if(strLine.Find ("12HR")>=0)
						{

							if(nType==0)
							{
								CParam::Split (strLine," ",vecOut,true);
								TYPHOONFORCAST *pTf=new TYPHOONFORCAST();
								pTf->Predict_Time =pTd->Date_Time +COleDateTimeSpan(0,12,0,0);
								I=vecOut[1].Find("!c");
								if(I<0)
								{
									I=vecOut[1].Find("DEG");

								}
								pTf->Direction =vecOut[1].Left(I)+"度";
								J=vecOut[2].Find("KM/H");
								pTf->Move_Speed =atof(vecOut[2].Left(J));
								I=vecOut[3].Find("M/S");
								pTf->Wind_Power=atof(vecOut[3].Left(I));
								pTd->AddForcast (pTf);
							}


						}
						else if(strLine.Find ("HR")==2)
						{
							if(nType==0)
							{
							
								CParam::Split (strLine," ",vecOut);
								TYPHOONFORCAST *pTf=new TYPHOONFORCAST();
								I=vecOut[1].Find("N");
								pTf->Latitude=atof(vecOut[1].Left(I));

								I=vecOut[2].Find("E");
								pTf->Longitude=atof(vecOut[2].Left(I));

								I=vecOut[3].Find("HPA");
								pTf->Pressure=atof(vecOut[3].Left(I));

								I=vecOut[4].Find("M/S");
								pTf->Wind_Power =atof(vecOut[4].Left(I));
								pTf->Predict_Time =pTd->Date_Time +COleDateTimeSpan(0,atoi(vecOut[0].Left(2)),0,0);
								pTd->AddForcast (pTf);
							}
							

						}
						else if(strLine.Find ("HR")>0)
						{
							if(nType==1)
							{
								TYPHOONFORCAST *pTf=new TYPHOONFORCAST();
								pTf->Predict_Time =pTd->Date_Time +COleDateTimeSpan(0,atoi(strLine.Left(2)),0,0);
								file.ReadString (strLine);
								CParam::Split (strLine," ",vecOut);
								pTf->Longitude =atof(vecOut[3]);
								pTf->Latitude  =atof(vecOut[1]);
							

								file.ReadString (strLine);
								I=strLine.Find ("GUSTS");
								strtemp=strLine.Mid  (I+5);
								strtemp.Trim ();
								I=strtemp.Find ("KNOTS");
								pTf->Wind_Power =atof(strtemp.Left (I))*1.852/3.6;
								pTd->AddForcast (pTf);
							


							}
							
						}

					}
					this->m_tdArray.Add (pTd);
					
				}
			}
			catch(...)
			{
			}
		
			//上海
			try
			{

				if(strLine.Find ("WOCI41 BCSH")>=0)
				{
					
					pTd=new TYPHOONDATA;
					pTd->Station_Name ="上海";
					while(file.ReadString (strLine))
					{
						strLine.TrimRight ();
						strLine.TrimLeft ();
						if(strLine=="")
							continue;
						if(strLine.Find ("NNNN")>=0)
							break;
						if(strLine.Find ("UTC")>=0)
						{
							
							if(strLine.Find ("TD")>0)
								break;
							//台风类型
							strtemp=strLine;
							if(strtemp.Find ("SUPER TY")>=0)
								I=strtemp.Find ("SUPER TY")+8;
							else
								I=strtemp.Find (" ");

							pTd->Intensity_EN =strtemp.Left (I);
							//台风名称
							strtemp.TrimLeft (pTd->Intensity_EN);
							strtemp.TrimLeft(" ");
							pTd->Typhoon_ID =strtemp.Left (4);
							strtemp.TrimLeft (pTd->Typhoon_ID);
							strtemp.TrimLeft(" ");

							pTd->Date_Time =ChackDateTime (dtFile.GetYear (),dtFile.GetMonth (),atoi(strtemp.Mid (0,2)),atoi(strtemp.Mid (2,2)),atoi(strtemp.Mid (4,2)),0,dtFile);
							
						}
						else if(strLine.Find ("12HR")>=0)
						{
							CParam::Split (strLine," ",vecOut);
							TYPHOONFORCAST *pTf=new TYPHOONFORCAST();
							pTf->Predict_Time =pTd->Date_Time +COleDateTimeSpan(0,12,0,0);
							pTf->Direction =vecOut[1].Left(vecOut[1].GetLength()-2)+"度";
							pTf->Move_Speed =atof(vecOut[1].Right(2));
							pTd->AddForcast (pTf);


						}
						else if(strLine.Find ("HR")==2)
						{
							CParam::Split (strLine," ",vecOut);
							TYPHOONFORCAST *pTf=new TYPHOONFORCAST();

							I=vecOut[1].Find("N");
							pTf->Latitude=atof(vecOut[1].Left(I));

							I=vecOut[2].Find("E");
							pTf->Longitude=atof(vecOut[2].Left(I));

							pTf->Predict_Time =pTd->Date_Time +COleDateTimeSpan(0,atoi(vecOut[0].Left(2)),0,0);
							pTd->AddForcast (pTf);

						}

					}
					this->m_tdArray.Add (pTd);
					
				}
			}
			catch(...)
			{
				
			}
			//台湾


			
			//关岛 
			try
			{
				if(strLine.Find ("WTPN31 PGTW")>=0)
				{
			
					
					pTd=new TYPHOONDATA;
					pTd->Station_Name ="关岛";
					while(file.ReadString (strLine))
					{
						strLine.TrimRight ();
						strLine.TrimLeft ();
						if(strLine=="")
							continue;
						if(strLine.Find ("NNNN")>=0)
							break;
						if(strLine.Find ("WARNING NR")>=0)
						{
							I=strLine.Find ("(");
							if(I>0)
							{
								J=strLine.Find (")");
								pTd->Title_EN =strLine.Mid (I+1,J-I-1);
								strtemp=strLine.Left (I);
								strtemp.TrimRight ();
								strtemp=strtemp.Right (3);
								pTd->Typhoon_ID=CParam::ToString (dtFile.GetYear ()).Mid (2)+strtemp.Left (2);
							}
							else
							{
							
								I=strLine.Find ("WARNING NR");
								strLine=strLine.Left (I);
								strLine.Trim ();
								strtemp=strLine.Right (3);
								pTd->Typhoon_ID=CParam::ToString (dtFile.GetYear ()).Mid (2)+strtemp.Left (2);
								I=strLine.Find ("FOR");
								strLine=strLine.Mid (I+3);
								strLine.Trim ();
								I=strLine.Find (" ");
								pTd->Title_EN =strLine.Left (I);
							}
							

						
							
						
							
						}
						else if(strLine.Find ("WARNING POSITION")>=0)
						{
							if(file.ReadString (strLine))

⌨️ 快捷键说明

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