tumic0 / GPXSee

GPS log file viewer and analyzer with support for GPX, TCX, KML, FIT, IGC, NMEA, SLF, SML, LOC, GPI, GeoJSON and OziExplorer files.
https://www.gpxsee.org
GNU General Public License v3.0
922 stars 130 forks source link

Make it possible to select the text within tooltip popups #142

Closed sikmir closed 4 years ago

sikmir commented 5 years ago

For now, it's impossible to select the text (let's say I want to copy coordinates) from tooltip popup: screenshot2 I'd like something like that (selecting text from popup in IDE): screenshot1

tumic0 commented 5 years ago

This makes sense, but the tooltips are now "regular system tooltips" where it is not possible. To enable this (and links - those are now also not possible) the tooltips must be completely reimplemented. This will for sure not be a trivial work so it falls into the category "maybe some day"...

tumic0 commented 4 years ago

Please have a look at the "tooltip" branch which contains custom tooltips that enable copy&paste (using Ctrl+C). The behaviour of items have change - they must now be clicked and there are some other limitations given by "collisions" of click events. The UX has still some glitches, but it is the best I could get to somehow work and enable links and copy&paste. But I'm still not sure if I want to merge it...

sikmir commented 4 years ago

Hmm, using the latest code from tooltip branch I don't see any tooltips at all...

tumic0 commented 4 years ago

You must click on the objects now.

sikmir commented 4 years ago

It would be good to have:

  1. Support for track/route links
  2. Support for multiple links
tumic0 commented 4 years ago

Added in 694847a424057e4a66c460c0fc09276e8a61e4ec. But I really doubt that there are some GPX files with multiple links...

sikmir commented 4 years ago

Added in 694847a.

Thanks!

But I really doubt that there are some GPX files with multiple links...

You won't believe, but I extensively use links in GPX files within my collection of tracks;) For example, I usually add one link to "event's homepage" / "report" / "blog post" / "photoalbum available on the web" / whatever, where I can find all details about the track, and one more link usually to GPSies (RIP) / Wikiloc, where the track is occasionally published. As for me, such approach is very handy, if I want quickly find some info about past events.

tumic0 commented 4 years ago

Implemented in master, will be part of 7.16.

sikmir commented 4 years ago

@tumic0 What about GPX 1.0 support? It uses <url> instead of <link>. For example geocaching still provides their points in GPX 1.0 format (link to cache page in <url>).

tumic0 commented 4 years ago

Added in 9905de67bde0d8231bda82861a12a383cbd43f47.

sikmir commented 4 years ago

@tumic0 One more thing here, I'm looking for a way to get POIs with images (that would be really cool). Currently, it's feasible using geotagged JPG files, but in such case POI ▶ POI files list getting too long obviously (1 entry per POI). What do you think about using <type> (Mime type of content) element of <link>, and show image preview instead of link if link's type is image/jpeg?

tumic0 commented 4 years ago

I do not like the idea to behave different for a link with a specific MIME type. Moreover, there is only place for one image per info at the moment and there can be multiple links. I could hovever add support for some GPX image extension if there is one as this looks like something useful and would be very easy to implement (the image info is already in every waypoint structure).

Or maybe there is some other format that supports waypoint image info (maybe KML, but from what I see its icon tag is connected with a style which is not exactly how I would define the image data is handled in GPXSee).

sikmir commented 4 years ago

I've just found another way:

$ export CID=10401
$ export GC_PHOTOS=~/.local/share/gpxsee/POI/GeocachePhotos
$ mkdir -p $GC_PHOTOS
$ wget -O $GC_PHOTOS/$CID.jpg https://geocaching.su/photos/caches/$CID.jpg
$ cat << EOF > ~/.local/share/gpxsee/POI/geocaching.su.gpx
<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="">
  <wpt lat="61.135466700" lon="29.773033300">
    <name>Тропа Хошимина в лесах Карелии</name>
    <desc>&lt;img width=&quot;240&quot; height=&quot;240&quot; src=&quot;file://$GC_PHOTOS/$CID.jpg&quot;/&gt;</desc>
    <link href="https://geocaching.su/?pn=101&amp;cid=$CID"></link>
  </wpt>
</gpx>
EOF

Result: scr1

tumic0 commented 4 years ago

Yes, this is maybe the easiest way - use HTML in the description ;-).

sikmir commented 4 years ago

Here is a full example of how to get POI+photos (geocaching.su):

#!/usr/bin/env python
import gpxpy
import gpxpy.gpx
from os.path import expanduser
import requests
import shutil

src_url = 'https://nakarte.me/geocachingSu/geocaching_su2.json'
gc_photos = expanduser('~/.local/share/gpxsee/POI/GeocachePhotos')

gpx = gpxpy.gpx.GPX()

for name, cid, lat, lon in requests.get(src_url).json():
    if 58 < lat < 62 and 27 < lon < 36:
        wpt = gpxpy.gpx.GPXWaypoint(lat, lon, name=name)
        wpt.link = 'https://geocaching.su/?pn=101&amp;cid={}'.format(cid)
        photo_url = 'https://geocaching.su/photos/caches/{}.jpg'.format(cid)
        local_photo_url = 'file://{}/{}.jpg'.format(gc_photos, cid)
        with requests.get(photo_url, stream=True) as r:
            if r.status_code == requests.codes.ok:
                with open('{}/{}.jpg'.format(gc_photos, cid), 'wb') as f:
                    shutil.copyfileobj(r.raw, f)
                    wpt.description = '<img width="240" height="240" src="{}"/>'.format(local_photo_url)
        gpx.waypoints.append(wpt)

with open('geocaching.su.gpx', 'w') as out:
    out.write(gpx.to_xml())