当前位置:网站首页>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. meshgrid()
- style中的scoped属性和lang属性
- 零基礎多圖詳解圖神經網絡
- What is digitalization? What is digital transformation? Why do enterprises choose digital transformation?
- 要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
- 药物发现综述-03-分子设计与优化
- Want to open an account to buy stock, is it safe to open an account on the Internet?
- Overview of drug discovery-01 overview of drug discovery
- Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
猜你喜欢

嵌入式必学!硬件资源接口详解——基于ARM AM335X开发板 (下)

766. toplitz matrix

Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection

Ten thousand words long article understanding business intelligence (BI) | recommended collection

Implementation of timed tasks in laravel framework

MapReduce elementary programming practice

ShardingSphere-proxy-5.0.0建立mysql读写分离的连接(六)

评价——灰色关联分析

Numpy----np.reshape()

【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
随机推荐
数据库查询优化:主从读写分离及常见问题
零基礎多圖詳解圖神經網絡
Cesium 多边形(polygon)extrudedHeight 和 height 的区别
Numpy----np. reshape()
Capacitor
How to study efficiently
机器学习笔记 - 时间序列作为特征
Import the data table in MySQL into Excel
How fiddle uses agents
Comprehensive evaluation of free, easy-to-use and powerful open source note taking software
Is it safe to open an online futures account?
Lmsoc: a socially sensitive pre training method
Numpy----np. Tile() function parsing
基于可学习尺寸自适应分子亚结构的药物相互作用预测
Using redis bitmap to realize personnel online monitoring
解决ionic4 使用hammerjs手势 press 事件,页面无法滚动问题
【sylixos】NEW_1 型字符驱动示例
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)
OS模块与OS.path 模块的学习
Hi, you have a code review strategy to check!