资源简介
用MFC实现对SHAPFILE文件的读取和现实,主要调用GDAL库文件。在这儿将主要的代码粘贴下来。
代码片段和文件信息
#include “stdafx.h“
#include “MyShapFile.h“
#define MaxFileNameSize 255
#define MaxPointsNumber 3000
#define MAX_WEIGHT 6
CMyShapFile::CMyShapFile()
: //Filepath(NULL)
m_filepath(NULL)
PointNum(0)
{
}
CMyShapFile::~CMyShapFile()
{
}
// 读取文件
bool CMyShapFile::ReadFile()
{
//this->m_filepath = Path;
OGRRegisterAll();
OGRDataSource *poDS = OGRSFDriverRegistrar::Open(this->m_filepath FALSE);
if (NULL == poDS)
{
//AfxMessageBox();
AfxMessageBox(_T(“读取失败“));
CString str;
str = this->m_filepath;
AfxMessageBox(str);
//cout<<“ReadFile Failed!“< return false;
}
OGRlayer *polayer = poDS->Getlayer(0);
OGRFeature *poFeature = polayer->GetNextFeature();
while (NULL != poFeature)
{
//读取属性数据
//OGRFeatureDefn int iField
//读取几何数据
OGRGeometry * poGeometry = poFeature->GetGeometryRef();
if (NULL != poGeometry && wkbFlatten(poGeome
- 上一篇:AES任意文件长度加解密C语言实现
- 下一篇:置换密码的c++实现程序
评论
共有 条评论