从Lat long on Three JS创建路径

时间:2017-02-15 09:18:03

标签: javascript 3d three.js

我正在尝试基于地理坐标实现管状结构,数据是json格式,看起来像这样。

[
{
    "LATITUDE": "55.10185525",
    "LONGITUDE": "-76.4629527"
},
{
    "LATITUDE": "55.10181625",
    "LONGITUDE": "-76.4629827"
},
{
    "LATITUDE": "55.10185525",
    "LONGITUDE": "-76.4629527"
},
{
    "LATITUDE": "55.10181625",
    "LONGITUDE": "-76.4629827"
},
{
    "LATITUDE": "55.10185525",
    "LONGITUDE": "-76.4329527"
},
{
    "LATITUDE": "55.10181625",
    "LONGITUDE": "-76.4629827"
},
{
    "LATITUDE": "55.10185525",
    "LONGITUDE": "-76.4629527"
},
{
    "LATITUDE": "55.10181625",
    "LONGITUDE": "-76.4629827"
}

我使用这种转换方法来创建Three js Vector3

function convertLatLonToVec3(lat,lon) {
lat =  lat * Math.PI / 180.0;
lon = -lon * Math.PI / 180.0;
return new THREE.Vector3( 
    Math.cos(lat) * Math.cos(lon),
    Math.sin(lat),
    Math.cos(lat) * Math.sin(lon));

}; 但这不是很好。所以还有其他方法在3d平面上实现lat long

1 个答案:

答案 0 :(得分:1)

如果要将点投影到坐标参照系,请查看Proj4js