Tag Archives: GPX Tool

Clean Route Tool

I had some minor issues with routes that I created for my chartplotter. The method and tools that I use creates random waypoint names. I can fix them manually, but decided to create a tool that can do it all at once. It’s a Perl script called “clnrte”. The first version renamed the waypoints, starting at a specified number and incrementing it for each waypoint. Next, I had it replace different waypoint symbols with a specified symbol name. Then, I had it hide the waypoint names on the display.

Later, I decided that I would make this tool available on my website. There was a problem with this—it was the ease of use.

I wrote Clean Route using a language called Perl. The Perl Language is very good at reading and manipulating text files, which is why I chose it for the Clean Route tool. Perl programs require a Perl interpreter, which can be downloaded for free, for personal use. They are also portable across multiple operating systems, like Windows, Mac and Linux. I already had it installed on my Windows PC when I wrote the Clean Route tool.

The main disadvantage of Perl is that it runs from a command prompt. I spent much of my career running programs from a command prompt, so this was never a problem for me. But I understand why most people don’t want to do this. I provided a “bat” file, so the program could be started from Windows Explorer, but this is not portable and it doesn’t allow for running with different options.

The Clean Route program takes options, which are passed in as command line arguments, in the style of the UNIX shell. If running from Windows Explorer, the default options can be changed by editing the “bat” file. That’s about –3 on a usability scale of 1 to 10.

For documentation, I provided a small “txt” file, or you could run the program with the “–help” flag, as shown below.

>clnrte --help

clnrte (Clean Route) Version: 1.05
Copyright (C) Ron Olson 2014

Reorder waypoints and clean symbols in GPX route files.
Syntax:
   clnrte [options] infile1.gpx [infile2.gpx ...[infileN.gpx]]
   Where infile1.gpx ... infileN.gpx are route files in GPX format.
Options:
   --help or -h - Display this message.
   --outfile or -o - Output File (optional), default is infileX_cln.gpx,
                     (does not work with multiple input files).
   --reorder or -r | --noreorder or -nor - Reorder | Don't reorder
                                  waypoint names (default is to reorder)
   --start or -s # - Starting waypoint number, if reordering, (default is 0).
   --digits or -d # - Minimum number of digits in waypoint name, if reordering
                      (default is 3).
   --cleansym or -c | --nocleansym or -noc - Clean | Don't clean waypoint
                                      symbols (default is to clean symbols).
   --wpsym or -w 'string' - Waypoint symbol, if cleaning symbols,
                            (default is 'Waypoint').
   --verbose or -v | --noverbose or -nov - Verbose | Nonverbose mode.

These bits of documentation do not cover how to get started running Perl.

The New GPX Tool

One day, out of nowhere, I had an idea…

The server that runs my website has a Perl interpreter. All I had to do was upload a GPX file to the server, run the program there, and make the output available for download.

I started with my other GPX utility “gpx2csv”, or Create CSV file from GPX file. Since I now have a easier way to specify options, I made some improvements to the CSV tool, like specifying different units of measurements. I also displayed a summary of the GPX file.

This was my first release of the GPX Tool. See my post GPX Tool for a description of the Create CSV part of the tool.

In release 2, I added “Clean Route”. I made some improvements to this utility as well.

Clean Route

Clean Route came about because of the way I create a route for my chartplotter. I start by creating starting and ending waypoints in OpenCPN. I connect the waypoints with a route, and then insert waypoints in between to keep my route at safe depths. The inserted waypoints are automatically named by OpenCPN. When my route looks good, I export it and import it into HomePort. Then I continue to refine it. HomePort automatically names inserted and appended waypoints as well. Refer to my series of posts on Planning Multi-Day Cruises for more details.

The route is slightly changed when exported/imported between tools. While OpenCPN is tolerant of duplicate names, HomePort is not. When Homeport imports a route with an existing waypoint, it appends a digit to the name to make it unique. It can get very messy.

HomePort and OpenCPN share some common waypoint symbols, like Anchor, but most of them are unique. Routes exported from HomePort use waypoint symbols named Waypoint, which is a black dot. Waypoint gets converted to Combo!, which appears as small circle with a dot in the middle, when imported into OpenCPN. OpenCPN lets you specify the waypoint symbol, but the default is diamond, which is not a valid symbol in HomePort.

Inserted and appended waypoints in OpenCPN default to not show the waypoint name, but you can change this by checking Show name for each waypoint. When you import a route into OpenCPN that was exported from HomePort all the waypoint names are shown. This clutters up the display. You can uncheck Show name for each one, or you can use Hide Name to hide them all.

Prescriptions are not required to purchase the herbal extract. canada pharmacy viagra Antidepressants have a buy viagra in usa distinguished status for influencing sexual presentation in males and females in a similar way. So Is It Safe? Not only will viagra pills for sale you be able to forever obtain low cost generic sildenafil on-line. it’s as effective as authorised sildenafil however prices considerably less and incorporates a generic . As of right now, 10 percent of men go through from erectile dysfunction owing to psychological factors such as stress, depression, unresolved levitra without prescription icks.org orientation, guilt, low confidence, fear and performance anxiety.

I added another option to Clean Route. Originally, all waypoint names were reordered and all waypoint symbols were cleaned. I added the Clean All option. If Clean All is unchecked, non-automatic waypoints, like anchorages, are left alone.

Cleaning a Route

To clean a route, start by opening the GPX Tool and setting the Clean Route options.

Click Show Options and check/uncheck Reorder, Clean Sym, Hide Name, and Clean All. Also set Num Digits and Symbol to desired values.

Clean Route Options

Click Hide Options to save and continue.

Click Chose File and select a GPX file with the route to be cleaned.

Clean Route Chose GPX File

The Upload GPX button is enabled.

Clean Route, Upload GPX Enabled

Click Upload GPX to upload the file for processing.

Clean Route, Uploaded GPX File

If there is a route, the Clean Route button is enabled. The Start Num field is set to one past the last waypoint name from the last route that was cleaned. Change it now if desired.

You can also download the uncleaned CSV file, if desired.

Click Clean Route to clean the route.

Cleaned Route

The message tells you how many waypoints were cleaned. Start Num is updated by this amount.

Click Download CSV and Download GPX to download the cleaned CSV and GPX files.

The file name is appended with _cln, but the route name is unchanged. I suggest that you delete the original route from HomePort and/or OpenCPN before importing the cleaned route.

Click Clear to restart any time during the process.

Summary

I hope that you find my tools useful. If you want to try them out, you can download an example route, MAR-FTJ.gpx by clicking on the name. This is a route from Marquesas Key to Fort Jefferson anchorage, in Dry Tortugas. Look for more examples in the future.

Speaking of future posts, you can now sign up to receive a notification when a new post is published.

If you enjoy any of my tools or my website, please consider a small donation by clicking here or on the This website is ad free banner.