Page MenuHomePhabricator

kmlexport can't give a name to items generated from <maplink>s
Closed, DeclinedPublicBUG REPORT

Description

Hello,

On fr:wiki, we use the {{Coord}} template to create <maplink>s and the {{GeoGroup}} template to generate a link to kmlexport and to osm4wiki. The {{Coord}} template accepts a name parameter which is used as the title of the geojson feature inside the <maplink>.

In my understanding, kmlexport parses the links of the article to determine what to export. When it finds a kartographer link generated using <maplink>, it can retrieve the coordinates using the attributes data-lat and data-lon, but it is unable to retrieve any name for those coordinates.
As a consequence, the exported items are numbered #1, #2, etc.

Would there be a way for kmlexport to retrieve those names? Like adding a name parameter to <maplink> that gets reflected as data-name on the generated link so that kmlexport can retrieve it?

Steps to replicate the issue (include links if applicable):

What happens?:

  • Despite the two {{Coord}}s having a name, the KML export generated when clicking on "au format KML" contains items named using numbers.
  • Similarly, clicking on "sur OpenStreetMap" opens a map using osm4wiki where the markers are numbered. I believe osm4wiki uses the data provided by kmlexport to get the names.

What should have happened instead?:

The KML export should use the names provided in the {{Coord}} templates, and so should the map.

Other information:

In kmlexport's source code, the kartographer links are retrieved on lines 327-330. Line 435 shows that no name is assigned to those items. Line 450 shows that those unnamed items are numbered instead.

Event Timeline

kmlexport is a webscraper. It can only find what you tell it to find. I see that while fr.wp's coord template accepts a name parameter, but it doesn't seem to actually do anything with that. It's not feeding the info the geodata api of mediawiki (using {{#coordinates}}, but its also not adding any additional hidden information in the generated html output for kmlexport to discover.

A workaround for this, is to hide the geohack url as a value in the generated html output. This is also something that en.wp has in their (not yet launched) maplink version of template:coord

I see that while fr.wp's coord template accepts a name parameter, but it doesn't seem to actually do anything with that. [...] It's not feeding the info the geodata api of mediawiki

I believe the name parameter is fed to the geodata api here. But I guess that would help only if kmlexport uses the geodata api.

its also not adding any additional hidden information in the generated html output for kmlexport to discover

Yes, exactly. Adding extra information on the generated html output of <maplink> would IMO be the easiest solution, but how can one add hidden information in the generated html output of <maplink>?

Yes, exactly. Adding extra information on the generated html output of <maplink> would IMO be the easiest solution, but how can one add hidden information in the generated html output of <maplink>?

Well you can't put it inside of <maplink>, but you can just add it adjacent to it with a display:none'ed element.

Actually, the text parameter of <maplink> could even be used to add hidden information inside the generated link.
<maplink text="&lt;span data-name=&quot;Hidden label&quot;&gt;&lt;/span&gt;Actual text of the link"> seems to properly render the <span>. Maybe that could be an easy way for kmlexport to retrieve the name.

Is there an official maintainer for kmlexport? They might have technical opinions on how it could be most easily parsed by kmlexport.

@Dvorapa is a maintainer of kmlexport.

You could also use WikiMap (https://wikimap.toolforge.org/?lang=fr&page=Paris) which uses the GeoData extension, but so it depends on calling the {{#coordinates}} parser function somewhere in your Coord templates.

Hi, as mentioned before, KMLexport is just a webscraper. It scans wiki page for geohack links/urls and parses parameters from these urls. One of the geohack url parameters is "title", which is directly used as a name. Therefore if coord/maplink adds this parameter to the geohack url, then KMLexport is using that automatically.

One possible solution is to add a hidden geohack link with the title parameter to the page somewhere, but that might be one of many solutions actualy. no need, see my comments below

Note that I'm just keeping KMLexport tool working, not adding new features. If anyone would like to add a new feature and have experience with Perl language, I would be more than happy to add him/her as a maintainer or test and deploy any code changes. Note that curent source code of the tool can be viewed here: https://kmlexport.toolforge.org/?source=

I investigated further and it seems fr's Module:Coordinates cann't correctly assign parameter name to geohack url parameter title. Not sure if this is module's fault or kartographer's/maplink's fault though.

Dvorapa closed this task as Declined.EditedJan 27 2024, 9:48 PM

Therefore marking this as declined as this is not an issue with kmlexport and has to be fixed elsewhere (frwiki? kartographer? maplink?)