--- a/README.md Wed Aug 30 17:53:53 2017 +0200
+++ b/README.md Fri Sep 01 15:23:33 2017 +0200
@@ -1,32 +1,39 @@
# gpx_reduce_light
-* gpx_reduce.py is a version of the [original gpx_reduce][1] with no dependencies.
+* gpx_reduce.py is a modified version of the [original gpx_reduce][1] with no dependencies.
- The [original version][1] depends on scipy, lxml, numpy and pylab.
- Because the program only does some basic linear algebra, all these dependencies can be easily removed.
+ The original depends on *scipy, lxml, numpy* and *pylab* (which are heavy requirements).
+ However, these dependencies can be easily removed, because the program only does basic linear
+ algebra.
This has two benefits:
1. easy installation (nothing needed apart from python)
- 2. the program is considerably faster than the original.
- This is because the original uses a numpy array for each trackpoint which
- incurs a large overhead for creating and for all subsequent little computations.
+ 2. the program is considerably faster than the original.
+
+ A stand alone windows executable (win32, 3 Mb) can be downloaded from <https://wim.vree.org/sporen/gpx.html>
- The one disadvantage of removing all depecencies is that the plot option had to be removed.
- Usage example:
+ Usage example (see [original][1] for a better description):
> gpx_reduce.py -d 2 -t 30 your_track.gpx
+ The disadvantage of removing all dependencies is that the plot option had to be removed.
I made a separate python script with one dependency for plotting tracks:
-* gpx_plot.py, a script to plot one or more tracks with "gnuplot".
+* gpx_plot.py, a script to plot one or more tracks with [gnuplot][3].
- Gnuplot has to be installed and the path to the binary has to be changed in the code
- to reflect your installation:
-
- gnuPlotCmd = 'path/to/gnuplot'
+ Gnuplot has to be installed and if the path to the gnuplot executable is not */usr/bin/gnuplot*
+ you have to specify the path with the command line option *-g /path/to/gnuplot*
Usage example that compares a reduced track with the original:
> gpx_plot.py your_track.gpx your_track_reduced.gpx
+
+ and with the -g option:
-[1]: https://github.com/Alezy80/gpx_reduce/
\ No newline at end of file
+ > gpx_plot.py -g /path/to/gnuplot your_track.gpx your_track_reduced.gpx
+
+ A stand alone windows executable (win32, 3 Mb) can be downloaded from <https://wim.vree.org/sporen/gpx.html>
+ (does not include [gnuplot][3])
+
+[1]: https://github.com/Alezy80/gpx_reduce/
+[3]: https://sourceforge.net/projects/gnuplot/files/gnuplot/
--- a/gpx_plot.py Wed Aug 30 17:53:53 2017 +0200
+++ b/gpx_plot.py Fri Sep 01 15:23:33 2017 +0200
@@ -21,24 +21,26 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
-import datetime
-import sys
-import time
+import datetime, sys, os, time
from math import *
import xml.etree.ElementTree as etree
from optparse import OptionParser
-# the path to the gnuplot binary
-gnuPlotCmd = 'gnuplot'
-
parser = OptionParser('usage: %prog [options] input-file.gpx')
+parser.add_option('-g', action='store', type='string', dest='gnuplot',
+ default='/usr/bin/gnuplot', help='PATH to the gnuplot binary (or .exe)', metavar='PATH')
(options, args) = parser.parse_args()
+# the path to the gnuplot binary
+gnuPlotCmd = options.gnuplot
+if not os.path.exists (gnuPlotCmd):
+ print gnuPlotCmd, 'does not exist'
+ parser.print_help ()
+ sys.exit ()
if len(args) < 1:
- parser.print_usage()
- exit(2)
-
+ parser.print_help ()
+ sys.exit ()
# use the WGS-84 ellipsoid
rE = 6356752.314245 # earth's radius
@@ -94,8 +96,11 @@
ntot = 0 # total number of trackpoints (sum of segments)
# import xml data from files
+ if not os.path.exists (fname):
+ print fname, 'does not exist'
+ continue
print 'opening file', fname
- infile = open(fname)
+ infile = open (fname)
tree = etree.parse(infile)
infile.close()
@@ -161,7 +166,11 @@
xmin -= dr
from subprocess import Popen, PIPE
-plot = Popen ([gnuPlotCmd], stdin=PIPE, stdout=PIPE, stderr=PIPE)
+try:
+ plot = Popen ([gnuPlotCmd], stdin=PIPE, stdout=PIPE, stderr=PIPE)
+except Exception as e:
+ print e, 'while executing', gnuPlotCmd
+ sys.exit ()
range = 'set xrange [%f:%f]\nset yrange [%f:%f]\n' % (xmin, xmax, ymin, ymax)
plot.stdin.write (range)
@@ -172,4 +181,4 @@
plot.stdin.write ("\n".join (data))
plot.stdin.write ('\n')
plot.stdin.flush ()
-raw_input ('druk')
+raw_input ('press enter to exit program')