Module:Coordinates: Difference between revisions

more formatting / comments
(comments and formatting)
(more formatting / comments)
Line 42:
 
Transforms decimal format latitude and longitude into the a
structure to be used in displaying coordinates
]]
function parseDec( lat, long, format )
Line 77:
end
 
--[[
parseDec
 
Transforms degrees, minutes, seconds format latitude and longitude
into the a structure to be used in displaying coordinates
]]
function parseDMS( lat_d, lat_m, lat_s, lat_f, long_d, long_m, long_s, long_f, format )
local coordinateSpec = {}
Line 83 ⟶ 89:
lat_f = lat_f:upper();
long_f = long_f:upper();
-- SpecifiedCheck if specified backward
if lat_f == 'E' or lat_f == 'W' then
local t_d, t_m, t_s, t_f;
Line 133 ⟶ 140:
end
 
--[[
--- A function that prints a table of coordinate specifications to HTML
specPrinter
 
Output formatter. Takes the structure generated by either parseDec
or parseDMS and formats it for inclusion on Wikipedia.
]]
function specPrinter(args, coordinateSpec)
local uriComponents = coordinateSpec["param"]
Line 165 ⟶ 177:
end
-- TODO requires DEC formatting
local geodechtml = '<span class="geo-dec" title="Maps, aerial photos, and other data for this location">'
.. geodeclat .. ' '
Line 176 ⟶ 187:
.. '</span>'
 
local inner;
inner = '<span class="' .. displayDefault(coordinateSpec["default"], "dms" ) .. '">' .. geodmshtml .. '</span>'
if args["name"] == "" or args["name"] == nil then
inner = '<span class="' .. displayDefault(coordinateSpec["default"], "dms" ) .. '">' .. geodmshtml .. '</span>'
.. '<span class="geo-multi-punct">&#xfeff; / &#xfeff;</span>'
.. '<span class="' .. displayDefault(coordinateSpec["default"], "dec" ) .. '">' .. geodechtml ;
 
if args["name"] == "" or args["name"] == nil then
inner = inner .. geodechtml
.. '<span style="display:none">&#xfeff; / ' .. geonumhtml .. '</span></span>'
else
inner = inner .. '<span class="' .. displayDefault(coordinateSpec["default"], "dms" ) .. 'vcard">' .. geodmshtmlgeodechtml .. '</span>'
.. '<span class="geo-multi-punct">&#xfeff; / &#xfeff;</span>'
.. '<span class="' .. displayDefault(coordinateSpec["default"], "dec" ) .. '"><span class="vcard">' .. geodechtml
.. '<span style="display:none">&#xfeff; / ' .. geonumhtml .. '</span>'
.. '<span style="display:none">&#xfeff; (<span class="fn org">'
Line 196 ⟶ 207:
end
 
--[[
Formats any error messages generated for display
]]
function errorPrinter(errors)
local result = ""
for i,v in ipairs(errors) do
local errorHTML = '<strong class="error">' .. v[2] .. ' in Module:Coordinates.: ' .. v[12] .."()" .. '</strong>'
result = result .. errorHTML .. "<br />"
end
Line 205 ⟶ 219:
end
 
--[[
--- Determine the required CSS class to display coordinates
-- Usually geo-nondefault is hidden by CSS, unless a user has overridden this for himself
 
-- default is the mode as specificied by the user when calling the {{coord}} template
-- Usually geo-nondefault is hidden by CSS, unless a user has overridden this for himself
-- mode is the display mode (dec or dms) that we will need to determine the css class for
-- default is the mode as specificied by the user when calling the {{coord}} template
-- mode is the display mode (dec or dms) that we will need to determine the css class for
]]
function displayDefault(default, mode)
if default == "" then
Line 221 ⟶ 238:
end
 
--- Check the arguments to determine what type of coordinates has been input
function formatTest(args)
local result, errors;
Anonymous user