gpt4 book ai didi

javascript - 从特定飞行计划航路点获取 GPS 坐标

转载 作者:行者123 更新时间:2023-11-30 14:57:50 25 4
gpt4 key购买 nike

我正在制作传单 map ,我想根据从 A 到 B 的航路点(交叉点)列表在上面显示飞行​​计划,例如网站 http://onlineflightplanner.org/它在 map 上显示飞行路线。

我的问题是,如何从航路点获取后面的 gps 坐标(例如:ADABI : N44°4943.15/W000°42'55.24''?是否有任何 javascript 库可以做到这一点?非常感谢

List of waypoints along with its gps coordinates (from onlineflightplanner.org)

And Display on Map

最佳答案

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

基于 Converting latitude and longitude to decimal values ,我们可以轻松制作适合您情况的特定转换实用程序:

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));

关于javascript - 从特定飞行计划航路点获取 GPS 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46977704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com