zoukankan      html  css  js  c++  java
  • ArcGIS Engine 编辑- IWorkspaceEdit

    转自原文 ArcGIS Engine 编辑- IWorkspaceEdit

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

      IWorkspaceFactory pWsF = new ShapefileWorkspaceFactory();

                    IFeatureWorkspace pFtWs = pWsF.OpenFromFile(@"E:arcgisEngine数据", 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());

    效果如下:

     

     
  • 相关阅读:
    loj#6433. 「PKUSC2018」最大前缀和(状压dp)
    PKUWC2019游记
    10. Regular Expression Matching
    9. Palindrome Number
    8. String to Integer (atoi)
    7. Reverse Integer
    6. ZigZag Conversion
    5. Longest Palindromic Substring
    4. Median of Two Sorted Arrays
    3. Longest Substring Without Repeating Characters
  • 原文地址:https://www.cnblogs.com/arxive/p/6262951.html
Copyright © 2011-2022 走看看