当前位置:网站首页>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) 这两个都是高程,可以从上图看出,有一些细微的差别,不过影响不大,用这两个任意一个都可以。
边栏推荐
- Final review (Day5)
- Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception
- BeanDefinitionRegistryPostProcessor
- 1. 兩數之和
- Ensemble, série shuishu] jour 9
- [together Shangshui Shuo series] day 7 content +day8
- 伯努利分布,二项分布和泊松分布以及最大似然之间的关系(未完成)
- Yum is too slow to bear? That's because you didn't do it
- How does win7 solve the problem that telnet is not an internal or external command
- 理解 YOLOV1 第一篇 预测阶段
猜你喜欢

多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
![[trivia of two-dimensional array application] | [simple version] [detailed steps + code]](/img/84/98c1220d0f7bc3a948125ead6ff3d9.jpg)
[trivia of two-dimensional array application] | [simple version] [detailed steps + code]

Skywalking8.7 source code analysis (I): agent startup process, agent configuration loading process, custom class loader agentclassloader, plug-in definition system, plug-in loading

Loss function in pytorch multi classification
![[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)](/img/c8/2995c503e9dabae4e2cc704449e04f.jpg)
[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)

Sophomore dilemma (resumption)

Maximum likelihood estimation, divergence, cross entropy

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

CKA certification notes - CKA certification experience post
![[teacher Zhao Yuqiang] use Oracle's tracking file](/img/0e/698478876d0dbfb37904d7b9ff9aca.jpg)
[teacher Zhao Yuqiang] use Oracle's tracking file
随机推荐
多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
项目总结--2(Jsoup的基本使用)
1. 兩數之和
Today, many CTOs were killed because they didn't achieve business
Jackson: what if there is a lack of property- Jackson: What happens if a property is missing?
BeanDefinitionRegistryPostProcessor
[teacher Zhao Yuqiang] MySQL high availability architecture: MHA
JS implements the problem of closing the current child window and refreshing the parent window
[teacher Zhao Yuqiang] use Oracle's tracking file
Convolution operation in convolution neural network CNN
Disruptor learning notes: basic use, core concepts and principles
[advanced pointer (1)] | detailed explanation of character pointer, pointer array, array pointer
[teacher Zhao Yuqiang] Flink's dataset operator
Ensemble, série shuishu] jour 9
一起上水碩系列】Day 9
SVN分支管理
为什么网站打开速度慢?
Together, Shangshui Shuo series] day 9
[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram
Kubernetes notes (IV) kubernetes network