当前位置: 首页 > news >正文

cesium-测量高度垂直距离

cesium做垂直测量

完整代码

<template><div id="cesiumContainer" style="height: 100vh;"></div><div id="toolbar" style="position: fixed;top:20px;left:220px;"><el-breadcrumb><el-breadcrumb-item>量测</el-breadcrumb-item><el-breadcrumb-item>垂直距离</el-breadcrumb-item></el-breadcrumb><el-row class="mb-4" style="margin-top: 15px"><el-button type="primary" @click="handleDrawPolyline">画线</el-button><el-button type="primary" @click="handleDrawPolylineCancel">清除</el-button></el-row></div>
</template>
<script setup>
import {onMounted, ref} from "vue";
import * as Cesium from "cesium";
import InitCesium from "../js/InitCesiumHide.js";
import DrawVerticalDistance from "@/assets/utils/measure/DrawVerticalDistance.js";let viewer = null;
let verticalDistance = null;onMounted(() => {let initCesium = new InitCesium('cesiumContainer')viewer = initCesium.initViewer({});verticalDistance = new DrawVerticalDistance(viewer);flyToRight2();
})const handleDrawPolyline = () => {if (verticalDistance) {// 开始量算verticalDistance.start();}
}const handleDrawPolylineCancel = () => {if (!verticalDistance) return;verticalDistance.destroy();
}const flyToRight2 = async () => {let tileset = await Cesium.Cesium3DTileset.fromUrl('/src/assets/tileset/12/tileset.json', {});update3dtilesMaxtrix(tileset);viewer.scene.primitives.add(tileset);viewer.flyTo(tileset);
}function update3dtilesMaxtrix(tileSet) {//调整参数let params = {tx: 113.06265738392063, //模型中心X轴坐标(经度,单位:十进制度)ty: 22.646803971034342, //模型中心Y轴坐标(纬度,单位:十进制度)tz: 40, //模型中心Z轴坐标(高程,单位:米)rx: 0, //X轴(经度)方向旋转角度(单位:度)ry: 0, //Y轴(纬度)方向旋转角度(单位:度)rz: 2, //Z轴(高程)方向旋转角度(单位:度)scale: 1.3, //缩放比例};//旋转const mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(params.rx));const my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(params.ry));const mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(params.rz));const rotationX = Cesium.Matrix4.fromRotationTranslation(mx);const rotationY = Cesium.Matrix4.fromRotationTranslation(my);const rotationZ = Cesium.Matrix4.fromRotationTranslation(mz);//平移const position = Cesium.Cartesian3.fromDegrees(params.tx,params.ty,params.tz);const m = Cesium.Transforms.eastNorthUpToFixedFrame(position);//旋转、平移矩阵相乘Cesium.Matrix4.multiply(m, rotationX, m);Cesium.Matrix4.multiply(m, rotationY, m);Cesium.Matrix4.multiply(m, rotationZ, m);//比例缩放const scale = Cesium.Matrix4.fromUniformScale(params.scale);Cesium.Matrix4.multiply(m, scale, m);// console.log("矩阵m:", m);//赋值给tilesettileSet._root.transform = m;
}
</script>
<style scoped>
#cesiumContainer {overflow: hidden;
}
</style>
<style>
.el-breadcrumb__inner {color: #ffffff !important;
}
</style>
InitCesiumHide
import * as Cesium from "cesium";class InitCesiumHide {constructor(cesiumContainer, options) {this.cesiumContainer = cesiumContainer;}initViewer(options) {Cesium.Ion.defaultAccessToken = 'token';// 西南东北,默认显示中国Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(90, -20, 110, 90);return new Cesium.Viewer(this.cesiumContainer, {animation: false, // 隐藏动画控件baseLayerPicker: false, // 隐藏图层选择控件fullscreenButton: false, // 隐藏全屏按钮vrButton: false, // 隐藏VR按钮,默认falsegeocoder: false, // 隐藏地名查找控件  地理编码homeButton: false, // 隐藏Home按钮infoBox: false, // 隐藏点击要素之后显示的信息窗口sceneModePicker: false, // 隐藏场景模式选择控件selectionIndicator: false, // 显示实体对象选择框,默认truetimeline: false, // 隐藏时间线控件navigationHelpButton: false, // 隐藏帮助按钮scene3DOnly: true, // 每个几何实例将只在3D中呈现,以节省GPU内存shouldAnimate: true, // 开启动画自动播放sceneMode: 3, // 初始场景模式 1:2D 2:2D循环 3:3D,默认3requestRenderMode: true, // 减少Cesium渲染新帧总时间并减少Cesium在应用程序中总体CPU使用率...options});}
}export default InitCesiumHide
DrawVerticalDistance
import BaseMeasure from "./baseMeasure";
import '../prompt/prompt.css'
import Prompt from '../prompt/prompt.js'
import * as Cesium from "cesium";/*** 三角测量类* @class* @augments BaseMeasure* @alias BaseMeasure.MeasureTriangle*/
class DrawVerticalDistance extends BaseMeasure {constructor(viewer, opt) {super(viewer, opt);if (!opt) opt = {};this.unitType = "length";this.style = opt.style || {};//线this.heightfloatLabel = null;this.spaceDistancefloatLabel = null;this.horizonDistancefloatLabel = null;this.heightLine = null;this.spaceLine = null;this.horizonLine = null;this.firstPosition = null;this.endPosition = null;this.midPosition = undefined;this.lowPosition = undefined;this.highPosition = undefined;}//开始测量start(callback) {if (!this.prompt && this.promptStyle.show) {this.prompt = new Prompt(this.viewer, this.promptStyle)}var that = this;this.state = 1;that.handler.setInputAction((evt) => { //单击开始绘制var cartesian = that.getCatesian3FromPX(evt.position, that.viewer);if (!cartesian) return;if (!that.firstPosition) {that.firstPosition = cartesian.clone();that.heightfloatLabel = that.createLabel(cartesian, "");that.spaceDistancefloatLabel = that.createLabel(cartesian, "", 10);that.horizonDistancefloatLabel = that.createLabel(cartesian, "");let point = that.createPoint(cartesian.clone());point.wz = 0;that.controlPoints.push(point);} else {that.endPosition = cartesian;that.computerPosition(that.firstPosition, that.endPosition);let point = that.createPoint(cartesian.clone());point.wz = 1;that.controlPoints.push(point);if (that.handler) {that.handler.destroy();that.handler = null;}if (that.prompt) {that.prompt.destroy();that.prompt = null;}that.state = "endCreate";if (callback) callback();}}, Cesium.ScreenSpaceEventType.LEFT_CLICK);this.handler.setInputAction(function (evt) {that.state = "creating";if (!that.firstPosition) {that.prompt.update(evt.endPosition, "左键点击确定起点,再次点击确定终点并结束");return;}that.prompt.update(evt.endPosition, "左键点击确定起点,再次点击确定终点并结束");var cartesian = that.getCatesian3FromPX(evt.endPosition, that.viewer);if (!cartesian) return;that.endPosition = cartesian;that.computerPosition(that.firstPosition, that.endPosition);if (that.firstPosition && that.endPosition && !that.heightLine) {that.heightLine = that.viewer.entities.add({polyline: {positions: new Cesium.CallbackProperty(function () {return [that.lowPosition, that.midPosition]}, false),show: true,material: new Cesium.PolylineOutlineMaterialProperty({color: Cesium.Color.GOLD,outlineWidth: 2,outlineColor: Cesium.Color.BLACK,}),width: 3,}});that.heightLine.objId = that.objId;that.horizonLine = that.viewer.entities.add({polyline: {positions: new Cesium.CallbackProperty(function () {return [that.highPosition, that.midPosition]}, false),show: true,material: new Cesium.PolylineOutlineMaterialProperty({color: Cesium.Color.GOLD,outlineWidth: 2,outlineColor: Cesium.Color.BLACK,}),width: 3,}});that.horizonLine.objId = that.objId;}if (that.heightLine) that.createLabels();}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);}//计算正上方的点computerPosition(p1, p2) {const cartographic1 = Cesium.Cartographic.fromCartesian(p1.clone());const cartographic2 = Cesium.Cartographic.fromCartesian(p2.clone());if (cartographic1.height > cartographic2.height) {this.highPosition = p1.clone();this.lowPosition = p2.clone();this.midPosition = Cesium.Cartesian3.fromRadians(cartographic2.longitude, cartographic2.latitude, cartographic1.height);} else {this.lowPosition = p1.clone();this.highPosition = p2.clone();this.midPosition = Cesium.Cartesian3.fromRadians(cartographic1.longitude, cartographic1.latitude, cartographic2.height);}}startEdit(callback) {if (!(this.state == "endCrerate" || this.state == "endEdit")) return;this.state = "startEdit";if (!this.modifyHandler) this.modifyHandler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);let that = this;for (let i = 0; i < that.controlPoints.length; i++) {let point = that.controlPoints[i];if (point) point.show = true;}this.modifyHandler.setInputAction(function (evt) {let pick = that.viewer.scene.pick(evt.position);if (Cesium.defined(pick) && pick.id) {if (!pick.id.objId)that.modifyPoint = pick.id;that.forbidDrawWorld(true);}}, Cesium.ScreenSpaceEventType.LEFT_DOWN);this.modifyHandler.setInputAction(function (evt) {if (!that.modifyPoint) return;let cartesian = that.getCatesian3FromPX(evt.endPosition, that.viewer);if (!cartesian) return;that.modifyPoint.position.setValue(cartesian.clone());if (that.modifyPoint.wz == 0) {that.firstPosition = cartesian.clone()} else {that.endPosition = cartesian.clone()}that.computerPosition(that.firstPosition, that.endPosition);that.createLabels();}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);this.modifyHandler.setInputAction(function (evt) {if (!that.modifyPoint) return;that.modifyPoint = null;that.forbidDrawWorld(false);that.state = "endEdit";if (callback) callback();}, Cesium.ScreenSpaceEventType.LEFT_UP);}endEdit() {let that = this;this.state = "endEdit";if (this.modifyHandler) {this.modifyHandler.destroy();this.modifyHandler = null;}for (let i = 0; i < that.controlPoints.length; i++) {let point = that.controlPoints[i];if (point) point.show = false;}}createLabels() {let that = this;//高度差var height = Math.abs(Cesium.Cartographic.fromCartesian(that.highPosition).height - Cesium.Cartographic.fromCartesian(that.lowPosition).height);var height_mid = Cesium.Cartesian3.midpoint(that.lowPosition, that.midPosition, new Cesium.Cartesian3());that.heightfloatLabel.show = true;that.heightfloatLabel.position.setValue(height_mid);let text1 = that.formateLength(height, that.unit);that.heightfloatLabel.label.text = "垂直距离:" + text1;that.heightfloatLabel.length = height;}claer() {this.destroy();}//清除测量结果destroy() {this.state = "no";let that = this;if (that.heightLine) {that.viewer.entities.remove(that.heightLine);that.heightLine = null;}// if (this.spaceLine) {// 	this.viewer.entities.remove(this.spaceLine);// 	this.spaceLine = null;// }if (that.horizonLine) {that.viewer.entities.remove(that.horizonLine);that.horizonLine = null;}if (that.heightfloatLabel) {that.viewer.entities.remove(that.heightfloatLabel);that.heightfloatLabel = null;}that.heightfloatLabel = null;if (this.spaceDistancefloatLabel) {this.viewer.entities.remove(this.spaceDistancefloatLabel);this.spaceDistancefloatLabel = null;}that.spaceDistancefloatLabel = null;if (that.horizonDistancefloatLabel) {that.viewer.entities.remove(that.horizonDistancefloatLabel);that.horizonDistancefloatLabel = null;}that.horizonDistancefloatLabel = null;if (that.prompt) {that.prompt.destroy();that.prompt = null;}if (that.handler) {that.handler.destroy();that.handler = null;}}setUnit(unit) {if (this.heightfloatLabel) {let text1 = this.formateLength(this.heightfloatLabel.length, unit);this.heightfloatLabel.label.text = "垂直距离:" + text1;}this.unit = unit;}
}export default DrawVerticalDistance;

效果图

相关文章:

cesium-测量高度垂直距离

cesium做垂直测量 完整代码 <template><div id"cesiumContainer" style"height: 100vh;"></div><div id"toolbar" style"position: fixed;top:20px;left:220px;"><el-breadcrumb><el-breadcrumb-i…...

Adobe Illustrator CEP插件开发入门指南

引言 Adobe Creative Cloud&#xff08;创意云&#xff09;中的Illustrator作为一款全球领先的矢量图形设计软件&#xff0c;为设计师提供了丰富的功能和无限的创作可能性。为了进一步增强其功能并满足个性化工作流程需求&#xff0c;Adobe引入了Common Extensibility Platform…...

【Spring】自定义注解 + AOP 记录用户的使用日志

目录 ​编辑 自定义注解 AOP 记录用户的使用日志 使用背景 落地实践 一&#xff1a;自定义注解 二&#xff1a;切面配置 三&#xff1a;Api层使用 使用效果 自定义注解 AOP 记录用户的使用日志 使用背景 &#xff08;1&#xff09;在学校项目中&#xff0c;安防平台…...

linux互斥锁:递归锁,非递归锁用法详解

在实际的项目中经常涉及到共享资源,共享资源被多个线程访问会出现竞争现象;为了解决竞争和保护共享资源常用的机制之一就是互斥锁! 互斥锁又分为递归锁和非递归锁,互斥锁默认是非递归锁,也是我们常用的上锁方式。那么什么是递归锁和非递归锁呢? 非递归锁(Non-recursive …...

MacOS安装dmg提示已文件已损坏的解决方法

MacOS安装dmg提示已文件已损坏的解决方法 导致原因是应用没有上传到苹果的appstroe&#xff0c;系统限制了安装&#xff0c;破碎提示是苹果的误导小手段 方法 一 App 在macOS Catalina&#xff08;比较新的系统&#xff0c;例如m1&#xff0c;m2也适用&#xff09;下提示已损坏…...

前端输入框简单实现检测@成员输入

大体逻辑是 给input框添加一个input监听&#xff0c;并判断输入是否为获取当前光标的位置&#xff0c;你输入的肯定在光标之前&#xff0c;且肯定是最后一个input输入的内容换行可以被认为空格&#xff0c;需要进行全局替换判断成功的逻辑分为两部分&#xff0c;前方一般来说是…...

通过与chatGPT交流实现零样本事件抽取

1、写作动机&#xff1a; 近来的大规模语言模型&#xff08;例如Chat GPT&#xff09;在零样本设置下取得了很好的表现&#xff0c;这启发作者探索基于提示的方法来解决零样本IE任务。 2、主要贡献&#xff1a; 提出了基于chatgpt的多阶段的信息抽取方法&#xff1a;在第一阶…...

使用nodejs和html布局一个简单的视频播放网站,但是使用localhost:端口访问html无法加载视频

js代码&#xff1a; // app.js const express require(express); const path require(path); const app express();// 设置静态文件目录&#xff0c;这里假设你的视频文件在public/videos/目录下 app.use(express.static(path.join(__dirname, )));// 设置主页路由&#xf…...

【AG32VF407】国产MCU+FPGA Verilog双边沿检测输出方波

视频讲解 [AG32VF407]国产MCUFPGA Verilog双边沿检测输出方波 实验过程 本次使用使用AG32VF407开发板中的FPGA&#xff0c;使用双clk的双边沿进行检测&#xff0c;同步输出方波 同时可以根据输出的方波检测clk的频率&#xff0c;以及双clk的相位关系&#xff0c;如下为verilog…...

[晓理紫]每日论文分享(有中文摘要,源码或项目地址)--强化学习、模仿学习、机器人

专属领域论文订阅 关注{晓理紫}&#xff0c;每日更新论文&#xff0c;如感兴趣&#xff0c;请转发给有需要的同学&#xff0c;谢谢支持 如果你感觉对你有所帮助&#xff0c;请关注我&#xff0c;每日准时为你推送最新论文。 为了答谢各位网友的支持&#xff0c;从今日起免费为3…...

为什么说TiDB在线扩容对业务几乎没有影响

作者&#xff1a; 数据源的TiDB学习之路 原文来源&#xff1a; https://tidb.net/blog/e82b2c5f 当前的数据库种类繁多&#xff0c;墨天轮当前统计的所有国产数据库已经有 290个 &#xff0c;其中属于关系型数据库的有 166个 。关系型数据库从部署架构上又可以分为集中式…...

STM32--SPI通信协议(2)W25Q64简介

一、W25Q64简介 1、W25Qxx中的xx是不同的数字&#xff0c;表示了这个芯片不同的存储容量&#xff1b; 2、存储器分为易失性与非易失性&#xff0c;主要区别是存储的数据是否是掉电不丢失&#xff1a; 易失性存储器&#xff1a;SRAM、DRAM&#xff1b; 非易失性存储器&#xff…...

svn安装与搭建

1、svn搭建 # yum install subversion -y //安装 # svnserve --version //查看版本 2、创建仓库目录repo # mkdir -p /opt/svn/repo //创建目录 # svnadmin create /opt/svn/repo/ //创建新仓库 # ls !$ …...

什么是缓存击穿、缓存穿透、缓存雪崩?

缓存雪崩 缓存雪崩是指缓存同一时间大面积的失效&#xff0c;所以&#xff0c;后面的请求都会落到数据库上&#xff0c;造成数据库短时间内承受大量请求而崩掉。 解决方案 缓存数据的过期时间设置随机&#xff0c;防止同一时间大量数据过期现象发生。一般并发量不是特别多的时…...

springboot153相亲网站

简介 【毕设源码推荐 javaweb 项目】基于springbootvue 的 适用于计算机类毕业设计&#xff0c;课程设计参考与学习用途。仅供学习参考&#xff0c; 不得用于商业或者非法用途&#xff0c;否则&#xff0c;一切后果请用户自负。 看运行截图看 第五章 第四章 获取资料方式 **项…...

CMake生成osg的FFMPEG插件及Windows下不生成VS工程问题解决

在Windows下&#xff0c;如何利用CMake生成osg的FFMPEG插件&#xff0c;请参考如下博文&#xff0c;同生成jpeg插件类似&#xff1a; osg第三方插件的编译方法&#xff08;以jpeg插件来讲解&#xff09;。 如下为生成FFMPEG时必要的设置&#xff1a; 注意&#xff1a; 一定要…...

代码随想录算法训练营Day25 | 216.组合总和III、17.电话号码的字母组合

216.组合总和III 与77.组合差不多&#xff0c;就返回条件中收集结果步骤多了一步判断&#xff0c;同时剪枝策略多了一种 vector<vector<int>> ans; vector<int> path; int sum 0;void backtracking(int num, int& k, int& n) {if (path.size() k…...

故障诊断 | 一文解决,SVM支持向量机的故障诊断(Matlab)

效果一览 文章概述 故障诊断 | 一文解决,SVM支持向量机的故障诊断(Matlab) 支持向量机(Support Vector Machine,SVM)是一种常用的监督学习算法,用于分类和回归分析。SVM的主要目标是找到一个最优的超平面(或者在非线性情况下是一个最优的超曲面),将不同类别的样本分开…...

12.1 Web开发_DOMBOM:JS关联CSS(❤❤)

12.1 Web开发_DOM&BOM 1. DOM&BOM2. DOM:文档对象模型2.1 获取页面元素1. getElementById2. getElementsByClassName3. querySelector3. 事件3.1 事件三要素3.2 绑定事件的三种方式1. 标签on2. 对象.on事件3. addEventListener3.3 常用事件...

scoped样式隔离原理

在 Vue 中&#xff0c;作用域样式&#xff08;Scoped Styles&#xff09;是通过以下原理实现的&#xff1a; 1、唯一选择器&#xff1a; 当 Vue 编译单文件组件时&#xff0c;在样式中使用 scoped 特性或 module 特性时&#xff0c;Vue 会为每个样式选择器生成一个唯一的属性…...

KubeSphere 容器平台高可用:环境搭建与可视化操作指南

Linux_k8s篇 欢迎来到Linux的世界&#xff0c;看笔记好好学多敲多打&#xff0c;每个人都是大神&#xff01; 题目&#xff1a;KubeSphere 容器平台高可用&#xff1a;环境搭建与可视化操作指南 版本号: 1.0,0 作者: 老王要学习 日期: 2025.06.05 适用环境: Ubuntu22 文档说…...

conda相比python好处

Conda 作为 Python 的环境和包管理工具&#xff0c;相比原生 Python 生态&#xff08;如 pip 虚拟环境&#xff09;有许多独特优势&#xff0c;尤其在多项目管理、依赖处理和跨平台兼容性等方面表现更优。以下是 Conda 的核心好处&#xff1a; 一、一站式环境管理&#xff1a…...

XCTF-web-easyupload

试了试php&#xff0c;php7&#xff0c;pht&#xff0c;phtml等&#xff0c;都没有用 尝试.user.ini 抓包修改将.user.ini修改为jpg图片 在上传一个123.jpg 用蚁剑连接&#xff0c;得到flag...

云原生核心技术 (7/12): K8s 核心概念白话解读(上):Pod 和 Deployment 究竟是什么?

大家好&#xff0c;欢迎来到《云原生核心技术》系列的第七篇&#xff01; 在上一篇&#xff0c;我们成功地使用 Minikube 或 kind 在自己的电脑上搭建起了一个迷你但功能完备的 Kubernetes 集群。现在&#xff0c;我们就像一个拥有了一块崭新数字土地的农场主&#xff0c;是时…...

CocosCreator 之 JavaScript/TypeScript和Java的相互交互

引擎版本&#xff1a; 3.8.1 语言&#xff1a; JavaScript/TypeScript、C、Java 环境&#xff1a;Window 参考&#xff1a;Java原生反射机制 您好&#xff0c;我是鹤九日&#xff01; 回顾 在上篇文章中&#xff1a;CocosCreator Android项目接入UnityAds 广告SDK。 我们简单讲…...

【决胜公务员考试】求职OMG——见面课测验1

2025最新版&#xff01;&#xff01;&#xff01;6.8截至答题&#xff0c;大家注意呀&#xff01; 博主码字不易点个关注吧,祝期末顺利~~ 1.单选题(2分) 下列说法错误的是:&#xff08; B &#xff09; A.选调生属于公务员系统 B.公务员属于事业编 C.选调生有基层锻炼的要求 D…...

SpringTask-03.入门案例

一.入门案例 启动类&#xff1a; package com.sky;import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCach…...

学习STC51单片机32(芯片为STC89C52RCRC)OLED显示屏2

每日一言 今天的每一份坚持&#xff0c;都是在为未来积攒底气。 案例&#xff1a;OLED显示一个A 这边观察到一个点&#xff0c;怎么雪花了就是都是乱七八糟的占满了屏幕。。 解释 &#xff1a; 如果代码里信号切换太快&#xff08;比如 SDA 刚变&#xff0c;SCL 立刻变&#…...

Reasoning over Uncertain Text by Generative Large Language Models

https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829 1. 概述 文本中的不确定性在许多语境中传达,从日常对话到特定领域的文档(例如医学文档)(Heritage 2013;Landmark、Gulbrandsen 和 Svenevei…...

虚拟电厂发展三大趋势:市场化、技术主导、车网互联

市场化&#xff1a;从政策驱动到多元盈利 政策全面赋能 2025年4月&#xff0c;国家发改委、能源局发布《关于加快推进虚拟电厂发展的指导意见》&#xff0c;首次明确虚拟电厂为“独立市场主体”&#xff0c;提出硬性目标&#xff1a;2027年全国调节能力≥2000万千瓦&#xff0…...