Coordinates: 52°28′59″N 1°53′37″W / 52.48306°N 1.89361°W / 52.48306; -1.89361

Module talk:Coordinates

From Doc-Wiki
Revision as of 14:38, 1 January 2026 by Docmoates (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Latest comment: 31 December 2025 by Zackmann08 in topic Edit request 28 December 2025
Jump to navigation Jump to search

Template:Permanently protected Template:Talk page header

User:MiszaBot/config

Interface-protected edit request 27 December 2023

Template:Sudo

Please sync from Module:Coordinates/sandbox (diff).

This adds a class and a data-gadget attribute to the span. For now, this is a no-op change. It is intended to facilitate a more performant way of loading the WikiMiniAtlas script, when coupled with the proposed changes in MediaWiki talk:Common.js#Class-triggered gadgets. – SD0001 (talk) 14:36, 27 December 2023 (UTC)Reply

Template:Done * Pppery * it has begun... 16:54, 27 December 2023 (UTC)Reply

Template:Sudo As MediaWiki now supports category-based gadget load, we can switch to that. Please sync from Module:Coordinates/sandbox (Special:Diff/1192107975/1226463973). For now, this is a no-op as the gadget isn't actually defined. – SD0001 (talk) 20:17, 30 May 2024 (UTC)Reply

Template:Done * Pppery * it has begun... 00:22, 31 May 2024 (UTC)Reply

coordinsert problem?

@Jonesey95 I recently found your old question on German WP. It could be because of a malformed Geohack link: "Infobox UK place" uses coordinsert which generates a broken string when "coord" got a "title" parameter: https://geohack.toolforge.org/geohack.php?pagename=Hatfield_Chase&params=53.528_N_0.893_W_&title=Tunnel+Pits_region:GB_type:city (see the splitted "params" seperated by the "title" parameter). "coordinsert" assumes "params" always as last parameter? Which isn't true when "title" is used. DB111 (talk) 09:10, 14 August 2024 (UTC)Reply

Add a "precedence" parameter

Hello. Can https://en.wikipedia.org/w/index.php?title=Module:Coordinates/sandbox&oldid=1319497477 be synced to Module:Coordinates please? This should add a "level" parameter that can be set to "primary" and that defaults to "secondary", matching the behavior of the GeoData extension that this module relies on.

We currently overload "display=title" to indicate that coordinates are the primary ones. Primary in this case means which coordinates get returned for the whole page in queries such as <https://en.wikipedia.org/w/api.php?action=query&prop=coordinates&titles=Cincinnati>. I'd like greater flexibility within this template and I'd like to be more explicit about the behavior by adding this "level" parameter.

Any and all code review is welcome. The name "level" isn't great. I considered doing "display=primary" initially but that seemed worse. Level or order matches what we typically call words such as primary, secondary, or tertiary. --MZMcBride (talk) 04:40, 30 October 2025 (UTC)Reply

It's a bit unfortunate choice of the parameter name. In this context, I thought level has something to do with altitude. How about "importance level", prominence, significance, priority, relevance, precedence, or primacy? 98.15.131.172 (talk) 09:26, 30 October 2025 (UTC)Reply
Precedence may be better, yeah. --MZMcBride (talk) 15:31, 30 October 2025 (UTC)Reply

{{sudo}}

Based on feedback, I switched to "precedence" in <https://en.wikipedia.org/w/index.php?title=Module:Coordinates/sandbox&oldid=1319561810>. Can this be please be reviewed for acceptance? --MZMcBride (talk) 15:34, 30 October 2025 (UTC)Reply

Should the {{#coordinates:}} not be included if the params are |display=title|precedence=secondary ? As precedence is currently ignored if display has title, or would then never be a case with the title coord not being the primary? -- WOSlinker (talk) 18:18, 30 October 2025 (UTC)Reply
Oh, good point. I believe this is now addressed in <https://en.wikipedia.org/w/index.php?title=Module:Coordinates/sandbox&oldid=1319669517>. --MZMcBride (talk) 05:15, 31 October 2025 (UTC)Reply
Template:Ping Did a little testing and didn't seem to work all the time, so made some changes. Did the check for display=title and precedence=secondary first and also set the value to blank rather than secondary that gets passed over to #coordinates as it didn't seem to accept secondary. Can you check that it looks ok with my changes? -- WOSlinker (talk) 08:49, 31 October 2025 (UTC)Reply
I like precedence better than level, but are we overspecifying this, making it easier to make typos and other errors? What if we just had |primary=yes for any primary coords on a page and |primary=no for all other (secondary) coordinates? – Jonesey95 (talk) 14:12, 2 November 2025 (UTC)Reply
Yeah, this might be a lot cleaner and clearer. --MZMcBride (talk) 18:55, 3 November 2025 (UTC)Reply
I meant to say, in case it is not implied: |primary=yes would be the default, as it essentially is now, so really only |primary=no would need to be used for secondary coordinates. We could also do |secondary=yes if that makes more logical sense. – Jonesey95 (talk) 20:41, 4 November 2025 (UTC)Reply
We currently set coords to secondary by default and only to primary if display=title is set. I'm trying to add functionality so that we can set primary coords without needing to overload display=title. We do not want every {{coords}} on the page trying to set itself as primary by default as far as I know. --MZMcBride (talk) 01:22, 7 November 2025 (UTC)Reply
Indeed. I either didn't know that or had forgotten. Carry on. – Jonesey95 (talk) 13:23, 7 November 2025 (UTC)Reply

Issue with inline coords

Template:Moved from

Coordinates: Script error: No such module "ISO 3166".

So I keep coming across pages where the |coordinates={{coords|...|display=title}}. The issue with this is that the logic in the if statement sees that {{{coordinates}}} is not empty, and therefore renders the Coorindates: text. See the example at right, note I have used a nbsp to achieve the same result here so as not to throw random coords on the talk page title.

We should fix this somehow... The options I see include:

  1. Detecting if |display=title and if so, hiding the Coordinates: text.
  2. Somehow modifying Module:coordinates so that in certain circumstances you can use the coordinsert functionality to change the display from just title to title and inline, though I now realize that would still require detecting what the current value of |display= is. We don't want to run into errors because the coords are defined as inline in the infobox then at the bottom of the page there is a 2nd set of coords defined for the title...

Open to any suggestions! Zackmann (Talk to me/What I been doing) 23:04, 14 December 2025 (UTC)Reply

Template:Ping any thoughts on this? Zackmann (Talk to me/What I been doing) 18:40, 15 December 2025 (UTC)Reply
Looks like the coordinates module already has some helper functions that parse the display parameter value, so maybe just make sure they are exported in a namespace from which they can be reused? --Joy (talk) 19:42, 15 December 2025 (UTC)Reply
Not sure how exactly that would look. I'm only able to picture an additional function that would return the a parsed display parameter. Zackmann (Talk to me/What I been doing) 22:33, 15 December 2025 (UTC)Reply
Can we test the output of |coordinates= to see if it wants to display the inline portion? Alternatively, can we somehow inject display=inline into the parameter, maybe with a string replacement? – Jonesey95 (talk) 01:02, 16 December 2025 (UTC)Reply
Exactly what I am thinking, just not really sure how to do that... Happy to dive into it though. Mainly wanted to sanity check that I wasn't missing something obvious before I went down the rabbit hole. Zackmann (Talk to me/What I been doing) 01:04, 16 December 2025 (UTC)Reply
This is a total hack and will definitely have negative side effects (I think), but {{Str rep|1={{coords|1|1|N|3|3|E|display=title}}|2=-hidden noexcerpt|3=}} might be fun to play with. – Jonesey95 (talk) 02:18, 17 December 2025 (UTC)Reply
Because there's no mention of 'display' or 'inline' or 'title' in the second or third parameters, nobody will remember what it does tomorrow. Let's not make it more complex and less likely to be maintained. --Joy (talk) 08:19, 17 December 2025 (UTC)Reply
I'm referring to isInline() and similar functions, Module:Coordinates#L-633. With a few relatively small interventions, this could be brought out of the local scope and we could conceivably use it to quickly check the display value from the outside. --Joy (talk) 08:47, 16 December 2025 (UTC)Reply
Hmm that could certainly help! I'll get into this later this week and see if I can't mock something up in the Sandbox. Zackmann (Talk to me/What I been doing) 16:46, 16 December 2025 (UTC)Reply
Template:Ping moved the discussion here where I probably should have started it. I have mocked up a solution in Module:Coordinates/sandbox. See below:
So with this we could wrap {{Infobox settlement}}'s {{{coordinates}}} param in the new function as follows: {{#invoke:coordinates|forceinline|{{{coordinates}}}}}. This would ensure that it always displays inline, in addition to in the title if that is desired. Note I have done VERY LITTLE testing of this, but am looking for feedback on this as a possible solution. Zackmann (Talk to me/What I been doing) 02:58, 19 December 2025 (UTC)Reply
Template:Ping as recent editors of this template, at your convenience, could you please review the above discussion and my attempted solution? Thanks! Template:Smiley Zackmann (Talk to me/What I been doing) 19:13, 22 December 2025 (UTC)Reply

Edit request 28 December 2025

Template:Edit fully-protected

Description of suggested change: To help solve the problem described at Issue with inline coords (above) I have written a new function that can be called to force coordinates to display inline. (Note: if/when implemented I will add documentation for this).

New code: please insert at Line 765

function coordinates.forceinline(frame)
	local text
	text = mw.ustring.gsub(frame.args[1], 'geo%-inline%-hidden', 'geo-inline')
	text = mw.ustring.gsub(text, 'style=\"display:none\"', '')
	return text
end

Zackmann (Talk to me/What I been doing) 19:46, 28 December 2025 (UTC)Reply

Template:Ping could one of you possibly review the above request? Trying to fix a problem that is plaguing a large number of settlement pages. Zackmann (Talk to me/What I been doing) 05:40, 31 December 2025 (UTC)Reply