当前位置:网站首页>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 .
边栏推荐
- JDBC connection database steps
- Leetcode solution - 02 Add Two Numbers
- Synthetic keyword and NBAC mechanism
- [teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb
- BeanDefinitionRegistryPostProcessor
- Zhiniu stock project -- 04
- 从小数据量分库分表 MySQL 合并迁移数据到 TiDB
- Project summary --04
- 项目总结--01(接口的增删改查;多线程的使用)
- [teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
猜你喜欢
Kubernetes notes (I) kubernetes cluster architecture
[teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb
Strategy pattern: encapsulate changes and respond flexibly to changes in requirements
Loss function in pytorch multi classification
Oauth2.0 - explanation of simplified mode, password mode and client mode
[teacher Zhao Yuqiang] Flink's dataset operator
Svn branch management
Convolution operation in convolution neural network CNN
技术管理进阶——你了解成长的全貌吗?
Solve the problem of automatic disconnection of SecureCRT timeout connection
随机推荐
Deep learning, thinking from one dimensional input to multi-dimensional feature input
Method of converting GPS coordinates to Baidu map coordinates
[Zhao Yuqiang] deploy kubernetes cluster with binary package
.NET程序配置文件操作(ini,cfg,config)
Installation du plug - in CAD et chargement automatique DLL, Arx
[video of Teacher Zhao Yuqiang's speech on wot] redis high performance cache and persistence
Btrfs and ext4 - features, strengths and weaknesses
GPS坐标转百度地图坐标的方法
Phpstudy setting items can be accessed by other computers on the LAN
About the difference between count (1), count (*), and count (column name)
PHP用ENV获取文件参数的时候拿到的是字符串
Synthetic keyword and NBAC mechanism
MySQL帶二進制的庫錶導出導入
PMP笔记记录
1. 兩數之和
PMP notes
智牛股项目--04
Solve the problem that Anaconda environment cannot be accessed in PowerShell
Sorry, this user does not exist!
Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)