編集の要約なし
template>Fryed-peach (翻訳開始) |
template>Fryed-peach 編集の要約なし |
||
53行目: | 53行目: | ||
if long == "" or long == nil then | if long == "" or long == nil then | ||
return nil, {{"parseDec", " | return nil, {{"parseDec", "経度が指定されていません"}} | ||
end | end | ||
61行目: | 61行目: | ||
local mode = coordinates.determineMode( lat, long ); | local mode = coordinates.determineMode( lat, long ); | ||
coordinateSpec["dms-lat"] = convert_dec2dms( lat, " | coordinateSpec["dms-lat"] = convert_dec2dms( lat, "北緯", "南緯", mode) -- {{coord/dec2dms|{{{1}}}|N|S|{{coord/prec dec|{{{1}}}|{{{2}}}}}}} | ||
coordinateSpec["dms-long"] = convert_dec2dms( long, " | coordinateSpec["dms-long"] = convert_dec2dms( long, "東経", "西経", mode) -- {{coord/dec2dms|{{{2}}}|E|W|{{coord/prec dec|{{{1}}}|{{{2}}}}}}} | ||
if format ~= "" then | if format ~= "" then | ||
90行目: | 90行目: | ||
local coordinateSpec = {} | local coordinateSpec = {} | ||
local errors = {} | local errors = {} | ||
local format_en2ja = { | |||
N = "北緯", | |||
S = "南緯", | |||
E = "東経", | |||
W = "西経" | |||
} | |||
lat_f = lat_f:upper(); | lat_f = lat_f:upper(); | ||
129行目: | 135行目: | ||
end | end | ||
coordinateSpec["dms-lat"] = lat_d.." | coordinateSpec["dms-lat"] = format_en2ja[lat_f] .. lat_d.."度"..optionalArg(lat_m,"分") .. optionalArg(lat_s,"秒") | ||
coordinateSpec["dms-long"] = long_d.." | coordinateSpec["dms-long"] = format_en2ja[long_f] .. long_d.."度"..optionalArg(long_m,"分") .. optionalArg(long_s,"秒") | ||
coordinateSpec["dec-lat"] = convert_dms2dec(lat_f, lat_d, lat_m, lat_s) -- {{coord/dms2dec|{{{4}}}|{{{1}}}|0{{{2}}}|0{{{3}}}}} | coordinateSpec["dec-lat"] = convert_dms2dec(lat_f, lat_d, lat_m, lat_s) -- {{coord/dms2dec|{{{4}}}|{{{1}}}|0{{{2}}}|0{{{3}}}}} | ||
coordinateSpec["dec-long"] = convert_dms2dec(long_f, long_d, long_m, long_s) -- {{coord/dms2dec|{{{8}}}|{{{5}}}|0{{{6}}}|0{{{7}}}}} | coordinateSpec["dec-long"] = convert_dms2dec(long_f, long_d, long_m, long_s) -- {{coord/dms2dec|{{{8}}}|{{{5}}}|0{{{6}}}|0{{{7}}}}} | ||
309行目: | 315行目: | ||
degrees, minutes, and seconds format based on the specified precision. | degrees, minutes, and seconds format based on the specified precision. | ||
]] | ]] | ||
function convert_dec2dms(coordinate, | function convert_dec2dms(coordinate, firstPrefix, secondPrefix, precision) | ||
local coord = tonumber(coordinate) or 0 | local coord = tonumber(coordinate) or 0 | ||
local | local prefix | ||
if coord >= 0 then | if coord >= 0 then | ||
prefix = firstPrefix | |||
else | else | ||
prefix = secondPrefix | |||
end | end | ||
precision = precision:lower(); | precision = precision:lower(); | ||
if precision == "dms" then | if precision == "dms" then | ||
return convert_dec2dms_dms( math.abs( coord ) ) | return prefix .. convert_dec2dms_dms( math.abs( coord ) ); | ||
elseif precision == "dm" then | elseif precision == "dm" then | ||
return convert_dec2dms_dm( math.abs( coord ) ) | return prefix .. convert_dec2dms_dm( math.abs( coord ) ); | ||
elseif precision == "d" then | elseif precision == "d" then | ||
return convert_dec2dms_d( math.abs( coord ) ) | return prefix .. convert_dec2dms_d( math.abs( coord ) ); | ||
end | end | ||
end | end | ||
330行目: | 336行目: | ||
--[[ Helper function, convert decimal to degrees ]] | --[[ Helper function, convert decimal to degrees ]] | ||
function convert_dec2dms_d(coordinate) | function convert_dec2dms_d(coordinate) | ||
local d = math_mod._round( coordinate, 0 ) .. " | local d = math_mod._round( coordinate, 0 ) .. "度" | ||
return d .. "" | return d .. "" | ||
end | end | ||
339行目: | 345行目: | ||
local m = coordinate % 60; | local m = coordinate % 60; | ||
coordinate = math.floor( (coordinate - m) / 60 ); | coordinate = math.floor( (coordinate - m) / 60 ); | ||
local d = coordinate % 360 .." | local d = coordinate % 360 .."度" | ||
return d .. string.format( "% | return d .. string.format( "%02d分", m ) | ||
end | end | ||
351行目: | 357行目: | ||
local m = coordinate % 60 | local m = coordinate % 60 | ||
coordinate = math.floor( (coordinate - m) / 60 ); | coordinate = math.floor( (coordinate - m) / 60 ); | ||
local d = coordinate % 360 .." | local d = coordinate % 360 .."度" | ||
return d .. string.format( "% | return d .. string.format( "%02d分", m ) .. string.format( "%02d秒", s ) | ||
end | end | ||