Module talk:Coordinates
Fix display inline/title shortcut
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
With display=i it displays the coodinates at the title, and display=t it displays them inline. Function coordinates.coord must be fixed. Instead of:
if string.find( Display, 'inline' ) ~= nil or Display == 't' or
Display == 'it' or Display == 'ti' then
text = displayinline(contents, Notes)
end
if string.find( Display, 'title' ) ~= nil or Display == 'i' or
Display == 'it' or Display == 'ti' then
text = text .. displaytitle(contents, Notes)
end
it should be:
if string.find( Display, 'inline' ) ~= nil or Display == 'i' or
Display == 'it' or Display == 'ti' then
text = displayinline(contents, Notes)
end
if string.find( Display, 'title' ) ~= nil or Display == 't' or
Display == 'it' or Display == 'ti' then
text = text .. displaytitle(contents, Notes)
end
--Vriullop (talk) 19:58, 29 March 2013 (UTC)
- Fixed. Good catch. Dragons flight (talk) 21:15, 29 March 2013 (UTC)
Geo microformat
I think this module (and the old coord template) currently contradicts against Geo specification. latitude and longitude classes should be given to machine-readable representation and be in geo class. Can someone fix it? --fryed-peach (talk) 01:26, 30 March 2013 (UTC)
- I think specPrinter function should be
Code sample
|
---|
--[[
specPrinter
Output formatter. Takes the structure generated by either parseDec
or parseDMS and formats it for inclusion on Wikipedia.
]]
function specPrinter(args, coordinateSpec)
local uriComponents = coordinateSpec["param"]
if uriComponents == "" then
-- RETURN error, should never be empty or nil
return "ERROR param was empty"
end
if args["name"] ~= "" and args["name"] ~= nil then
uriComponents = uriComponents .. "&title=" .. mw.uri.encode(coordinateSpec["name"])
end
local geodmshtml = '<span class="geo-dms" title="Maps, aerial photos, and other data for this location">'
.. '<span class="nowrap">' .. coordinateSpec["dms-lat"] .. '</span> '
.. '<span class="nowrap">' ..coordinateSpec["dms-long"] .. '</span>'
.. '</span>'
local lat = tonumber( coordinateSpec["dec-lat"] ) or 0
if lat < 0 then
-- FIXME this breaks the pre-existing precision
geodeclat = coordinateSpec["dec-lat"]:sub(2) .. "°S"
else
geodeclat = (coordinateSpec["dec-lat"] or 0) .. "°N"
end
local long = tonumber( coordinateSpec["dec-long"] ) or 0
if long < 0 then
-- FIXME does not handle unicode minus
geodeclong = coordinateSpec["dec-long"]:sub(2) .. "°W"
else
geodeclong = (coordinateSpec["dec-long"] or 0) .. "°E"
end
local geodechtml = '<span class="geo-dec" title="Maps, aerial photos, and other data for this location">'
.. '<span class="nowrap">' .. geodeclat .. '</span> '
.. '<span class="nowrap">' .. geodeclong .. '</span>'
.. '</span>'
local geonumhtml = '<span class="geo">'
.. '<span class="latitude">' .. coordinateSpec["dec-lat"] .. '</span>; '
.. '<span class="longitude">' .. coordinateSpec["dec-long"] .. '</span>'
.. '</span>'
local inner;
inner = '<span class="' .. displayDefault(coordinateSpec["default"], "dms" ) .. '">' .. geodmshtml .. '</span>'
.. '<span class="geo-multi-punct"> / </span>'
.. '<span class="' .. displayDefault(coordinateSpec["default"], "dec" ) .. '">';
if args["name"] == "" or args["name"] == nil then
inner = inner .. geodechtml
.. '<span style="display:none"> / ' .. geonumhtml .. '</span></span>'
else
inner = inner .. '<span class="vcard">' .. geodechtml
.. '<span style="display:none"> / ' .. geonumhtml .. '</span>'
.. '<span style="display:none"> (<span class="fn org">'
.. args["name"] .. '</span>)</span></span></span>'
end
return '<span class="plainlinks nourlexpansion">' .. globalFrame:preprocess(
'[http://toolserver.org/~geohack/geohack.php?pagename={{FULLPAGENAMEE}}¶ms=' ..
uriComponents .. ' ' .. inner .. ']') .. '</span>'
end
|
--fryed-peach (talk) 23:51, 31 March 2013 (UTC)
- Honestly, I don't know the issues well enough to know if a change is appropriate here or not. Perhaps it would be good to discuss the specification issue at Template talk:Coord or one of the relevant WikiProjects (Wikipedia:WikiProject Geographical coordinates / Wikipedia:WikiProject Microformats)? Dragons flight (talk) 00:18, 1 April 2013 (UTC)
- I introduced the geo microformat to Wikipedia; and founded the microformat project. I'm not a Lua coder, but I understand the necessary HTML. Can I help? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 15:44, 1 April 2013 (UTC)
- Thanks! Currently 57°18′22″N 4°27′32″W / 57.30611°N 4.45889°W produces
- I introduced the geo microformat to Wikipedia; and founded the microformat project. I'm not a Lua coder, but I understand the necessary HTML. Can I help? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 15:44, 1 April 2013 (UTC)
<span class="plainlinks nourlexpansion">[http://toolserver.org/~geohack/geohack.php?pagename=Module_talk:Coordinates¶ms=57_18_22_N_4_27_32_W_ <span class="geo-default"><span class="geo-dms" title="Maps, aerial photos, and other data for this location"><span class="latitude">57°18′22″N</span> <span class="longitude">4°27′32″W</span></span></span><span class="geo-multi-punct"> / </span><span class="geo-nondefault"><span class="geo-dec" title="Maps, aerial photos, and other data for this location">57.30611°N 4.45889°W</span><span style="display:none"> / <span class="geo">57.30611; -4.45889</span></span></span>]</span>
- But according to Geo specification, latitude and longitude classes should be inside of geo class and should include machine-readable coodinates. So it should produce
<span class="plainlinks nourlexpansion">[http://toolserver.org/~geohack/geohack.php?pagename=Module_talk:Coordinates¶ms=57_18_22_N_4_27_32_W_ <span class="geo-default"><span class="geo-dms" title="Maps, aerial photos, and other data for this location"><span class="nowrap">57°18′22″N</span> <span class="nowrap">4°27′32″W</span></span></span><span class="geo-multi-punct"> / </span><span class="geo-nondefault"><span class="geo-dec" title="Maps, aerial photos, and other data for this location"><span class="nowrap">57.30611°N</span> <span class="nowrap">4.45889°W</span></span><span style="display:none"> / <span class="geo"><span class="latitude">57.30611</span>; <span class="longitude">-4.45889</span></span></span>]</span>
- instead. (extra nowrap classes are for correct text wrapping.) Am I right? --fryed-peach (talk) 09:54, 2 April 2013 (UTC)
- No;
<span class="geo">57.30611; -4.45889</span>
(with a semi-colon) is a valid Geo microformat. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 19:50, 2 April 2013 (UTC)- Oh I overlooked it. Then, latitude and longitude class should be eliminated altogether? What do you think of? They are currently used for "white-space:nowrap". I think we should replace them with "nowrap" classes and also give "nowrap" class to decimal coodinates. --fryed-peach (talk) 05:28, 3 April 2013 (UTC)
- That would make no difference to the Geo microformat. You'd need to be careful that those class names aren't used by users, in their local stylesheets, for styling. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 10:31, 3 April 2013 (UTC)
- If there is a
name
parameter other than pagename then it should be<div class="geo">Name: <span class="latitude">57.30611</span>; <span class="longitude">-4.45889</span></div>
. Right? --Vriullop (talk) 07:29, 3 April 2013 (UTC)- The Geo microformat doesn't have a name parameter. You could use the markup you suggest (it would still be a valid Geo microformat), but I don't see anything gained by doing so. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 10:31, 3 April 2013 (UTC)
- Sorry, I misunderstood it. Geo Spec reads: "the publisher must use hCard instead of just geo to publish the name and geo lat/long of the location." This gets me confused when a page has multiple coordinates with multiple names. --Vriullop (talk) 12:29, 3 April 2013 (UTC)
- The Geo microformat doesn't have a name parameter. You could use the markup you suggest (it would still be a valid Geo microformat), but I don't see anything gained by doing so. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 10:31, 3 April 2013 (UTC)
- Oh I overlooked it. Then, latitude and longitude class should be eliminated altogether? What do you think of? They are currently used for "white-space:nowrap". I think we should replace them with "nowrap" classes and also give "nowrap" class to decimal coodinates. --fryed-peach (talk) 05:28, 3 April 2013 (UTC)
- No;
- instead. (extra nowrap classes are for correct text wrapping.) Am I right? --fryed-peach (talk) 09:54, 2 April 2013 (UTC)
Not protocol-neutral
This module does not return a protocol-neutral URL (or whatever it's called). It's always http:// - please see Template talk:GeoTemplate#Https for Wikipedia link in this template. --Redrose64 (talk) 17:12, 10 April 2013 (UTC)
- Am I correct that the way to do this is to replace things like:
- with
- //toolserver.org/~geohack/geohack.php
- I've never really worried about protocol neutral URLs, so I want to make sure. Dragons flight (talk) 17:30, 10 April 2013 (UTC)
- Yes, but with two caveats: (i) only if the ultimate wikicode has a left-square bracket as the immediately-preceding character; and (ii) only if the target server respects both the http: and https: protocols.
- In the specific case of Module:Coordinates as it presently (19:57, 10 April 2013 (UTC)) stands, both of these two conditions are satisfied because the string constant reads
'[http://toolserver.org/~geohack/geohack.php?pagename={{FULLPAGENAMEE}}¶ms='
and toolserver is happy to be accessed as https://toolserver.org/ so it may be altered to'[//toolserver.org/~geohack/geohack.php?pagename={{FULLPAGENAMEE}}¶ms='
--Redrose64 (talk) 19:57, 10 April 2013 (UTC)
- Okay, done. Dragons flight (talk) 20:11, 10 April 2013 (UTC)
Odd default direction in dms2dec
As the code stands today, if the direction parameter is passed empty in dms2dec, then factor is set to -1. In other words, the code assumes that the default hemisphere is South or West. That's rather surprising.
Perhaps direction should be set explicitly to "E" if empty or nil? —hike395 (talk) 05:13, 30 April 2013 (UTC)
Update the GeoHack link
It is requested that an edit be made to the fully protected module at Module:Coordinates. (edit · history · last · links · sandbox · edit sandbox · sandbox history · sandbox last edit · sandbox diff · test cases · transclusion count · protection log) This template must be followed by a complete and specific description of the request, so that an editor unfamiliar with the subject matter could complete the requested edit immediately.
Edit requests to fully protected pages should only be used for edits that are either uncontroversial or supported by consensus. If the proposed edit might be controversial, discuss it on the protected page's talk page before using this template. Consider making changes first to the module's sandbox and test them thoroughly here before submitting an edit request. To request that a page be protected or unprotected, make a protection request. When the request has been completed or denied, please add the |
I just noticed that the GeoHack tool has been moved to Labs. So, idealy, the link to GeoHack should be changed so that it links to Labs - like so:
//toolserver.org/~geohack/geohack.php
should be changed to
//tools.wmflabs.org/geohack/geohack.php
--Snaevar (talk) 13:41, 2 June 2013 (UTC)
- Sorry for my absence, but Labs is running an unsupported shoddy copy of GeoHack and the official version still on the Toolserver. Additionally, this change should've somehow be made at Template:Coor URL. — Dispenser 18:01, 27 August 2013 (UTC)
Nonsense value for the parameter "display" kills the text to be returned
It is requested that an edit be made to the fully protected module at Module:Coordinates. (edit · history · last · links · sandbox · edit sandbox · sandbox history · sandbox last edit · sandbox diff · test cases · transclusion count · protection log) This template must be followed by a complete and specific description of the request, so that an editor unfamiliar with the subject matter could complete the requested edit immediately.
Edit requests to fully protected pages should only be used for edits that are either uncontroversial or supported by consensus. If the proposed edit might be controversial, discuss it on the protected page's talk page before using this template. Consider making changes first to the module's sandbox and test them thoroughly here before submitting an edit request. To request that a page be protected or unprotected, make a protection request. When the request has been completed or denied, please add the |
Hallo. I just found a very ugly bug of this module. If you use the following code, thus, with a nonsense value for the parameter "display":
{{#Invoke:Coordinates| coord |11.5|-153.43333333333|display=elephant}}
then it returns nothing: . I found a solution for this bug. The part
local text = '' if string.find( Display, 'inline' ) ~= nil or Display == 'i' or Display == 'it' or Display == 'ti' then text = displayinline(contents, Notes) end if string.find( Display, 'title' ) ~= nil or Display == 't' or Display == 'it' or Display == 'ti' then text = text .. displaytitle(contents, Notes) end return text
has to be changed into
local text = '' local nothing = '' if string.find( Display, 'inline' ) ~= nil or Display == 'i' or Display == 'it' or Display == 'ti' then text = displayinline(contents, Notes) else nothing = "i" end if string.find( Display, 'title' ) ~= nil or Display == 't' or Display == 'it' or Display == 'ti' then text = text .. displaytitle(contents, Notes) else if nothing = "i" then text = displayinline(contents, Notes) end end return text
I just tested this solution on a testing page of the Esperanto Wikpedia. It works very fine there. Greetings --Tlustulimu (talk) 12:26, 29 June 2013 (UTC)
- Wouldn't it be better to return an error message and tracking category rather than simply assuming that the user who entered "elephant" really meant inline? Dragons flight (talk) 15:43, 29 June 2013 (UTC)
- Yes, because the error may be a misspelling of "title". Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 15:26, 4 August 2013 (UTC)
- What CoI? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 15:26, 4 August 2013 (UTC)
Strange results
Hallo. I just tested the function dmsdec in this module. But some results are wrong:
{{#Invoke:Coordinates | dms2dec | N|52|28|59 }} {{#Invoke:Coordinates | dms2dec | S|52|28|59 }}
returns: 52.48306 -52.48306 Why the results are the same for North and South?
{{#Invoke:Coordinates | dms2dec | W|1|53|37 }} {{#Invoke:Coordinates | dms2dec | E|1|53|37 }}
returns: -1.89361 1.89361 Why the results for East and West are the same? Greetings --Tlustulimu (talk) 22:57, 29 June 2013 (UTC)
- Fixed. The spaces needed trimming from the parameter before comparison. -- WOSlinker (talk) 23:19, 29 June 2013 (UTC)
- Thank you :-) --Tlustulimu (talk) 23:33, 29 June 2013 (UTC)
Wikidata
It is now easy to retrieve coordinates from Wikidata:
mw.wikibase.getEntity().claims.p625[0].mainsnak.datavalue.value["latitude"]
Should it be added to this module or further downstream ? --Superzoulou (talk) 06:54, 10 July 2013 (UTC)
Solved bug in the link to the toolserver
Hallo. I just corrected the bug in the link to the toolserver, if there are coordinates in southern or western hemisphere. E.g. {{coord|43.651234|-79.383333}}
now returns a negative value for the longitude and E in the link for the toolserver: 43°39′04″N 79°23′00″W / 43.651234°N 79.383333°W. This looks very strangely. The link text isn't concerned.
The following code in the function formatTest
result.param = table.concat( {args[1], "_N_", args[2], "_E_", args[3] } );
has to be changed into
local declat = tonumber( args[1], 10 ) or 0
if declat < 0 then
dirNS = "_S_"
declat = 0 - declat
else
dirNS = "_N_"
declat = args[1]
end
local declong = tonumber( args[2], 10 ) or 0
if declong < 0 then
dirEW = "_W_"
declong = 0 - declong
else
dirEW = "_E_"
declong = args[2]
end
result.param = table.concat( {declat, dirNS, declong, dirEW, args[3] } );
--result.param = table.concat( {args[1], "_N_", args[2], "_E_", args[3] } );
I tested the code on the Esperanto Wikipedia. It works very fine there: sandbox version with tests in its documentation. You can see the effect in a template too: Ŝablono:Koord/provejo. Greetings --Tlustulimu (talk) 07:41, 1 August 2013 (UTC)
- I just corrected a little bit, because a function formatPoint is used in the code of the Esperanto Wikipedia, that doesn't exist here. Greetings --Tlustulimu (talk) 07:54, 1 August 2013 (UTC)