Template talk:Infobox settlement/densdisp

Expression error
Waht causes the expression error in the example at the bottom in this version? Anrie (talk) 08:50, 30 November 2007 (UTC)
 * Sorry, I'd forgotten to udpate the example when the order of the parameters was changed. Think it's fixed now.--Kotniski (talk) 09:08, 30 November 2007 (UTC)
 * Thank you. Anrie (talk) 09:40, 30 November 2007 (UTC)

Automatic calc of population density
I don't really know whether to raise this here, or at one of the following: Template talk:Infobox settlement/permi2km2; Template talk:Infobox settlement; Template talk:Infobox French canton.

Basically, the problem is that when is given (say) 1000 but all of km², area and dens are empty, error messages are shown in the infobox and the article ends up in Category:ParserFunction errors. To see some examples, visit that category and pick almost any of the "Canton of ..." articles, such as Canton of Albertville-Nord, and examine the "Population" section of the infobox. If you edit the page, and fill in a positive, non-zero value for area, the error message disappears. Unfortunately I do not have all the correct figures to fill in, so would prefer a template amendment.

Referring to the documentation of this template: What I would like is that if either  or   has the value , and both   and   are blank, the density calculation should not be performed. -- Red rose64 (talk) 15:40, 26 January 2010 (UTC)


 * I agree. I had been meaning to make the change for sometime.  It's somewhat annoying to see an error there just because the area or pop is missing. Plastikspork ―Œ (talk)  16:17, 26 January 2010 (UTC)
 * I see that you have added as a pretest to one of the calls to  - but there are four other calls within, each of which could potentially exhibit similar problems. That said, the French canton articles are now dropping out of Category:ParserFunction errors (which is taking an absolute age to rebuild), so the problem that I described above is sorted. -- Red rose64 (talk) 22:36, 3 February 2010 (UTC)
 * Great, I am glad to hear that I didn't break anything. I am proceeding slowly due to the complexity of these subtemplates.  Basically, it appears I need to add a similar pretest to each call of densdisp?  I also added some code to densdisp itself to remove the "auto" keyword in the case that the area and/or pop was missing. It appears to at least not introduce any new breakage. Plastikspork ―Œ (talk)  22:49, 3 February 2010 (UTC)

Edit request on 19 July 2013
Please update to use [//en.wikipedia.org/w/index.php?title=Template:Infobox_settlement/densdisp/sandbox&oldid=564974472 this version] of the sandbox. this will fix a long-standing bug described in this thread. if you check the code for rnd, it looks for bad values for the precision, then sends them to Category:Pages with bad rounding precision. it then ignores the value specified here, and uses (1 - order of magnitude) instead. this patch corrects the bug by simply sending the value of (1 - order of magnitude) to the template. hence, the ultimate output will be unchanged, but it will remove the tens of thousands of articles appearing in Category:Pages with bad rounding precision.

Frietjes (talk) 21:09, 19 July 2013 (UTC)
 * Done! Thanks for fixing the bug! Plastikspork ―Œ (talk) 00:11, 20 July 2013 (UTC)
 * another small tweak, it appears as though this still adds articles to Category:Pages with bad rounding precision if the population is zero. it looks like this due to whitespace sensitivity of order of magnitude when checking if the input is zero.  In the sandbox version, I removed some space and it fixes the problem. Frietjes (talk) 15:55, 27 July 2013 (UTC)
 * Done! Plastikspork ―Œ (talk) 23:50, 27 July 2013 (UTC)
 * thank you, the category has dropped from over 50,000 pages to under 200 pages, so it appears this has worked! Frietjes (talk) 16:08, 28 July 2013 (UTC)

Auto
Did "auto" for the settlement infobox at Urban agglomeration of Montreal, and it doesn't work. I've noticed this with other pages, too. What could be causing it not to work? Criticalthinker (talk) 10:03, 27 February 2023 (UTC)