簡體   English   中英

如何將 x、y、z 轉換為 Cesium 中的經度、緯度、高度?

[英]How to convert x, y, z to longitude, latitude, altitude in Cesium?

使用three.js庫我已經組裝了一個設計(植物)。 該設計包含許多較小的模型,這些模型具有從原點 (0,0,0) 在 (x, y, z) 中的位置參考。 在以下鏈接中附上了示例屏幕截圖

組裝模型參考圖像

現在我想將具有自己位置的單個模型加載到 Cesium 中。 當我嘗試加載直接將位置 (x, y, z) 轉換為 (north, Eastern, up) 時,結果並不如預期。 所有的模型都是分散的。

我試圖實現的功能是,基於一些原點(lon,lat,alt)點,我應該將模型定位到銫中,參考(x,y,z)相對於銫坐標(lon,lat,alt )

例如

  • 原點地理坐標 (ori_lon, ori_lat, ori_alt) => (-106.690647, 36.806761, 0)

  • 模型坐標 (m_x, m_y, m_z) => (-150.9, 126.26, 217.7)

  • 銫的期望坐標:(ori_lon + m_x、ori_lat + m_y、ori_alt + m_z)

或一些算法來實現這一點。

我已嘗試使用以下文章將 (x, y, z) 轉換為具有某些來源 (long, lat, alt) 的 (long, lat, alt),但沒有成功:(

(x, y, z) 坐標 >> 地理坐標

解決問題的建議/幫助。

編輯:由於搜索引擎似乎將人們發送到這里尋找笛卡爾到制圖的轉換,我將在這里提供一個答案。

Cartographic.fromCartesian函數是執行此轉換的最簡單方法。 請注意,它將返回以弧度而非度數表示的Cartographic 高度以米為單位返回。

var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
console.log(
    'lon ' + Cesium.Math.toDegrees(cartographic.longitude) + ', ' +
    'lat ' + Cesium.Math.toDegrees(cartographic.latitude) + ', ' +
    'alt ' + cartographic.height);

原始答案:如果您在此處閱讀原始問題的詳細信息,則提問者試圖在 LLA 空間中將坐標添加在一起,這是不正確的。 我在這里的原始答案解釋了如何將它們都轉換為笛卡爾空間並在那里添加結果。

這可以通過Cesium.Cartesian3.fromDegrees來完成。

var position = Cesium.Cartesian3.fromDegrees(-106.690647, 36.806761, 0);
var offset = new Cesium.Cartesian3(-150.9, 126.26, 217.7);
Cesium.Cartesian3.add(position, offset, position);

根據坐標系offset的不同,它可能需要旋轉才能應用於全局笛卡爾空間。 例如,如果它是 East-North-Up,您將使用相應的函數來創建並應用該轉換。

Cartesian3 到 longlat,以防有人需要

 function toDegrees(cartesian3Pos) { let pos = Cesium.Cartographic.fromCartesian(cartesian3Pos) return [pos.longitude / Math.PI * 180, pos.latitude / Math.PI * 180] } console.log(toDegrees({ x: -1681498.1800000381, y: 4576516.394998055, z: 4098410.649998016 })) // [110.17428132202518, 40.23966923800238]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM