Module:Coordinates: Difference between revisions

Jump to navigation Jump to search
comments and formatting
No edit summary
(comments and formatting)
Line 1:
--[[
-- AThis module thatis mimicsintended to replace the functionality of Template:{{Coord}} and its sub templatesrelated
-- The attempt is to actually mimic a conversion of an often used en.wp template in the way
tmeplates. It provides several methods, including
-- that most templates will actually be converted by the wiki users.
-- Attempt is not really to write a nice and proper module from scratch :D
local math_mod = require "Module:Math";
 
{{#Invoke:Coordinates | coord }}
 
Which provides the functionality to generate a coordinate link equivalent to
{{Coord}}
 
]]
 
local math_mod = require( "Module:Math" );
globalFrame = nil
 
coordinates = {};
 
---[[ ReplacementHelper function, replacement for {{coord/display/title}} ]]
function displaytitle (s)
local l = "[[Geographic coordinate system|Coordinates]]: " .. s
Line 15 ⟶ 22:
end
 
---[[ Helper function, Replacement for {{coord/display/inline}} ]]
function displayinline (s)
return s
end
 
--[[ Helper function, used in detecting DMS formatting ]]
--- Test if the arguments imply that DMS might be in use
local dmsTest = function(first, second)
local concatenated = first:upper() .. second:upper();
Line 31 ⟶ 38:
end
 
--[[
--- Parse the frame assuming that it is in dec format.
parseDec
-- @frame
 
-- @returns a table with all information needed to display coordinates
Transforms decimal format latitude and longitude into the a
structure to used in displaying coordinates
]]
function parseDec( lat, long, format )
local coordinateSpec = {}
Line 59 ⟶ 69:
end
 
--[[ Helper function, handle optional args. ]]
function optionalArg(arg, suplement)
if arg ~= nil and arg ~= "" then
Line 64 ⟶ 75:
end
return ""
end
 
function isEmpty(arg)
if arg == nil or arg == "" then
return true
end
return false
end
 
Line 97 ⟶ 101:
errors = validate( lat_d, lat_m, lat_s, long_d, long_m, long_s, 'parseDMS', true );
if isEmpty(long_d) == nil or long_d == "" then
table.insert(errors, {"parseDMS", "Missing longitude" })
end
Line 345 ⟶ 349:
local precision = 0
if notseconds_str ~= nil and isEmpty(seconds_str) ~= '' then
precision = 5 + math.max( math_mod._precision(seconds_str), 0 );
elseif notminutes_str ~= nil and isEmpty(minutes_str) ~= '' then
precision = 3 + math.max( math_mod._precision(minutes_str), 0 );
else
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu