Module:Coordinates: Difference between revisions

more formatting
(more formatting / comments)
(more formatting)
Line 299:
end
 
--[[ Helper function, convert decimal to degrees ]]
function convert_dec2dms_d(coordinate)
local d = math_mod._round( coordinate, 0 ) .. "°"
Line 304 ⟶ 305:
end
 
--[[ Helper function, convert decimal to degrees and minutes ]]
function convert_dec2dms_dm(coordinate)
coordinate = math_mod._round( coordinate * 60, 0 );
Line 313 ⟶ 315:
end
 
--[[ Helper function, convert decimal to degrees, minutes, and seconds ]]
function convert_dec2dms_dms(coordinate)
coordinate = math_mod._round( coordinate * 60 * 60, 0 );
Line 324 ⟶ 327:
end
 
--[[
--- Convert a latitude or longitude to the DMS format
Helper function, convert decimal latitude or longitude to
degrees, minutes, and seconds format based on the specified precision.
]]
function convert_dec2dms(coordinate, firstPostfix, secondPostfix, precision)
-- {{Coord/dec2dms/{{{4}}}|{{#ifexpr:{{{1}}} >= 0||-}}{{{1}}}}}{{#ifexpr:{{{1}}} >= 0|{{{2}}}|{{{3}}}}}
Line 356 ⟶ 362:
local minutes = tonumber(minutes_str) or 0
local seconds = tonumber(seconds_str) or 0
-- {{#expr:{{#switch:{{{1}}}|N|E=1|S|W=-1}}*({{{2|0}}}+({{{3|0}}}+{{{4|0}}}/60)/60) round {{{precdec|{{#if:{{{4|}}}|5|{{#if:{{{3|}}}|3|0}}}}+{{precision1|{{{4|{{{3|{{{2}}}}}}}}}}}}}}}}
local factor
Line 381 ⟶ 386:
end
 
-- Check the input for out of range errors.
function validate( lat_d, lat_m, lat_s, long_d, long_m, long_s, source, strong )
local errors = {};
Anonymous user