当前位置:网站首页>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
边栏推荐
- [Niuke discussion area] Chapter 4: redis
- Numpy----np. reshape()
- Overview of drug discovery-01 overview of drug discovery
- Numpy----np. meshgrid()
- Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
- Prometeus 2.35.0 新特性
- Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known
- Solve storage problems? WMS warehouse management system solution
- JS 数组随机取值(随机数组取值)
- Review of drug discovery-03-molecular design and optimization
猜你喜欢

Overview of drug discovery-01 overview of drug discovery

如何理解 Transformer 中的 Query、Key 与 Value

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

766. toplitz matrix

Self supervised learning and drug discovery

【嵌入式基础】内存(Cache,RAM,ROM,Flash)

The practice of dual process guard and keeping alive in IM instant messaging development

评价——灰色关联分析

基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例

树莓派实现温控风扇智能降温
随机推荐
面试官问:能否模拟实现JS的new操作符
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
How fiddle uses agents
对比学习中的4种经典训练模式
Appium自动化测试基础 — ADB常用命令(一)
树莓派实现温控风扇智能降温
【嵌入式基础】串口通信
混合app的介绍
PV operation primitive
Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
Self supervised learning and drug discovery
【sylixos】i2c设备驱动创建和使用
Intensive reading of transformer thesis paragraph by paragraph
Neural network of zero basis multi map detailed map
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
【永艺XY椅】试用体验
Lefse analyzes the local implementation method with all installation files and details to ensure success.
Cesium 点击获取经纬度(二维坐标)
Deep parsing of kubernetes controller runtime
Numpy----np. Tile() function parsing