当前位置:网站首页>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 .
边栏推荐
- BeanDefinitionRegistryPostProcessor
- It is said that the operation and maintenance of shell scripts are paid tens of thousands of yuan a month!!!
- Detailed explanation of findloadedclass
- Detailed explanation of contextclassloader
- Oauth2.0 - using JWT to replace token and JWT content enhancement
- QT read write excel -- qxlsx insert chart 5
- Project summary --04
- Kubernetes notes (VII) kuberetes scheduling
- 【系统设计】邻近服务
- pytorch DataLoader实现miniBatch(未完成)
猜你喜欢

How does win7 solve the problem that telnet is not an internal or external command

Maximum likelihood estimation, divergence, cross entropy
![[teacher Zhao Yuqiang] MySQL flashback](/img/93/75998e28fd309880661ea723dc8de6.jpg)
[teacher Zhao Yuqiang] MySQL flashback

Cesium 点击获取模型表面经纬度高程坐标(三维坐标)

Clickhouse learning notes (2): execution plan, table creation optimization, syntax optimization rules, query optimization, data consistency

Kubernetes notes (VII) kuberetes scheduling

Zhiniu stock -- 03

Redhat7 system root user password cracking

Solve the problem of automatic disconnection of SecureCRT timeout connection
![[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database
随机推荐
理解 YOLOV1 第一篇 预测阶段
Project summary --2 (basic use of jsup)
[teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb
从 Amazon Aurora 迁移数据到 TiDB
PHP用ENV获取文件参数的时候拿到的是字符串
MySQL帶二進制的庫錶導出導入
Installation du plug - in CAD et chargement automatique DLL, Arx
Kubernetes notes (V) configuration management
智牛股--03
MySQL带二进制的库表导出导入
Zhiniu stock project -- 05
Ext4 vs XFS -- which file system should you use
Solve the problem that Anaconda environment cannot be accessed in PowerShell
Solve the 1251 client does not support authentication protocol error of Navicat for MySQL connection MySQL 8.0.11
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
PMP笔记记录
phpstudy设置项目可以由局域网的其他电脑可以访问
Bio, NiO, AIO details
Simple solution of small up main lottery in station B
The programmer shell with a monthly salary of more than 10000 becomes a grammar skill for secondary school. Do you often use it!!!