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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。