关于SuperMap Objects .NET中点串拟合飞行轨迹的说明

在三维GIS开发中,场景飞行是一种常用的展示手段,平滑的飞行轨迹能使三维展示更加流畅。下面介绍在SuperMap Objects .NET中如何将一系列的坐标点串拟合成平滑的飞行轨迹线:

// 定义轨迹点串,包括X、Y、Z三维坐标
double[][] coordinates = new double[99][];
// 定义相关点集
Point2Ds point2Ds = new Point2Ds();
Point2Ds heightItemPoint2Ds = new Point2Ds();
Point2Ds heightPoint2Ds = new Point2Ds();
// 定义曲线拟合段数
int cardinalSegment = 20;
// 遍历所有轨迹点
foreach (double[] coordinate in coordinates)
{
    // 根据X、Y坐标创建高度曲线
    Point2D point2D = new Point2D(coordinate[0], coordinate[1]);
    point2Ds.Add(point2D);
    heightItemPoint2Ds.Add(point2D);
    GeoCardinal heightItemGeoCardinal = new GeoCardinal(heightItemPoint2Ds);
    // 将高度曲线转换为几何线对象
    GeoLine heightItemGeoLine = heightItemGeoCardinal.ConvertToLine(cardinalSegment);
    // 将高度曲线长度和Z坐标定义为轨迹曲线的坐标
    point2D = new Point2D(heightItemGeoLine.Length, coordinate[2]);
    heightPoint2Ds.Add(point2D);
}
// 获取水平轨迹曲线
GeoCardinal geoCardinal = new GeoCardinal(point2Ds);
GeoLine geoLine = geoCardinal.ConvertToLine(cardinalSegment);
// 获取垂直轨迹曲线
GeoCardinal heightGeoCardinal = new GeoCardinal(heightPoint2Ds);
GeoLine heightGeoLine = heightGeoCardinal.ConvertToLine(cardinalSegment);
// 获取轨迹点集
Point2Ds allPoint2Ds = geoLine[0];
Point2Ds allHeightPoint2Ds = heightGeoLine[0];
// 拟合轨迹曲线
Point3Ds allPoint3Ds = new Point3Ds();
for (Int32 i = 0; i < allHeightPoint2Ds.Count; i++)
{
    allPoint3Ds.Add(new Point3D(allPoint2Ds[i].X, allPoint2Ds[i].Y, allHeightPoint2Ds[i].Y));
}
GeoLine3D geoLine3D = new GeoLine3D(allPoint3Ds);
// 返回轨迹曲线
return geoLine3D;

发表回复