2017-10-27 10 views
1

リーフレットマップを作成していますが、http://onlineflightplanner.org/のようなAからBへのウェイポイント(交差点)リストに基づいてフライトプランを表示したいと思いますそこには地図上の飛行ルートが表示されます。 ?これを行うことができます任意のJavaScriptライブラリがあるN44°4943.15/W000°42'55.24「」おかげでたくさん特定のフライトプランウェイポイントからGPS座標を取得

に:?ADABI:

私の質問は、GPSの背後にあるウェイポイントから(元の座標を取得する方法であり、

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

And Display on Map

答えて

2

あなたは確かにJavascript GeoPoint Libraryのようなライブラリを使用することができますが、このような変換は、実装するのはむしろ容易である。さらに、言及したライブラリは、あなたが既に知っていることを期待緯度(北上)であるとされている値1つは経度(東洋)ですが、あなたの入力が"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));

関連する問題