Template talk:GPX indicator

From Wikivoyage
Jump to navigation Jump to search

Idea for an improvement: Show gpx tracks on the maps and be able to download them for usage in map application[edit]

Swept in from the pub

Imagine we were able to show gpx tracks on the mapframe (e.g. a city walking tour, which covers the highlights of Istanbul). Then – with a click of a button, one could download exactly that gpx file to the phone and import it into OsmAnd, Maps.me, … best with POI pictures and some text. I personally think, that would be a huge improvement for Wikivoyage! --Renek78 (talk) 18:53, 13 October 2016 (UTC)[reply]

This feature was once introduced to WV, but then reverted with some not very clear reasoning. Check out also the old discussion on this topic. And while this feature keeps being missing from WV, you can anyway download GPX using this external tool. --Kiaora (talk) 04:49, 14 October 2016 (UTC)[reply]
Renek78, that feature has been implemented in it:voy as a pilot. You can see for example it:Nelle terre dei Gonzaga. From the GPX indicator icon you can download both the GPX track and all the listing present in the page (provided that they have the coordinates).
Kiaora, the revert has been done for technical reason. If this is the only problem, I can correctly activate it here as well. Let me know. PS The original purpose of the external tool that you have mentioned, is to extract POI from more than one article. --Andyrom75 (talk) 07:06, 14 October 2016 (UTC)[reply]
It would be extremely helpful to have this feature enabled. As it's very unlikely a lot of people know about this tool at all. And yeah, I've seen it's capable of combining POIs from several articles, quite handy. --Kiaora (talk) 07:22, 14 October 2016 (UTC)[reply]
Kiaora, I've just activate it the GPX indicator on all the articles that have been associated to a GPX itinerary like London/City of London. To activate it on every article that has a listing I need the support of an en:voy-admin to change MediaWiki files. I'll keep you posted. --Andyrom75 (talk) 09:21, 14 October 2016 (UTC)[reply]
Done!
Kiaora, Renek78, now from all the articles is possible to download GPX file, with POIs and tracks information ready to be installed on external devices. --Andyrom75 (talk) 19:29, 14 October 2016 (UTC)[reply]
Thanks for your support, Andyrom75! That's already a big step in the right direction. But somehow I don't fully understand how to add a track to a Wikivoyage article. For example I wanted to upload a gpx file for the "Hike along the coastal path from Monaco to Carnoles". I would create the trace with a tool like GPSies, upload to this place and then somehow link the gpx in the article. But I already fail on the upload part. The wikihelp "Wikivoyage:How to use dynamic maps" wasn't really helpful. I guess I'm too new to all this...
Renek78, you need to save the mentioned GPX track in Template:GPX/Monaco. Once done, if the syntax do not contain mistakes, the track will be automatically added to the article. Unfortunately the maps used here in en:voy has a bug that do not show the tracks directly in the map. If you want to see it, you can try it first on it:voy where the tracks are visibile (when well written) because we still used the old maps that in general have less problems. Once satisfied with the track, you can copy it here too. --Andyrom75 (talk) 22:45, 14 October 2016 (UTC)[reply]
I am going to try it as soon as possible. Means, that my idea is already implemented - you are the man, Andyrom75! --Renek78 (talk) 11:38, 16 October 2016 (UTC)[reply]
Quick update: I have just created a track now on GPSies and uploaded it to the Monaco gpx template. If I now download the Monaco gpx file the track is included, but I am not able to see the track on the article map - neither on the English version nor on the Italian one with this "Mappa dinamica" element. So not sure now whether more cleaning of the gpx is needed or the mapframe feature just has to be updated.--Renek78(talk) 12:23, 16 October 2016 (UTC)[reply]
Another update: The track can be seen when clicking on the button "Full Screen dynamic map". The next step would be to make the mapframe show gpx tracks and to be able to link the "do" map marker "Carnoles hike" with the gpx track. Then it's close to perfection. --Renek78 (talk) 12:37, 16 October 2016 (UTC)[reply]
Fantastic! Thanks. --Kiaora (talk) 03:56, 15 October 2016 (UTC)[reply]
Renek78, 2 notes.
  1. To see the GPX track in a language version, you must save the track in that specific language version. You have saved it only here in en:voy
  2. You can see the GPX track in the en:voy "big map", because that map is still linked to the old one that is currently in use in it:voy (not only as a "big map" but in every article). It's not a matter of template name. What changes is the content. See the different marker icons for example. --Andyrom75 (talk) 13:57, 16 October 2016 (UTC)[reply]
GPX track shows on the geo map - Work is being done to show the GPX tracks on a mapframe - Though it is possible to do so in a temporary roundabout way - it would be better to wait for a final solution(s)... -- Matroc (talk) 01:30, 17 October 2016 (UTC)[reply]

Template broken[edit]

Unfortunately, there currently seems to be a bug with this template. Since descriptions are now added to the downloadable GPX files from the original article but without properly parsing them, XML-uncompliant GPX files are produced (e.g. <desc>Foo & bar</desc>), breaking the functionality of Navigation- and Geo-Apps like OSMand for smartphones. I consider this is quite severe, because I reckon many people use these GPX files.

Example: https://tools.wmflabs.org/wikivoyage/w/poi2gpx.php?print=gpx&lang=en&name=Tallinn (from Tallinn's upper right corner, search for "& " in the GPX file)

How do we correct this bug?

Cheers, Ceever (talk) 18:58, 13 October 2017 (UTC)[reply]

Ceever I don't know who add description to the GPX file, but I can confirm you that is not possible to simply add it for two problems:
  1. HTML tag
  2. wiki tag
Any field added to the GPX file must be parsed in order to remove any kind of tag, to obtain a plain text. There's no other solution. --Andyrom75 (talk) 07:33, 14 October 2017 (UTC)[reply]
I don't quite get, what you are trying to say. The "content" field is currently put as <desc>SOMETHING</desc> into the GPX file. However, the parsing is incomplete, since it does not remove XML-nonconforming characters. How can we get this corrected? Ceever (talk) 14:18, 14 October 2017 (UTC)[reply]
Ceever, with a huge programming effort. --Andyrom75 (talk) 20:06, 17 October 2017 (UTC)[reply]
Well, I reckon reverting to when there was no <desc> would be straight forward. Ceever (talk) 20:56, 17 October 2017 (UTC)[reply]
I agree. --Andyrom75 (talk) 21:27, 22 October 2017 (UTC)[reply]

GPX track download?[edit]

Swept in from the pub

Special:Upload currently lists permitted file types: tiff, tif, png, gif, jpg, jpeg, webp, xcf, pdf, mid, ogg, ogv, svg, djvu, oga, flac, opus, wav, webm. Would it be worth asking that Wikimedia add .gpx as one of the valid file types?

I could see it being useful for providing downloadable tracks for itinerary (the {{GPX indicator}} link on every page downloads just the article's POI's); that data could then be loaded into GPS units and taken on the road.

We seem to be accumulating novelty itinerary for roads which don't actually exist cross-country (such as Oregon Trail and Route 66, which are popular as fiction). The missing chunks are bridged by sending the voyager onto a long list of real highways (so "US66" in the Texas Panhandle ends up mostly on I-40, for instance). Those quickly become hard to follow; "it's not on my GPS" is a running joke in Cars (2006 film) for a reason. K7L (talk) 16:09, 25 July 2017 (UTC)[reply]

Wow, silence. I'd wanted to upload GPX for Oregon Trail before it becomes the featured travel topic on the 21st, but I guess I can't? K7L (talk) 14:31, 17 August 2017 (UTC)[reply]
@K7L: Hi, I apologize for the late response to your question. This type of feature was brought up a few years ago in Phabricator and there are links in that ticket that explain how a GPX file can be uploaded. However, the GPX file would need to be converted to GeoJSON before being able to be displayed on a map in Wikivoyage, as I think you're trying to do in your question above. DTankersley (WMF) (talk) 17:33, 23 August 2017 (UTC)[reply]
There already is a GeoJSON track on the map in Oregon Trail#Prepare. That track was created by taking a National Park Service itinerary, tracing the turn-by-turn road directions on GPX Creator, then converting to GeoJSON for inclusion in the article. The documentation at Wikivoyage:How to use dynamic maps is rather limited (and was merely updated from GPX to "...and then convert to GeoJSON" as an afterthought to accommodate mw:Extension:Kartographer) but the map was added to the page in time for the article to be featured.
My question was how to make the original GPX available for download, for instance to allow the voyager to load the points into a handheld GPS unit. This was what Garmin originally intended as GPX's role when they first promoted the format. Attempting to use modern roads to re-create an 1843 ox-cart trail is a convoluted mess, where the voyager needs the information in a form which they can bring with them. A map which only works on the desktop while still online isn't very portable. I did try upload to https://commonsarchive.wmflabs.org/wiki/File:Oregon_Trail_GPX,_Independence_MO_to_Oregon_City_OR.gpx but the only way to link to that file from here appears to be a full external link; the media: or file: prefixes just generate a redlink.
Admittedly, I'd prefer to avoid depending on items hosted across multiple wikis (commons, wikidata, now this...) as that makes articles more difficult for new users to maintain or update and risks breaking content if the pieces hosted on other WMF wikis are deleted (which has happened with both wikicomons and wikidata in the past, and will happen again). We need to be able to store both GPX and GeoJSON here, locally. K7L (talk) 14:31, 25 August 2017 (UTC)[reply]
Shouldn't the track, when inserted into the article as GeoJSON, just simply be part of the GPX which is already available for each article containing all the mentioned geo-tagged POIs? We should maybe just extend this functionality. But who can implement such a change? Ceever (talk) 22:01, 3 October 2017 (UTC)[reply]
Exactly Ceever! GeoJSON and GPX only have minor differences. It shouldn't be too hard to add it to the gpx for each article. That would improve Wikivoyage by leaps and bounds! Imagine a suggested city walking tour is just a download button away and another 5sec later you have it in OsmAnd or any other navigation app on your phone and can follow the track. Nobody would ever use a paper travel guide again. --Renek78 (talk) 19:46, 11 October 2017 (UTC)[reply]

The only real solution I found so far[edit]

Thanks for all the tips given above. Unfortunately, none of the above tips are relevant for this (I actually don't know about AWB since I don't got access/permission to use it)... as I need to be able to easily only "clean" the content of six parameters - Hours, Price, Content, Checkin, Checkout, Directions (while any sort of global "search and replace" would replace everything in the code (so, for example, while it is easy to change the parameter "hours=" to "hours= <!--", it is almost impossible to change the "|" to "--> |" only at the end of those six parameters.

After searching for a solution on Google I came across the following recommendation for anyone using Notepad++ to accomplish this. While this solution is a bit more complicated than one click and done (it involved probably around 10-15 clicks AND paying A LOT of attention to see that nothing of value was erased, YET, this actually helps cut down the time involved in importing articles that contain a lot of listings). ויקיג'אנקי (talk) 17:11, 15 August 2017 (UTC)[reply]

In emacs I'd use a keyboard macro that would search for the first of the keywords, move beyond the "=", mark that point, search for the "|" and delete back to the mark, then search for the next keyword etc. (in practise, I'd put the first search last, so that I can see what is going to get deleted before pushing Go). Where there are several listings after each other, so that I can see that nothing goes wrong, I'd give a repeat number (^Shours^U5^X^E would run the macro on five listings starting at an "hours"; ^S=ctrl-S etc.). With regular expressions you can avoid having to check every match, but you have to think hard instead. For your job thinking hard and using sed (or awb or perl or whatever) would probably be the most efficient solution. --LPfi (talk) 21:30, 15 August 2017 (UTC)[reply]
Removed comment as issue was found -- Matroc (talk) 12:47, 16 August 2017 (UTC)[reply]
You don't need to use an offline editor to use regexes. Use the 2010 WikiEditor, click "Advanced", find the find-and-replace icon (right edge of toolbar in LTR languages) and tick the box to "Treat search string as a regular expression". WhatamIdoing (talk) 20:08, 16 August 2017 (UTC)[reply]

Userpage script[edit]

You could try the script at User:WOSlinker/comment listings.js. I've set it to only work on userpages. -- WOSlinker (talk) 11:23, 16 August 2017 (UTC)[reply]

@WOSlinker: Thank you so much!. בזכותך חודשים רבים (ואולי אפילו שנים!) מהחיים שלי לא יוקדשו יותר להעתקה + הדבקה בלבד (translate sentence with Google Translate to see funny comment). ויקיג'אנקי (talk) 03:08, 17 August 2017 (UTC)[reply]
The first article on the Hebrew Wikivoyage which was significantly expanded with listings that were automatically fixed and imported thanks to WOSlinker's new script ויקיג'אנקי (talk) 03:11, 17 August 2017 (UTC)[reply]

Wikidata not exported[edit]

Unfortunately, for listing with just the Wikidata ID, no gpx point is created.

Can we find a solution for that?

Cheers, Ceever (talk) 08:26, 21 September 2019 (UTC)[reply]

It is technically impossible because the current tool analyses the unexpanded source code. On the German Wikivoyage we made it completely different by using a JavaScript script getting the data from html code. This script is able to add tracks from Commons and OpenStreetMap, too. Unfortunately, changes must be made in the listings template. --RolandUnger (talk) 17:19, 21 September 2019 (UTC)[reply]
Could you just explain the functionality to me ... I don't quite get it from the code.
Maybe this should be added to the English WV, since many are just adding the WD ID instead of the GPS information nowadays.
Cheers, Ceever (talk) 10:30, 22 September 2019 (UTC)[reply]

──────────────────────────────────────────────────────────────────────────────────────────────────── Some remarks at the beginning. Some time ago we decided at the German Wikivoyage to make the tools anew because nobody knows if the old scripts of May2008 would be available in future and if they are working properly. And we made other decisions: we do not use GPX files any longer because we cannot display them on Karthographer maps. All GPX data are now stored of Wikimedia Commons or on OpenStreetMap. And we wrote the {{Marker}} and {{Listings}} templates anew using Lua scripts to work better with Wikidata. The last change must not be done now on other Wikis, but adaptions are necessary. The GPX tracks can be converted for instance with GPSies.de. Main aim was to create outputs which are 100 percent XML compatible.

Some documentation:

We added one new type (in WV/de) to distinguish between mapshapes which should not be added to GPX files and which should be added. All mapshapes will be put to the type mask, but tracks should be use track.

Now we are using two GPX standards:

For markers and listings, we added some additional information in the div or span tags which we need for display. It is of some importance that markers and listings use a common class like vcard to find them all. The tag name of the wrapper tag is not analyzed. Example:

<span class="h-card vcard Marker" data-name="a special museum" data-color="#4682B4" data-type="see"
 data-url="https://a.special.museum.org"...>

data-name contains the plain name of a location without any links. Also the phone number will get an additional data field data-phone.

The script consists of three main steps: (1) initialization and getting data from KarthographerLiveData. (2) Searching for all markers. (3) Adding tracks. Lets start with the listings and markers. This is simple, and you can analyze the function getText = function(). The information needed were retrieved from containers by their class names. The line tracks = writeTracks(); is used to add the tracks.

Now to the tracks because this is more complicated. In all articles which contain a mapframe the Javascript variable wgKartographerLiveData is available which contains all map data. But in case of external data these data are not incorporated but the source is named. These data must be retrieved from the mapserver of the Wikimedia Foundation. This is done in the function getKartographerLiveData = function(). Of course, getting the data can be failed. I am using a special technique to get them using promises. All inquiries were made at the same time and we wait until we having them all. After this, these data are analyzed and converted to GPX data. If the process of promises fail then only marker and listing data are given.

The script is working with all modern browser including IE11. It is available on mobile phones, too.

You can visit the article of Bayerisch-Böhmischer Freundschaftsweg to get an imagination of the mode of operation of the script. Please check the output, too. The symbol is given in the header.

I hope that this short explanation helps to understand the script. --RolandUnger (talk) 15:28, 23 September 2019 (UTC)[reply]