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

📄 analyze.cpp

📁 GemoMedia 应用 演示了其使用方法
💻 CPP
字号:
// analyze.cpp: implementation of the Canalyze class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SvfToGeoMedia.h"
#include "analyze.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

extern list<CGeoObj*>  G_GEOList;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Canalyze::Canalyze(void)
: m_nPosLength(-1)
, m_nCur_Pos(0)
, m_nAttrLength(-1)
, m_nAttr_Pos(0)
, m_bNewGeo(false)
, m_pGeoObj(NULL)
{

}

Canalyze::~Canalyze(void)
{


}
//字符串分析方法
void Canalyze::decodeCString( CString source, CStringArray& dest , CString division)
{
	dest.RemoveAll();

	while(true)
	{
		int nIndex = source.Find(division,0);
		if(nIndex == -1)
		{
			source = source;
			dest.Add(source);
		}
		else
		{
			dest.Add(source.Left(nIndex));
			source = source.Right(source.GetLength() - nIndex -1);
		}

		if(nIndex == -1)
			break;
		} 
}

/*
得到字符串分析
进行分析,形成地理对象实体
*/
void Canalyze::ReadString(CString strLine)
{
	CStringArray strlist;
	decodeCString(strLine,strlist,",");
	//若当前无对象实体创建对象实体
	if (!m_bNewGeo)
	{
		m_pGeoObj = new CGeoObj;
		m_bNewGeo = true;
		m_pGeoObj->m_strGeoCode = strLine.GetBuffer(0);

		return;
	}

	//若点集合个数为0,则得到点个数
	if (m_nPosLength==-1)
	{
		m_nPosLength =  atoi(strLine);
		return;
	}
	else
	{
		//将位置信息添加到地理实体对象
		if (m_nCur_Pos!= m_nPosLength)
		{
			
			if (strlist.GetSize()>=4)
			{
				struct  Node node;
				node.fPosX = atof(strlist[1]);
				node.fPosY = atof(strlist[2]);
				node.fPosH = atof(strlist[3]);
				m_pGeoObj->m_PosList.push_back(node);
			}
			m_nCur_Pos++;
		}
		else
		{
			if (m_nAttrLength==-1)
			{
				m_nAttrLength = atoi(strLine);
			}
			else
			{	
				//将属性信息添加到地理实体对象
				if (strlist.GetSize()>=2)
				{
					struct Attr attr;
					attr.strAttrName = strlist[0];
					attr.strAttr = strlist[1];
					m_pGeoObj->m_AttrList.push_back(attr);
				}
				m_nAttr_Pos++;
				
				//重新初始化环境,把地理对象加到对象列表中去
				if  (m_nAttrLength == m_nAttr_Pos)
				{
					 m_nPosLength =-1;
					 m_nCur_Pos =0;
					 m_nAttrLength =-1;
					 m_nAttr_Pos =0;
					 m_bNewGeo = false;

					 if (m_pGeoObj->m_strGeoCode.c_str()=="0")
					 {
						 AfxMessageBox("");
					 }
					 
					 G_GEOList.push_back(m_pGeoObj);
					 
				}
			}
		}
	}				
}

⌨️ 快捷键说明

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