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 01-11-2009, 11:34   #61
Obsfucator, Second Class
 
dacust's Avatar

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,745
Quote:
Originally Posted by jonasaberg View Post
Dan,
I think this is excellent progress.
It makes for a nice workflow:
-Scan a bunch of charts. Convert to png using max 127 colors.
-Load them one at a time into MapCalII pressing save between each.
-Exit and batch convert all png to gif to enforce a color table format (using mogrify -colors 127 -format gif *.png in image magic)
-batch convert to tif. (using mogrify -colors 127 -format tif *.gif in image magic)
-use mc2bsbh to create *.hdr files.
-Use tif2bsb to create kap files.

Only thing left is a batch version of tif2bsb...
Would this be easy Dan?
A program that would do
tif2bsbb *.hdr

That would run through all *.hdr files, combine them with the corresponding *.tif files to create *.kap files.

What do you think?

/Jonas
It would be very easy to code that in a shell script. And I imagine in DOS as well (I just don't remember back 25+ years how to do parameters in DOS, was it "%"?).

To make it portable, I think it can be done from c++, but I'd have to figure that out.

I forget what platform you are on.. If it's a unix variant, I'll write one right quick. Or if you have MinGW, same thing.

-dan
dacust is offline   Reply With Quote
Old 01-11-2009, 11:50   #62
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 309
Dan,
I am running on WinXP right now.
You are right, should be possible to figure out.

Maybe a shellscript in a package with libbsb, mc2bsbh, OpenCPN. The only thing left then is MapCalII, but since it is inside Seaclear we would need to send Seaclear into the deal to...

/Jonas
jonasaberg is offline   Reply With Quote
Old 01-11-2009, 11:50   #63
Registered User
 
sinbad7's Avatar

Join Date: Sep 2003
Location: Ubatuba,SP,Brazil (Ex Norway)
Boat: (Ex) Alu. 60' yacht-"Eight Bells"
Posts: 2,731
Images: 57
Send a message via Skype™ to sinbad7
Dan..

I like the idea that was suggested earlier. Adapt/re-write MapCal to do the entire job.
It would produce a xx.kap file readable by both OpenCpn as well as MapCal.
I feel sure the MapCal editor(s) would welcome the opportunity of adding such a
facility to SeaClear.. Has anyone tried to approach them with such a suggestion?

Jonas.. "Great minds think alike!" (Our posts were both at 1750.)
__________________
"And all I ask is a tall ship and a star to steer her by."
sinbad7 is offline   Reply With Quote
Old 01-11-2009, 12:04   #64
Obsfucator, Second Class
 
dacust's Avatar

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,745
Here's a shell script to process every header file in a directory. It assumes the extensions are in lower case. And assumes all the files are in the same directory. It also creates a temporary file called "ls.txt", so make sure you don't have a file like that you want to keep.

Someone familiar with Windows scripting should be able to do the same thing, but I don't think Windows has anything like grep, awk and cut.

Code:
# Run tif2bsb for each .hdr file in directory.

ls -al | grep .hdr | awk '{print $9}' > ls.txt

    while [ 1 ]
    do
        read HEADERFILE || break
        FILE=$( echo $HEADERFILE | cut -d"." -f1)
        TIFFILE=$FILE.tif
        KAPFILE=$FILE.kap
        echo "tif2bsb $HEADERFILE $TIFFILE $KAPFILE"
        tif2bsb $HEADERFILE $TIFFILE $KAPFILE
    done < ls.txt

rm ls.txt

exit
-dan
dacust is offline   Reply With Quote
Old 01-11-2009, 12:22   #65
Obsfucator, Second Class
 
dacust's Avatar

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,745
Modifying MapCal is another story.

You might think they would jump at the chance, but then they might not. Creating BSB charts is at the very least on the border of legality. And why have they not made it an open source project? As far as I am aware, the source code is not available.

Even if they were to let me have the code, I very much doubt I could modify it without breaking more than I fix.

I'm not saying your thinking is bad. It's very good. Just probably not as simple as it sounds.

I'll try to contact the SeaClear people, though. So, what do we want to ask them? We'd like a button that calls mc2bsbh? Or actually, mc2bsb - which would be
  • mc2bsbh
  • convert (optional)
  • tif2bsb.
Since some people already have the charts in tif, probably 3 buttons:
  • mc2bsbh
  • mc2bsbh + tif2bsb (if tif already exists)
  • mc2bsbh + convert + tif2bsb

Then again, we might have to include some boxes to click for how the conversion should work. Does it need to go to an intermediate .gif?

Would we also like new fields to enter the missing elements?

EDIT: Of course I'd ask for the source code, as well.

-dan
dacust is offline   Reply With Quote
Old 01-11-2009, 12:52   #66
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 309
I have a friend that had a conversation with Olle, the Seaclear author, a couple of years ago and he declined to make it an open project.
It does not hurt to ask though.

Olle used to answer mail in the early days of its development. I did myself try to convince him n the early days to support BSB charts before he descided to do so and he used to answer and discuss ideas then.
I guess nowadays with probably tens of thousands of users it is just to much for any one person to handle. Seaclear has been around a long time, its totally free, its been advertised in numerous magazinbe articles, spread via "free" cover CDs, distributed as a free tool together with comercial BSB charts.
At some point he probably just turned off and continue to develop it for his own needs, and is just happy if someone else likes it.

EDIT. Dan, of course you should send that mail and ask him!

Jonas
jonasaberg is offline   Reply With Quote
Old 01-11-2009, 13:46   #67
Registered User

Join Date: Sep 2009
Location: Rome
Posts: 320
If someone is looking for a batch tif2bsb conversion in windows...

Copy the following code in a file and call the file convert.bat

Code:
@echo off
for %%I IN (*.HDR) DO (
    echo converting %%~nI.tif
    tif2bsb %%~nI.hdr %%~nI.tif %%~nI.kap
)
echo.
echo conversion complete
echo.
pause
Put convert.bat, a copy of tif2bsb.exe, all the xxx.hdr and the xxx.tif in the same directory

double click convert.bat

Of course you can modify convert.bat as you like.

Ciao, Marco.

P.S. it only works in OS>=windows2000
GPS-Marco is offline   Reply With Quote
Old 01-11-2009, 14:06   #68
Obsfucator, Second Class
 
dacust's Avatar

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,745
Quote:
Originally Posted by GPS-Marco View Post
If someone is looking for a batch tif2bsb conversion in windows...

Copy the following code in a file and call the file convert.bat

Code:
@echo off
for %%I IN (*.HDR) DO (
    echo converting %%~nI.tif
    tif2bsb %%~nI.hdr %%~nI.tif %%~nI.kap
)
echo.
echo conversion complete
echo.
pause
Put convert.bat, a copy of tif2bsb.exe, all the xxx.hdr and the xxx.tif in the same directory

double click convert.bat

Of course you can modify convert.bat as you like.

Ciao, Marco.

P.S. it only works in OS>=windows2000
COOL! That's even a little simpler than in Bash.

Thanks for doing that!

(But you named it the same name as "convert" from ImageMagick... I wish IM hadn't named it that.)

EDIT: I added it to my page along with the shell script.

-dan
dacust is offline   Reply With Quote
Old 01-11-2009, 14:43   #69
Registered User

Join Date: Sep 2009
Location: Rome
Posts: 320
Dan, I do not have linux, but something like that should work... (no ls.txt required)

Code:
#!/bin/bash
for filename in *.hdr
do
  echo "Converting $filename"
  tif2bsb $filename ${filename%.hdr}.tif ${filename%.hdr}.kap
done
read -p "Conversion complete. Press any key..."
Let me know

Ciao, Marco.
GPS-Marco is offline   Reply With Quote
Old 01-11-2009, 15:08   #70
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 309
Marco, thanks, I did not make it as fast as you!

Allthough it will work naming it convert.bat I would advice against naming it the same as the convert function in Image Magic. It is confusing to have a installed function with the same name as a bat file.

My suggestion for the file below is png2bsbb.bat
the last b for batch.

When Dans batch version is ready this should work. (Sticking my neck outfor untested code)

Now we are down to three steps:
1. Scan charts in *.png
2. Create calibrations with MapCalII, intermediate saves
3. run the script below.
Voala!

For security: Create a new directory containing image *.png files and a corresponding CHARTCAL.DIR
You also need installed Image Magic for the mogrify function to work.

Code:
@echo off
echo Converting *.png files using CHARTCAL.DIR to BSB/kap files

echo First step: Converting CHARTCAL.DIR to *.hdr files
 mc2bsbh CHARTCAL.DIR
echo Second step: Converting *.png files to *.gif files to force use of color palett
 mogrify -colors 127 -format gif *.png
echo Third step: Converting *.gif files to *.tif files
mogrify -colors 127 -format tif *.gif
for %%I IN (*.HDR) DO ( 
	echo converting %%~nI.tif to a BSB/kap file
	tif2bsb %%~nI.hdr %%~nI.tif %%~nI.kap
)
echo.
echo conversion complete
echo.
pause
I can't wait to try!
/Jonas
jonasaberg is offline   Reply With Quote
Old 01-11-2009, 15:09   #71
Obsfucator, Second Class
 
dacust's Avatar

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,745
Quote:
Originally Posted by GPS-Marco View Post
Dan, I do not have linux, but something like that should work... (no ls.txt required)

Code:
#!/bin/bash
for filename in *.hdr
do
  echo "Converting $filename"
  tif2bsb $filename ${filename%.hdr}.tif ${filename%.hdr}.kap
done
read -p "Conversion complete. Press any key..."
Let me know

Ciao, Marco.
Yep. That worked. I replaced mine with this one in my downloads.

Thanks, Marco!

-dan
dacust is offline   Reply With Quote
Old 01-11-2009, 18:10   #72
Obsfucator, Second Class
 
dacust's Avatar

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,745
It would be great to start a collection of New Zealand MapCal .DIRs. I'd be glad to post them on my site. If people want to post them or e-mail them to me, I'll put them up.

Even if I don't have the batch version of mc2bsbh working, yet, I can write a batch file that will call mc2bsbh and tif2bsb for each one so they can all be created at once. Put it all in a .zip for easy download and install.

-dan
dacust is offline   Reply With Quote
Old 02-11-2009, 04:46   #73
Obsfucator, Second Class
 
dacust's Avatar

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,745
Quote:
Originally Posted by jonasaberg View Post
I have a friend that had a conversation with Olle, the Seaclear author, a couple of years ago and he declined to make it an open project.
It does not hurt to ask though.

Olle used to answer mail in the early days of its development. I did myself try to convince him n the early days to support BSB charts before he descided to do so and he used to answer and discuss ideas then.
I guess nowadays with probably tens of thousands of users it is just to much for any one person to handle. Seaclear has been around a long time, its totally free, its been advertised in numerous magazinbe articles, spread via "free" cover CDs, distributed as a free tool together with comercial BSB charts.
At some point he probably just turned off and continue to develop it for his own needs, and is just happy if someone else likes it.

EDIT. Dan, of course you should send that mail and ask him!

Jonas
His reply was very nice. Turns out he used to live in Atlanta many years ago.

He basically says he has a license for BSB from NOAA for reading the charts, and doesn't think he should be involved.

-dan
dacust is offline   Reply With Quote
Old 02-11-2009, 06:32   #74
Registered User
 
sinbad7's Avatar

Join Date: Sep 2003
Location: Ubatuba,SP,Brazil (Ex Norway)
Boat: (Ex) Alu. 60' yacht-"Eight Bells"
Posts: 2,731
Images: 57
Send a message via Skype™ to sinbad7
Quote:
As a point of interest,our .kap conversion is ALSO readable by the shipplotter.com AIS browser. Wonder why it is not readable by Sea Clear?
I just posted this in the Chart thread... any comments??
__________________
"And all I ask is a tall ship and a star to steer her by."
sinbad7 is offline   Reply With Quote
Old 02-11-2009, 09:51   #75
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 309
Dan-
Nice to hear and good to know.

So, the next step is maybe to send a similar request to NOAA and ask for permission to generate unencrypted version2.0 or 3.0 BSB files in this non-profit project.

Maybe this would actually give us information about the BSB standard?
I think it is unlikelly but maybe not impossible.

Some info/statistics:
Starting in January 2009 about with 1000 downloads of OpenCPN per month. The latest version 1.3.4 has been downloaded over 15000 times during October and watching the statistics the number of downloads per version/month is steadily increasing.
Maybe it is worth arguing that the work is well underway to make a back-alley version to create kap files that thousands of people will use and then it is better to actually make sure the correct standardized kap files is actually created. This should be in NOAAs interest too if they indeed can give permission for this. I dont know the details of patents/copyrights.

I think I have read somewere that MapTech owns the rights to BSB creation and then it will probably be harder...

/Jonas
jonasaberg is offline   Reply With Quote
Reply

Tags
bsb


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
Bahamas Explorer Charts in BSB Format? geoffschultz Navigation 29 16-05-2015 10:21
Free (and Legal) BSB Charts from Maptech! exposure Navigation 15 31-07-2013 11:51
Sales Agreements - Template Anyone? cyberkitty Dollars & Cents 3 11-02-2010 14:49
OpenCPN with BSB v4 selkie Navigation 4 03-08-2009 11:32
Survey Template bbhflts Construction, Maintenance & Refit 3 23-06-2009 22:42

Advertise Here


All times are GMT -7. The time now is 15:31.


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.