あなたは確かに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));