您好,登錄后才能下訂單哦!
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());
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。