Cruisers Forum
 


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 13-05-2012, 12:33   #1
Registered User

Join Date: May 2012
Posts: 13
.kap files header

hi,

i need to read .kap file for writting vb.net app.
i found information about header .kap files at :
https://github.com/ngacharts/ngachar...r-and-bsb-file

but some mistake?

REF field give reference point from x,y image position to geoposition (index,x,y,lat,lon)
but in some kap file i found that :

REF/1,7752,754,43.666666667,5.216666667
REF/2,7770,11463,41.233333333,5.216666667
REF/3,315,11502,41.233333333,2.916666667
REF/4,297,793,43.666666667,2.916666667

i've got same longitude (2,91666) for different x pos 315 and 297.....?

Opencpn give me the right position how he do it that?

my kap file are official files from SHOM charts and GE2KAP files generated
I've only right pos with opencpn kap files

anothers things :

numer and order of REF fildeds are not fixed ?
and what is exactlly PLY fileds ?

Thanks
r2b2s is offline   Reply With Quote
Old 13-05-2012, 13:01   #2
Registered User
 
jonasaberg's Avatar

Join Date: Jul 2008
Location: Kristiansand, Norway
Boat: Wasa 410
Posts: 309
Re: .kap files header

There's a monster thread discussing how to make your own charts
http://www.cruisersforum.com/forums/...tml#post339045

also, some condensed information on the opencpn web page

imgkap | Official OpenCPN Homepage

and, I am sure, some of the Opencpn gurus will follow up with more info soon... ;-)

Ply defines the extent of the chart. You may think of it as a number of coordinates that circumvent the part of the chart that is "charted". Typically its the area that is within the white rim of the paper chart. That would take 4 PLY points. For some other charts it would be more complicated with more PLY points.
jonasaberg is offline   Reply With Quote
Old 13-05-2012, 13:06   #3
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,145
Re: .kap files header

This is normal when the chart image is not an ideal rectangle (or the calibration is wrong). Pretty usual for charts coming from scans of paper originals.
Number of the REF and PLY points is not fixed, let's say there can be up to 99 of them (then some parsers could perhaps get confused). In the ngacharts project we used clockwise order starting from lower left corner and it worked in all the tested charting software.
To make the resulting kap look better it's quite handy to apply some image corrections during the creation process as you can use way smarter (and slower) image processing algorithms than those that can be implemented in the chartplotter. Have a look at the code in the ngacharts project - we had the corner coordinates, so calculating the needed rotation was pretty easy, but it will show you what I mean.

PLY points define the polygon covered by the actual chart in the bitmap, which serves to get rid of the white border with text, inset plans etc. and allows the charts to quilt.

If you need more info let me know

Pavel
nohal is online now   Reply With Quote
Old 13-05-2012, 14:19   #4
Registered User

Join Date: May 2012
Posts: 13
Re: .kap files header

Thank at all

Ngacharts project are broken urls ...

I just would like how can i get the right calculation for convert x and y to l'on and lat géoposition maybe middel from each REF fields... ??

What you thing about that ? How can i get or set right geoposition from or to x and y location on my raster image file

Thank.... I'm going to bed right now i'm sure i'll read something tomorow thank
r2b2s is offline   Reply With Quote
Old 14-05-2012, 00:14   #5
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,145
Re: .kap files header

By ngacharts project I meant the code for the tooling at github, not the website with the produced charts, which unfortunately is and will have to stay, offline. - Browse the code at the same place where you found the header docs, notably https://github.com/ngacharts/ngachar.../tools/KAPtool, which is the toolkit used to produce all the thousands of charts and I spent a good few dozen hours of research and coding making it produce kaps of reasonable quality.

I don't want to sound discouraging, but I would suggest you study the subject of chart creation a little bit more before you start to write some code. The bare minimum being
Mercator projection - Wikipedia, the free encyclopedia
Transverse Mercator projection - Wikipedia, the free encyclopedia
Rotation matrix - Wikipedia, the free encyclopedia

If you really need some math without actually realizing what you do, here's a simple calculation for a perfect rectangle chart in lat/lon projection:
Code:
latPerPixel = (LatMax-LatMin) / (Ymax - Ymin)
lonPerPixel = (LonMax-LonMin) / (Xmax - Xmin)
latXY = LatMin + (Y - Ymin) * latPerPixel;
lonXY = LonMin + (X - Xmin) * lonPerPixel;
You will soon realize it's not what you need (If you will read the first two links above, you won't even have to convert it into code - in reality Earth is a sphere and so different projections have to be used to convert it to a plain piece of paper. For example parallels are not equally spaced in Mercator projection, so the latitude will always be wrong using this calculation, the only projection for which the above formula is 100% valid is LAT/LON projection, not used on nautical charts. But it looks simple enough.)

Pavel
nohal is online now   Reply With Quote
Old 14-05-2012, 09:13   #6
Registered User

Join Date: May 2012
Posts: 13
Re: .kap files header

Thank Pavel

I'll read your link. I know that projection are math complicate...

But i don't need a lot of précision. I'll use my code for displaying the boat trip on Google earth image on a large screen in passengers are (day touristic trip) and for display some photo when the boat will be on approch from spécial place.

Thank again
r2b2s is offline   Reply With Quote
Reply

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


Advertise Here


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


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.