当前位置:网站首页>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 .
边栏推荐
- [teacher Zhao Yuqiang] Flink's dataset operator
- Core principles and source code analysis of disruptor
- Solve the problem of automatic disconnection of SecureCRT timeout connection
- [Zhao Yuqiang] deploy kubernetes cluster with binary package
- pytorch 多分类中的损失函数
- [teacher Zhao Yuqiang] use Oracle's tracking file
- Pytorch dataloader implements minibatch (incomplete)
- Strategy pattern: encapsulate changes and respond flexibly to changes in requirements
- Virtual memory technology sharing
- GPS坐标转百度地图坐标的方法
猜你喜欢

Kubernetes cluster environment construction & Deployment dashboard
![[teacher Zhao Yuqiang] MySQL flashback](/img/93/75998e28fd309880661ea723dc8de6.jpg)
[teacher Zhao Yuqiang] MySQL flashback

pytorch 多分类中的损失函数

有意思的鼠标指针交互探究
![[teacher Zhao Yuqiang] MySQL high availability architecture: MHA](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[teacher Zhao Yuqiang] MySQL high availability architecture: MHA

Cesium 点击获三维坐标(经纬度高程)

GPS坐标转百度地图坐标的方法

Analysis of Clickhouse mergetree principle
![[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system
![[teacher Zhao Yuqiang] use the catalog database of Oracle](/img/0b/73a7d12caf955dff17480a907234ad.jpg)
[teacher Zhao Yuqiang] use the catalog database of Oracle
随机推荐
Project summary --04
Strategy pattern: encapsulate changes and respond flexibly to changes in requirements
Kubernetes notes (II) pod usage notes
Complete set of C language file operation functions (super detailed)
arcgis创建postgre企业级数据库
BeanDefinitionRegistryPostProcessor
Analysis of Clickhouse mergetree principle
Understand the first prediction stage of yolov1
Oauth2.0 - using JWT to replace token and JWT content enhancement
QT read write excel -- qxlsx insert chart 5
Pytorch builds the simplest version of neural network
有意思的鼠标指针交互探究
Detailed explanation of contextclassloader
Method of converting GPS coordinates to Baidu map coordinates
Skywalking8.7 source code analysis (II): Custom agent, service loading, witness component version identification, transform workflow
Redhat7系统root用户密码破解
phpstudy设置项目可以由局域网的其他电脑可以访问
CAD插件的安裝和自動加載dll、arx
Kubernetes notes (IX) kubernetes application encapsulation and expansion
88. 合并两个有序数组