当前位置:网站首页>Cesium obtains the latitude and longitude range of the screen
Cesium obtains the latitude and longitude range of the screen
2022-06-28 02:09:00 【The most ferocious little seal】
// viewer Namely new Cesium.Viewer, Mount to window Yes , So you can use it directly
function getCesiumViewerExtend() {
let params = {
};
// computeViewRectangle, Calculate the approximate visible rectangle on the ellipsoid ( return Rectangle), If the oval is not visible at all , Then return to undefined.
let extend = viewer.camera.computeViewRectangle();
if (typeof extend === "undefined") {
//2D You may not be able to pick up the coordinates under the ,extend return undefined, So do the following conversion
let canvas = viewer.scene.canvas;
let upperLeft = new Cesium.Cartesian2(0, 0); //canvas Top left coordinate rotation 2d coordinate
let lowerRight = new Cesium.Cartesian2(canvas.clientWidth, canvas.clientHeight); //canvas The coordinates of the lower right corner turn 2d coordinate
let ellipsoid = viewer.scene.globe.ellipsoid;
let upperLeft3 = viewer.camera.pickEllipsoid(upperLeft, ellipsoid); //2D turn 3D World coordinates
let lowerRight3 = viewer.camera.pickEllipsoid(lowerRight, ellipsoid); //2D turn 3D World coordinates
let upperLeftCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(upperLeft3); //3D World coordinate to radian
let lowerRightCartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(lowerRight3); //3D World coordinate to radian
let minx = Cesium.Math.toDegrees(upperLeftCartographic.longitude); // Radian to latitude and longitude
let maxx = Cesium.Math.toDegrees(lowerRightCartographic.longitude); // Radian to latitude and longitude
let miny = Cesium.Math.toDegrees(lowerRightCartographic.latitude); // Radian to latitude and longitude
let maxy = Cesium.Math.toDegrees(upperLeftCartographic.latitude); // Radian to latitude and longitude
params.minx = minx; // Minimum longitude
params.maxx = maxx; // Maximum longitude
params.miny = miny; // Minimum latitude
params.maxy = maxy; // Maximum latitude
} else {
//3D Access method
// Maximum longitude
params.maxx = Cesium.Math.toDegrees(extend.east); // Radian to latitude and longitude
// Maximum latitude
params.maxy = Cesium.Math.toDegrees(extend.north); // Radian to latitude and longitude
// Minimum longitude
params.minx = Cesium.Math.toDegrees(extend.west); // Radian to latitude and longitude
// Minimum latitude
params.miny = Cesium.Math.toDegrees(extend.south); // Radian to latitude and longitude
}
return params; // Return to the latitude and longitude range of the screen
}

Reprint :https://blog.csdn.net/chenguizhenaza/article/details/116783045
边栏推荐
- 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)
- Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
- PV操作原语
- Four classic training modes in comparative learning
- Overview of drug discovery-01 overview of drug discovery
- 混合app的介绍
- 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
- 1382. 将二叉搜索树变平衡-常规方法
- Using redis bitmap to realize personnel online monitoring
- What problems should be evaluated before implementing MES management system
猜你喜欢

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

Réseau neuronal pour la solution détaillée Multi - diagrammes de fondation zéro

将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)

Cesium 获取屏幕所在经纬度范围

Drug interaction prediction based on learning size adaptive molecular substructure

利用redis bitmap实现人员在线情况监控

类的初始化与回调的用法

Class initialization and callback usage

Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)

Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
随机推荐
【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
Coscon'22 lecturer solicitation order
一张图弄懂 MIT,BSD,Apache几种开源协议之间的区别
面试官问:能否模拟实现JS的new操作符
1382. 将二叉搜索树变平衡-常规方法
Drug interaction prediction based on learning size adaptive molecular substructure
Solon 1.8.3 release, cloud native microservice development framework
766. 托普利茨矩阵
What are the risks of opening a compass stock account? Is it safe to open a compass account
如何高效读书学习
Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
Supervised, unsupervised and semi supervised learning
药物发现综述-03-分子设计与优化
PV operation primitive
树莓派实现温控风扇智能降温
Implementation of timed tasks in laravel framework
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
What problems should be evaluated before implementing MES management system
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
How to read a paper