Cesium实现淹没分析效果(polygon方式)

通过cesium可以实现一些常规的分析功能,本文通过拉伸polygon的方式实现三维淹没分析效果

效果图如下:

原理也比较简单,大家可以试想一下通过一个立方体从地形最低处开始上升,地势低洼的地方会率先显示立方体(水),从而在视觉上实现淹没分析效果。

核心代码:

​
        let ref = {
            "color": "rgba(0,191,255,0.5)",
            "targetHeight": 10,
            "waterHeight": 0
        }
        this.viewer.entities.add({
            polygon: {
              hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights(floodtemparr),
              extrudedHeight: new Cesium.CallbackProperty(function () {
                  ref.waterHeight += 0.0025;
                if (ref.waterHeight > 10) {
                  ref.waterHeight = ref.targetHeight; 
                }
                return ref.waterHeight
              }, false),
              perPositionHeight: true,
              closeTop: false,
              material: new Cesium.Color.fromCssColorString(ref.color),
            }
          })

​

注:floodtemparr数组是划线的经纬度坐标数组,包含每一个点的高度坐标,其余相关参数根据业务需求自行动态配置至ref。