点线面空间信息的获取
在实际的GIS中,坐标的空间信息是个比较重要的数据,大多数的操作、分析也都是基于这个方面的
1.进入选中模式
选中模式
2.选中一个要获取信息feature
选中要素
3.区分选中的要素是点线面的哪一种
if (selFeature.Geometry.Type == EnumGeometryType.GeoMarker)
else if(selFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
else if (selFeature.Geometry.Type == EnumGeometryType.GeoPolygon3D)
点
线
面
4.获取坐标信息
4.1点的坐标信息
GSOGeoPoint3D point = selFeature.Geometry as GSOGeoPoint3D;
if (point != null)
{
Console.WriteLine("选中的是一个点要素");
Console.WriteLine("经度=" + point.X + "纬度=" + point.Y, "经纬度显示");
}
点信息
4.2线的坐标信息
注意:线和点不同,线有多个节点,也就是说,线的点有一个集合的概念
else if(selFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
{
GSOGeoPolyline3D polyline = selFeature.Geometry as GSOGeoPolyline3D;
//判断选中的线的feature是否是一个空的feature
if (polyline != null)
{
Console.WriteLine("选中的是一个线要素");
int count= polyline[0].Count;
for (int i = 0; i < count; i++)
{
GSOPoint3d polyline_point = polyline[0][i];
Console.WriteLine("经度=" + polyline_point.X + "纬度=" + polyline_point.Y, "经纬度显示");
}
}
}
线的信息
4.3面的坐标信息
注意:面和线类似,输出的也是多个的节点
else if (selFeature.Geometry.Type == EnumGeometryType.GeoPolygon3D)
{
GSOGeoPolygon3D polygon = selFeature.Geometry as GSOGeoPolygon3D;
//判断选中的面的feature是否是一个空的feature
if (polygon != null)
{
Console.WriteLine("选中的是一个面要素");
int count = polygon[0].Count;
for (int i = 0; i < count; i++)
{
GSOPoint3d polygon_point = polygon[0][i];
Console.WriteLine("经度=" + polygon_point.X + "纬度=" + polygon_point.Y, "经纬度显示");
}
}
}
面的信息
5.完整示例
private void button4_Click(object sender, EventArgs e)
{
globeControl1.Globe.Action = EnumAction3D.SelectObject;//鼠标变成选中状态
}
private void button3_Click(object sender, EventArgs e)
{
GSOFeature selFeature = globeControl1.Globe.SelectedObject;//选中了一个feature
//判断选中的对象是点线面中的哪一种
if (selFeature.Geometry.Type == EnumGeometryType.GeoMarker)
{
GSOGeoPoint3D point = selFeature.Geometry as GSOGeoPoint3D;
if (point != null)
{
Console.WriteLine("选中的是一个点要素");
Console.WriteLine("经度=" + point.X + "纬度=" + point.Y, "经纬度显示");
}
}
else if(selFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
{
GSOGeoPolyline3D polyline = selFeature.Geometry as GSOGeoPolyline3D;
//判断选中的线的feature是否是一个空的feature
if (polyline != null)
{
Console.WriteLine("选中的是一个线要素");
int count= polyline[0].Count;
for (int i = 0; i < count; i++)
{
GSOPoint3d polyline_point = polyline[0][i];
Console.WriteLine("经度=" + polyline_point.X + "纬度=" + polyline_point.Y, "经纬度显示");
}
}
}
else if (selFeature.Geometry.Type == EnumGeometryType.GeoPolygon3D)
{
GSOGeoPolygon3D polygon = selFeature.Geometry as GSOGeoPolygon3D;
//判断选中的面的feature是否是一个空的feature
if (polygon != null)
{
Console.WriteLine("选中的是一个面要素");
int count = polygon[0].Count;
for (int i = 0; i < count; i++)
{
GSOPoint3d polygon_point = polygon[0][i];
Console.WriteLine("经度=" + polygon_point.X + "纬度=" + polygon_point.Y, "经纬度显示");
}
}
}
}
6.这样就可以快速的输出选中的要素的信息了
上一篇
下一篇