码迷,mamicode.com
首页 > 其他好文 > 详细

ArcGIS Engine 编辑- IWorkspaceEdit

时间:2017-01-09 00:21:30      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:relay   engine   port   tail   on()   cto   lap   结合   arcgis   

转自原文 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());

效果如下:

 

 

 

ArcGIS Engine 编辑- IWorkspaceEdit

标签:relay   engine   port   tail   on()   cto   lap   结合   arcgis   

原文地址:http://www.cnblogs.com/arxive/p/6262951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!