Cruisers Forum
 

Go Back   Cruisers & Sailing Forums > Seamanship, Navigation & Boat Handling > OpenCPN
Cruiser Wiki Click Here to Login
Register Vendors FAQ Community Calendar Today's Posts Log in

Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 14-12-2012, 03:40   #1
Registered User
 
GrowleyMonster's Avatar

Join Date: Dec 2012
Location: New Orleans
Boat: Bruce Roberts 44 Ofshore
Posts: 2,863
OpenCPN Route-Putter-Inner thingie I wrote

<gpx><rte>
<rtept lat=30.029090184 lon=-90.111572469></rtept>
<rtept lat=30.204728445 lon=-89.836468985></rtept>
<rtept lat=30.203715893 lon=-89.834170824></rtept>
<rtept lat=30.197912995 lon=-89.809026230></rtept>
<rtept lat=29.171015039 lon=-88.916687617></rtept>
</rte></gpx>
*****************************

Keep an eye on the stuff up there above this paragraph. It is
gonna do a trick for you in a minute.

I had used Fugawi for a while as an ECDIS system, before I
got iNavX for my iphone. The "i" is nice cause I can take it
out into the cockpit and see the display even in daylight. But
it is still nice to have something that runs on a bigger screen
for voyage planning and stuff, I tried OpenCPN before and
found it lacking back then, but it is certainly getting better
now, so it seems like a good time to get on the OpenCPN
wagon. The future has a name, and it is OpenCPN.

Only problem is, I got all these routes and stuff that won't
import into OpenCPN. I can't even open the saved RTE files
that Fugawi makes. When I open them in a text editor it is just
binary gobbledysquabble. However, I can run a screen shot
through a text reading program like ABBY Fine Reader or
Acrobat, and extract text from the image, and work with that.
But do I really want to paste lats and longs one by one into a
route? OpenCPN does not make that process trivial. Some
kind of tool is needed. (update: I figured out how to make
Fugawi export a route as a text file, so that simplifies things
greatly!)

Okay, what we have at the top of this post is a sample of an
OpenCPN GPX file, stripped down to its bare essentials. I
wanted to make a BAT file to automatically parse a list of
coordinates into a file that I could import into an OpenCPN
route. But when I opened an exported GPX file with a text
editor, I saw a whole bunch of tags and syntax that looked
superflewus and redundink. By the process called calculatus
eliminatus by the ancients, I found out what was needed for a
clean import, and what was not. It turns out that what is
needed, isn't very much at all. You don't even have to have a
name for the route, though it is simple enough to add one with
a "<name> and a </name> tag, surrounding the desired
name, right after the <rte> tag.

The <gpx> tag of course tells OpenCPN that it is looking at a
gpx file. The closing </gpx> tag says, "hey, that's all!". <rte>
tag tells the program that this is a route, and the closing
</rte> says, "THE END!". The <rtept> tag means "this is a
route point", and the lat and lon modifiers set the coordinates
of the point, and the </rtept> tag of course closes the route
point entry. There are several of these open/close tag pairs,
and you need at least two pairs for a route. The two final
tags, as already discussed, close out the first two opening
tags. Most html and xml type syntaxes use these tags in pairs
like that, with the </> version the closer to the opener.

Sometimes a closing tag is not needed, as in the case of the
<p> tag in html, which begins a paragraph. The next <p> tag
tells the browser or other interpreter that the previous
paragraph is finished because this is the start of a new one.
However, I tried leaving off the </rtept> tags, and OpenCPN
would not import the file. So here you have it... the minimum
needed to import a route into OpenCPN. Everything after the
closing </gpx> tag is ignored by OpenCPN. When I import
this file, the route is loaded and displayed as an unnamed
route, and if I export the route, it is exported with all the
garbage re-put back in that I edited out with the text editor.
This is probably a good thing, because maybe some GPS
units want to see all that garbage.

Yes, the text content of this entire post, as you see it, is a
perfectly legal and technically functional route file that can
be imported. Try it if you don't believe me. Copy the
complete text of the body of this post, paste it into notepad,
and save it as "whatevah.gpx". Make sure it does not append
the "txt" filename extension. Sorry Lunix guys... I know I am
using windoze-speak here. Mac guys... get a real computer
haha. Copy the resulting file into wherever you keep your
GPX files. Start OpenCPN and import the file. ta-dah! Of
course if you like, you can delete all the stuff after the closing
tag, but you could also leave a comment if you like. Oh yeah
I know I know... the route has you driving your boat overland.
That's because I took a real route and for the sake of brevity
I deleted a bunch of points, the ones that dodge around
through the Rigolets and out into Lake Borgne. So please no
wise-ass remarks about my navigational acumen, please!

Okay, that's the raw anatomee of a gpx file. Should be simple
to create a BAT file or a simple app or script to parse a
bunch of lat/longs into a usable route, I'll be doing that some
day soon. Stay tuned.

Okay, you stayed tuned long enough. I just completed a
preliminary release of GPXer. Its temporary home is
http://growleymonster.webs.com/downloads/GPXerWin.rar.
just download, unzip, put it in a convenient directory on your
windoze box, and run it. No installation necessary. Put a
shortcut in your start menu or on your desktop if you like. It's freeware. There's no help file but I will post a quickie how-to tomorrow. It is pretty obvious how to use it. In fact I will post it now.
GrowleyMonster is online now   Reply With Quote
Old 14-12-2012, 03:42   #2
Registered User
 
GrowleyMonster's Avatar

Join Date: Dec 2012
Location: New Orleans
Boat: Bruce Roberts 44 Ofshore
Posts: 2,863
Re: OpenCPN Route-Putter-Inner thingie I wrote

Here's the how-to-do-it stuff. I was gonna write an html help file with screen shots but I'm kinda busy, so here is the text draft without tags and pics and stuff.

*******************************************

GPXer by GrowleyMonster 0.1
This program is freeware. Do what you like with it. I am not responsible for use, misuse, or abuse. Use at your own risk.
This application is very much a work in progress. In fact, I haven't made much progress since I have only put a couple of hours into it. I will add refinements as I go along, as I see a need for them. In other words, as I need them for my own use. Your suggestions are welcome but please understand that I wrote this for myself and all I am doing in presenting it is making it available as-is, for whoever else has use for it.

THE PROBLEM
I was using Fugawi. Now I am switching over to OpenCPN. I had several routes that I created with Fugawi but the Fugawi saved routes don't import into OpenCPN. I figured out the bare essentials of a GPX file that can be imported into OpenCPN as a route, and did a quick paste-up of a Fugawi route saved as a text file, adding the tags and formatting necessary for the importation. Well, that works, but I wanted a more convenient way to do it. So, I wrote this little application to do all the parsing and formatting for me.

THE SOLUTION
GPXer. Basically, you paste a list of waypoints into the main text box of the program, hit one button to fix all the route points with all the taggy schmaggy stuff, and save everything as a brand new OpenCPN *.gpx file. I also added a File Open capability so I can directly open a text file for a route created by Fugawi and the contents magically appear in the text box without copying and pasting. And I added a Route Name box, even though it is not needed in the file.

THE RESULTS
The saved *.gpx file has no line feeds in it. I could put that in there but it doesn't matter. Running it altogether has no detrimental effect. It is just like running HTML together. It still works. Line Feeds in these files don't do anything but make it easier for a human to read the file. Once you import the new file into OpenCPN, you can add properties to the route and save it by exporting it from CPN and then the exported file looks just the same as any other *.gpx file if you open it with a text editor.

LIMITATIONS
I wrote this specifically for processing Fugawi route files. It will work on any text file that is a list of waypoints, BUT in this preliminary version, those waypoints must be formatted in a specific manner. NO SPACES! No skipped lines. Coordinates are in degrees and decimal degrees, not degrees and minutes. The words "LAT" and "LON" must not be in there. N, E, S, or W must not be present, either. Lattitude must be stated before Longitude, and both Lat and Lon must be on the same line, separated by a comma only. South Latitude and West Longitude are indicated by the "-" (negative) symbol. The following short list of waypoints can be pasted into GPXer and processed:
30.1963441,-89.7746256
30.1751497,-89.7551238
30.1740900,-89.7519363
30.1740900,-89.7519363
30.1740900,-89.7519363
30.1763154,-89.7432320
30.1708578,-89.7335430
30.1613203,-89.7154639
30.1686324,-89.6976912
The following waypoints will not work.
30.1963441 N, 89.7746256 S
30° 17' 51" N, 89° 75.5' W
30-17.4 North, 89-75.1 West
So those of you with lists and lists of route points in Degrees and minutes, or degrees, minutes, and seconds, you are all S.O.L. for now.

REQUIREMENTS
I don't really know. I wrote the program on a laptop running Windows 7 so maybe you need a PC running Windows 7. Maybe it will run on something else, I don't know. Maybe not. I'm not a fortune teller. I will try to port this to Mac and Linux but I make no promises because the End Of Line characters and file operations are different, and anyway, I have no way of testing ported versions. Linux geeks, write your own app or script. Mac guys, get a real computer. Windows guys, cross your fingers and hope it runs on your puter.

INSTALLATION
Just copy the executable wherever you want it. My suggestion is to open up C:\Program Files\ or whatever, create a subdirectory named "GPXer", copy the executable into there, and create a shortcut to it in your Start menu and also on your Desktop. Then you can open the app with either shortcut. If you get the program as a self-installer, which I might or might not make, just install normally.
If you put the exe file in the same directory where OpenCPN looks for gpx files to import, by default GPXer will save its output files right where you need them. Just sayin.

OPERATION
1. Populate the text box with route points. You can do this with the "Open File" command button. Just use the dialog to navigate to the desired file for input. Or, open a file with Notepad or another text editor. Select, and Copy, the relevant text. Paste it into the program's main text box. Edit as necessary so that the text is in the required format, as specified in the LIMITATIONS section above.
2. Format the text. Click the "Fix Rtepts" command button and the required formatting will magically appear. If you previously filled in a Route Name into the one line text box above the main one, it will be incorporated into the output text. If not, then it won't be there, and no big deal. Do any necessary editing before the next step.
3. Save your results as a gpx file that can be imported into OpenCPN using the "Save File" command button. Be sure to save it in the same place as all your other CPN route files. This will probably be somewhere in your "My Documents" folder. What you do is open OpenCPN, and export one of your routes, and make a note of where it was exported to. That's where you want your new gpx file to be saved to.
4. Import into OpenCPN. Open the Route Manager and click the "Import" command. Use the dialog to select your file, and abber cadaver, your route should appear, ready for you to use. Re-export it after you set all the additional properties like start and destination, cruising speed, etc.

COMING SOON, or maybe not.
I will probably add a semi-manual conversion capability in the next bit of work I do on the program. If it is there, you will simply paste or type the LAT and LON into the widget and it will convert the minutes or decimal minutes (and seconds, if any) in your own list of waypoints to decimal degrees, and automatically paste the fixed coordinate into the text box for processing. Later on, I might add user-defined masked input so you can specify exactly how your list of points is constructed, so GPXer can suck all the data and nothing but the data out of your list and import it into the text box for processing. MAYBE I will even add customizable output, so you can take a list of coordinates in whatever format, even an exported *.gpx file, and output a list that has good old NESW descriptors, and degrees, minutes and decimal minutes instead of degrees and decimal degrees only, which will be handy for manually plotting the points on a paper chart.
LIKE IT?
Brush my ego, I don't care. Really, I don't. If you find it useful, use it. If you don't, then don't use it and please, no whining directly to me about how it won't do this and it won't do that, because I am not a real programmer, I don't do this for a living, I don't do this for anyone else, and I don't even like doing it for myself, but I do it when it needs to be done. Sort of like going to the pump-out station. Feel free to post about it in Cruising Forum or wherever. Anybody who wants the source code as written for RealBasic, is welcome to it but I promise you it won't be pretty.

CONTACT THE AUTHOR
No, don't bother. See above.

FINAL COMMENTS
I once saw a video of some idiot feeding a sandwich to a "tame" alligator from his boat. Now the gator I am sure harbored no ill will whatsoever to this dumbass. In fact, he probably appreciated the free snack. Unfortunately, alligators are not real bright, and their world is divided into three parts... that which can be eaten, that which can eat them, and everything else. Benefactors have no permanent spot in any particular category, and besides, the gator probably was not smart enough to figure out just where the offered snack ended and the offering hand began. The results I leave to your imagination. Computers are sort of like gators. They don't know what is a snack (data) and what is simply other stuff. I could easily spend the next year writing code that would enable GPXer to accept data in just about any form and figure out on its own what to take and what to do to make it work, but I won't, at least not right now. Get your input data right, or it simply won't work.
GrowleyMonster is online now   Reply With Quote
Old 14-12-2012, 06:48   #3
Registered User

Join Date: Mar 2010
Location: Behind the garlic curtain - east central Saskatchewan
Boat: Baylurker 2755
Posts: 608
Re: OpenCPN Route-Putter-Inner thingie I wrote

I have no use for your utility but I love your writing. I'm a fellow ex-Fugawite but I switched sooner than you did so I didn't have much invested in routes and I was too much of a Luddite to even consider moving them in such a sophisticated manner.

I'll use that alligator story somehow sometime. Thanks.
bobofthenorth is offline   Reply With Quote
Old 12-06-2013, 23:55   #4
Registered User

Join Date: Nov 2010
Location: San Diego Bay
Boat: Hunter Legend 40
Posts: 320
Re: OpenCPN Route-Putter-Inner thingie I wrote

yes, where the fugawi. still there
__________________
Gary

I'm wet nurse to a last place dead to the neck up ball club and I'm choking to death.
gpshephe is offline   Reply With Quote
Old 13-06-2013, 04:39   #5
Registered User

Join Date: May 2011
Location: UK
Boat: Bavaria 46 Cruiser
Posts: 14
Re: OpenCPN Route-Putter-Inner thingie I wrote

Looks a great conversion programme.

Can you do the same from Seaclear ? I have loads of old tracks saved from previous users as a seaclear user - I would like to keep them as part of my log and have them converted to OpenCPN tracks ? Any chance ?
SolentBlue is offline   Reply With Quote
Old 13-06-2013, 04:57   #6
Registered User
 
yachtvalhalla's Avatar

Join Date: Aug 2009
Location: Philippines
Boat: Formerly Fuji 32 Ketch
Posts: 1,017
Re: OpenCPN Route-Putter-Inner thingie I wrote

GrowleyMonster:

I'm very sorry you didn't know about the GPS Utility program.

GPS Utility - Home

Might have saved some work!

Terry
yachtvalhalla is offline   Reply With Quote
Reply

Tags
opencpn


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


Advertise Here


All times are GMT -7. The time now is 10:47.


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

ShowCase vBulletin Plugins by Drive Thru Online, Inc.