# HG changeset patch # User wim # Date 1504089448 -7200 # Node ID 89108adbc4687bd4ce00812a7bb7b7c436e04cfe # Parent b379310ee21c5ddc8b90e5cf9c782c56edb91197 gpx_plot: numpy verijderd uit gpx_plot gpx_reduce: changelog aangepast readme: verbeterd diff -r b379310ee21c -r 89108adbc468 README.md --- a/README.md Wed Aug 30 09:26:39 2017 +0200 +++ b/README.md Wed Aug 30 12:37:28 2017 +0200 @@ -1,24 +1,25 @@ # gpx_reduce_light -* gpx_reduce.py, a version of gpx_reduce with no dependencies (only the standard python libraries) +* gpx_reduce.py, a version of gpx_reduce with no dependencies (only the standard python libraries) Only the plot option has been removed. See [original version](https://github.com/Alezy80/gpx_reduce) for more info. -Usage example: -``` -> gpx_reduce.py -d 2 -t 30 your_track.gpx +>Usage example: + +>>``` +$ gpx_reduce.py -d 2 -t 30 your_track.gpx ``` -* gpx_plot.py, a separate program to plot one or more tracks with "gnuplot". +* gpx_plot.py, a separate program to plot one or more tracks with "gnuplot". Gnuplot has to be installed and the path to the binary has to be changed in the code to reflect your installation: -```python -# the path to the gnuplot binary +>>``` gnuPlotCmd = 'path/to/gnuplot' ``` -Usage example that compares a reduced track with the original: +>Usage example that compares a reduced track with the original: + +>>``` +gpx_plot.py your_track.gpx your_track_reduced.gpx ``` -> gpx_plot.py your_track.gpx your_track_reduced.gpx -``` diff -r b379310ee21c -r 89108adbc468 gpx_plot.py --- a/gpx_plot.py Wed Aug 30 09:26:39 2017 +0200 +++ b/gpx_plot.py Wed Aug 30 12:37:28 2017 +0200 @@ -2,6 +2,11 @@ # -*- coding: utf8 -*- ''' +gpx_plot.py calls gnuplot to draw the gpx-tracks given as arguments. +Copyright 2017 willem179 +Extracted from the code of "gpx_reduce.py" +Copyright (C) 2011,2012,2013,2015,2016,2017 travelling_salesman on OpenStreetMap + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -19,12 +24,12 @@ import datetime import sys import time -import numpy as np -import numpy.linalg as la 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') (options, args) = parser.parse_args() @@ -42,6 +47,9 @@ timeformat = '%Y-%m-%dT%H:%M:%SZ' +# the linear algebra with lists +norm = lambda p: sqrt (sum (a * a for a in p)) + def rotate(x, y, phi): return x*cos(phi) - y*sin(phi), x*sin(phi) + y*cos(phi) @@ -51,7 +59,7 @@ lon -= lonm xyz = latlonele_to_xyz(lat, lon, 0.0) zy = rotate(xyz[2], xyz[1], radians(90 - latm)) - lat2 = atan2(zy[0], la.norm([zy[1], xyz[0]])) + lat2 = atan2(zy[0], norm([zy[1], xyz[0]])) lon2 = atan2(xyz[0], -zy[1]) x_meters = rE * sin(lon2) * (pi / 2.0 - lat2) y_meters = -rE * cos(lon2) * (pi / 2.0 - lat2) @@ -61,18 +69,18 @@ def latlonele_to_xyz(lat, lon, ele): s = sin(radians(lat)) c = cos(radians(lat)) - r = ele + a * b / la.norm([s*a, c*b]) + r = ele + a * b / norm([s*a, c*b]) lon = radians(lon) return r * c * sin(lon), r * c * (-cos(lon)), r * s def xyz_to_latlonele(x, y, z): - r = la.norm([x, y, z]) + r = norm([x, y, z]) if (r == 0): return 0.0, 0.0, 0.0 - lat = degrees(atan2(z, la.norm([x, y]))) + lat = degrees(atan2(z, norm([x, y]))) lon = degrees(atan2(x, -y)) - ele = r * (1.0 - a * b / la.norm([a*z, b*x, b*y])) + ele = r * (1.0 - a * b / norm([a*z, b*x, b*y])) return lat, lon, ele @@ -153,8 +161,7 @@ xmin -= dr from subprocess import Popen, PIPE -gnuPlotCmd = ['gnuplot'] -plot = Popen (gnuPlotCmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) +plot = Popen ([gnuPlotCmd], stdin=PIPE, stdout=PIPE, stderr=PIPE) range = 'set xrange [%f:%f]\nset yrange [%f:%f]\n' % (xmin, xmax, ymin, ymax) plot.stdin.write (range) diff -r b379310ee21c -r 89108adbc468 gpx_reduce.py --- a/gpx_reduce.py Wed Aug 30 09:26:39 2017 +0200 +++ b/gpx_reduce.py Wed Aug 30 12:37:28 2017 +0200 @@ -6,14 +6,14 @@ tries to keep introduced distortions to the track at a minimum. Copyright (C) 2011,2012,2013,2015,2016,2017 travelling_salesman on OpenStreetMap -changelog: v1.3: removal of all dependencies (lxml, scipy, numpy, pylab) - v1.2: clarity refractoring + speedup for identical points +changelog: v1.2: clarity refractoring + speedup for identical points v1.3: new track weighting functions, progress display v1.4: new track weighting function, restructuring for memory saving v1.5: algorithm speedup by roughly a factor of 2 by eliminating some cases. v1.6: presets for train etc. v1.7: introduced weighting function for elevation errors v1.8: speed-dependent distance limit + v1.9: removal of all dependencies (lxml, scipy, numpy, pylab) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by