ArcGis 创建 FeatureClass
2016-03-09 16:12
447 查看
ArcGis 创建 FeatureClass C++代码
bool CreateNewFeatureClass( CString strFeatureClassName, IFeatureWorkspacePtr pFeatureWorkspace ) { IFieldsPtr ipFields( CLSID_Fields ); IFieldsEditPtr ipFieldsEdit = ipFields; IFieldEditPtr pFieldEdit; IWorkspaceDomainsPtr pWorkspaceDomain(pFeatureWorkspace); IDomainPtr pDomain; // Field:OBJECTID IFieldPtr pField1( CLSID_Field ); pFieldEdit = (IFieldEditPtr)pField1; pFieldEdit->PutName( _T("OBJECTID") ); pFieldEdit->PutAliasName( _T("OBJECTID") ); pFieldEdit->PutType( **esriFieldTypeOID** ); if(FAILED(ipFieldsEdit->AddField( pField1 ))) return nullptr; // Field:SHAPE IFieldPtr pField2( CLSID_Field ); pFieldEdit = ( IFieldEditPtr )pField2; pFieldEdit->PutName( _T("SHAPE") ); pFieldEdit->PutAliasName( _T("Shape") ); pFieldEdit->PutType( esriFieldTypeGeometry ); pFieldEdit->putref_GeometryDef( createGeometryDefine( esriGeometryPoint, esriSRGeoCS_WGS1984 ) ); if(FAILED(ipFieldsEdit->AddField( pField2 ))) return nullptr; // 其他Field ....... IFeatureClassPtr ipFeatureClass; HRESULT hr = pFeatureWorkspace->CreateFeatureClass( CComBSTR( strFeatureClassName ) ,ipFields , NULL , NULL , esriFTSimple , CComBSTR( L"SHAPE" ) , NULL , &ipFeatureClass ) ; } IGeometryDefPtr createGeometryDefine ( esriGeometryType geometryDefine, esriSRGeoCSType geocsType ) { ISpatialReferenceFactory2Ptr ipSpaRefFact2( CLSID_SpatialReferenceEnvironment ); IGeographicCoordinateSystemPtr ipGeoCoordSys; ipSpaRefFact2->CreateGeographicCoordinateSystem( geocsType ,&ipGeoCoordSys); ISpatialReferencePtr ipSRef = ipGeoCoordSys; IGeometryDefPtr ipGeoDef( CLSID_GeometryDef ); IGeometryDefEditPtr ipGeoDefEdit = ipGeoDef; ipGeoDefEdit->put_GeometryType( geometryDefine ); ipGeoDefEdit->putref_SpatialReference(ipSRef); return ipGeoDef; }
相关文章推荐
- To remove HTML markup, use BeautifulSoup's get_text() function解决方案
- CSS 布局
- CSS - 针对不同浏览器的写法
- psync scheduled to be closed ASAP for overcoming of output buffer limits
- webstorm+nodejs+JetBrains IDE Support+chrome打造前端开发神器
- 总结的JS数据类型判定(非常全面)
- css3实现背景切换
- jquery checkbox 全选 全不选 反选
- 读书笔记---HTML5实战 MARCO CASARIO(后六章)
- css3技巧——产品列表之鼠标滑过效果(一)
- WebPack系列教程(八):DEV TOOLS
- CreateFeature
- HTML5:多文件上传 Upload multiple files at once with HTML5, jQuery and PHP
- jQuery全屏滚动插件fullPage.js
- javascript中callee与caller的用法和应用场景
- JS第11天
- AngularJs优化小记
- html5 canvas画进度条
- WebPack系列教程(七):使用Plugins
- JS中关于 一个关于计时器功能效果的实现