Module talk:Coordinates/Archive 1
This is an archive of past discussions about Module:Coordinates. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | Archive 2 |
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)
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)
Update the GeoHack link
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
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)
- Toolserver has been unreliable during the last several months and unless something changes is likely to be discontinued. I don't see much logic in switching back. I did update Template:Coor URL, so it is now linked to whatever is used here, but that template is almost entirely unused now (only 70 transclusions), so I can't see it being very important. Dragons flight (talk) 16:07, 28 August 2013 (UTC)
- Labs has also been unreliable too and the foundation is not known for smarts nor follow through. As principle maintainer I can tell you Labs' GeoHack continues to use Toolserver resources. Template:Coor URL exists in nearly all languages so downstream users could grab the wikitext and start parsing from the coordinates. So that's might be broken. In the future please notify me about URL changes as I have to change my software which is used by WikiMiniAtlas, Kolossos's WikipediaWorld, and more. — Dispenser 17:29, 28 August 2013 (UTC)
- Not done: Unless the Labs version of Geohack is causing serious problems we should probably stick with it. All the Toolserver tools will have to be moved over to Labs eventually, if I have understood the WMF's position on this correctly, so we will have to do it at some point or other. Unless things are really broken, that point may as well be now. — Mr. Stradivarius ♪ talk ♪ 05:52, 1 September 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)
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Fixed this bug in the sandbox: dms2dec defaults to positive hemisphere unless a "W" or "S" is explicitly passed in. This will reduce the guard code used in various infoboxes that call this code.
{{#Invoke:Coordinates|dms2dec|N|23|34|45}} produces 23.57917
{{#Invoke:Coordinates/sandbox|dms2dec|N|23|34|45}} produces 23.57917
{{#Invoke:Coordinates|dms2dec|S|23|34|45}} produces -23.57917
{{#Invoke:Coordinates/sandbox|dms2dec|S|23|34|45}} produces -23.57917
{{#Invoke:Coordinates|dms2dec||23|34|45}} produces 23.57917
{{#Invoke:Coordinates/sandbox|dms2dec||23|34|45}} produces 23.57917
Please update the main code from the sandbox — Preceding unsigned comment added by Hike395 (talk • contribs)
- I was hoping someone else would have commented here to at least confirm this change was needed. So I hope you haven't made a mistake ... Done — Martin (MSGJ · talk) 08:19, 22 October 2013 (UTC)
Nonsense value for the parameter "display" kills the text to be returned
{{edit COI}} 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)
- I've disabled the edit request as it seemed to be the wrong template, and more importantly there is some disagreement about how it should be implemented. Once there is a consensus on how to make the fix and there is some code in the sandbox that has been tested, please use the {{edit protected}} template (not the {{edit COI}} template). — Mr. Stradivarius ♪ talk ♪ 06:26, 31 October 2013 (UTC)
Language links on labs
Language links don't work on labs. Have invalid url. --84.3.90.28 (talk) 20:23, 11 November 2013 (UTC)
- Good point! I think it doesn't depend neither on this module nor on Template:GeoTemplate, but on some rewrite rule as described here: https://wiki.toolserver.org/view/GeoHack, section "Nice urls". --Rotpunkt (talk) 11:11, 12 November 2013 (UTC)
- Where should it be reported? --84.3.90.28 (talk) 22:38, 12 November 2013 (UTC)
- I have reported the problem to Dispenser (I have read he works on the GeoHack page). --Rotpunkt (talk) 10:54, 13 November 2013 (UTC)
- Where should it be reported? --84.3.90.28 (talk) 22:38, 12 November 2013 (UTC)
Script error on Module:Coordinates
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Specifying coordinate to the news infobox on 2013 Riga Maxima superstore collapse threw the following Lua error:
Lua error in Module:Coordinates at line 596: attempt to index field 'claims' (a nil value). Backtrace: Module:Coordinates:596: in function "chunk" mw.lua:553: ? [C]: in function "getExpandedArgument" mw.lua:264: ? Module:Infobox:313: in function "preprocessArgs" Module:Infobox:366: in function "chunk" mw.lua:553: ?
As this seems to be in a code looking for coordinate data from Wikidata, I was able to fix this error by manually adding the coordinate to Wikidata. Meanwhile, I think this code bug can be fixed by chaning the line 596 in Module:Coordinates from:
if entity and entity.claims.p625 then
to:
if entity and entity.claims and entity.claims.p625 then
--hydrox (talk) 08:40, 22 November 2013 (UTC)
- Done. Thanks for the fix! It looks like I was mistaken to assume that a claims table always existed. Please let me know if you find any other bugs. — Mr. Stradivarius ♪ talk ♪ 08:54, 22 November 2013 (UTC)
Just noticed these script errors today
Does anyone know why {{coord|17|30|N|68|20|W|display=title}} 17°30′N 68°20′W / 17.500°N 68.333°W (changed to inline, here) does not work on MV C.O. Stillman? The entire history of that page has the error. Was it always that way? Certain pages, part of the list at Category:Pages_with_script_errors, seem to have trouble with script errors when transcluding coord, either directly or indirectly through other templates. I noticed this while migrating pages to Template:infobox settlement. Both old and new templates generate script errors, and so does coord, but when I copy the problem code to a test page, and preview it, it works. Previewing on the original pages also shows Script error. -PC-XT+ 06:56, 22 November 2013 (UTC)
- Sorry, that was my stupid mistake, which you can see outlined in the section below. Let me know if you see any more script errors on these pages. — Mr. Stradivarius ♪ talk ♪ 09:16, 22 November 2013 (UTC)
Only add Wikidata category when displayed in title
The Wikidata categories are now added when "valid_Display" is true. This means that the category code is also called on pages like National Register of Historic Places listings in Scotland County, North Carolina where we only have inline coordinates. Can someone (@Mr. Stradivarius:?) please modify the code to have it only work when the coordinates are in the title? All the title variants are in Template:Coord by the way. Thank you, Multichill (talk) 10:28, 22 December 2013 (UTC)
- @Multichill: I think the code in Module:Coordinates/sandbox should do what you are asking for. Could you verify it with {{coord/sandbox}}? If there are no problems, I'll update the module. — Mr. Stradivarius ♪ talk ♪ 14:26, 23 December 2013 (UTC)
- Looks ok to me. You can probably collapse the code, so instead of the "displayed_in_title = true" enter the "if mw.wikibase and current_page.namespace == 0 then" there. Multichill (talk) 19:21, 23 December 2013 (UTC)
- Right you are. I've refactored it slightly and put it up live. Let me know if you spot any issues with it. — Mr. Stradivarius ♪ talk ♪ 00:12, 24 December 2013 (UTC)
- Thank you! Multichill (talk) 12:37, 26 December 2013 (UTC)
- Right you are. I've refactored it slightly and put it up live. Let me know if you spot any issues with it. — Mr. Stradivarius ♪ talk ♪ 00:12, 24 December 2013 (UTC)
- Looks ok to me. You can probably collapse the code, so instead of the "displayed_in_title = true" enter the "if mw.wikibase and current_page.namespace == 0 then" there. Multichill (talk) 19:21, 23 December 2013 (UTC)
New module
Hi, on it.wiki I have written a new Module:Coord (it:Modulo:Coord). It has a lot of improvements:
- it uses classes (DecCoord and DmsCoord) instead of a lot of simple types and a lot of functions
- it uses HtmlBuilder instead of raw html
- it has a configuration page (it:Modulo:Coord/Configurazione)
- it has a simpler logic for recognize input formats ("dec", "d", "dm", "dms"), see function "paramsParse" compared to "formatTest" in this module
- it has a strong parameter validation (based on configuration file) with detailed error messages
- it has a complete collection of unit tests (it:Modulo:Coord/test)
- it's shorter (400 lines of code instead of 600)
If you are interested in it, I can put it in a sandbox and translate in English the code comments.
Cya. --Rotpunkt (talk) 11:13, 28 October 2013 (UTC)
- Thanks. I think I think would be worth being added would be the ability to get the coordinates from another module, using named parameters for latitude and longitude. Most notably, it would make it much easier to use data from Wikidata in infoboxes. --Superzoulou (talk) 11:32, 28 October 2013 (UTC)
- @Superzoulou, for wikidata do you mean for example a feature like this: when the template (and so the module) is called without positional arguments, e.g. {{Coord}} or {{Coord|display=title}}, then the module looks up on wikidata for property P625 ("coordinate location"). Is this what you meant? --Rotpunkt (talk) 11:54, 28 October 2013 (UTC)
- That is one possiblity (and that is what we currently have in fr.wikipedia). But actually, it seems better to let the calling module retrieve the data from Wikidata separately. This way, Module:Coordinates do not need to bother about Wikidata. More importantly, it gives more flexibility when the Wikidata query is a bit unusual. For instance, in some cases, we do not want to retrieve the first value of p625, but the one that uses a particular qualifier. So, we should be able to do things like:
- @Superzoulou, for wikidata do you mean for example a feature like this: when the template (and so the module) is called without positional arguments, e.g. {{Coord}} or {{Coord|display=title}}, then the module looks up on wikidata for property P625 ("coordinate location"). Is this what you meant? --Rotpunkt (talk) 11:54, 28 October 2013 (UTC)
Module:Simple Infobox
if args.latitude then
latitude = args.latitude
else --use Wikidata by default
latitude = entity.p625[0].datavalue.value.latitude --this is the simplest case, but in some cases, the Wikidata query have to be customized
end
...
coord_output = require['module:Wikidata'].coord({latitude = latitude, longitude = longitude})
end
--Superzoulou (talk) 13:15, 28 October 2013 (UTC)
- Actually it already works, also with en.wiki module, with:
coord_output = require('Module:Coordinates').coord( { args = { latitude, longitude } } )
- However it's easy to add another entry-point (coordLink) so you can write:
coord_output = require('Module:Coordinates').coordLink(latitude, longitude)
- --Rotpunkt (talk) 13:49, 28 October 2013 (UTC)
- Oh, ok sorry, I thought that longitude was at least parameter 3. Actually, an advantage of coordinates from Wikidata is that they are all provided in decimal format, so it does not really need to go thourgh function paramsParse. Assuming that most coordinates come from Wikidata (which will probably be the case in most projects in the future), do you have any idea if there could be a significant efficiency gain in skipping paramsParse ? Possibly something something like:
- --Rotpunkt (talk) 13:49, 28 October 2013 (UTC)
if args.latitude = then
latitude = makedecimal(args.latitude) -- for the unusual case when the coordinates are provided locally, convert first into decimal
else
latitude = entity.p625[0].datavalue.value.latitude -- for the most common case, retrieve Wikidata coordinates that are already in dec
end
coord_ouptut = require('Module:Coordinates').coordfromDec(latitude, longitude) -- same as function coord, except that it does not need to go through paramsParse
- Superzoulou (talk) 14:54, 28 October 2013 (UTC)
- paramsParse() checks lat and long are number and also their limits (-90/+90 for lat -180/+180 for long). Calling that function or rewrite a new one makes no difference, there are just a couple of if and comparisons (ms or less?). If you have concerns about some "if" and comparisons remember also that all pages on wikipedia are cached, and a module (or a template) is executed only when page/module/template are modified, otherwise wikipedia returns a cached version of the page. --Rotpunkt (talk) 15:42, 28 October 2013 (UTC)
- Ok. Yhere are also other parameters that need to be taken into account (globe, scale etc.) For them too, I think it could be convenient to be allowed to use named parameters (they are currently all jumbled together in a pretty ugly way, like: "dim:30_region:US-WI_type:event"). By the way, does your template support these parameters. I do not see any test with another globe than the Earth ? --Superzoulou (talk) 07:50, 31 October 2013 (UTC)
- Thanks, I can add named parameters for these geohack params. However if the same param is used both as a positional and as a named param which one should have the priority? Example {{coord|10|20|dim:30_region:US-WI|dim=40}}, dim is 30 or 40 (or it's an error)? --Rotpunkt (talk) 14:12, 31 October 2013 (UTC)
- I would say give priority to named parameters or maybe throw an error. Named parameters seem clearer to me, and less likely to be the result of some copy-paste error. --Superzoulou (talk) 06:37, 1 November 2013 (UTC)
- Hi Superzoulou. Priority to named parameters is ok for me too. I'd just like to respond to one of your previous question (does your template support these parameters?) Yes, it support them all like this module Coordinates. However there is no parsing or check on them, as for Coordinates. Coordinates does only 1 check at lines 296-301:
- I would say give priority to named parameters or maybe throw an error. Named parameters seem clearer to me, and less likely to be the result of some copy-paste error. --Superzoulou (talk) 06:37, 1 November 2013 (UTC)
- Thanks, I can add named parameters for these geohack params. However if the same param is used both as a positional and as a named param which one should have the priority? Example {{coord|10|20|dim:30_region:US-WI|dim=40}}, dim is 30 or 40 (or it's an error)? --Rotpunkt (talk) 14:12, 31 October 2013 (UTC)
- Ok. Yhere are also other parameters that need to be taken into account (globe, scale etc.) For them too, I think it could be convenient to be allowed to use named parameters (they are currently all jumbled together in a pretty ugly way, like: "dim:30_region:US-WI_type:event"). By the way, does your template support these parameters. I do not see any test with another globe than the Earth ? --Superzoulou (talk) 07:50, 31 October 2013 (UTC)
- paramsParse() checks lat and long are number and also their limits (-90/+90 for lat -180/+180 for long). Calling that function or rewrite a new one makes no difference, there are just a couple of if and comparisons (ms or less?). If you have concerns about some "if" and comparisons remember also that all pages on wikipedia are cached, and a module (or a template) is executed only when page/module/template are modified, otherwise wikipedia returns a cached version of the page. --Rotpunkt (talk) 15:42, 28 October 2013 (UTC)
- Superzoulou (talk) 14:54, 28 October 2013 (UTC)
local extra_param = {'dim', 'globe', 'scale', 'region', 'source', 'type'}
for _, v in ipairs( extra_param ) do
if (args[v] or '') ~= '' then
table.insert( errors, {'formatTest', 'Parameter: "' .. v .. '=" should be "' .. v .. ':"' } );
end
end
- This check gives an error if you write "dim=value", "globe=value", ... to remind you that there are no parameters with this name. Well, until we add them :) --Rotpunkt (talk) 09:09, 6 November 2013 (UTC)
- Sorry for late reply. That sounds good to me, does the current version of it:Modulo:Coord incorporate all the proposed changes ? I would gladly try it on French Wikipedia. --Superzoulou (talk) 08:35, 19 November 2013 (UTC)
- Hi, not yet. On itwiki at the moment we are discussing about the possibility of leaving some fields empty ({{coord|1|2|N|3||E}}), 0-padding (1°2′N 4°5′E or 1°02′N 4°05′E ?) and how to show precision for both lat and lon (1°00′N 3°45′E or 1°N 3°45′E ?). I hope we will solve these issues soon and I will return on these new params. --Rotpunkt (talk) 12:07, 19 November 2013 (UTC)
- FYI the fr.wikipedia has a new module that includes:
- better error detection
- functions designed be callable from other modules (it is a bit unwieldy in the English module because of frame.args and globalFrame)
- reorganized and hopefully more readable code + module documentation (the html rendering is based on it.wikipedia)
- better internationalization support
- customizable Wikidata support (most notably: allows to query coordinates with a specific qualifier in Wikidata). Requires fr:Module:Wikidata.
- a function computing distance between two points on any globe supported by geohack (used for comparison with Wikidata coordinates)
- Apart from the Wikidata part, I think everything is reusable in Wikipedias that have imported en:Module:Math.--Superzoulou (talk) 08:26, 10 March 2014 (UTC)
- FYI the fr.wikipedia has a new module that includes:
- Hi, not yet. On itwiki at the moment we are discussing about the possibility of leaving some fields empty ({{coord|1|2|N|3||E}}), 0-padding (1°2′N 4°5′E or 1°02′N 4°05′E ?) and how to show precision for both lat and lon (1°00′N 3°45′E or 1°N 3°45′E ?). I hope we will solve these issues soon and I will return on these new params. --Rotpunkt (talk) 12:07, 19 November 2013 (UTC)
- Sorry for late reply. That sounds good to me, does the current version of it:Modulo:Coord incorporate all the proposed changes ? I would gladly try it on French Wikipedia. --Superzoulou (talk) 08:35, 19 November 2013 (UTC)
- This check gives an error if you write "dim=value", "globe=value", ... to remind you that there are no parameters with this name. Well, until we add them :) --Rotpunkt (talk) 09:09, 6 November 2013 (UTC)
Protected edit request on 26 June 2014
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please make these changes so that this module doesn't unnecessarily use global variables. Jackmcbarn (talk) 00:50, 26 June 2014 (UTC)
- Done Thanks for the update. :) — Mr. Stradivarius ♪ talk ♪ 04:15, 26 June 2014 (UTC)
Protected edit request on 12 July 2014
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please make these changes. The nature of the pattern being used means that it gets no benefit from being used with ustring (which is significantly slower than string), and the square braces were redundant since they contained only one character. Jackmcbarn (talk) 00:49, 12 July 2014 (UTC)
Protected edit request on 16 July 2014
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please replace the contents of the module with the version at Special:Permalink/617225902. Jackmcbarn (talk) 20:38, 16 July 2014 (UTC)
- @Jackmcbarn: Three of the test cases are failing - did you forget to update them? — Mr. Stradivarius ♪ talk ♪ 23:24, 16 July 2014 (UTC)
- Hmm, looking at the actual test case code, I see the test cases are of the old-school, will-break-straight-away variety. Do you think it's worth converting them to something more robust? — Mr. Stradivarius ♪ talk ♪ 23:27, 16 July 2014 (UTC)
- @Mr. Stradivarius: Perhaps, but I don't think it needs to hold up this change. (And until I fixed a bug in the testcase code today, 17 were failing). Jackmcbarn (talk) 23:53, 16 July 2014 (UTC)
- Done Fair enough - done. — Mr. Stradivarius ♪ talk ♪ 00:47, 17 July 2014 (UTC)
Protected edit request on 12 August 2014
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please make these changes to prevent treating a blank degree value as zero. Jackmcbarn (talk) 01:35, 12 August 2014 (UTC)
- Not done: The page's protection level and/or your user rights have changed since this request was placed. You should now be able to edit the page yourself. If you still seem to be unable to, please reopen the request with further details. — Mr. Stradivarius ♪ talk ♪ 02:40, 12 August 2014 (UTC)
- Also, here's a courtesy ping. — Mr. Stradivarius ♪ talk ♪ 02:44, 12 August 2014 (UTC)
This template doesn't support wikidata!
Now it:Modulo:Wikidata supports getting coordination from wikidata correctly. if it is possible please update this module to get coordinations from wikidata Yamaha5 (talk) 19:26, 5 August 2014 (UTC)
- Not done for now: @Yamaha5: Could you add the relevant code to Module:Coordinates/sandbox first? Edit requests are only for when code is written, tested, and already has consensus, so this request is premature. Also, your ping won't have worked, as you didn't include a signature in the same edit as the link, so here's one that will work: User:Jackmcbarn. — Mr. Stradivarius ♪ talk ♪ 19:43, 5 August 2014 (UTC)
- @Rotpunkt: Since you made the changes there, would you be interested in porting them here? Jackmcbarn (talk) 02:22, 6 August 2014 (UTC)
- @Jackmbarn Hi, in itwiki I have written module coord from scratch because enwiki one was based too much on the overcomplicated old template, so I am not confortable to edit it. However the logic is really simple, when the template is called without coordinates, I push Wikidata coords in args table, see function checkWikidata in it:Module:Coord. --Rotpunkt (talk) 05:57, 31 August 2014 (UTC)
- @Rotpunkt: In doing so, on it.WP, you have broken the emitted microformat; your HTML (in it:Birmingham's infobox) is
<span class="latitude">52°28′59″N</span> <span class="longitude">1°53′37″W</span>
. That sits outside theclass="vcard"
span (which in any case should not be used in infoboxes). I suggest you roll back your changes, if you cannot fix them. Either way, please don't do that here. If you need clarification, or other help, drop me a line on my talk page on this wiki, as it.WP is off-topic on this page. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 10:16, 31 August 2014 (UTC)- @Pigsonthewing: You mean there is a bug? I have written the generated HTML in this sandbox in a more readable way. Could you explain in my talk page, which is the problem in your opinion? Thanks in advance. --Rotpunkt (talk) 11:40, 31 August 2014 (UTC)
- @Rotpunkt: In doing so, on it.WP, you have broken the emitted microformat; your HTML (in it:Birmingham's infobox) is
- @Jackmbarn Hi, in itwiki I have written module coord from scratch because enwiki one was based too much on the overcomplicated old template, so I am not confortable to edit it. However the logic is really simple, when the template is called without coordinates, I push Wikidata coords in args table, see function checkWikidata in it:Module:Coord. --Rotpunkt (talk) 05:57, 31 August 2014 (UTC)
I strongly support the idea of Yamaha5 to support Wikidata. Importing coordinates from Wikidata can be done with this syntax ({{#property:P625}}
) but its output is not formatted right to be accepted by this module. I'm asking if the functionality can be added so that we can import coordinates directly from Wikidata, using the {{Coord}} template maybe in this format: {{Coord|{{#property:P625}}|display=...}}
. Is someone willing/able to write the test code? Thanks. -- P 1 9 9 ✉ 16:46, 11 August 2014 (UTC)
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
- Done the requested change above in the sandbox, in these edits. I have allready checked the testcases and they all work. The coordinates from wikidata will only display if there is no template arguments (that is no arguments from articles) and no config arguments (no arguments from templates). This is in accordance with Wikipedia:Requests for comment/Wikidata Phase 2.--Snaevar (talk) 18:18, 9 September 2014 (UTC)
Hold on I'm not against these changes per se (indeed, I welcome them), but what about:
- Setting the
|type=
parameter automatically (based on "instance of...") - Setting the
|region=
parameter automatically (ditto) - Allowing one or both of those parameters to be set locally, but still importing the actual lat/ long values
- Allowing
|display=
to be set locally, but still importing the actual lat/ long values
Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 19:35, 9 September 2014 (UTC)
- I would like to clarify that the change only checks numbered arguments. Setting configuration arguments such as "type", "region" and "display" does not change anything. Having an template inclusion with no numbered arguments but with those configuration arguments specified will still show an coordinate from wikidata. So, with that said, I have reactivated the request.--Snaevar (talk) 20:58, 9 September 2014 (UTC)
- Done — Martin (MSGJ · talk) 10:57, 10 September 2014 (UTC)
Thanks all! Can someone update Template:Coord/doc to describe its features and use? -- P 1 9 9 ✉ 20:01, 15 September 2014 (UTC)
Bug
Per Snaevar's comments, above:
- {{coord|type:landmark_region:GB-WSM|format=dms|display=inline,title}}
should work, but - as can be seen at Old revision of Statue of Captain James Cook, The Mall - it causes an error. Have I misunderstood Snaevar's explanation, or do we need a bugfix/ rollback? In either case, the recent updates to the documentation does not explain such use adequately. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 12:50, 21 September 2014 (UTC)
- I am completely flummoxed as to what to specify. I tried {{coord}} with no numbers, and it didn't work. Then I tried {{#invoke:coordinates|coord}} which works, kind of. First of all, it coverts dms coords to absurdly long decimals; secondly I don't know how to specify format=dms and display=inline,title within the invocation, as the documentation is a lot less than deficient. In fact deficient would be good! Thirdly, it works only inline in the article, but not inside the infobox as the coordinates parameter. How do I specify it correctly? [As an aside, it is seemingly impossible to specify on wikidata anything less than overly precise coordinates - when I blanked arcseconds, it displayed latitude as ... 60"N and longitude as ...0"E neither of which I actually want.] 112.198.77.164 (talk) 05:59, 17 October 2014 (UTC)
- Andy Mabbett, I just tried previewing {{#invoke:coordinates/sandbox|coord|3=type:landmark_region:GB-WSM|format=dms|display=inline,title}} on that article, and it works for me. If you find a problem with the sandbox, please post in the edit request, below. Thanks. —PC-XT+ 09:03, 21 October 2014 (UTC)
Change from mw.wikibase.getEntity (deprecated) to mw.wikibase.getEntityObject
Due to the fact, that mw.wikibase.getEntity is deprecated and it would be great to change it into a wrapper around mw.wikibase.getEntityObject at one point, we first need to bring all Lua modules up to date and change them to mw.wikibase.getEntityObject. More details [1].
Shouldn't be too hard in this case since it's used only once.
Any arguments against changing it? --Lucie Kaffee (WMDE) (talk) 09:55, 25 February 2015 (UTC)
Using the wikidata import feature in infobox settlement
please comment at Template talk:Infobox settlement#Enabling wikidata. Frietjes (talk) 15:09, 28 February 2015 (UTC)
Template-protected edit request on 3 March 2015
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
local entity = mw.wikibase.getEntity() if entity and entity.claims and entity.claims.p625 then local snaktype = entity.claims.p625[0].mainsnak.snaktype
at line 626-628 should be:
local entity = mw.wikibase.getEntityObject() if entity and entity.claims and entity.claims.P625 then local snaktype = entity.claims.P625[1].mainsnak.snaktype
GZWDer (talk) 05:14, 3 March 2015 (UTC)
- Done, diff - Hoo man (talk) 14:25, 3 March 2015 (UTC)
Suggestion
I have noticed in some Wikipedias, that the input for coords in infoboxes are much simplier, see for example ru:Шаблон:Лес#Координаты. Maybe someone would like to add it also here? It shouldn't be too hard to split the string to correct parameters in module, right? Pinging @Mr. Stradivarius as the main editor(?) of this module and @Jackmcbarn, because (as I suppose) Module:Location map would be also involved. P.S. Someone should take a look at this. --Edgars2007 (talk/contribs) 00:39, 2 March 2015 (UTC)
- The problem is that we already have hundreds of thousands of articles that use the existing formats, so adding more formats would be increasing complexity unless we wanted to get serious about changing all of the existing transclusions. Also, I'm not the main editor of the module - I just added the Wikidata stuff onto the end after an edit request. The main author is Dragons flight, who wrote it back in March 2013. — Mr. Stradivarius ♪ talk ♪ 05:50, 5 March 2015 (UTC)
Flummoxed
I am completely flummoxed as to what to specify. I tried {{coord}} with no numbers, and it didn't work. Then I tried {{#invoke:coordinates|coord}} which works, kind of:
- It coverts dms coords to absurdly long decimals;
- I don't know how to specify format=dms and display=inline,title within the invocation, as the documentation is a lot less than deficient. In fact deficient would be good!
- It works only inline in the article, but not inside the infobox as the coordinates parameter. How do I specify it correctly? (I note that there is a hidden category for pages which have a {{coord}} inside the infobox.)
[As an aside, it is seemingly impossible to specify on wikidata anything less than overly precise coordinates - when I blanked arcseconds, it displayed latitude as ... 60"N and longitude as ...0"E neither of which I actually want.]
112.198.77.33 (talk) 01:50, 18 October 2014 (UTC)
- As far as I can tell, the actual use of wikidata is flawless. The problem is that this module is not designed to have the first parameter omitted, but rather to report an error in such cases. Because the module wasn't designed for this, all parameters may be lost when the first is omitted, including format and display. (Only the "parent frame" parameters are kept, whatever they are.)
- dec is the default format, and is actually how wikidata presents coordinates. The module actually converts it to dms for metadata purposes, but doesn't get the message to also display it that way.
- There isn't a way, unless, as I said, you put the information in parent frame parameters. (I'm honestly not sure what that means, here.)
- Infobox settlement and others which use {{Geobox coor}} purposely display only if given the first parameter. I or someone else will put that change in a separate edit request once this template is working. (Actually, I just looked again, and it should work if the 3rd parameter is provided, which I believe infoboxes at least attempt to do, so changes may not actually be necessary. Wait... it sets a default of 0... so, changes will likely still be necessary.) —PC-XT+ 08:42, 21 October 2014 (UTC)
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
- I just made edits to the sandbox to make it handle omission of the first parameter, and it seems to work, but others should check it. To try the sandbox version, preview "{{#invoke:coordinates/sandbox|coord|format=dms}}" etc. in articles with wikidata coordinates. (The testcases seem ok to me, but they did before, as well.) —PC-XT+ 08:37, 21 October 2014 (UTC)
- Pinging a couple module editors from above to ask if they can check what I did with the frames, since I don't understand what the parent frame is: User:Mr. Stradivarius, Jackmcbarn, thanks! —PC-XT+ 09:11, 21 October 2014 (UTC)
- @PC-XT: If you call Module:Coordinates like
{{#invoke:Coordinates|coord|foo|bar=baz}}
then frame.args will look like{'foo', bar = 'baz'}
. However, if you call it using{{coord|foo|bar=baz}}
then frame.args will be empty, and frame:getParent().args will look like{'foo', bar = 'baz'}
. It's not a good idea to load all of the frame args and all of the parent frame args, because a) it is one of the most performance-intensive steps in the module, and b) if the module is called using #invoke, then it might get junk arguments passed to it accidentally. I think it would be a good idea to switch the module to use Module:Arguments, as it sorts a lot of this stuff out automagically. — Mr. Stradivarius ♪ talk ♪ 12:34, 21 October 2014 (UTC)- Thanks, I was afraid of something like that, but Module:Arguments makes it much easier. Since this function is tied to {{#coordinates:}}, I expect a second function for use by other modules would be unused? I also edited {{Coord/sandbox}} to use the sandbox module and avoid using #coordinates when the first parameter is blank. (Maybe GeoHack can be updated in a different way, possibly from wikidata?) So, we can test that template instead of directly from the module, since frames are the issue. —PC-XT+ 20:20, 21 October 2014 (UTC)
- I'm not so sure it would be unused if everything could be done through the module, but I remember that #coordinates didn't work at all well with Scribunto, which is why the current hack is in place. There's a bug open about that somewhere - the best thing would be to fix the bug somehow and move everything inside the module, but we shouldn't worry about that right now. It wouldn't hurt to define an interface for other modules to access this module from, though, so that it is easier to write the required code whenever that bug is fixed. — Mr. Stradivarius ♪ talk ♪ 02:45, 25 October 2014 (UTC)
- I'll split the function, then, just in case. —PC-XT+ 20:01, 25 October 2014 (UTC)
- I'm not so sure it would be unused if everything could be done through the module, but I remember that #coordinates didn't work at all well with Scribunto, which is why the current hack is in place. There's a bug open about that somewhere - the best thing would be to fix the bug somehow and move everything inside the module, but we shouldn't worry about that right now. It wouldn't hurt to define an interface for other modules to access this module from, though, so that it is easier to write the required code whenever that bug is fixed. — Mr. Stradivarius ♪ talk ♪ 02:45, 25 October 2014 (UTC)
- Thanks, I was afraid of something like that, but Module:Arguments makes it much easier. Since this function is tied to {{#coordinates:}}, I expect a second function for use by other modules would be unused? I also edited {{Coord/sandbox}} to use the sandbox module and avoid using #coordinates when the first parameter is blank. (Maybe GeoHack can be updated in a different way, possibly from wikidata?) So, we can test that template instead of directly from the module, since frames are the issue. —PC-XT+ 20:20, 21 October 2014 (UTC)
- @PC-XT: If you call Module:Coordinates like
- Pinging a couple module editors from above to ask if they can check what I did with the frames, since I don't understand what the parent frame is: User:Mr. Stradivarius, Jackmcbarn, thanks! —PC-XT+ 09:11, 21 October 2014 (UTC)
Ok, I converted the numeric data to strings to avoid errors with negative values, and the current sandboxes seem to be working, now. —PC-XT+ 22:16, 21 October 2014 (UTC)
- I would like to look into something that would work for maps, too, but that may require getting the coordinates, then feeding them through the template, unless the map called the coordinate module... anyway, this seems to work for coords themselves... —PC-XT+ 04:03, 23 October 2014 (UTC)
- I've had a look at the sandbox, and the whole module is doing a lot of things that don't make sense if we're removing blank arguments with Module:Arguments. For example, there are a lot of tests for things like
args[3] ~= ''
that should just be changed tonot args[3]
. I've made a start on fixing these, but there's a lot to do, so I've deactivated the edit request for now. We can reactivate the request (or I can just update the module) when the code is ready. — Mr. Stradivarius ♪ talk ♪ 02:45, 25 October 2014 (UTC)- Yes, it sets args it understands to "" if they are omitted (or removed.) I thought about changing this, myself, but the other functions relied on this so heavily that I didn't think I should attempt a change on my own, since I am already in new territory. —PC-XT+ 20:01, 25 October 2014 (UTC)
- Mr. Stradivarius, I think the module is functioning as well as it was before these changes. It passes both the testcases and the article preview tests I used before. —PC-XT+ 02:32, 26 October 2014 (UTC)
- Yes, it sets args it understands to "" if they are omitted (or removed.) I thought about changing this, myself, but the other functions relied on this so heavily that I didn't think I should attempt a change on my own, since I am already in new territory. —PC-XT+ 20:01, 25 October 2014 (UTC)
- I've had a look at the sandbox, and the whole module is doing a lot of things that don't make sense if we're removing blank arguments with Module:Arguments. For example, there are a lot of tests for things like
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Changes are in the sandbox. This request comes from Template talk:Infobox settlement#Enabling wikidata, but the majority of changes happened during this older discussion. I suppose I could have changed the earlier edit request back to |answered=no
, but it has been a while, so I started a new one. —PC-XT+ 19:19, 4 March 2015 (UTC)
Pinging User:Mr. Stradivarius, in case he has further comments —PC-XT+ 21:49, 4 March 2015 (UTC)
- no objections, so done? Frietjes (talk) 14:26, 12 March 2015 (UTC)
line 498: attempt to index field '?' (a nil value).
What's up, pages were showing line 498: attempt to index field '?' (a nil value).. Was this is transient bug? —Sladen (talk) 15:02, 12 March 2015 (UTC)
- Sladen, should be fixed now. let me know if you still see this error. Frietjes (talk) 15:07, 12 March 2015 (UTC)
Enabling wikidata
as mentioned in the prior thread, this module is able to work with no args and grabs the coordinates from wikidata. however, {{coord}} doesn't quite work with no args, so I created template:coord/wikidata. I am hoping to delete this later if we can find a workable solution for merging this with {{coord}}. also, it would be good to have a method for specifying the precision of the coordinates. Frietjes (talk) 15:09, 12 March 2015 (UTC)
- @Mr. Stradivarius and PC-XT: let me know if you have any suggestions, comments, etc. Frietjes (talk) 15:10, 12 March 2015 (UTC)
- If automatic precision adjustment would only be needed when pulling from wikidata, something like this might work, though the parameter could possibly be named
|wikidata_precision=
or something, instead of just|precision=
. I expect parameters could simply be trimmed manually, otherwise? —PC-XT+ 23:43, 13 March 2015 (UTC) It seems the module was originally designed with precision handling in mind, so another solution may very well be more appropriate: Template talk:Coord/Archive 10#Lua replacement —PC-XT+ 01:49, 14 March 2015 (UTC)
- If automatic precision adjustment would only be needed when pulling from wikidata, something like this might work, though the parameter could possibly be named
This edit request to Module:Coordinates has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Near the end of the code, please replace:
if not args[1] and not args[2] and mw.wikibase.getEntityObject() then local entity = mw.wikibase.getEntityObject() if entity and entity.claims and entity.claims.P625 and entity.claims.P625[1].mainsnak.snaktype == 'value' then args[1]=entity.claims.P625[1].mainsnak.datavalue.value.latitude args[2]=entity.claims.P625[1].mainsnak.datavalue.value.longitude end end
with
if not args[1] and not args[2] and mw.wikibase.getEntityObject() then local entity = mw.wikibase.getEntityObject() if entity and entity.claims and entity.claims.P625 and entity.claims.P625[1].mainsnak.snaktype == 'value' then local precision= entity.claims.P625[1].mainsnak.datavalue.value.precision args[1] = entity.claims.P625[1].mainsnak.datavalue.value.latitude args[2] = entity.claims.P625[1].mainsnak.datavalue.value.longitude if precision then precision=-math_mod._round(math.log(precision)/math.log(10),0) args[1] = math_mod._round(args[1],precision) args[2] = math_mod._round(args[2],precision) end end end
This edit can also be seen as part of this sandbox diff. This comes from further discussion at Template talk:Infobox settlement#Enabling wikidata. It rounds degree decimal places to the precision pulled from wikidata. —PC-XT+ 04:46, 16 March 2015 (UTC)
- done, thank you! note that I did not change the stuff in displaytitle since we still have this issue from the last time? Frietjes (talk) 14:58, 18 March 2015 (UTC)
#coordinates parser function
I am looking into adding the #coordinates parser function to the module, and am trying to find the exact reason why the #coordinates parser function was left out, before. I found phab:T65597, which I tested in module:sandbox/PC-XT/Coordinates. It seems to be resolved. I also found a mention at Template talk:Coord/Archive 11#Wikidata tracking, but it is not very specific. Are there any issues that are still a problem? If so, I'd like to collect them in sandbox examples for future testing. Thanks. —PC-XT+ 02:56, 14 March 2015 (UTC)
- from my conversation with the author of #coordinates, the test is if the coordinates show up in 'https://en.wikipedia.org/w/api.php?action=query&prop=coordinates&coprimary=all&titles=PAGNAMEHERE'. it would be great if we could merge it with the module since that is currently the only thing that is keeping me from calling _coord in module:geobox coor (currently, I am calling template:coord instead, which is less efficient). also, as far as I can tell, that's the only thing that's keeping template:coord from working without args on pages with coordinates in wikidata. Frietjes (talk) 15:19, 18 March 2015 (UTC)
translation
I want to translate some errors messages, but i don't locate this one "cannot have more than one primary tag per page". And by the way, I want to know how can this module detect a previous call ? --وهراني (talk) 10:24, 4 April 2015 (UTC)
- It's not part of the module. It's used by the {{#coordinates:}} tag and the message is at MediaWiki:Geodata-multiple-primary. -- WOSlinker (talk) 14:42, 4 April 2015 (UTC)
Check Wikidata
Maybe module should include checking, if coordinates here and at Wikidata are the same (and add some tracking category)? Of course, there could be some cases, when it's ok to have different coords, but in most cases they should be the same. --Edgars2007 (talk/contribs) 06:42, 26 April 2015 (UTC)
- I would agree with this comment. --Izno (talk) 15:40, 28 May 2015 (UTC)
Always display dms
Hi, I am translating this module into another language, but there is one thing I would like to change. That would be to always show dms, even if the input is dec. Would that be possible, without rewriting the entire module? If so, could someone please tell me what should be changed? 95.34.40.173 (talk) 21:08, 19 June 2015 (UTC)
Module error at line 626
Hi, we have issue with this Module for Kyrgyz Wikipedia
Our Infobox Settlement Tempalte returns next error:
Lua error in Module:Coordinates at line 626: attempt to call field 'getEntityObejct' (a nil value).
How to fix it? Please, help --Chorobek (talk) 03:55, 18 December 2015 (UTC)
- Correcting "Obejct" to "Object" fixes the Lua error. It does introduce a non-script error Coordinates: Parameter: "scale=" should be "scale:", apparently due to some wrong parameters in the ОЖ infobox template. SiBr4 (talk) 12:04, 18 December 2015 (UTC)
All Coordinates on Welsh Language Wikipedia have stopped working
Can someone take a look at w:cy:Copaon_yr_Alban_Adran_3-4 and ALL coordinates. I'm not sure when they stopped working; it may have been when I imported this module. Many thanks. Llywelyn2000 (talk) 13:50, 3 December 2013 (UTC)
- If you click on the script error it gives you an error message which might give you a clue about what went wrong. In this case the error is "module `Module:Math' not found", so it looks like you also need to import Module:Math. Try that and see if it fixes your problem. — Mr. Stradivarius ♪ talk ♪ 13:54, 3 December 2013 (UTC)
- Music to my ears! Many thanks for the tip. How do I now change the word 'Coordinates' (which are down twice: w:cy:Llyn Cefni) to 'Cyfesurynnau'? We're getting there! Llywelyn2000 (talk) 14:44, 3 December 2013 (UTC)
- One of those looks to be the link on line 28 of the module; not sure about the other one just yet. There are also a load of categories which are specific to the English Wikipedia (some of which are my fault). It looks like someone needs to go through this module and internationalise it properly, so that all you have to do is update a config file. That might take a while, though (unless Dragons flight wants to have a go at it...?). Anyway, try changing the link on line 28 and see what that does. — Mr. Stradivarius ♪ talk ♪ 15:02, 3 December 2013 (UTC)
- Music to my ears! Many thanks for the tip. How do I now change the word 'Coordinates' (which are down twice: w:cy:Llyn Cefni) to 'Cyfesurynnau'? We're getting there! Llywelyn2000 (talk) 14:44, 3 December 2013 (UTC)
@Mr. Stradivarius, Redrose64, and Dragons flight: The problem returned yesterday cy:Afon Gwy. The problem is in the mouth of the river... somewhere! Thanks! It's also back in many others, in a different form - see here. Llywelyn2000 (talk) 02:36, 19 May 2016 (UTC)
- The problem persists; and does not look good. If this can't be corrected then the only other option is to delete the infobox. Llywelyn2000 (talk) 08:35, 25 May 2016 (UTC)
Call of {{#coordinates:}}
Hello all, a module comments says: "In order to load coordinates into the database, the {{#coordinates:}} parser function must also be called, this is done automatically in the Lua version of {{coord}}." Where exactly is this mentioned Lua version of {{coord}} located? --Aschroet (talk) 11:12, 24 August 2015 (UTC)
- This is that module. That comment seems worded a little strangely. --Izno (talk) 11:15, 24 August 2015 (UTC)
- Thanks Izno, but i must ask one more detail. Which line of code is calling the parser function and passes the arguments? --Aschroet (talk) 11:21, 24 August 2015 (UTC)
- That part is also misleading--each parser function has a corresponding Lua implementation which is in this case more abstract than "coordinates" in specific (and yet more specific at a point). The main function at the end of the page
coordinates._coord(args)
and the following 10 or so lines make the call to Wikidata. Then the module as a whole processes that as called by the particular page or template of interest. --Izno (talk) 11:30, 24 August 2015 (UTC)- I do not get it. You are explaining how the main function calls Wikidata, but the {{#coordinates:}} parser function is called by the template, not the module. Moroever, calling Wikidata when the firsts two parameters are empty raises an error: "Invalid arguments have been passed to the {{#coordinates:}} function", so it is not currently a working option. --Vriullop (talk) 08:28, 26 August 2015 (UTC)
- Vriullop, you might try asking User:MaxSem. Frietjes (talk) 13:33, 12 September 2015 (UTC)
- #coordinates is not called in a module, it is called in Template:Coord. There is documentation on how #coordinates works at mw:extension:GeoData#Parser function. #coordinates is not related to wikidata, but it is used for things like Special:Nearby.--Snaevar (talk) 20:32, 21 September 2015 (UTC)
- Yep, if you want to pull coordinates in Lua, you also need to call {{#coordinates}} from Lua. Max Semenik (talk) 16:55, 2 December 2015 (UTC)
- I do not get it. You are explaining how the main function calls Wikidata, but the {{#coordinates:}} parser function is called by the template, not the module. Moroever, calling Wikidata when the firsts two parameters are empty raises an error: "Invalid arguments have been passed to the {{#coordinates:}} function", so it is not currently a working option. --Vriullop (talk) 08:28, 26 August 2015 (UTC)
- That part is also misleading--each parser function has a corresponding Lua implementation which is in this case more abstract than "coordinates" in specific (and yet more specific at a point). The main function at the end of the page
- Thanks Izno, but i must ask one more detail. Which line of code is calling the parser function and passes the arguments? --Aschroet (talk) 11:21, 24 August 2015 (UTC)
coords doesn't work from Wikidata
From the thread above, I'd expect that Template:coord would now work without longitude and latitude if those values are available in Wikidata. When I try:
- {{coord|display=title}}
on 2015 Colorado Springs shooting, I get the co-ordinates displayed, but also:
- Invalid arguments have been passed to the {{#coordinates:}} function
How do I get past this? Cheers, Bovlb (talk) 15:06, 29 November 2015 (UTC)
- Bovlb, see the thread directly above. or, try asking User:MaxSem. Frietjes (talk) 17:51, 1 December 2015 (UTC)
- Thanks. I don't see how the thread above helps me. I pinged User:MaxSem but I didn't get a substantive response. It still doesn't work. Is there anyone else who can help? Bovlb (talk) 19:31, 10 December 2015 (UTC)
- I guess not. I raised the same question at Template_talk:Coord#Using_coord_to_inherit_co-ordinates_from_wikidata in hopes of getting an answer. Bovlb (talk) 03:20, 29 December 2015 (UTC)
- Thanks. I don't see how the thread above helps me. I pinged User:MaxSem but I didn't get a substantive response. It still doesn't work. Is there anyone else who can help? Bovlb (talk) 19:31, 10 December 2015 (UTC)
We don't have consensus to use values returned from Wikidata outside of infoboxes. But if you want to get coordinates from Wikidata into an infobox, I've got a working Lua function that fetches coordinates from Wikidata and passes the values through {{Coord}} at Module:WikidataIB, and an example of how you might code it in an infobox at Template:Sandbox/Infobox biosphere reserve. --RexxS (talk) 21:39, 1 June 2016 (UTC)
Template-protected edit request on 30 August 2016
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Could the module sandbox be merged into the main module? This change adds two functions for injecting and extracting values of a {{Coord}} transclusion for use in infobox templates only. See Help:Coordinates in infoboxes for more information on why this is necessary. Thanks, Jc86035 (talk • contribs) Use {{re|Jc86035}} to reply to me 09:43, 30 August 2016 (UTC)
- Has this been discussed anywhere? Have the changes been extensively tested? Regards — Martin (MSGJ · talk) 09:15, 31 August 2016 (UTC)
- @MSGJ: A while ago there was an RfC which concluded with the result that all coordinates-related parameters in infoboxes should be replaced by
|coordinates=
. Injecting parameters is useful for some infoboxes that currently add them by default (such astype:railwaystation
for {{Infobox station}}) and extracting parameters would be useful for templates (including other parts of the infobox) which use the infobox's coordinate values. I've tried testing it in preview mode so that it doesn't generate any errors, but it's still unlikely given that the functions are only supposed to be used in infoboxes. Jc86035 (talk • contribs) Use {{re|Jc86035}} to reply to me 09:25, 31 August 2016 (UTC) - (edit conflict) @MSGJ: The requestor has stated that this request is backed by this RfC.—Godsy(TALKCONT) 09:28, 31 August 2016 (UTC)
- Thanks for clarifying. I have made the change — Martin (MSGJ · talk) 09:34, 31 August 2016 (UTC)
- @MSGJ: A while ago there was an RfC which concluded with the result that all coordinates-related parameters in infoboxes should be replaced by