/// <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;
}
返回SDE中某要素上所有点的坐标
最新推荐文章于 2021-10-28 11:49:26 发布