繁体   English   中英

从特定的飞行计划航点获取GPS坐标

[英]Getting GPS Coordinates from a specific flight plan waypoints

我正在开发一个传单地图,并希望根据从A到B的航路点(交叉点)列表在其上显示飞行计划,例如该网站显示航班的http://onlineflightplanner.org/在地图上的路线。

我的问题是,如何从航路点获取gps坐标(例如:ADABI:N44°4943.15 / W000°42'55.24”?有没有可以这样做的JavaScript库?非常感谢

航点列表及其GPS坐标(来自onlineflightplanner.org)

并在地图上显示

您确实可以使用Javascript GeoPoint Library之类的 ,但是这种转换非常容易实现。 此外,提到的库希望您已经知道哪个值是纬度(北),哪个值是经度(东),如果您输入的是"N44°49'43.15 / W000°42'55.24''" ,则可能不是这种情况"N44°49'43.15 / W000°42'55.24''"你的建议。

将经度和纬度转换为十进制值的基础上 ,我们可以轻松地制作一个适合您情况的特定转换实用程序:

 var input = "N44°49'43.15 / W000°42'55.24''"; function parseDMS(input) { var halves = input.split('/'); // Separate northing from easting. return { // Ready to be fed into Leaflet. lat: parseDMSsingle(halves[0].trim()), lng: parseDMSsingle(halves[1].trim()) }; } function parseDMSsingle(input) { var direction = input[0]; // First char is direction (N, E, S or W). input = input.substr(1); var parts = input.split(/[^\\d\\w.]+/); // 0: degrees, 1: minutes, 2: seconds; each can have decimals. return convertDMSToDD( parseFloat(parts[0]) || 0, // Accept missing value. parseFloat(parts[1]) || 0, parseFloat(parts[2]) || 0, direction ); } function convertDMSToDD(degrees, minutes, seconds, direction) { var dd = degrees + minutes/60 + seconds/(60*60); if (direction == "S" || direction == "W") { dd = dd * -1; } // Don't do anything for N or E return dd; } console.log(input); console.log(parseDMS(input)); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM