?? analyze.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 + -