Importing GPX tracks into TangoGPS
TangoGPS is a wonderful tool to navigate using OpenStreetMap data. Currently though, it does not yet support the loading of track files. However, here is a little hack to insert track points from a GPX file into the tangoGPS POI database. This may be useful for rudimentary routing and for geocaching. As seen on the screenshot, a route is displayed as a series of unconnected track points.
The small script is written in python. It requires pysqlite2. It reads a gpx file, and inserts track points directly into the file poi.db which you can find in your .tangogps directory. It works for me and files generated by the Open Route Service. Your mileage may vary, and you might have to edit the regular expression which identifies the track points (Refer to the comments for using it with gpsbabel) . Don’t forget your backup.
Download here: gpx2tango.py
More tools:
- loc2tango.py for those geocaching.com loc files.
- An advanced version by nlaurance (blog entry | download)
- pocket2tango.py for those geocaching.com pocket query GPX files. Includes basic information (and, optionally, hints) into waypoint information. Writes full html cache description to separate html file.



9 Comments so far
Leave a comment
Hello,
i just tried your script gpx2tango.py.
It works fine, but i had to switch the order of lat and lon, because in the GPX-file generated with gpsbabel, the order is lat-lon:
RE_TRKPT = ‘<trkpt lat=”([0-9\.]+)” lon=”([0-9\.]+)”‘
and:
lat, lon = match.groups()
Greetings,
Wolfram
By wolfram on 08.23.08 7:29 pm
Thank you for testing! I agree; for a clean implementation, I’d probably have to use an XML parser.
By Thomas on 08.24.08 1:54 am
You forget to catch poi’s with cordinates less than 0.
by the way.. but thanks for the script anyway
By Gi9bi on 10.21.08 2:22 am
Hi, I slightly improved your script, and wrote a blog entry myself on the same subject. Thanks for the idea !
By nlaurance on 12.02.08 2:03 pm
Merci beaucoup! I’ve linked your version in the original article.
By Thomas on 12.02.08 3:23 pm
You can use this script to convert a gpx track (like generated by OpenRouteService) to a fake tangogps log file (load it via “Track -> Load”):
#!/bin/bash
if [ $# == 0 ]
then
echo "usage: $0 track.gpx [another-track.gpx etc.gpx]"
fi
DATE="`date +%FT%TZ`"
for p in $*
do
OUTFILE="`basename $p .gpx`.log"
echo $DATE
echo $OUTFILE
sed -n -e"s/^[^<]*/\2,\1,0,0,0,$DATE/p" $p > $OUTFILE
done
By Mitja on 05.09.09 5:19 pm
It seems like they changed the syntax. Once I changed the RE_TRKPT expression from trkpt to wpt I could import.
Great script, thanks!
By Hannes on 06.19.10 2:34 pm
That’s what I get for abusing the gpx converter for a pocket file. All I was missing was a ./html/ directory so pocket2tango.py could work. Maybe you could add a warning about that?
By Hannes on 06.19.10 3:06 pm
Yup, I should. I haven’t used the software in a while.
By Thomas on 07.11.10 11:49 pm
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>