Cesium 水淹分析

一、概述

这是采用polygon加高度模拟出来的,extrudedHeight是高度。

二、效果

三、代码

1、分析(部分)

复制代码

    /**
     * 开始分析
     * @param {*} cartesiansArray 笛卡尔坐标数组,范围
     */
    start(cartesiansArray,callback) {
        if (!this._polygon) {
            this._drawPolygon(cartesiansArray);
        }
        this._interval = window.setInterval(() => {
            if ((this._maxHeight > this._extrudedHeight) && (this._extrudedHeight >= this._minHeight)) {
                this._extrudedHeight += this._speed;
            } else {
                this._extrudedHeight = this._minHeight;
            }
            if(callback){
                callback(this._extrudedHeight);
            }
        }, this._intervalStep)
        this.viewer.scene.globe.depthTestAgainstTerrain = true;
    }

复制代码

2、调用

复制代码

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    let t = [
      //初始范围
      107.428594,
      41.282392,
      107.456929,
      41.282392,
      107.456929,
      41.305005,
      107.428594,
      41.305005,
    ];
    let t2 = [
      //初始范围
      107.345147,
      41.395337,
      107.568974,
      41.396442,
      107.555225,
      41.224117,
      107.376214,
      41.228213,
    ];
    let drawPolygon = null; //绘制的范围
    let waterAnalysis = null; //水淹分析类
    let drawPositions = Cesium.Cartesian3.fromDegreesArray(t2); //绘制产生的点
    let polygonEntity = null; //绘制的多边形实体
    let form = {
      auto: false,
      curHeight: 990,
      minHeight: 990,
      maxHeight: 1440,
      setpHeight: 20,
    };
    //这里存放数据
    return {
      form,
      t,
      t2,
      drawPolygon,
      waterAnalysis,
      drawPositions,
      polygonEntity,
      defaultPolygon: undefined,
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {
    "form.auto"(v) {
      if (v) {
        this.start();
      } else {
        this.notAuto();
      }
    },
  },
  //方法集合
  methods: {
    changeslider(v) {
      if (!this.form.auto) {
        if (this.waterAnalysis) {
          this.waterAnalysis.noAuto(this.drawPositions, this.form.curHeight);
        }
      }
    },
    notAuto() {
      this.pause();
      if (this.waterAnalysis) {
        this.waterAnalysis.noAuto(this.drawPositions, this.form.curHeight);
      }
    },
    changeHeigit(type) {
      if (this.waterAnalysis) {
        this.waterAnalysis.resetParas(this.form);
      }
    },
    init() {
      let that = this;
      bus.$on("analysis_water", (visible) => {
        if (visible) {
          that.initWater();
          that.defaultPolygon = that.waterAnalysis.drawDefaultPolygon(that.t2);
          var center = Cesium.Cartesian3.fromDegrees(107.428594, 41.282392, 0);
          var center2 = Cesium.Cartesian3.fromDegrees(107.456929, 41.305005, 0);
          cesiumLocateUtil.flyToRectangle(
            [center, center2],
            0,
            -45,
            1.3,
            2,
            function () {}
          );
        } else {
          that.clear();
        }
      });
    },
    initWater() {
      this.clear();
      if (!this.waterAnalysis) {
        this.waterAnalysis = new CesiumWaterAnalysis(window.viewer, {
          minHeight: this.form.minHeight,
          maxHeight: this.form.maxHeight,
          speed: this.form.start,
          intervalStep: 300,
        });
      }
    },
    draw() {
      let that = this;
      if (this.waterAnalysis) {
        this.waterAnalysis.stop();
        this.waterAnalysis = null;
      }
      if (this.drawPolygon) {
        this.drawPolygon.clear();
        this.drawPolygon = null;
      }
      if (this.polygonEntity) {
        viewer.entities.remove(this.polygonEntity);
        this.polygonEntity = null;
      }
      that.initWater();
      if (!this.drawPolygon) {
        this.drawPolygon = new DrawPolygon(viewer, {
          onCompleted: function (positions) {
            that.drawPositions = positions;
            that.polygonEntity = that.drawPolygon.polygonPoint;
            that.drawPolygon.polygonPoint.polygon.fill = false;
          },
        });
      }
      this.drawPolygon.startDraw();
    },
    start() {
      if (!this.waterAnalysis) {
        alert("未初始化");
        return;
      }
      this.waterAnalysis.start(this.drawPositions, (h) => {
        this.form.curHeight = h;
      });
    },
    pause() {
      if (this.waterAnalysis) {
        this.waterAnalysis.pause();
      }
    },
    stop() {
      this.clear();
    },
    clear() {
      this.form = {
        auto: false,
        curHeight: 990,
        minHeight: 990,
        maxHeight: 1440,
        setpHeight: 20,
      };
      if (this.waterAnalysis) {
        this.waterAnalysis.stop();
        this.waterAnalysis = null;
      }
      if (this.drawPolygon) {
        this.drawPolygon.clear();
        this.drawPolygon = null;
      }
      if (this.defaultPolygon) {
        viewer.entities.remove(this.defaultPolygon);
      }
    },
  },
  //生命周期 - 创建完成(可以访问当前this实例)
  created() {},
  //生命周期 - 挂载完成(可以访问DOM元素)
  mounted() {
    this.init();
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
};

复制代码

骋天淹没分析系统 骋天淹没分析系统是以三维地理信息系统为基础平台,基于数字高程模型(DEM)格网模型,通过改进迭代种子蔓延算法将淹没分析结果直观在三维地理系统系统上呈现出来。 骋天淹没分析系统应用于水库的库区淹没分析时,设置好起止水位和终止水位,以三维的形式呈现库区淹没区域,根据不同是水深来计算库容量,移民数量、直接经济影响和间接经济影响。可将数据制作成柱状图、饼状图、曲线图等多种多样的统计图;能够根据业务流程和用户要求定制各类表格,进行业务报表输出;还能按某一要素生成范围图、点密度图、分级符号图等,进行专题图分析,形象直观地反映防洪要素的时空变化规律。 骋天淹没分析系统亦可应用于洪水淹分析时,根据洪水演进过程,配合数字化地图,利用三维模型,计算洪水淹没范围和淹没水深,并动态显示淹没区域并动态显示淹没区域,计算人口、家庭财产、工商、企业、农业、林业、渔业和畜牧业等淹没信息。并可根据预报调度、实时调度和历史调度等不同洪水下泻过程,计算分析水淹没损失,显示淹没分布状况,从而得出最佳洪水调度预案,提供泄洪区域内人员撤退、避灾转移和救灾物资供应等最佳行动路线。 广西骋天信息科技有限公司 网站 www.gxchengtian.com
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

苹果园dog

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值