当前位置:网站首页>Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
2022-07-03 06:08:00 【The most ferocious little seal】
The following code applies to Get the terrain surface Three dimensional coordinates .
Be careful :
- It is applicable to picking points with terrain elevation
- Not applicable to model 、 Tilt photography and other surface heights ( Please read my other article )
- Depth detection needs to be turned on
depthTestAgainstTerrain = true.
// Open depth detection
viewer.scene.globe.depthTestAgainstTerrain = true
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function (evt) {
// Return to one ray And an intersection of the earth's surface Cartesian3 coordinate .
let ray = viewer.camera.getPickRay(evt.position);
let cartesian = viewer.scene.globe.pick(ray, viewer.scene);
// // Space coordinates to world coordinates ( radian )
let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
// Radian to angle ( Longitude and latitude )
let lon = Cesium.Math.toDegrees(cartographic.longitude); // Longitude value
let lat = Cesium.Math.toDegrees(cartographic.latitude); // Latitude value
// Terrain height ( Just choose one of the following two )
let height = cartographic.height;
let height2 = viewer.scene.globe.getHeight(cartographic)
console.log(' The longitude and latitude elevation is :', {
x: lon, y: lat, height: height, height2: height2 })
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Cancel the left click event
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)

Elevation part :cartographic.height and viewer.scene.globe.getHeight(cartographic) These two are elevations , You can see from the above figure that , There are some subtle differences , But it doesn't matter , You can use either of these two .
边栏推荐
- Detailed explanation of findloadedclass
- 有意思的鼠标指针交互探究
- Common exceptions when Jenkins is released (continuous update...)
- Kubernetes notes (10) kubernetes Monitoring & debugging
- pytorch 多分类中的损失函数
- .NET程序配置文件操作(ini,cfg,config)
- Kubernetes notes (VIII) kubernetes security
- Deep learning, thinking from one dimensional input to multi-dimensional feature input
- [teacher Zhao Yuqiang] RDB persistence of redis
- QT read write excel -- qxlsx insert chart 5
猜你喜欢

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

【系统设计】邻近服务

pytorch 搭建神经网络最简版

Code generator - single table query crud - generator

Kubesphere - build Nacos cluster

深度学习,从一维特性输入到多维特征输入引发的思考

Oauth2.0 - user defined mode authorization - SMS verification code login

Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception

Zhiniu stock -- 03

Solve the problem of automatic disconnection of SecureCRT timeout connection
随机推荐
Kubernetes notes (III) controller
Svn branch management
Project summary --2 (basic use of jsup)
Alibaba cloud Alipay sandbox payment
Exportation et importation de tables de bibliothèque avec binaires MySQL
輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
CKA certification notes - CKA certification experience post
Kubernetes notes (VI) kubernetes storage
Kubernetes notes (VIII) kubernetes security
It is said that the operation and maintenance of shell scripts are paid tens of thousands of yuan a month!!!
Disruptor learning notes: basic use, core concepts and principles
Oauth2.0 - use database to store client information and authorization code
Kubernetes notes (I) kubernetes cluster architecture
1. Somme des deux nombres
Kubesphere - build MySQL master-slave replication structure
Kubernetes notes (IX) kubernetes application encapsulation and expansion
最大似然估计,散度,交叉熵
Clickhouse learning notes (2): execution plan, table creation optimization, syntax optimization rules, query optimization, data consistency
MySQL帶二進制的庫錶導出導入
Crontab command usage