admin管理员组文章数量:1241159
Using three.js library I have assembled a design(plant). That design is contains of so many smaller models which have the reference of position in (x, y, z) from origin (0,0,0). Attached the sample screenshot in the following link
Now I want to load the individual model with its own position into Cesium. When I try to load the directly converting the position (x, y, z) to (north, east, up) the result is not as expected. All the models are scattered.
The functionality which I am trying to achieve is, based on some origin (lon, lat, alt) point, I should position the model into cesium with reference of (x, y, z) relative to cesium coordinates (lon, lat, alt)
E.g.
Origin geo-coordinates (ori_lon, ori_lat, ori_alt) => (-106.690647, 36.806761, 0)
Model coordinates (m_x, m_y, m_z) => (-150.9, 126.26, 217.7)
Expecting Coordinates for Cesium: (ori_lon + m_x, ori_lat + m_y, ori_alt + m_z)
or some algorithm to achieve this.
I have tried with the following article to convert the (x, y, z) to the (long, lat, alt) with some origin (long, lat, alt), but no luck: (
(x, y, z) coordinates >> geo-coordinates
Advice/help to fix the issue.
Using three.js library I have assembled a design(plant). That design is contains of so many smaller models which have the reference of position in (x, y, z) from origin (0,0,0). Attached the sample screenshot in the following link
Now I want to load the individual model with its own position into Cesium. When I try to load the directly converting the position (x, y, z) to (north, east, up) the result is not as expected. All the models are scattered.
The functionality which I am trying to achieve is, based on some origin (lon, lat, alt) point, I should position the model into cesium with reference of (x, y, z) relative to cesium coordinates (lon, lat, alt)
E.g.
Origin geo-coordinates (ori_lon, ori_lat, ori_alt) => (-106.690647, 36.806761, 0)
Model coordinates (m_x, m_y, m_z) => (-150.9, 126.26, 217.7)
Expecting Coordinates for Cesium: (ori_lon + m_x, ori_lat + m_y, ori_alt + m_z)
or some algorithm to achieve this.
I have tried with the following article to convert the (x, y, z) to the (long, lat, alt) with some origin (long, lat, alt), but no luck: (
(x, y, z) coordinates >> geo-coordinates
Advice/help to fix the issue.
Share Improve this question edited Apr 29, 2021 at 15:01 Peter O. 32.9k14 gold badges84 silver badges97 bronze badges asked Feb 6, 2015 at 4:06 PremkumarPremkumar 7012 gold badges10 silver badges30 bronze badges 1- To bee less confused: gis.stackexchange./questions/334002/cesium-projection-system To bee more confused: groups.google./forum/#!topic/cesium-dev/a7QjKQ1Dt1M – Andrew Commented May 6, 2020 at 23:21
2 Answers
Reset to default 9EDIT: Since search engines appear to be sending folks here looking for Cartesian-to-cartographic conversions, I'll supply an answer to that here.
The Cartographic.fromCartesian
function is the simplest way to perform this conversion. Note that it will return a Cartographic
expressed in radians, not degrees. Height is returned in meters.
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
console.log(
'lon ' + Cesium.Math.toDegrees(cartographic.longitude) + ', ' +
'lat ' + Cesium.Math.toDegrees(cartographic.latitude) + ', ' +
'alt ' + cartographic.height);
Original Answer: If you read the details of the original question here, the asker was attempting to add coordinates together in LLA space, which is incorrect. My original answer here explains how to convert them both to Cartesian space and add the results there.
This can be done with 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);
Depending on what coordinate frame offset
is in, it may need a rotation to apply to the global Cartesian space. For example, if it's East-North-Up, you would use the corresponding function to create and then apply that transformation.
Cartesian3 to longlat, in case somebody need
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]
本文标签:
版权声明:本文标题:javascript - How to convert x, y, z to longitude, latitude, altitude in Cesium? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740020715a2220765.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论