zoukankan      html  css  js  c++  java
  • featurecursor

     //IFeatureBuffer Example

        public void IFeatureBuffer_Example(IFeatureClass featureClass)
        {
            //Function is designed to work with polyline data
            if (featureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) { return; }


            //get the Workspace from the IDataset interface on the feature class
            IDataset dataset = (IDataset)featureClass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;


            //Start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();


            //Create the Feature Buffer
            IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
            //Create insert Feature Cursor using buffering = true.
            IFeatureCursor featureCursor = featureClass.Insert(true);


            object featureOID;


            //With a feature buffer you have the ability to set the attribute for a specific field to be
            //the same for all features added to the buffer.
            featureBuffer.set_Value(featureBuffer.Fields.FindField("InstalledBy"), "K Johnston");


            //Here you can set the featurebuffers's shape by setting the featureBuffer.Shape
            //to a geomerty that matched the featureclasses.
            //Create 100 features using FeatureBuffer and insert into a feature cursor
            ESRI.ArcGIS.Geometry.IPolyline polyline = new ESRI.ArcGIS.Geometry.PolylineClass();
            ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass();
            for (int i = 0; i < 100; i++)
            {
                //Create the polyline geometry to assign to the new feature
                point.X = 498490 + i * 10;
                point.Y = 675380 + i * 10;
                polyline.FromPoint = point;
                point = new ESRI.ArcGIS.Geometry.PointClass();
                point.X = 498480 + i * 10;
                point.Y = 675390 + i * 10;
                polyline.ToPoint = point;
                featureBuffer.Shape = polyline;


                //Insert the feature into the feature cursor
                featureOID = featureCursor.InsertFeature(featureBuffer);
            }
            //Flush the feature cursor to the database
            //Calling flush allows you to handle any errors at a known time rather then on the cursor destruction.
            featureCursor.Flush();


            //Stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);


            //Release the Cursor
            System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);

  • 相关阅读:
    vcruntime140.dll 14.0与PHP版本不兼容,PHP Warning: 'vcruntime140.dll' 14.0 is not compatible with this PHP build linked with 14.16 in Unknown on line 0
    PHP处理字符中的emoji表情
    Thinkphp5 使用unlink删除文件出错Permission denied
    TP5多字段排序
    TP5 按照汉字的拼音排序
    PHP发送微信模版消息
    [52ABP系列]
    [52ABP系列]
    通过微信公众号实现微信快捷登陆
    [Jexus系列] 一、安装并运行 Jexus
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1406133.html
Copyright © 2011-2022 走看看