读取线图层上的点,输出为点图层

 1 private void 输出断面点ToolStripMenuItem_Click(object sender, EventArgs e)
 2         {
 3             ESRI.ArcGIS.Geodatabase.IWorkspaceFactory wsf = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory();
 4             IWorkspace ws = wsf.OpenFromFile(@"F:\1-水利项目\安徽水利\0826处理", 0);
 5             
 6             IFeatureClass autoStation = (ws as IFeatureWorkspace).OpenFeatureClass("站点位置线");
 7             IFeatureClass f1 = (ws as IFeatureWorkspace).OpenFeatureClass("断面点");
 8 
 9             int num = autoStation.FeatureCount(null);
10             //List<IPoint> listpt = new List<IPoint>();
11             int k = 0;
12             for (int i = 0; i < num; i++) //for (int i = 0; i < ptc.PointCount; i++)// for (int i = 0; i < num; i++)
13             {
14                 IPolyline pl = autoStation.GetFeature(i).Shape as IPolyline;
15                 IPointCollection ptc = pl as IPointCollection;
16                 if (i < num - 1)
17                 {
18                     IPoint pt = ptc.get_Point(0);
19                     k++;
20                     IFeature fea = f1.CreateFeature();
21                     fea.Shape = pt;
22                     fea.set_Value(fea.Fields.FindField("Id"), k);
23                     fea.set_Value(fea.Fields.FindField("longi"), pt.X);
24                     fea.set_Value(fea.Fields.FindField("latit"), pt.Y);
25                     fea.Store();
26 
27                 }
28                 else
29                 {
30                     IPoint pt = ptc.get_Point(0);
31                     k++;
32                     IFeature fea = f1.CreateFeature();
33                     fea.Shape = pt;
34                     fea.set_Value(fea.Fields.FindField("Id"), k);
35                     fea.set_Value(fea.Fields.FindField("longi"), pt.X);
36                     fea.set_Value(fea.Fields.FindField("latit"), pt.Y);
37                     fea.Store();
38                     pt = ptc.get_Point(1);
39                     k++;
40                     fea = f1.CreateFeature();
41                     fea.Shape = pt;
42                     fea.set_Value(fea.Fields.FindField("Id"), k);
43                     fea.set_Value(fea.Fields.FindField("longi"), pt.X);
44                     fea.set_Value(fea.Fields.FindField("latit"), pt.Y);
45                     fea.Store();
46                 }
47             }
48         }

 

posted @ 2013-08-27 10:17  寻梦放歌  阅读(325)  评论(0编辑  收藏  举报