ao增加操作

 //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);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值