• 大小: 777KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-13
  • 语言: C/C++
  • 标签: GIS  C++  

资源简介

通过vc++平台,利用arcgis engine组件,进行地图绘制,图层加载,鼠标漫游!

资源截图

代码片段和文件信息

// DateOperator.cpp: implementation of the CDateOperator class.
//
//////////////////////////////////////////////////////////////////////

#include “stdafx.h“
#include “MyMap.h“
#include “MapComposer.h“
#include “DateOperator.h“
#include “TableView.h“


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

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

CDateOperator::CDateOperator()
{

}

CDateOperator::~CDateOperator()
{

}

IFeatureClassPtr CDateOperator::OpenSHPFeatCls(CString sFullName)
{
if (m_ipMap==NULL)
{
return NULL;
}
HRESULT hr;

CString sPathName=sFullName.Left(sFullName.ReverseFind(‘\\‘));
CString sFCName=sFullName.Mid(sFullName.ReverseFind(‘\\‘)+1);
sFCName=sFCName.Left(sFCName.ReverseFind(‘.‘));

IWorkspacePtr ipWorkspace;
IWorkspaceFactoryPtr ipWSFactory(CLSID_ShapefileWorkspaceFactory);
//ipWSFactory=new ShapefileWorkspaceFactoryClass();
//hr=ipWSFactory->OpenFromFile(sPathName0);
  //ipWSFactory.CreateInstance(__uuidof(ShapefileWorkspaceFactory));
  hr=ipWSFactory->OpenFromFile((_bstr_t)sPathNameNULL&ipWorkspace);

if (FAILED(hr))
{
return NULL;
}

IFeatureWorkspacePtr ipFeatureWS;
    IFeatureClassPtr ipFeatCls;

hr=ipWorkspace->QueryInterface(__uuidof(IFeatureWorkspace)((void**)(&ipFeatureWS)));
//hr=ipWorkspace.CreateInstance(__uuidof(IFeatureWorkspace));

if (FAILED(hr))
{
return NULL;
}

hr=ipFeatureWS->OpenFeatureClass((_bstr_t)sFCName&ipFeatCls);

if (FAILED(hr))
{
return NULL;
}

return ipFeatCls;

}

BOOL CDateOperator::GetFeatLyrFromShpfile()
{
CString sFullName=“H:\\地名图层\\sm.shp“;
CString sLyrName=“sm.shp“;

IFeatureClassPtr ipFeatCls=OpenSHPFeatCls(sFullName);
if (ipFeatCls==NULL)
{
return FALSE;
}

BOOL bRes=AddFC2Map(ipFeatClssLyrName5);
if (bRes==FALSE)
{
return FALSE;
}

return TRUE;
}

BOOL CDateOperator::AddFC2Map(IFeatureClassPtr ipFeatCls CString sLyrName int iPos)
{
if (m_ipMap==NULL)
{
return FALSE;
}
HRESULT hr;

IFeaturelayerPtr ipFeatLyr(CLSID_Featurelayer);

hr=ipFeatLyr->putref_FeatureClass(ipFeatCls);
if (FAILED(hr))
{
return FALSE;
}

hr=ipFeatLyr->put_Name((_bstr_t)sLyrName);
if (FAILED(hr))
{
return FALSE;
}
hr=m_ipMap->Addlayer(ipFeatLyr);
    if (FAILED(hr))
    {
return FALSE;
    }

if (iPos>0)
{
m_ipMap->Movelayer(ipFeatLyriPos);
}

return TRUE;
}

IWorkspacePtr CDateOperator::OpenPGD(CString sFullName)
{
IWorkspacePtr ipWorkspace;
HRESULT hr;

IWorkspaceFactoryPtr ipWSFactory(CLSID_AccessWorkspaceFactory);
    hr=ipWSFactory->OpenFromFile((_bstr_t)sFullNameNULL&ipWorkspace);

if (FAILED(hr))
{
return NULL;
}

return ipWorkspace;
}

IFeatureClassPtr CDateOperator::OpenPGDFeatCls

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       8038  2008-09-09 17:02  Map\DateOperator.cpp

     文件       1084  2008-09-01 08:54  Map\DateOperator.h

     文件        977  2008-09-01 11:13  Map\DlgHospital.cpp

     文件       1241  2008-09-01 11:13  Map\DlgHospital.h

     文件       1673  2008-09-02 14:14  Map\licensecontroldefault.cpp

     文件       1953  2008-09-02 14:14  Map\licensecontroldefault.h

     文件       2568  2008-08-11 16:01  Map\MainFrm.cpp

     文件       1487  2008-08-11 13:57  Map\MainFrm.h

     文件       4962  2008-12-02 16:03  Map\MapAnalysis.cpp

     文件        665  2008-09-09 17:23  Map\MapAnalysis.h

     文件       8544  2008-11-17 10:11  Map\MapComposer.cpp

     文件        982  2008-08-27 16:36  Map\MapComposer.h

     文件      16000  2008-08-07 09:16  Map\mapcontroldefault.cpp

     文件       4465  2008-08-07 09:16  Map\mapcontroldefault.h

     文件     120372  2008-12-02 15:42  Map\MyMap.aps

     文件       4417  2008-12-02 16:03  Map\MyMap.clw

     文件       4191  2008-08-07 09:13  Map\MyMap.cpp

     文件       8791  2008-09-09 17:33  Map\MyMap.dsp

     文件        753  2008-09-02 14:30  Map\MyMap.dsw

     文件       1345  2008-08-07 09:13  Map\MyMap.h

     文件    2622464  2008-12-02 16:04  Map\MyMap.ncb

     文件      65024  2008-12-02 16:04  Map\MyMap.opt

     文件        244  2008-12-02 16:04  Map\MyMap.plg

     文件     309069  2008-12-02 15:42  Map\MyMap.rc

     文件       1722  2008-08-07 09:13  Map\MyMapDoc.cpp

     文件       1464  2008-08-07 09:13  Map\MyMapDoc.h

     文件      17657  2008-12-02 15:56  Map\MyMapView.cpp

     文件       4301  2008-09-10 08:56  Map\MyMapView.h

     文件        923  2008-09-01 09:58  Map\MyToolbase.cpp

     文件       1323  2008-09-08 09:36  Map\MyToolbase.h

............此处省略31个文件信息

评论

共有 条评论