我是靠谱客的博主 个性便当,最近开发中收集的这篇文章主要介绍C#+Arcengine获得点集合,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 最近在研究C#+arcengine,本人属于不写下来记不住的型,就把最近的功能全部写成博客记录下来,以备以后使用,有大神看到,路过就好


通过polyline文件路径获得其点集合,程序很简单,如下

    /// <summary>
        /// 得到点集合
        /// </summary>
        /// <param name="path"> line的路径+名称</param>
        /// <returns></returns>
        private List<IPoint> GetPointCollection(string path)
        {
            try
            {
                List<IPoint> pointCollList = new List<IPoint>();
                int iindx = path.LastIndexOf("\");
                string suffixRasterName = (path.Substring(iindx + 1));//线的的名称
                string maskPath = path.Remove(iindx);//线的路径
                //创建工作空间
                IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory();
                IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(maskPath, 0);
                //得到用户所选shp文件中的featureClass
                IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(suffixRasterName));
                //得到feature
                IFeatureCursor featureCursor = featureClass.Search(null, false);
                IFeature feature = featureCursor.NextFeature();
                while (feature != null)
                {
                    if (featureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline polyline = (IPolyline)feature.Shape;
                        //得到line的点集合
                        IPointCollection PointCol = polyline as IPointCollection;
                        for (int i = 0; i < PointCol.PointCount; i++)
                        {
                            pointCollList.Add(PointCol.get_Point(i));
                        }
                    }
                    feature = featureCursor.NextFeature();
                }
                return pointCollList;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
        }

最后

以上就是个性便当为你收集整理的C#+Arcengine获得点集合的全部内容,希望文章能够帮你解决C#+Arcengine获得点集合所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(76)

评论列表共有 0 条评论

立即
投稿
返回
顶部