Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Titled coords
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- *** Version 1.1 (Alpha) *** local p = {} function p.main(frame) local raw_coords = frame.args[1] local title = frame.args[2] or "" local options = frame.args[3] or "" local has_seconds = 1 local output = "", coords, sidx, eidx local lat_d, lat_m, lat_s, lat_NS, lon_d, lon_m, lon_s, lon_WE -- ** Display the raw coordinates obtained from {{wikidata}} ** if string.find(options,"raw") ~= nil then output = output .. "raw_coords:" .. raw_coords end -- ** Extract the individual fields from the raw coordinates ** -- ** See https://www.lua.org/manual/5.3/manual.html#6.4.1 ** sidx, _, lat_d, lat_m, lat_s, lat_NS, lon_d, lon_m, lon_s, lon_WE = string.find(raw_coords, "(%d+)/(%d+)/(%d+%.?%d*)/(%a)/(%d+)/(%d+)/(%d+%.?%d*)/(%a)") if sidx == nil then -- extract without seconds sidx, eidx, lat_d, lat_m, lat_NS, lon_d, lon_m, lon_WE = string.find(raw_coords, "(%d+)/(%d+)/(%a)/(%d+)/(%d+)/(%a)") if sidx == nil then return output .. "<br/>Error: Failed to process raw_coords: " .. raw_coords end if string.find(options,"idx") ~= nil then output = output .. "<br/>start: " .. sidx .. " end: " .. eidx .. " lat_d: " .. lat_d return output end has_seconds = 0 end if string.find(options,"debug") ~= nil then if has_seconds == 1 then output = output .. "<br/>raw_coords:" .. raw_coords .. "<br/>lat dms = " .. lat_d .. "|" .. lat_m .. "|" .. lat_s .. "|" .. lat_NS .. "<br/>lon dms = " .. lon_d .. "|" .. lon_m .. "|" .. lon_s .. "|" .. lon_WE else output = output .. "<br/>raw_coords:" .. raw_coords .. "<br/>lat dm = " .. lat_d .. "|" .. lat_m .. "|" .. lat_NS .. "<br/>lon dms = " .. lon_d .. "|" .. lon_m .. "|" .. lon_WE end end -- ** URL encode spaces in the title with + ** local enc_title = title:gsub(" ", "+") -- ** Call {{coord}} passing individual fields and setting the title ** local type_title = "type:mountain&title=" .. enc_title if has_seconds == 1 then coords = frame:expandTemplate{title='coord', args= { lat_d, lat_m, lat_s, lat_NS, lon_d, lon_m, lon_s, lon_WE, type_title}} else coords = frame:expandTemplate{title='coord', args= { lat_d, lat_m, lat_NS, lon_d, lon_m, lon_WE, type_title}} -- ** Doesn't like me adding these args ** --"type:mountain","format=dms","name=" .. name}} end if output ~= "" then return output .. "<br/>" .. coords end return coords end return p --[[ Tried to invoke {{wikidata}} directly but not working: local raw_coords = frame:expandTemplate{title='wikidata', args={'property','page=' .. page,'raw','coord'}} ]]
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Error
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Pp
(
edit
)
Template:Protection padlock
(
edit
)
Template:Sandbox other
(
edit
)
Template:Side box
(
edit
)
Template:Sister project
(
edit
)
Template:Template link
(
edit
)
Template:Template other
(
edit
)
Template:Tl
(
edit
)
Template:Uses Wikidata
(
edit
)
Module:Error
(
edit
)
Module:File link
(
edit
)
Module:Message box
(
edit
)
Module:Protection banner
(
edit
)
Module:Side box
(
edit
)
Module:String
(
edit
)
Module:Titled coords/doc
(
edit
)