Module talk:Coordinates
Fix display inline/title shortcut
This edit request has been answered. Set the |answered= 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
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