最近在基于cesium做水利项目的淹没分析 因为真实的洪水情况下,对于不同的地势来说 每个淹没区间的不同时刻水位高度肯定是不一样的 所以要求对多河段的高度做一个动态的水位上涨与下降的效果 不同河段水位高要以不一样的颜色显示  以下是其中一个河段的实现的代码参考

先看看效果吧

cesium淹没分析

初始化地图

<template><div class="water-page"><div id="cesiumContainer"></div></div>
</template>
<script setup>
import { onMounted, ref } from "vue";
import FloodAnalysis from "./FloodAnalysis.js";
const initMap = () => {CesiumMap = new Cesium.Viewer("cesiumContainer", {geocoder: false,animation: false,timeline: false,infoBox: false,baseLayerPicker: false,fullscreenButton: false,homeButton: false,sceneModePicker: false,navigationHelpButton: false,imageryProvider: new Cesium.ArcGisMapServerImageryProvider({url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",}),CreditsDisplay: false,selectionIndicator: false,scene3DOnly: true,requestRenderMode: true,terrainProvider: Cesium.createWorldTerrain({requestVertexNormals: true,requestWaterMask: true,}),terrainProvider: new Cesium.ArcGISTiledElevationTerrainProvider({url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer",}),});// CesiumMap.timeline.container.style.visibility = "hidden";CesiumMap._cesiumWidget._creditContainer.style.display = "none"; //LOGO显示CesiumMap.scene.globe.depthTestAgainstTerrain = true;CesiumMap.camera.setView({destination :  Cesium.Cartesian3.fromDegrees(105.5793, 30.5305127, 1000),orientation: {heading :0, // 相机方向指向当地东向pitch : Cesium.Math.toRadians(-15),    // 再将相机方向转向地心,此时Up方向指向当地东向roll : 0.0                             }
});createWater();
};
/*** 获取数据创建水面*/
const waterColor = ref("rgba(183, 149, 75, 0.91)");
const createWater = () => {let data = require("./flood_data.json");let waterEntity = new FloodAnalysis(CesiumMap, {...data,waterColor: waterColor.value,show: true,});
};onMounted(() => {initMap();
});
</script>
<style lang="scss" scoped>
.water-page {width: 100vw;height: 100vh;#cesiumContainer {width: 100%;height: 100%;}
}
</style>

关键代码

/*** @description 淹没分析函数,通过拉伸面的高度来进行分析*/
class FloodAnalysis {constructor(viewer, options) {if (!viewer) throw new Error("no viewer object!");this.viewer = viewer;this.positions = this.CoorsFormt(options.polygon);this.times_height = options.times_height;this.currentIndex = 0;this.initialHeight = this.times_height[this.currentIndex];this.targertHeight = this.times_height[this.currentIndex + 1];this.increaseHeight = this.targertHeight - this.initialHeight;this.waterColor = options.waterColor;this.show = options.show;this.start = null;this.init();this.getNowHeight();}CoorsFormt(coors) {let Arr = [];coors.forEach((coor) => {Arr.push(coor[0]);Arr.push(coor[1]);});return Arr;}async init() {this.viewerSET();// this.start = Cesium.JulianDate.now(new Date());const self = this;this.property = this.computeFlight(this.times_height);this.viewer.scene.globe.depthTestAgainstTerrain = true;this.entity = this.viewer.entities.add({show: this.show,availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({start: this.start,stop: Cesium.JulianDate.addMinutes(this.start,10 * this.times_height.length,new Cesium.JulianDate()),}),]),polygon: {hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(this.positions)),extrudedHeight: this.property,height:this.property,material: Cesium.Color.fromCssColorString(this.waterColor)},});}
/*
*时间水位与时间关联
*/computeFlight(data) {let property = new Cesium.SampledProperty(Number);data.forEach((item, i) => {property.addSample(Cesium.JulianDate.addMinutes(this.start,10 * i,new Cesium.JulianDate()),item);});return property;}
/*
*设置时间
*/viewerSET() {this.start = Cesium.JulianDate.fromDate(new Date());this.start = Cesium.JulianDate.addHours(this.start,8,new Cesium.JulianDate());this.stop = Cesium.JulianDate.addMinutes(this.start,10 * this.times_height.length,new Cesium.JulianDate());this.viewer.clock.startTime = this.start.clone();this.viewer.clock.currentTime = this.start.clone();this.viewer.clock.stopTime = this.stop.clone();// this.viewer.clock.multiplier = 3600if (this.viewer.timeline)this.viewer.timeline.zoomTo(this.start, this.stop);this.viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;}/*** 获取实时水面高度*/getNowHeight() {const self = this;this.viewer.clock.onTick.addEventListener(function () {if (self.increaseHeight > 0) {if (self.initialHeight > self.targertHeight) {self.currentIndex += 1;if (self.currentIndex > self.times_height.length - 2) {self.currentIndex = 0;}self.initialHeight = self.times_height[self.currentIndex];self.targertHeight = self.times_height[self.currentIndex + 1];self.increaseHeight = self.targertHeight - self.initialHeight;}}if (self.increaseHeight < 0) {if (self.initialHeight < self.targertHeight) {self.currentIndex += 1;if (self.currentIndex > self.times_height.length - 2) {self.currentIndex = 0;}self.initialHeight = self.times_height[self.currentIndex];self.targertHeight = self.times_height[self.currentIndex + 1];self.increaseHeight = self.targertHeight - self.initialHeight;}}self.initialHeight += self.increaseHeight / 100;});}/*** 改变颜色* @param {水体颜色} val*/changeWaterColor(val) {this.entity.polygon.material = val;}/*** 隐藏与显示* @param {Boolean} val*/changeWaterShow(val) {this.entity.show = val;}destroy() {this.viewer.entities.remove(this.entity);delete this.entity;delete this.positions;delete this.initialHeight;delete this.targertHeight;delete this.increaseHeight;}
}export default FloodAnalysis;

Cesium洪水淹没分析 洪水淹没高度的上涨与下降相关推荐

  1. cesium开发淹没分析_淹没在Web开发行业的工具中

    cesium开发淹没分析 Every once in a while in this industry we need a reminder that our trade as front-end d ...

  2. vue3+SuperMap iClient3D for Cesium实现淹没分析功能

    本人小白一枚,文章如有问题还请各位大神评论区指出.整体实现是参考SuperMap iClient3D for Cesium的淹没分析功能源码~ 文章目录 前言 一.主要功能 二.具体实现 1.HTML ...

  3. vue + cesium 洪水淹没分析完整示例

    目录 一.洪水淹没分析效果 二.部分核心代码 1.绘制多边形范围 2.处理多边形区域的最大和最小高程 三.JS完整代码 一.洪水淹没分析效果 二.部分核心代码 1.绘制多边形范围 /*** @auth ...

  4. 怎么使用ArcScene进行洪水淹没分析

    概述 水经注软件除了可以轻松下载无水印Google Earth卫星影像.有明确拍摄日期的历史影像.地方高清天地图.百度高德大字体打印地图,按1万/5千等国家标准图幅下载,对百度坐标与火星坐标进行纠偏: ...

  5. ArcGIS利用DEM进行洪水淹没分析(附练习数据下载)

    ArcGIS利用DEM进行洪水淹没分析(附练习数据下载) 图片 基于数字高程模型 ( DEM )格网模型, , 实现给定水深情况下洪水淹没区的计算模型, 讨论洪水 淹没演进过程可视化实现的关键技术, ...

  6. 如何用ArcScene进行洪水淹没分析

      近几年来,将GIS技术与RS技术相结合,根据数字高程模型DEM提供的三维数据和遥感影象数据来预测.模拟显示洪水淹没场景,并进行洪水灾害评估,已成为GIS在洪水方面主要研究领域.这里分享一下如何使用 ...

  7. 【ArcGIS教程】洪水淹没分析——以青海省为例

    Part1准备数据 如下为已经处理好的所需数据:青海省90mDEM.青海省边界数据.青海省影像 青海省90mDEM:可从地理空间数据云等网站下载好后进行镶嵌拼接处理 青海省边界数据:可直接下载处理 青 ...

  8. 有源淹没分析arcgis_基于ArcGIS的洪水淹没分析与三维模拟

    基于 ArcGIS 的洪水淹没分析与三维模拟 孙 君 , 奚赛英 , 尤 迪 , 郑付涛 [摘 要] 摘 要 : 洪水淹没范围的确定是洪灾损失评估和防洪决策的核心环节 . 基 于 TIN 数据 , 运 ...

  9. 怎么使用ArcMap进行洪水淹没分析

    概述 水经注软件除了可以轻松下载无水印Google Earth卫星影像.有明确拍摄日期的历史影像.地方高清天地图.百度高德大字体打印地图,按1万/5千等国家标准图幅下载,对百度坐标与火星坐标进行纠偏: ...

最新文章

  1. 面试:说说Java中的 volatile 关键词?
  2. python画图武汉加油-python实现“武汉加油”点阵字
  3. Java并发编程的艺术 记录(一)
  4. centos linux 内核升级,Centos系统的升级及Linux 内核升级
  5. 【HDU - 1863】 畅通工程(并查集+最小生成树)
  6. Objective-C 【从文件中读写字符串(直接读写/通过NSURL读写)】
  7. NDoc修改手记(一)
  8. python post body_python写http post请求的四种请求体
  9. 【源码解读】EOS测试插件:txn_test_gen_plugin.cpp
  10. c语言用链表实现成绩管理系统,C语言写的学生成绩管理系统(链表)
  11. 关于Android中为什么主线程不会因为Looper.loop()里的死循环卡死?引发的思考,事实可能不是一个 epoll 那么 简单。...
  12. 乐鑫再次称王WiFi MCU市场
  13. Python3 使用psycopg2模块 批量写入数据到PostgreSQL数据库(最强输出速度,单机数据库3000W数据写入最多180秒)
  14. vue 自定义marquee横向无缝滚动组件
  15. 百度地图点聚合仿链家定位点多级聚合,且滑动、刷新加载定位点
  16. 一个简单的静态网页制作(html+css)
  17. 终端模拟器常用快捷键
  18. 前端、数据库面试要点
  19. 输入学生的学号及语文、数学、英语成绩, 输出学生各科成绩及率均成绩信息
  20. 差分函数(差分运算)

热门文章

  1. USBASP USB Programmer
  2. Linux解压命令tar -zxvf中参数zxvf解释
  3. OpenCV 4.x API 详解与C++实例-Mat数据类型详解
  4. Kali渗透之基于SMB协议收集信息
  5. 在Kubernetes上搭建新版fluentd-elasticsearch_1.22日志收集工具
  6. vue.runtime.esm.js?2b0e:619 [Vue warn]: Invalid prop: type check failed for prop “uniqueOpened“. Exp
  7. Python后端学习路线
  8. OKHttp3 Cookie 持久化
  9. 写完申请书,又要更新了
  10. 苹果 iPhone 4 手机拆机组图,看看 iPhone 4 的内部构造与零件(二)_打杂的_新浪博客...