Module:Coordinates: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 38:
if long == "" or long == nil then
return coordinateSpecnil, {{"parseDec", "Missing longitude"}}
end
Line 106:
 
return coordinateSpec, errors
end
 
--- BAD BAD URL escape
-- replace this later with the actual helper template
function urlEscape(arg)
return mw.uri.encode( arg );
end
 
Line 122 ⟶ 116:
end
if args["name"] ~= "" and args["name"] ~= nil then
uriComponents = uriComponents .. "&title=" .. urlEscapemw.uri.encode(coordinateSpec["name"])
end
Line 130 ⟶ 124:
.. '</span>'
 
local geodeclatlat = tonumber( coordinateSpec["dec-lat-display"] ) or 0
if geodeclatlat ==< nil0 then
-- FIXME this breaks the pre-existing precision
local lat = tonumber( coordinateSpec["dec-lat"] ) or 0
geodeclat = (coordinateSpec["dec-lat"] or 0:sub(2) .. "°NS"
if lat < 0 then
else
-- FIXME this breaks the pre-existing precision
geodeclat = (coordinateSpec["dec-lat"]:sub(2 or 0) .. "°SN"
else
geodeclat = (coordinateSpec["dec-lat"] or 0) .. "°N"
end
end
 
local latlong = tonumber( coordinateSpec["dec-latlong"] ) or 0
-- FIXME ugly code duplication, but lazy :D
if latlong < 0 then
local geodeclong = coordinateSpec["dec-long-display"]
-- FIXME does not handle unicode minus
if geodeclong == nil then
local longgeodeclong = tonumber( coordinateSpec["dec-long"] :sub(2) or.. 0"°W"
else
if long < 0 then
local geodeclong = (coordinateSpec["dec-long-display"] or 0) .. "°E"
-- FIXME does not handle unicode minus
geodeclong = coordinateSpec["dec-long"]:sub(2) .. "°W"
else
geodeclong = (coordinateSpec["dec-long"] or 0) .. "°E"
end
end
Line 219 ⟶ 206:
-- dec logic
result, errors = parseDec( args[1], args[2], args['format'] )
if geodeclongresult == nil then
return errorPrinter( errors );
end
else
result.param = table.concat( {args[1], "_N_", args[2], "_E_", args[3] } );
elseif dmsTest(args[4], args[8]) then
Anonymous user