User talk:Mxn/overpass.js

From Wikidata
Jump to navigation Jump to search

To do[edit]

  • Stop running the query automatically; only run it on click.
  • Integrate with WIWOSM somehow?

 – Minh Nguyễn 💬 02:21, 11 August 2017 (UTC)[reply]

Position[edit]

Could the position perhaps be changed to under/after the "Other sites" sitelinks? Currently it splits the sitelinks between "Wiktionary" and "Other sites" which is not nice. Thank you, --Marsupium (talk) 14:09, 13 September 2017 (UTC)[reply]

@Marsupium: Fixed – Minh Nguyễn 💬 05:41, 3 May 2019 (UTC)[reply]
Thank you!! --Marsupium (talk) 09:19, 3 May 2019 (UTC)[reply]

BUG[edit]

When I have active this script, I am able to edit labels inly from Special:SetLabelDescriptionAliases. When I disable it, I can edit it directly in page. JAn Dudík (talk) 11:07, 15 December 2017 (UTC)[reply]

@Mxn: I'm having the same issue. I'd be cool if you could take a look at it. Thanks! NMaia (talk) 01:27, 2 May 2019 (UTC)[reply]
@JAn Dudík, NMaia: Fixed. Wikibase's design unfortunately leaves few options for styling that don't break JavaScript-based functionality, but I think I worked around it OK, at least when using the default Vector skin. – Minh Nguyễn 💬 07:13, 2 May 2019 (UTC)[reply]
@Mxn: that was fast, thank you! This is kind of unrelated, but it would be useful to have a direct link to the OSM feature beside the link to Overpass. It'd make checking (and editing) OSM items a little faster. NMaia (talk) 07:22, 2 May 2019 (UTC)[reply]
@NMaia: There can be arbitrarily many OSM features corresponding to a single Wikidata item. This is often a mistake, as when numerous individual McDonald's restaurant locations were being tagged with the wikidata tag instead of brand:wikidata. However, there are valid cases such as a company having multiple headquarters, a river's banks being mapped along with its thalweg and distributaries, or a city's traditional centerpoint being mapped along with its boundary. Whether there is only one result or multiple results, you can click on them to reveal a popup that begins with a link to the feature's page on OSM. If this popup isn't working for you, please let me know. Thanks! – Minh Nguyễn 💬 05:37, 3 May 2019 (UTC)[reply]
That's a good point. I wasn't aware of the popup though, thanks for the FYI! NMaia (talk) 05:40, 3 May 2019 (UTC)[reply]

Search also subject:wikidata[edit]

To link a grave or a memorial to one or more person, the subject:wikidata tag is used.

The query will be :

let oql = `
[out:json][timeout:25];
(
  nwr["subject:wikidata"="${qid}"];
  nwr["wikidata"="${qid}"];
);
out body;
>;
out skel qt;`;

To find the wikidata item in a multi-valued list, use this regular expression (slow) :

let oql = `
[out:json][timeout:25];
(
  nwr["subject:wikidata"~"^(?:.*;)?(${qid})(?:;.*)?$"];
  nwr["wikidata"~"^(?:.*;)?(${qid})(?:;.*)?$"];
);
out body;
>;
out skel qt;`;


Pyrog (talk) 11:47, 10 December 2019 (UTC)[reply]

query is downloading more then needed[edit]

Instead of writing explicitly querying nodes, ways and relations the shorter nwr might be used.

But the more important part is, that

   out body;
   >;
   out skel qt;

is outputing the elements with the wikidata tag with every tag (body), and then all nodes and ways with their coordinates and ids (skel), though with the output type geom this can be reduced to contain less ids, which can reduce output size and speed.

Hence I would recommend to use

   [out:json][timeout:25];
   nwr["wikidata"="${qid}"];
   out body geom qt;

-- CamelCaseNick (talk) 15:57, 10 December 2019 (UTC)[reply]

@CamelCaseNick: ✓ Done in 1131274450. Thanks for the tip! – Minh Nguyễn 💬 18:13, 7 March 2020 (UTC)[reply]

Don't show a box if there are no results[edit]

@Mxn: Hi! This is a great tool, thank you! However, for the vast majority of items, it gives no results since they aren't geography-related. Would it be possible to just not show the box if there are no results from the Overpass Turbo query? Jon Harald Søby (talk) 12:21, 3 November 2022 (UTC)[reply]

@Jon Harald Søby: To be clear, this script simply embeds Overpass turbo in an iframe and leaves it up to Overpass turbo to query the Overpass API for OSM features. Unfortunately, browser cross-site scripting restrictions prevent the script from reaching into the Overpass turbo embed to check whether it shows any results. The script could perform a preflight Overpass API call to check whether it should show the iframe, but this would be wasteful and either result in jumping (as the iframe is hidden) or delayed results. I'm considering redesigning this script to only show the Overpass turbo embed on demand, when clicking on a link, in order to minimize wasteful API calls. You'd likely have a good sense upfront about whether an article is geographical and therefore should have Overpass results. Minh Nguyễn 💬 06:03, 5 November 2022 (UTC)[reply]
I'm wondering if having this script run on articles that are subclasses or instances of subclasses of physical location (Q17334923) would be a doable workaround. NMaia (talk) 14:59, 7 November 2022 (UTC)[reply]
@NMaia: Yes, that’s a good idea, at least as a configuration option. But I think recursing up the tree of superclasses would require a SPARQL query, which could be a performance issue too. It also wouldn’t account for items that are linked from OSM but don’t have the appropriate statements in the Wikidata item. I’ve considered solving the problem of wasteful queries in a very different way, by only running the query if you scroll the box into view, or making the box collapsed by default for all items and only running the query when you manually expand the box. I haven’t gotten around to making a change like that but would be open to suggestions on how to accomplish it. Minh Nguyễn 💬 04:13, 8 November 2022 (UTC)[reply]