当前位置:网站首页>Cesium 获取屏幕所在经纬度范围
Cesium 获取屏幕所在经纬度范围
2022-06-28 00:05:00 【最凶残的小海豹】
// viewer 就是new Cesium.Viewer,挂载到window上了,所以可以直接用
function getCesiumViewerExtend() {
let params = {
};
// computeViewRectangle,计算椭球上的近似可见矩形(返回 Rectangle),如果椭圆形根本不可见,则返回undefined。
let extend = viewer.camera.computeViewRectangle();
if (typeof extend === "undefined") {
//2D下会可能拾取不到坐标,extend返回undefined,所以做以下转换
let canvas = viewer.scene.canvas;
let upperLeft = new Cesium.Cartesian2(0, 0); //canvas左上角坐标转2d坐标
let lowerRight = new Cesium.Cartesian2(canvas.clientWidth, canvas.clientHeight); //canvas右下角坐标转2d坐标
let ellipsoid = viewer.scene.globe.ellipsoid;
let upperLeft3 = viewer.camera.pickEllipsoid(upperLeft, ellipsoid); //2D转3D世界坐标
let lowerRight3 = viewer.camera.pickEllipsoid(lowerRight, ellipsoid); //2D转3D世界坐标
let upperLeftCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(upperLeft3); //3D世界坐标转弧度
let lowerRightCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(lowerRight3); //3D世界坐标转弧度
let minx = Cesium.Math.toDegrees(upperLeftCartographic.longitude); //弧度转经纬度
let maxx = Cesium.Math.toDegrees(lowerRightCartographic.longitude); //弧度转经纬度
let miny = Cesium.Math.toDegrees(lowerRightCartographic.latitude); //弧度转经纬度
let maxy = Cesium.Math.toDegrees(upperLeftCartographic.latitude); //弧度转经纬度
params.minx = minx; // 最小经度
params.maxx = maxx; // 最大经度
params.miny = miny; // 最小纬度
params.maxy = maxy; // 最大纬度
} else {
//3D获取方式
// 最大经度
params.maxx = Cesium.Math.toDegrees(extend.east); //弧度转经纬度
// 最大纬度
params.maxy = Cesium.Math.toDegrees(extend.north); //弧度转经纬度
// 最小经度
params.minx = Cesium.Math.toDegrees(extend.west); //弧度转经纬度
// 最小纬度
params.miny = Cesium.Math.toDegrees(extend.south); //弧度转经纬度
}
return params; //返回屏幕所在经纬度范围
}

转载:https://blog.csdn.net/chenguizhenaza/article/details/116783045
边栏推荐
- Interview guide for data person | prepare these points to be prepared!
- [Yocto RM]8 - OpenEmbedded Kickstart (.wks) Reference
- Numpy----np.reshape()
- 面试官问:能否模拟实现JS的new操作符
- Solon 1.8.3 发布,云原生微服务开发框架
- Some problems in awk
- How to optimize the "message" list of IM
- Database query optimization: master-slave read-write separation and common problems
- 药物发现综述-03-分子设计与优化
- Deep parsing of kubernetes controller runtime
猜你喜欢
![The number of nodes of a complete binary tree [non-O (n) solution > Abstract dichotomy]](/img/56/768f8be9f70bf751f176e40cbb1df2.png)
The number of nodes of a complete binary tree [non-O (n) solution > Abstract dichotomy]

MapReduce elementary programming practice
![[Niuke discussion area] Chapter 4: redis](/img/53/f8628c65890f1c68cedab9008c1b84.png)
[Niuke discussion area] Chapter 4: redis

【牛客討論區】第四章:Redis

Numpy----np.tile()函数解析

Implementation of timed tasks in laravel framework

Database query optimization: master-slave read-write separation and common problems

基于可学习尺寸自适应分子亚结构的药物相互作用预测

Review of drug discovery-03-molecular design and optimization

What problems should be evaluated before implementing MES management system
随机推荐
利用redis bitmap实现人员在线情况监控
Review of drug discovery-02-prediction of molecular properties
Xctf attack and defense world misc wage earner advanced zone
[Yocto RM] 4 - Source Directory Structure
[Yocto RM]3 - Yocto Project Releases and the Stable Release Process
学习 pickle
药物发现综述-01-药物发现概述
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
COSCon'22 讲师征集令
【嵌入式基础】串口通信
How to understand query, key and value in transformer
对比学习中的4种经典训练模式
Transformer论文逐段精读
Prometeus 2.35.0 new features
嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
Ten thousand words long article understanding business intelligence (BI) | recommended collection
[Yocto RM] 4 - Source Directory Structure
Take n multiple table names of a database as the values of a column in another table (the range can be a table in another database)