You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GCSGUI/src/utils/map/SpatialAnalysis.ts

42 lines
1.3 KiB
TypeScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
文件描述:空间分析方法
创建时间2024/4/15 9:52
创建人Zhaipeixiu
*/
import {getDistance, getElevation} from "@/utils/map/geocomputation.ts";
import {Cartesian3, Viewer} from "cesium";
/**
* 地形剖面分析数值计算
* @param viewer 地图Viewer
* @param start 起点
* @param end 终点
* @param interval 线段采样间隔 m为单位
* @return 从起点至终点剖面线的海拔高度数组
*/
export function elevationProfile(viewer: Viewer, start:Cartesian3, end:Cartesian3, interval: number)
{
let breakPointsHeight = []
// 计算首尾点距离 m
let totalLen = getDistance(start, end) * 1000
console.log('总距离',totalLen)
// 获取起点高度
breakPointsHeight.push(getElevation(viewer, start))
//断点数量
let breakNum = Math.floor(totalLen/interval)
console.log('断点数量',breakNum)
// 如果采样间隔小于首尾点距离,则获取每个断点的坐标 并获取其高度
if(breakNum>=1){
for (let i = 1; i <= breakNum; i++) {
let breakP = Cartesian3.lerp(start, end, i/breakNum, new Cartesian3())
breakPointsHeight.push(getElevation(viewer, breakP))
console.log(`断点${i}高度:`,getElevation(viewer, breakP))
}
}
// 获取终点高度
breakPointsHeight.push(getElevation(viewer, end))
return breakPointsHeight
}