当前位置:网站首页>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
边栏推荐
- 【牛客討論區】第四章:Redis
- 一张图弄懂 MIT,BSD,Apache几种开源协议之间的区别
- Machine learning notes - time series as features
- 【sylixos】NEW_1 型字符驱动示例
- Coscon'22 lecturer solicitation order
- [Yocto RM]9 - QA Error and Warning Messages
- Intensive reading of transformer thesis paragraph by paragraph
- 什么是数字化?什么是数字化转型?为什么企业选择数字化转型?
- Xctf attack and defense world misc wage earner advanced zone
- Réseau neuronal pour la solution détaillée Multi - diagrammes de fondation zéro
猜你喜欢
Evaluation - grey correlation analysis
Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known
万字长文看懂商业智能(BI)|推荐收藏
Réseau neuronal pour la solution détaillée Multi - diagrammes de fondation zéro
Raspberry pie realizes intelligent cooling by temperature control fan
9. Openfeign service interface call
The research group of Xuyong and duanwenhui of Tsinghua University has developed an efficient and accurate first principles electronic structure deep learning method and program
评价——灰色关联分析
Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)
药物发现综述-03-分子设计与优化
随机推荐
如何理解 Transformer 中的 Query、Key 与 Value
205. isomorphic string
向excel中导入mysql中的数据表
深入解析kubernetes controller-runtime
Is it safe to open an online futures account?
[Yocto RM]9 - QA Error and Warning Messages
学习 pickle
零基礎多圖詳解圖神經網絡
Li Kou today's question -522 Longest special sequence
评价——秩和比综合评价
Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例
I/O限制进程与CPU限制进程
面试官问:JS的this指向
LMSOC:一种对社会敏感的预训练方法
Implementation of timed tasks in laravel framework
[Yocto RM] 2 - Yocto Project Terms
【sylixos】NEW_1 型字符驱动示例
Modular development
Centos8 operation record command version Yum redis MySQL Nacos JDK