返回SDE中某要素上所有点的坐标

/// <summary>
    /// 返回SDE中某要素上所有点的坐标
    /// </summary>
    /// <param name="workspace">工作空间</param>
    /// <param name="featureclassname">要素集名称</param>
    /// <param name="featureindex">要素集中要素索引</param>
    /// <returns>返回数据集,[ID,X,Y]</returns>
    public static DataSet GetPointsofPolylin(IWorkspace workspace, string featureclassname, int featureindex)
    {
        //打开工作空间
        IFeatureWorkspace featureworkspace = (IFeatureWorkspace)workspace;
        IFeatureClass featureclass = featureworkspace.OpenFeatureClass(featureclassname);
        //获取一个要素
        IFeature feature = featureclass.GetFeature(featureindex);
        IGeometry boundgeometry = feature.Shape;
        IPointCollection poincollection = boundgeometry as ESRI.ArcGIS.Geometry.IPointCollection;
        //获取点选中集中点的个数
        int pointCount = poincollection.PointCount;
        //定义一个数据集用来存放查询到的所有的点的X,Y坐标
        DataSet ds = new DataSet("PolylinePoints");
        DataTable tb1 = new DataTable("Points");
        ds.Tables.Add(tb1);
        DataColumn col1 = tb1.Columns.Add("ID", typeof(int));
        //col1.AutoIncrement = true;
        //col1.AutoIncrementSeed = -1;
        //col1.AutoIncrementStep = -1;
        //col1.ReadOnly = true;
        DataColumn col2 = tb1.Columns.Add("X", typeof(double));
        DataColumn col3 = tb1.Columns.Add("Y", typeof(double));
        for (int i = 0; i < poincollection.PointCount; i++)
        {
            DataRow row = ds.Tables["Points"].NewRow();
            //row["ID"] = "ALFKI";
            ds.Tables["Points"].Rows.Add(row);
            object[] avalues = { i, poincollection.get_Point(i).X, poincollection.get_Point(i).Y };
            ds.Tables["Points"].LoadDataRow(avalues, false);           
        }
        //返回数据集
        return ds;
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值