Module:Coordinates: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(comments and formatting) |
(more formatting / comments) |
||
Line 42: | Line 42: | ||
Transforms decimal format latitude and longitude into the a |
Transforms decimal format latitude and longitude into the a |
||
structure to used in displaying coordinates |
structure to be used in displaying coordinates |
||
]] |
]] |
||
function parseDec( lat, long, format ) |
function parseDec( lat, long, format ) |
||
Line 77: | Line 77: | ||
end |
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 ) |
function parseDMS( lat_d, lat_m, lat_s, lat_f, long_d, long_m, long_s, long_f, format ) |
||
local coordinateSpec = {} |
local coordinateSpec = {} |
||
Line 83: | Line 89: | ||
lat_f = lat_f:upper(); |
lat_f = lat_f:upper(); |
||
long_f = long_f:upper(); |
long_f = long_f:upper(); |
||
-- |
-- Check if specified backward |
||
if lat_f == 'E' or lat_f == 'W' then |
if lat_f == 'E' or lat_f == 'W' then |
||
local t_d, t_m, t_s, t_f; |
local t_d, t_m, t_s, t_f; |
||
Line 133: | Line 140: | ||
end |
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) |
function specPrinter(args, coordinateSpec) |
||
local uriComponents = coordinateSpec["param"] |
local uriComponents = coordinateSpec["param"] |
||
Line 165: | Line 177: | ||
end |
end |
||
-- TODO requires DEC formatting |
|||
local geodechtml = '<span class="geo-dec" title="Maps, aerial photos, and other data for this location">' |
local geodechtml = '<span class="geo-dec" title="Maps, aerial photos, and other data for this location">' |
||
.. geodeclat .. ' ' |
.. geodeclat .. ' ' |
||
Line 176: | Line 187: | ||
.. '</span>' |
.. '</span>' |
||
local inner |
local inner; |
||
⚫ | |||
⚫ | |||
⚫ | |||
.. '<span class="geo-multi-punct"> / </span>' |
.. '<span class="geo-multi-punct"> / </span>' |
||
.. '<span class="' .. displayDefault(coordinateSpec["default"], "dec" ) .. '">' |
.. '<span class="' .. displayDefault(coordinateSpec["default"], "dec" ) .. '">'; |
||
⚫ | |||
inner = inner .. geodechtml |
|||
.. '<span style="display:none"> / ' .. geonumhtml .. '</span></span>' |
.. '<span style="display:none"> / ' .. geonumhtml .. '</span></span>' |
||
else |
else |
||
inner = '<span class=" |
inner = inner .. '<span class="vcard">' .. geodechtml |
||
.. '<span class="geo-multi-punct"> / </span>' |
|||
.. '<span class="' .. displayDefault(coordinateSpec["default"], "dec" ) .. '"><span class="vcard">' .. geodechtml |
|||
.. '<span style="display:none"> / ' .. geonumhtml .. '</span>' |
.. '<span style="display:none"> / ' .. geonumhtml .. '</span>' |
||
.. '<span style="display:none"> (<span class="fn org">' |
.. '<span style="display:none"> (<span class="fn org">' |
||
Line 196: | Line 207: | ||
end |
end |
||
--[[ |
|||
Formats any error messages generated for display |
|||
]] |
|||
function errorPrinter(errors) |
function errorPrinter(errors) |
||
local result = "" |
local result = "" |
||
for i,v in ipairs(errors) do |
for i,v in ipairs(errors) do |
||
local errorHTML = '<strong class="error"> |
local errorHTML = '<strong class="error">Module:Coordinates: ' .. v[2] .. '</strong>' |
||
result = result .. errorHTML .. "<br />" |
result = result .. errorHTML .. "<br />" |
||
end |
end |
||
Line 205: | Line 219: | ||
end |
end |
||
--[[ |
|||
Determine the required CSS class to display coordinates |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
]] |
|||
function displayDefault(default, mode) |
function displayDefault(default, mode) |
||
if default == "" then |
if default == "" then |
||
Line 221: | Line 238: | ||
end |
end |
||
-- Check the arguments to determine what type of coordinates has been input |
|||
function formatTest(args) |
function formatTest(args) |
||
local result, errors; |
local result, errors; |