Anonymous user
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();
--
if lat_f == 'E' or lat_f == 'W' then
local t_d, t_m, t_s, t_f;
Line 133 ⟶ 140:
end
--[[
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
local geodechtml = '<span class="geo-dec" title="Maps, aerial photos, and other data for this location">'
.. geodeclat .. ' '
Line 176 ⟶ 187:
.. '</span>'
local inner;
if args["name"] == "" or args["name"] == nil then▼
▲ inner = '<span class="' .. displayDefault(coordinateSpec["default"], "dms" ) .. '">' .. geodmshtml .. '</span>'
.. '<span class="geo-multi-punct"> / </span>'
.. '<span class="' .. displayDefault(coordinateSpec["default"], "dec" ) .. '">'
▲ if args["name"] == "" or args["name"] == nil then
inner = inner .. geodechtml
.. '<span style="display:none"> / ' .. geonumhtml .. '</span></span>'
else
inner = inner .. '<span class="
.. '<span style="display:none"> / ' .. geonumhtml .. '</span>'
.. '<span style="display:none"> (<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">
result = result .. errorHTML .. "<br />"
end
Line 205 ⟶ 219:
end
--[[
-- 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▼
-- 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
function formatTest(args)
local result, errors;
|