Magdec BGL File
| This page is a work-in-progress. Generic message - Please note some detail may possibly be missing or incorrect. |
Introduction
The Magdec.bgl file is located in the ..\Scenery\Base\Scenery subfolder (FS2004, FSX and all P3D versions). It provides the basis for magnetic variation (declination) calculation by the simulator at current aircraft position.
By convention, East magnetic variation values are POSITIVE, while west values are NEGATIVE.
See this Wikipedia article for some basics regarding magnetic declination meaning.
File length is 130,468 bytes in FS2004 (offsets 0x0 to 0x1FDA3) and 130,456 bytes in FSX and P3D (offsets 0x0 to 0x1FD97)
File structure
Magdec.bgl file includes a header, a latitude/longitude table and optionally (FS2004 only) an ending string.
File header
File header is 136 bytes long (offsets 0x0 to 0x87) and has the following structure
| Offset | Length | Description | Content |
|---|---|---|---|
| 0x00 | 1 - BYTE | World set number | 0X01 |
| 0x01 | 127 - ? | Unknown | All 0, except 0x80 at offset 0x6E |
| 0x80 | 2 - WORD | Number of longitude values | 0x168 (360) |
| 0x82 | 2 - WORD | Number of latitude values | 0xB5 (181) |
| 0x84 | 1 - BYTE | Reference date day (?) | 0x01 |
| 0x85 | 1 - BYTE | Reference date month (?) | 0x01 (FS2004) - 0x11 (FSX/P3D) |
| 0x86 | 2 - WORD | Reference date year (?) | 0x1993 (FS2004) - 0x2006 (FSX/P3D) |
Latitude/Longitude table
Latitude/Longitude table is 130,320 bytes length and starts at offset 0x88
Magnetic variations for all entire degree latitude/longitude values are stored as a WORD list starting at E000-S90.
For each longitude value from E000 to W179, the list tabulates magnetic variations by increasing latitude from S90 to N90
This organization can be sumarized as follows
E000 (S90->S89->S88...->S01->N00->N01->...->N90), then
E001 (S90->S89->S88...->S01->N00->N01->...->N90), followed by E002, E003 lines
...
E180 (S90->S89->S88...->S01->N00->N01->...->N90), then
W179 (S90->S89->S88...->S01->N00->N01->...->N90), followed by W178, W177 lines
...
W001 (S90->S89->S88...->S01->N00->N01->...->N90) that is the last line
Therefore, for each of the 360 longitude values, there is 181 latitude values for a total of 65,160 consecutive WORD values.
First value of this table is at offset 0x88 (E000/S90) and last is at offset 0x1FD96 (W001/N90).
References
Translation - Ask Fr. Bill.