Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Rate Thread Display Modes
Old 25-10-2009, 12:47   #1
Obsfucator, Second Class
 
dacust's Avatar

Cruisers Forum Supporter

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,743
mc2bsbh - MapCal Template to BSB Template Conversion

With Marco's help, we have a conversion tool to convert MapCal templates to BSB headers.

When you geo-reference a scanned chart in Map Cal, it puts out a text file with information about the chart. mc2bsbh will take this file and create a BSB header file. So, now you can use MapCal to georeference a chart to be used in OpenCPN.

The discussion and download links are found on the MapCal Utilities page. There you will find the Windows executable, c++ source to compile on your chosen platform, and the template files used for development and testing.

This is DEFINITELY a beta. Probably have much work to do, but I used it on one chart with success.

If there is any interest, we can put it in SourceForge as an open source project. I'll be a little surprised if the audience extends much beyond the readers of the OpenCPN threads, but who knows. I'm mainly saying this so if anyone wants to contribute, they needn't worry about me keeping it to myself.

Dave: If you got nothing better to do, look at my newbie code and tell me how bad it is. Among other things, I couldn't figure out how to start back at the beginning of a file to read it a second time, so I just defined it again. And the type conversions are killing me. But, it's only my third program. I'm learning.

-dan
__________________

dacust is offline   Reply With Quote
Old 25-10-2009, 13:59   #2
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 305
Absolutely fabulous!

Thanks Dan
__________________

__________________
jonasaberg is offline   Reply With Quote
Old 25-10-2009, 14:25   #3
Obsfucator, Second Class
 
dacust's Avatar

Cruisers Forum Supporter

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,743
Quote:
Originally Posted by jonasaberg View Post
Absolutely fabulous!

Thanks Dan
Thank Marco. He did all the real work by creating the data map. All I did was code it to do what he said.

-dan
dacust is offline   Reply With Quote
Old 25-10-2009, 14:52   #4
Registered User

Join Date: Sep 2009
Location: Rome
Posts: 320
Great first shot Dan!!!

Of course we have some work to do!

I just repeat here, also to get the forum participant's opinion, the point I've already told you and that will need a little more coding:

1)

missing CED/ like

CED/SE=2009,RE=12,ED=10/10/2009

well CED should be Chart Edition Date. I think the meaning is SE=Starting Edition, RE=revision number, ED=Edition Date. I'd put a default like SE= the year of today (the date the program runs), RE=1, ED= the date of today. But I'd also define a new optional parameter ti be given to the program like [-CED SE=2000,RE=4,ED=1/1/2008] that, if present, would override the default. Note that the ED date is the one shown by OpenCPN as chart date.

2)

> KNP/SC=48000,GD=WGS84,PR=TRANSVERSE MERCATOR
> PP=0,PI=UNKNOWN,SP=UNKNOWN,SK=0.0
> UN=UNKNOWN,SD=LAT,DX=4.08,DY=4.08

I guess that PI=0.0 and SP=0.0 is better than UNKNOWN (any other opinions?)

SD=LAT ??? Better to hard code a SD=MEAN LOW WATER SPRINGS. We will check later on if there is a better solution

Then I add something more, I saw just now:

- the DU calculation seems not working (I found DU=0 in the header result)

- "BSB/NA=*** - USE AT YOUR OWN RISK!" ... I think is too much! this is just the map name that will be shown by OCPN. Just leave what people have input in MapCal.

- "! Created by mc2bsbh - Use at your own risk!" ... This place should be for the copyright. There is a CRR/ template for the notes. Following is from a NOAA map:

Code:
CRR/This electronic chart was produced under the authority of USA-NOAA/NOS.
    By using this chart you acknowledge that you have read, understood
    and accepted the terms and conditions stated in the User Agreement:
    http://www.nauticalcharts.noaa.gov/mcd/Raster/download_agreement.htm
The following is still from the NOAA map:
Code:
KNP/SC=80000,GD=NAD83,PR=MERCATOR,PP=32.250,PI=10.000,SP=,SK=0.0000000
    TA=90.0000000,UN=FEET,SD=MEAN LOWER LOW WATER,DX=8.00,DY=8.00
I can say:

add a PI=0.0, before the SP=
add a TA=90.0, before the UN=

- I still saw a DTM=60,0.6 instead of DTM/60,0.6

Anyway, let me thank you for your effort.

Ciao, Marco.
__________________
GPS-Marco is offline   Reply With Quote
Old 25-10-2009, 15:03   #5
Registered User

Join Date: Sep 2009
Location: Rome
Posts: 320
MapCal & Wine

Hello penguins

Can some Linux fan try to check if MapCal can be used under wine?

I saw this about SeaClear... WineHQ - SeaClear

Thanks, Marco.
__________________
GPS-Marco is offline   Reply With Quote
Old 25-10-2009, 15:08   #6
Obsfucator, Second Class
 
dacust's Avatar

Cruisers Forum Supporter

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,743
Quote:
Originally Posted by GPS-Marco View Post
Great first shot Dan!!!

Of course we have some work to do!

I just repeat here, also to get the forum participant's opinion, the point I've already told you and that will need a little more coding:

1)

missing CED/ like

CED/SE=2009,RE=12,ED=10/10/2009

well CED should be Chart Edition Date. I think the meaning is SE=Starting Edition, RE=revision number, ED=Edition Date. I'd put a default like SE= the year of today (the date the program runs), RE=1, ED= the date of today. But I'd also define a new optional parameter ti be given to the program like [-CED SE=2000,RE=4,ED=1/1/2008] that, if present, would override the default. Note that the ED date is the one shown by OpenCPN as chart date.

Since we don't know the date of the original chart, should we put anything in here at all?

2)

> KNP/SC=48000,GD=WGS84,PR=TRANSVERSE MERCATOR
> PP=0,PI=UNKNOWN,SP=UNKNOWN,SK=0.0
> UN=UNKNOWN,SD=LAT,DX=4.08,DY=4.08

I guess that PI=0.0 and SP=0.0 is better than UNKNOWN (any other opinions?)

Since I saw UNKNOWN in some of my headers, isn't UNKNOWN better the 0, which could be a valid value?

SD=LAT ??? Better to hard code a SD=MEAN LOW WATER SPRINGS. We will check later on if there is a better solution

Then I add something more, I saw just now:

- the DU calculation seems not working (I found DU=0 in the header result)

Hmmm, while debuggung, I thought dx and dy were 0 which would explain. But I was wrong. That's a bug to fix.

- "BSB/NA=*** - USE AT YOUR OWN RISK!" ... I think is too much! this is just the map name that will be shown by OCPN. Just leave what people have input in MapCal.

- "! Created by mc2bsbh - Use at your own risk!" ... This place should be for the copyright. There is a CRR/ template for the notes. Following is from a NOAA map:

Code:
CRR/This electronic chart was produced under the authority of USA-NOAA/NOS.
    By using this chart you acknowledge that you have read, understood
    and accepted the terms and conditions stated in the User Agreement:
    http://www.nauticalcharts.noaa.gov/mcd/Raster/download_agreement.htm
Maybe so. I just kinda wanted a warning to show on the screen. Maybe it shouldn't though.

The following is still from the NOAA map:
Code:
KNP/SC=80000,GD=NAD83,PR=MERCATOR,PP=32.250,PI=10.000,SP=,SK=0.0000000
    TA=90.0000000,UN=FEET,SD=MEAN LOWER LOW WATER,DX=8.00,DY=8.00
I can say:

add a PI=0.0, before the SP=
add a TA=90.0, before the UN=

I can hard-code those if you think it's necessary.

- I still saw a DTM=60,0.6 instead of DTM/60,0.6

I think this relates to the dx/dy bug from above.

Anyway, let me thank you for your effort.

Ciao, Marco.
See my comments above. And thanks for all your input!
dacust is offline   Reply With Quote
Old 25-10-2009, 15:21   #7
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 305
Tried it with one of my charts and it works great . Thanks again Dan and Marco.

I agree with Marco regarding erasing the "...use at own risk" comment.
I don't think there is a way to input the date of the chart (CED) in MapCal so it wont be able to convert that to the template file.

The text written in the big text box in MapCal "Other information" turns up as the "CR" heading in Chartcal.dir. It would be nice if this could be fed into a heading in the kap file and be possible to view from within OpenCPN. Needs to be checked so it does'nt interfer with the kap format...
Example from my test:
"CR=Soundings and heights in metres reduced to mean sea level 1980.
Land rise 0.4cm annually"

The created chart shows fine in OpenCPN, I guess we have to do some testing to see wether the missing parameters will activelly affect its usability...

Some reflections:
Of course, all the old knowledge gained about requirements for tif2bsb still holds. We need a tif using a color palet with max 127 colors.

Most seacharts I have seen has considerably less color than this and they are typical bitmapped-prone. They contain large areas of the same color as opposed to photographs which typically do not have two adjacent pixels with the same color. Photographs compress well with the jpg format. Bitmaped images is better used better with png, which also works well in MapCal II.
Png is also a lossless compression format.
Jpg versions of bitmapped files typicaly give artefacts like blurred text and blurred bordersbetween adjacent color fields.

My suggestion is to avoid jpg when scanning scarts. I think avoiding jpg will make better and smaler chart files.

So, my suggestion is to:
-Scan the image to png using a limited amount if colors (maybe 16, 32 or so..)
-Create a calibration by using MapCal.
-Convert the image by first converting to a gif.
By doing so a palette with 256 colors is forced since this is a part of the gif standard.
c:\kap\convert infile.png infile.gif
-Convert the gif to a tif.
c:\kap\convert infile.gif infile.tif

and finally create the kap file using tif2bsb.
c:\kap\tif2bsb template.txt infile.tif

I have tried this for a few files and it works just fine!
Maybe there is a way to make sure a color palet is used when converting from png to tif using some option setting, this would be great.

Also, and maybe I should repeat this as a new feature request, it would be nice to be able to see the chart/kap info inside of OpenCPN. I cant find a way to do that now.

/Jonas
__________________
jonasaberg is offline   Reply With Quote
Old 25-10-2009, 15:22   #8
Senior Cruiser
 
sinbad7's Avatar

Cruisers Forum Supporter

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

BUT...where does MapCal store the CHARTCAL.DIR file?? Is it overwritten for each calibration? I recently calibrated a map but I found no CHARTCAL.DIR file...
__________________
"And all I ask is a tall ship and a star to steer her by."
sinbad7 is offline   Reply With Quote
Old 25-10-2009, 15:23   #9
Obsfucator, Second Class
 
dacust's Avatar

Cruisers Forum Supporter

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,743
Fixed DU

DS=0, which is where the DTM is derived, so I think the DTM calculation is correct.

Since this header works, I don't think I want to add hardcoded stuff until someone comes forward with information as to why it is required for some other nav package. Hopefully, they will come forward with why it is needed and how we need to calculate it.

New code posted.

It would be great for people to post some other MapCal headers that have different pieces in them, just so we know we are catching it all. I'll be glad to run the conversion and post the results.

-dan
dacust is offline   Reply With Quote
Old 25-10-2009, 15:23   #10
Registered User

Join Date: Sep 2009
Location: Rome
Posts: 320
Dan,

> Since we don't know the date of the original chart, should we put anything in here at all?


Maybe you are right (we must check that the SWs do not complain the absence). But of course a parameter like [-CED SE=2000,RE=4,ED=1/1/2008] should be handled

Since I saw UNKNOWN in some of my headers, isn't UNKNOWN better the 0, which could be a valid value?

Maybe you are right (we must check that the SWs do not complain the string UNKNOWN where they are expecting a number...). In my charts I sometimes see just nothing like the SP value in the NOAA chart (PI=10.000,SP=,SK=0.0000000)

Ciao, Marco.
__________________
GPS-Marco is offline   Reply With Quote
Old 25-10-2009, 15:36   #11
Registered User

Join Date: Sep 2009
Location: Rome
Posts: 320
Quote:
Originally Posted by dacust View Post
DS=0, which is where the DTM is derived, so I think the DTM calculation is correct.
Dan, The DTM calculation is perfect. But the output syntax in the header file should not be

DTM=0,0

but it should be

DTM/0,0

There is just the char = that shall be a /

Ciao, Marco.
__________________
GPS-Marco is offline   Reply With Quote
Old 25-10-2009, 15:37   #12
Obsfucator, Second Class
 
dacust's Avatar

Cruisers Forum Supporter

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,743
Quote:
Originally Posted by jonasaberg View Post
I agree with Marco regarding erasing the "...use at own risk" comment.
OK, I removed that.

Quote:
Originally Posted by jonasaberg View Post
I don't think there is a way to input the date of the chart (CED) in MapCal so it wont be able to convert that to the template file.

The text written in the big text box in MapCal "Other information" turns up as the "CR" heading in Chartcal.dir. It would be nice if this could be fed into a heading in the kap file and be possible to view from within OpenCPN. Needs to be checked so it does'nt interfer with the kap format...
Example from my test:
"CR=Soundings and heights in metres reduced to mean sea level 1980.
Land rise 0.4cm annually"
Get me a copy of a MapCal DIR with the CR heading and I'll at least get it into a comment, for starters.

Quote:
Originally Posted by sinbad7 View Post
Fantastic .. Dan and Marco...

BUT...where does MapCal store the CHARTCAL.DIR file?? Is it overwritten for each calibration? I recently calibrated a map but I found no CHARTCAL.DIR file...
You'll have to ask Jonas or Marco. Funny, but I've never used MapCal...

Quote:
Originally Posted by GPS-Marco View Post
Maybe you are right (we must check that the SWs do not complain the absence). But of course a parameter like [-CED SE=2000,RE=4,ED=1/1/2008] should be handled
Hmmm, using switches like that will take me some time to learn. It calls for some complicated code to examine incoming arguments.

Quote:
Originally Posted by GPS-Marco View Post
we must check that the SWs do not complain the string UNKNOWN where they are expecting a number...). In my charts I sometimes see just nothing like the SP value in the NOAA chart (PI=10.000,SP=,SK=0.0000000)

Ciao, Marco.
I have seen the empty parms, as well. We can adjust as needed when people try the charts in programs other than OpenCPN.

-dan
dacust is offline   Reply With Quote
Old 25-10-2009, 15:38   #13
Obsfucator, Second Class
 
dacust's Avatar

Cruisers Forum Supporter

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,743
Quote:
Originally Posted by GPS-Marco View Post
Dan, The DTM calculation is perfect. But the output syntax in the header file should not be

DTM=0,0

but it should be

DTM/0,0

There is just the char = that shall be a /

Ciao, Marco.
Oh. Silly me. Fixed.
dacust is offline   Reply With Quote
Old 25-10-2009, 15:53   #14
Registered User

Join Date: Sep 2009
Location: Rome
Posts: 320
Quote:
Originally Posted by sinbad7 View Post
Fantastic .. Dan and Marco...

BUT...where does MapCal store the CHARTCAL.DIR file?? Is it overwritten for each calibration? I recently calibrated a map but I found no CHARTCAL.DIR file...
Tore, you can calibrate bmp and png (not tif, as far as I know)

The best process is:
1) Run mapcalc
2) Load the map,
3) put 3 calibration points (not aligned!)
4) click File->SaveCalibration

this will create the CHARTCAL.DIR in the same directory of the map

But you have not finished!

5) continue to add calibration points. Now things are esier since mapcalc guess the lat/long of the point you insert and you have only to slightly correct the guessed value. If the values are very far from what you expect, this means the first 3 points you saved contain some error(s)

6) after the calibration, go to the Border tab and draw the border of the map: you must follow the limit between the usable map (for navigation purpose) and the non usable map.

At the end, save again the calibration. This CHARTCAL.DIR will overwrite the previous and will contain all the reference point and all the border points.

This is the final CHARTCAL.DIR that mc2bsbh can convert in the kap header you need.

Ciao, Marco.
__________________
GPS-Marco is offline   Reply With Quote
Old 25-10-2009, 16:33   #15
Obsfucator, Second Class
 
dacust's Avatar

Cruisers Forum Supporter

Join Date: Feb 2008
Location: Southeast USA.
Boat: 1982 Sea Ray SRV360
Posts: 1,743
Quote:
Originally Posted by GPS-Marco View Post
[COLOR=Blue]Maybe you are right (we must check that the SWs do not complain the absence). But of course a parameter like [-CED SE=2000,RE=4,ED=1/1/2008] should be handled
Well, I thought it would be a problem, but it wasn't as bad as I thought.

It will now handle a "-ced" and insert the line. Right now, it requires lower case for the switch, but I'll make it so it will accept upper, as well.

Also, if there is a CR line, it will put it in as a comment. I suspect from your example that it may possibly go over more than one line, though. So I'd like an example with a very long comment to work with.

-dan
__________________

dacust is offline   Reply With Quote
Reply

Tags
bsb

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



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

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


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

ShowCase vBulletin Plugins by Drive Thru Online, Inc.