📄 skf_mapdoc.cpp
字号:
// Skf_MapDoc.cpp : implementation of the CSkf_MapDoc class
//
#include "stdafx.h"
#include "Skf_Map.h"
#include "Skf_MapDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSkf_MapDoc
IMPLEMENT_DYNCREATE(CSkf_MapDoc, CDocument)
BEGIN_MESSAGE_MAP(CSkf_MapDoc, CDocument)
//{{AFX_MSG_MAP(CSkf_MapDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSkf_MapDoc construction/destruction
CSkf_MapDoc::CSkf_MapDoc()
{
//地图文件路径
char *fname[]={
"Mapdata\\skfmainland.txt",
"Mapdata\\skftaiwan.txt",
"Mapdata\\skfhainan.txt",
"Mapdata\\skfyellowriver.txt",
};
for (int i=0;i<4;i++)
LoadMapData(fname[i],i);
}
CSkf_MapDoc::~CSkf_MapDoc()
{
}
BOOL CSkf_MapDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CSkf_MapDoc serialization
void CSkf_MapDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
void CSkf_MapDoc::LoadMapData(char *filename,int layer )
{
FILE *fp;
CPoint p;
if ((fp= fopen(filename,"r"))==NULL )
{
CString msg;
msg+=filename;
msg+="没找到!将退出系统。";
AfxMessageBox(msg);
exit( -1 );
}
while ( !feof(fp))
{
fscanf( fp, "%d,%d", &p.x, &p.y );
//如果地理文件提供的是经纬度,
//最好在这里转换后加入数组,
//尽可能不要在绘图时作运算处理
pMapDataAry[layer].Add(p);
}
fclose(fp);
}
/////////////////////////////////////////////////////////////////////////////
// CSkf_MapDoc diagnostics
#ifdef _DEBUG
void CSkf_MapDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CSkf_MapDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSkf_MapDoc commands
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -