BGL File Format

From FSDeveloper Wiki
Revision as of 09:07, 3 March 2016 by MichaelCox (talk | contribs) (minor updates)
Jump to navigationJump to search

Introduction

The information contained in this wiki comes from different sources:

  • "FSX File structure" by Winfried Orthmann
This is the first document about BGL file format. It describes the generic format of a BGL file and the content of some important sections like Airport, Scenery Objects,etc.
  • "FS9 FSX_BGL_Format.doc" by Jon Masterson (a.k.a. ScruffyDuck)
  • Some reverse engineering work on the TmfViewer and BglComp applications by Patrick Germain



BGL Common Format

All BGL files share the same generic format. A BGL file is made of a header, sections, subsections and subsection data. Subsections are children of sections. The sections are here to help us locate the subsections in the file. Data specific information is contained in the subsections data and their format is dependent on the section type.
A BGL file is really a big container where all kind of information can be stored (in the subsection).The meaning of the data contained in the subsections is known only by the application using it. Th only contraint is for the file to comply to the generic format described below.

A BGL file always start with a header (Size = 0x38 bytes), followed by a list of section pointers. The number of section pointers is defined in the header.

File Header

The header consists of 0x38 (56) bytes. It contains the number of sections defined in the file as well as the bounding geographical coordinates of the covered squared area.

Offset Number of bytes Description
0x00 4 - DWORD Magic Number #1 – Must be 0x01, 0x02, 0x92, 0x19
0x04 4 - DWORD Header size : 0x38
0x08 4 - DWORD dwLowDateTime of the FILETIME structure.
Date and Time the file was created

The FILETIME structure represents the number of 100-nanosecond intervals since January 1, 1601
See Working with the FILETIME Structure.

0x0C 4 - DWORD dwHighDateTime of the FILETIME structure
0x10 4 - DWORD Magic Number #2 – Must be 0x03, 0x18, 0x05, 0x08
Maybe to identify the FS version
0x14 4 - DWORD The number of sections following this header.
0x18 32 Array[8] of unsigned integers (DWORD).

Each value derives from a QMID(l,u,v). See the algorithm in Annexe A to retrieve l,u,v values from these dwords. In that case, the second DWORD needed by the algorithm is zero.
The QMIDs (up to 8) define the area covered in this BGL file.
Even if 8 slots are provided, it is not necessary to have all 8 values filled. The list stops at the first null (0x00000000) value.
You can also get the upper-left corner and lower-right corner coordinates of each QMID using Computing the bounding coordinates from a DWORD value.
To get the bounding coordinates of the area covered by the file, just keep the minimal and maximal values from each bounding coordinates.

See also How are the header QMIDs computed? in Annexe A.



Example

For example, in CVX2815.bgl :

Offset Values Description
0x00
01 02 92 19
Magic Number #1
0x04
38 00 00 00
Header size
0x08
EF 82 DF E2
Low = 3806298863
0x0C
E8 C7 C6 01
High = 29804520
=> February 27, 2007
0x10
03 18 15 08
Magic Number #2
0x14
01 00 00 00
1 section following this header
0x18
E8 07 02 00
MinLatitude(Deg) = 46.40625
MaxLatitude(Deg) = 47.8125
MinLongitude(Deg) = -75.0
MaxLongitude(Deg) = -73.125

QMID (u=56, v=30, l=8) , using 0x000207E8 as A and 0 as B in this algorithm.

0x1C
E9 07 02 00
MinLatitude(Deg) = 46.40625
MaxLatitude(Deg) = 47.8125
MinLongitude(Deg) = - 73.125
MaxLongitude(Deg) = -71.25

QMID (u=57, v=30, l=8)

0x20
EA 07 02 00
MinLatitude(Deg) = 45.0
MaxLatitude(Deg) = 46.40625
MinLongitude(Deg) = -75.0
MaxLongitude(Deg) = -73.125

QMID (u=56, v=31, l=8)

0x24
EB 07 02 00
MinLatitude(Deg) = 45.0
MaxLatitude(Deg) = 46.40625
MinLongitude(Deg) = -73.124
MaxLongitude(Deg) = -71.25

QMID (u=57, v=31, l=8)

0x28
00 00 00 00
0x2C
00 00 00 00
0x30
00 00 00 00
0x34
00 00 00 00

You’ll notice that only 4 subareas are defined (on a possibility of 8) and the last 4 available slots are empty (Value = 0)
So the bounding coordinates of the area covered by cvx2815.bgl are:

MinLatitude(Deg) = 45.0
MaxLatitude(Deg) = 47.8125
MinLongitude(Deg) = -75.0
MaxLongitude(Deg) = -71.25

Sections

Following the header, at offset 0x38, there are as many sections as defined at offset 0x14 of the header. A same file may contain sections of different type. Each section has a size of 20 bytes and has the following structure:

Relative Offset Number of bytes Description
0x00 4 - DWORD Section type (as defined by microshit Flight Simulator): one of the following values:

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

Offers private label cosmetics with custom design. We produce lip balms, serum, creams and more. Easy to buy with eshop. Private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]

[private label cosmetics, custom made cosmetic, custom made cream, custom lip stick lip balm]