Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 08-03-2020, 18:57   #1
Registered User
 
CaptTom's Avatar

Join Date: Apr 2004
Location: Southern Maine
Boat: Prairie 36 Coastal Cruiser
Posts: 1,873
How to Edit (rename and re-sequence) GPX Route Points

I'm doing some route planning with OpenCPN. I've created a number of routes, with dozens to hundreds of route points each. OpenCPN creates these points with sequential names at first, but that leads to two problems:

1) As points are added and deleted, the sequence is broken.

2) Each route has points with many of the same names. Loading these into some chartplotters causes problems.

I export them all to GPX anyway. I could go through and manually edit the GPX files. I could write a script to do that in some programming language. I could use GPS Bable or some other utility to convert to a file format that's easier to edit by hand. But it seems there should be an easier way.

Has anyone else run into this and found a more elegant solution?
__________________

CaptTom is offline   Reply With Quote
Old 09-03-2020, 09:20   #2
Registered User
 
transmitterdan's Avatar

Join Date: Oct 2011
Boat: Valiant 42
Posts: 6,053
Re: How to Edit (rename and re-sequence) GPX Route Points

What do you want to happen to waypoint names automatically?
__________________

transmitterdan is offline   Reply With Quote
Old 09-03-2020, 11:08   #3
Registered User
 
CaptTom's Avatar

Join Date: Apr 2004
Location: Southern Maine
Boat: Prairie 36 Coastal Cruiser
Posts: 1,873
Re: How to Edit (rename and re-sequence) GPX Route Points

Quote:
Originally Posted by transmitterdan View Post
What do you want to happen to waypoint names automatically?
OK, sorry I wasn't more specific. My OpenCPN route point names look something like this:

225
001
002
004
006
NM001
007
...
154
NM005
155
001

In this example, I started with the end point from the last route (225), added a bunch in between (001 through 155), deleted some (003, 005), inserted new ones in between (NM001...) and ended with the first point of the next route (001.)

Ideally, I'd want to rename them all, sequentially, with an abbreviation for the route name, followed by sequential numbers (MyRt001, MyRt002, etc.)

The logic in a program to do this is simple. The hard part would be picking a language, downloading an IDE for that language, gathering the routines and sample code to read and write GPX files, studying the examples and building the input/output dialogs. Iterating through the route point names and replacing them with a sequence of new names is trivial, in any language.

So, I figured there must be someone out there who has already done it. But I'm drawing a blank.
CaptTom is offline   Reply With Quote
Old 10-03-2020, 19:22   #4
Registered User
 
CaptTom's Avatar

Join Date: Apr 2004
Location: Southern Maine
Boat: Prairie 36 Coastal Cruiser
Posts: 1,873
Re: How to Edit (rename and re-sequence) GPX Route Points

I gave up trying to automate this. Here's what I ended up doing:

Set up a macro in my text editor to remove all the OpenCPN GPX extensions, leaving just the needed data under <rtept...>.

Set up a macro to remove the carriage returns and leading blanks on each of these lines, making one line for each route point.

Copied the column of route point names to an Excel worksheet.

Changed the first point to "001". Did a "fill sequential" on the rest of the column.

Added a column to the left with the route abbreviation. Did a "fill down" on the rest of the column.

Copied to two columns to a new file in my text editor.

Removed the tabs between the columns.

Still in the text editor, copied the merged column back over the route names in the original, flattened GPX file.

Opened the flattened and edited GPX file in OpenCPN.

Exported the GPX file back out again, restoring the carriage returns and spaces.

It's a stupid amount of work for such a simple thing, but still easier than writing a new program to read, edit and re-save the GPX file. And really, with macros and the search-and-replace capabilities of a decent text editor, each file took only a minute or less.

I already had the macro to remove all the extensions. It saves a ton of space. I don't know why OpenCPN doesn't have some options for what to include or omit in exported GPX files.

Funny how applications come and applications go, and the technology changes and improves every year, but I still come back to an old-fashioned text editor, to do the same type of thing, decade after decade.
CaptTom is offline   Reply With Quote
Old 11-03-2020, 10:10   #5
Registered User
 
AnglaisInHull's Avatar

Join Date: May 2015
Location: Sailing Lake Ontario
Boat: Mirage 35
Posts: 793
Re: How to Edit (rename and re-sequence) GPX Route Points

I can relate. I wanted to convert between GPX and my old chartplotter's non-standard format - actually a bigger job than could be easily handled with a text editor because I wanted to convert tracks as well as routes.

I ended up writing a routine to do it, but that was because I had time on my hands and wanted an excuse to learn Python.
__________________
My boat is like me. People look, and say "... pretty good shape ... for its age ..."
AnglaisInHull is offline   Reply With Quote
Old 11-03-2020, 13:59   #6
Registered User
 
CaptTom's Avatar

Join Date: Apr 2004
Location: Southern Maine
Boat: Prairie 36 Coastal Cruiser
Posts: 1,873
Re: How to Edit (rename and re-sequence) GPX Route Points

Quote:
Originally Posted by AnglaisInHull View Post
I can relate. I wanted to convert between GPX and my old chartplotter's non-standard format - actually a bigger job than could be easily handled with a text editor because I wanted to convert tracks as well as routes.

I ended up writing a routine to do it, but that was because I had time on my hands and wanted an excuse to learn Python.
Same here. Long ago I wrote a translation program in (get this!) Visual Basic 3.0. It seems there were always a bunch of different formats for the various equipment I used, and I was always converting between them. Mine was sort of like GPSBabel, but smarter about routes vs. tracks vs. waypoints, since all the different hardware handled those differently (or not at all.)

You'd think now that so many devices use GPX there would be a quick and dirty GPX editing tool out there. Were I still actively coding I'd probably whip one up, but I'm not set up for that any more.
CaptTom is offline   Reply With Quote
Old 16-03-2020, 12:50   #7
Registered User

Join Date: Sep 2019
Posts: 5
Re: How to Edit (rename and re-sequence) GPX Route Points

Quote:
Originally Posted by CaptTom View Post
I'm doing some route planning with OpenCPN. Has anyone else run into this and found a more elegant solution?
If you right-click the route and reverse it, it offers to rename the waypoints. This might be just what you want. If you don't mind doing it twice
ironman is offline   Reply With Quote
Old 16-03-2020, 13:54   #8
Registered User
 
CaptTom's Avatar

Join Date: Apr 2004
Location: Southern Maine
Boat: Prairie 36 Coastal Cruiser
Posts: 1,873
Re: How to Edit (rename and re-sequence) GPX Route Points

Quote:
Originally Posted by ironman View Post
If you right-click the route and reverse it, it offers to rename the waypoints. This might be just what you want. If you don't mind doing it twice
I tried that. But it didn't re-number them in any useful way. It left the oddball names in between (NM001, etc) from inserted points, and it didn't seem to do the rest in any reliable sequence.

It's a good trick though, when you want to connect the start of one route to the finish of another. You can "append" to an existing waypoint, but only onto the end of a route. Reverse it and you can append to the beginning, then reverse it back.
CaptTom is offline   Reply With Quote
Old 17-03-2020, 13:03   #9
Registered User

Join Date: Sep 2019
Posts: 5
Re: How to Edit (rename and re-sequence) GPX Route Points

Well I tried this on a Linux and Windows port of OpenCPN 5.0 and it does rename the NM001 waypoint name that is seen in the Route Properties; see attached.

Must say, I have not checked whether this is exactly the same waypoint name that is sent in the NMEA message, but for now I presume so.

Nice trick to prepend a waypoint!
Attached Thumbnails
Click image for larger version

Name:	before.JPG
Views:	14
Size:	65.6 KB
ID:	210777   Click image for larger version

Name:	after.JPG
Views:	17
Size:	63.5 KB
ID:	210778  

ironman is offline   Reply With Quote
Old 17-03-2020, 16:56   #10
Registered User

Join Date: Sep 2019
Posts: 5
Re: How to Edit (rename and re-sequence) GPX Route Points

I found out, after doing it a few times in a row, that the non-renaming of the intermediate waypoint sometimes occurs, both on Windows and Linux ports. I can force this non-renaming by checking the box next to the Waypoint Name (which seems to show the waypoint name in the map), but I cannot make it go away by unchecking the box. So I think this is a bug, and now we know it, it ought to be reported. Can you do that?
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	11
Size:	21.2 KB
ID:	210785  
ironman is offline   Reply With Quote
Old 17-03-2020, 18:45   #11
Registered User
 
CaptTom's Avatar

Join Date: Apr 2004
Location: Southern Maine
Boat: Prairie 36 Coastal Cruiser
Posts: 1,873
Re: How to Edit (rename and re-sequence) GPX Route Points

Quote:
Originally Posted by ironman View Post
Well I tried this on a Linux and Windows port of OpenCPN 5.0 and it does rename the NM001 waypoint name that is seen in the Route Properties; see attached.
Wow. I just tried a simple example and it worked for me, too!

That would have saved me a lot of time. But when I tried that before, it didn't work. I reversed twice and still didn't end up with sequentially named waypoints. Maybe there are some conditions under which it doesn't work. I had a lot of pretty complex routes in play at the time.

Plus, I wanted to give the waypoints "real" names, with an abbreviation for the route followed by the sequential number. Many chartplotters and apps won't take multiple routes with identically-named waypoints in different places.

Edit: I confirmed it doesn't work on some of the old un-renamed routes I still had kicking around. Maybe the waypoints have to be in sequential order to start with. Since my routes started at an "old" waypoint from another route, and sometimes combined two or more previous routes, they weren't sequential. The old sequencing and "NM..." waypoints were retained even if I checked the box to re-number them.
__________________

CaptTom is offline   Reply With Quote
Reply

Tags
enc, route

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thin and thick nuts on propshaft: sequence?? theoleduc Propellers & Drive Systems 58 12-02-2020 10:47
To Rename Or Not Rename A Boat? boatingnewbie Our Community 51 26-08-2018 06:02
Bad Luck to Rename a Boat ? Lovelyr3ta Liveaboard's Forum 40 26-09-2016 03:55
Rename this thread GordMay Families, Kids and Pets Afloat 13 24-01-2006 23:03

Advertise Here


All times are GMT -7. The time now is 02:06.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2020, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.