Module:Coordinates: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(trim spaces on direction for convert_dms2dec)
(update from sandbox. Add export hook for coord_url, remove uneccesary use of frame:preprocess)
Line 11: Line 11:
{{#Invoke:Coordinates | dms2dec }} : Simple function for converting DMS format
{{#Invoke:Coordinates | dms2dec }} : Simple function for converting DMS format
to decimal degree format.
to decimal degree format.

{{#Invoke:Coordinates | link }} : Export the link used to reach the tools


]]
]]
Line 16: Line 18:
math_mod = require( "Module:Math" );
math_mod = require( "Module:Math" );
globalFrame = nil
globalFrame = nil

coordinates = {};
coordinates = {};

page_name = mw.uri.encode( mw.title.getCurrentTitle().prefixedText, 'WIKI' );
coord_link = '//tools.wmflabs.org/geohack/geohack.php?pagename=' .. page_name .. '&params='


--[[ Helper function, replacement for {{coord/display/title}} ]]
--[[ Helper function, replacement for {{coord/display/title}} ]]
Line 205: Line 209:
end
end


return '<span class="plainlinks nourlexpansion">' .. globalFrame:preprocess(
return '<span class="plainlinks nourlexpansion">' ..
'[' .. coord_link .. uriComponents .. ' ' .. inner .. ']' .. '</span>'
'[//tools.wmflabs.org/geohack/geohack.php?pagename={{FULLPAGENAMEE}}&params=' ..
uriComponents .. ' ' .. inner .. ']') .. '</span>'
end
end


Line 454: Line 457:
return errors;
return errors;
end

--[[
link

Simple function to export the coordinates link for other uses.

Usage:
{{ Invoke:Coordinates | link }}
]]
function coordinates.link(frame)
return coord_link;
end
end