转自原文 ArcGIS Engine 编辑- IWorkspaceEdit

这个例子中,我创建了1000条要素,并结合缓冲将数据写到文件中,并且添加了时间统计,当然数据是我捏造的,还请原谅,这个花费的时间为0.978秒,速度还行。

IWorkspaceFactory pWsF = new ShapefileWorkspaceFactory();

IFeatureWorkspace pFtWs = pWsF.OpenFromFile(@"E:\arcgis\Engine\数据", 0) as IFeatureWorkspace;

IFeatureClass pFtClass = pFtWs.OpenFeatureClass("edit");

IFeatureLayer pFt = new FeatureLayerClass();

pFt.FeatureClass = pFtClass;
                pFt.Name = "画线";

axMapControl1.Map.AddLayer(pFt as ILayer);

axMapControl1.Refresh();

//为了进一步说明Idataset,我特意从下面的代码

IDataset pDataset = pFtClass as IDataset;

IWorkspace pWs = pDataset.Workspace;

pWsEdit = pWs as IWorkspaceEdit;

pWsEdit.StartEditing(true);

pWsEdit.StartEditOperation();

pBoolStart = pWsEdit.IsBeingEdited();

System.Diagnostics.Stopwatch TimeWatch = new System.Diagnostics.Stopwatch();

TimeWatch.Start();

IFeatureBuffer pFeatureBuffer = pFtClass.CreateFeatureBuffer();

IFeatureCursor pFtCusor = pFtClass.Insert(true);

ESRI.ArcGIS.Geometry.IPolyline polyline = new ESRI.ArcGIS.Geometry.PolylineClass();
                ESRI.ArcGIS.Geometry.IPoint pPoint = new ESRI.ArcGIS.Geometry.PointClass();

ESRI.ArcGIS.Geometry.IPoint pPoint2 = new ESRI.ArcGIS.Geometry.PointClass();
                for (int i = 0; i < 1000; i++)
                {

pPoint.X = 48 + i * 102;

pPoint.Y = 65 + i * 10;

polyline.FromPoint = pPoint;

pPoint2.X = 480 + i * 10;

pPoint2.Y = 615 + i * 102;

polyline.ToPoint = pPoint2;

pFeatureBuffer.Shape = polyline;

pFeatureBuffer.set_Value(2, i);

object pFeatureOID = pFtCusor.InsertFeature(pFeatureBuffer);
                }

pFtCusor.Flush();

pWsEdit.StopEditing(true);

axMapControl1.Refresh();
                TimeWatch.Stop();

MessageBox.Show(TimeWatch.Elapsed.Milliseconds.ToString());

效果如下:

 

最新文章

  1. CentOS 7 安装RabbitMQ 3.3
  2. Ajax跨域的几种方法以及每种方法的原理
  3. 【LeetCode】Product of Array Except Self
  4. SQL Server数据同步的研究(单向/双向)
  5. Linux合并文件、去除重复行的命令
  6. Linux下c函数dlopen实现加载动态库so文件代码举例
  7. Method Swizzling 和 AOP 实践(转)
  8. Webservices-2.C#创建web服务,及引用访问、代码访问
  9. 解决MYSQL弃用模块错误Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future
  10. java设计模式--创建模式--原型模式
  11. ODBC、OLE DB、 ADO、ODAC、ODP.NET
  12. 两个栈实现队列+两个队列实现栈----java
  13. strchr,wcschr 和strrchr, wcsrchr,_tcschr,_tcsrchr功能
  14. C# MVC权限验证
  15. 关于laravel5.2仓库的建立,以及简单调用
  16. LANMP一键安装包 版本服务任你选 可安装单一服务
  17. Log4j使用详解
  18. bmob云代码中生成缩略图
  19. 使用mongodb的一些笔记
  20. Dynamics 365 Customer Engagement V9 活动源功能报错的解决方法

热门文章

  1. 37.Node.js工具模块---处理和转换文件路径的工具 Path模块
  2. mahout的特性(三)
  3. Java学习笔记二.1
  4. ubuntu搭建交叉编译环境makeinfo: command not found
  5. python 新模块或者包的安装方法
  6. CentOS7下简单安装python3.7.0步骤
  7. groupbox里面添加Form
  8. C# 报表
  9. Mahjong tree (hdu 5379 dfs)
  10. 计算机系统—CPU结构和内部工作