- Messages
- 34,981
- Country

My head hurts
I am trying to understand how the packing of ICAO codes works in the bgl file format.
Reading Winfried's documentation each letter or number has a value between 0...37 With:
blank 00
digits 0 .. 9 02 .. 11
letters A .. Z 12 .. 37
I am to take the leftmost letter/number coded as above and multiply it by 38. I then add the next letter/number code to the result and multiply that by 38. Keep going until all the letters/numbers have been consumed. Multiply the result by 0x20 to left shift it by 5 bytes and hey presto that is the packed number!
Well not here it ain't!! So I must be doing something wrong - consistently.
Take MXA3 - M=24, X=35, A=12 and 3=5. The result in the bgl file for this is 43773729 but if I use the above calculation (WITHOUT the shift) I get 51981302. Compare the two numbers and mine is 1.187499973 times the number stored in the bgl.
I tried 6 other ICAOs and in each case got a value 1.18749973 times the value in the BGL file. Clearly I don't understand how this works so any help would be much appreciated.
I am trying to understand how the packing of ICAO codes works in the bgl file format.
Reading Winfried's documentation each letter or number has a value between 0...37 With:
blank 00
digits 0 .. 9 02 .. 11
letters A .. Z 12 .. 37
I am to take the leftmost letter/number coded as above and multiply it by 38. I then add the next letter/number code to the result and multiply that by 38. Keep going until all the letters/numbers have been consumed. Multiply the result by 0x20 to left shift it by 5 bytes and hey presto that is the packed number!
Well not here it ain't!! So I must be doing something wrong - consistently.
Take MXA3 - M=24, X=35, A=12 and 3=5. The result in the bgl file for this is 43773729 but if I use the above calculation (WITHOUT the shift) I get 51981302. Compare the two numbers and mine is 1.187499973 times the number stored in the bgl.
I tried 6 other ICAOs and in each case got a value 1.18749973 times the value in the BGL file. Clearly I don't understand how this works so any help would be much appreciated.
Last edited:


