当前位置:网站首页>Cesium 点击获三维坐标(经纬度高程)
Cesium 点击获三维坐标(经纬度高程)
2022-07-03 06:03:00 【最凶残的小海豹】
下面代码适用于 获取地形表面的三维坐标。
注意:
- 适用于拾取有地形高程的点
- 不适用于模型、倾斜摄影等表面高度(请看我的另一篇文章)
- 需要开启深度检测
depthTestAgainstTerrain = true。
// 开启深度检测
viewer.scene.globe.depthTestAgainstTerrain = true
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function (evt) {
// 返回一个ray和地球表面的一个交点的Cartesian3坐标。
let ray = viewer.camera.getPickRay(evt.position);
let cartesian = viewer.scene.globe.pick(ray, viewer.scene);
// // 空间坐标转世界坐标(弧度)
let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
// 弧度转为角度(经纬度)
let lon = Cesium.Math.toDegrees(cartographic.longitude); //经度值
let lat = Cesium.Math.toDegrees(cartographic.latitude); //纬度值
// 地形高度(下面两个二选一就行)
let height = cartographic.height;
let height2 = viewer.scene.globe.getHeight(cartographic)
console.log('经纬度高程是:', {
x: lon, y: lat, height: height, height2: height2 })
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
取消左键点击事件
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)

高程部分:cartographic.height 和 viewer.scene.globe.getHeight(cartographic) 这两个都是高程,可以从上图看出,有一些细微的差别,不过影响不大,用这两个任意一个都可以。
边栏推荐
- [branch and cycle] | | super long detailed explanation + code analysis + a trick game
- Kubernetes notes (VI) kubernetes storage
- Leetcode solution - 02 Add Two Numbers
- Capacity expansion mechanism of map
- Jedis source code analysis (II): jediscluster module source code analysis
- [trivia of two-dimensional array application] | [simple version] [detailed steps + code]
- Kubernetes notes (V) configuration management
- Es 2022 officially released! What are the new features?
- [function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation
- PHP用ENV获取文件参数的时候拿到的是字符串
猜你喜欢
![[branch and cycle] | | super long detailed explanation + code analysis + a trick game](/img/aa/543d4f0dcbcd664be963579af77ec9.jpg)
[branch and cycle] | | super long detailed explanation + code analysis + a trick game

伯努利分布,二项分布和泊松分布以及最大似然之间的关系(未完成)

Maximum likelihood estimation, divergence, cross entropy

智牛股--03

最大似然估计,散度,交叉熵

理解 期望(均值/估计值)和方差

Kubernetes notes (I) kubernetes cluster architecture

Redis cannot connect remotely.

深度学习,从一维特性输入到多维特征输入引发的思考
![[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history](/img/18/f91d3d21a39743231d01f2e4015ef8.jpg)
[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
随机推荐
Analysis of the example of network subnet division in secondary vocational school
Alibaba cloud OOS file upload
Together, Shangshui Shuo series] day 9
[teacher Zhao Yuqiang] use the catalog database of Oracle
MySQL 5.7.32-winx64 installation tutorial (support installing multiple MySQL services on one host)
Jedis source code analysis (II): jediscluster module source code analysis
Kubernetes notes (VI) kubernetes storage
There is no one of the necessary magic skills PXE for old drivers to install!!!
Pytorch dataloader implements minibatch (incomplete)
Skywalking8.7 source code analysis (I): agent startup process, agent configuration loading process, custom class loader agentclassloader, plug-in definition system, plug-in loading
Method of finding prime number
Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram
Analysis of Clickhouse mergetree principle
1. Sum of two numbers
多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
Ansible firewall firewalld setting
[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
[teacher Zhao Yuqiang] index in mongodb (Part 1)
Redis encountered noauth authentication required