I know this is a bit OT, but as many of you are using gpx-files I think the OSM-forum is the best place for this.
I’m developing a program for reducing the number of points on gpx-tracks. Of course there are already many programs that can do this, but it’s hard to find one for Linux that doesn’t just delete every 2. point, decreasing the quality of the track enormously (please correct me if I’m wrong).
My program (in Java, so it will run on most operating systems) uses the Douglas-Peucker algorithm (see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm for details) to decide which points can be deleted.
There are still a lot of bugs, but it can already be used to reduce the size of gpx-files, as long as there aren’t any “” or “” tags.
Well, I could remove whitespaces (in fact, I had to do some extra work to include whitespaces and newlines), but for developing and testing, being able to read the file is very useful; if I’d remove all whitespaces the whole thing would no longer be human-readable (have you ever tried to understand a gpx-file with only one line?).
A gzipped file can’t be used in other programs; you’d first have to unzip it, so why should I gzip the file?
I just updatet the files, now there are 3 more possible options. Now you can set whether a the output should be human-readable (structured, line breaks and whitespaces) or not (no line breaks, no whitespaces). You also can set a default.
Thanks for testing!
Do you think it’s okay for everyday use?
I’ve tested the program on Windows now, and so far there were no problems.
Sorry, I didn’t know this. But actually, my program should just be able to reduce the number of points on a track, e.g. to show tracks on website (small files) or to use them in programs that are limited to a certain number of points. I think uploading a reduced file to OSM isn’t that good, because you use the track to draw maps, so you need more exact traces.
For me it is ok. I used a perl script to reduce the trackpoints of a gpx file up to now, because my Etrex Vista HCx can only store gpx files up to 500 trackpoints (as ACTIVE LOG up to 10000, but then the recording of tracks is blocked).
With your program the track is near the original track and that is important for reduced tracks.
And you can also serve it this way.
You could add an encoding line to your Apache mod_rewrite (or other servers), so that it can be sent gzipped, but is opened in the browser (the map, …) as a usual gpx file:
Now I added an option for gzipping the output file. It seems to work and when I leave out whitespaces at the same time, I get a 5KiB file (original: 190KiB) instead of 25KiB (without gzipping).
I also corrected the line separator (it’s chosen automatically now, instead of using “\n”, which doesn’t work on Windows).
As I understand the Douglas Peucker algorithm, it’s exactly what is described in the gpsbabel filter.
Plus you are able not only to give the number of points wanted but also the max lenght distance error introduced by removing a point, wich is more convenient when your gpx track as an unknown shape