Greasemonkey script to set description when uploading .gpx tracks

Hi all,

I’ve created a new Greasemonkey script that automatically pre-populates the description field when you select a .gpx file to upload. You can find it here.

The idea is the following:
I use the MyTracks applications on my Android-G1 to record GPS tracks. You can set the title for each track, and when exporting the track to a .gpx file, the program automatically creates the filename based on the title of the track, removing white spaces and replacing non-ASCII characters with underscores.

I’ve also taken the habit of prepending an integer to the title of the track, so that when I have exported it to .gpx, I can upload the tracks in the order that I recorded them.

So a typical title that I would put in MyTracks would be:
4 Estadio - Paintball
(sorry, it’s in Spanish, but you’ll get the idea… This is a track I’ve recorded from the stadium to the paintball field for those wondering :wink: )
The “4” starting the title is because I had already recorded 3 other tracks before that.

MyTracks will export that track to a file that will be called:
4EstadioPaintball.gpx

Once you have installed the Greasemonkey script, when you select that .gpx file on http://www.openstreetmap.org/traces/mine , the description will automatically be set to:
Estadio - Paintball

You will note that the script will automatically remove all integers starting the filename. In my use-case those integers have meaning when creating the .gpx file in order to upload them in the same order as they where created, but they don’t have to be in the track description…

To me it is useful because my gpx tracks [almost] always contain the data I want to have in the description. Of course, this approach has some caveats, like if you have more spaces that dashes in your file name… Example: “Bus61OosterplasStation.gpx”. This description will be “Bus - 61 - Oosterplas - Station” when I’d like it to be “Bus 61 Oosterplas - Station”. But I can live with that, removing the dashes by hand instead of having to re-write the entire description. In order to reduce this “dash-hell” a bit, the script will automatically remove some obvious extra dashes, like after words like “The”, “El”, “Of”, etc.

Feel free to test the script and tell me if you like it/you think about something that would improve it!

Cheers,
Emilien.