解决通视分析未加载地形时会报错的问题

This commit is contained in:
zh
2025-08-19 10:58:07 +08:00
parent ef2c158727
commit de4aead219

View File

@ -63,11 +63,15 @@ class VisibilityAnalysis extends Tools {
that.tip.set_text("左键创建视角终点,右键结束通视分析") that.tip.set_text("左键创建视角终点,右键结束通视分析")
if (!that.resultObject.viewPoint) { if (!that.resultObject.viewPoint) {
let pos84 = that.cartesian3Towgs84(cartesian, that.viewer) let pos84 = that.cartesian3Towgs84(cartesian, that.viewer)
let positions = await Cesium.sampleTerrainMostDetailed( let positions
that.sdk.viewer.terrainProvider, if(that.sdk.viewer.terrainProvider.availability)
[Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)] {
); positions = await Cesium.sampleTerrainMostDetailed(
if (positions[0].height > pos84.alt) { that.sdk.viewer.terrainProvider,
[Cesium.Cartographic.fromDegrees(pos84.lng, pos84.lat)]
);
}
if (positions && positions[0].height > pos84.alt) {
pos84.alt = positions[0].height pos84.alt = positions[0].height
} }
pos84.alt = pos84.alt + that.viewPointHeight pos84.alt = pos84.alt + that.viewPointHeight