BGLXML - a freeware multi-platform decompiler for FS2004 BGL files

(C) 2004-2005, Alessandro G. Antonini - (Central Park Informatica)


What is BGLXML?

BGLXML is an utility which analyzes and decompiles BGL files into FS2004 format and produces human readable XML files to be recompiled with Microsoft BGLCOMP (which is available from FS2004 SDK page). It fully supports almost if not all options included into new BGL file format (Microsoft has introduced significant changements since previous FS releases). If a BGL file contains objects created with Microsoft MakeMDL (which is the utility to convert three-dimensional objects created with GMax), BGLXML is able to extract them and write back to hard disk in .MDL format (for each XML file produced by BGLXML there will be nnn MDL files in the same directory than XML). BGLXML is also able to decode all objects into a BGL or only those interesting you (see Partial decode switches below).


BGLXML License

BGLXML is freeware, open-source, and is licensed under GNU GPL - if you are in doubt about what this means, please read the COPYING file which is contained inside the distribution archive.

**** FRIENDLY WARNING ***
GNU General Public License implies that any application and / or program library must be redistributed with source code (or with the chance to get source code for anybody making request of it). Therefore, if you build a program or a library using BGLXML source code, then you also have to release it under GNU GPL (with source code). If this bothers, you don't have to use even a line of BGLXML source code within your programs.


WARRANTY
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
INSTALLATION

Simply create a directory on your hard drive and UNZIP the distribution archive inside it. You have four executable files, which are:

The rest of the distribution archive contains:


IMPORTANT: CHANGES to BGLCOMP.XSD !!!

Please note that the original BGLCOMP.XSD (the schema file) supplied by Microsoft along with BGLCOMP archive is incomplete and has typos. Therefore you have to apply some changes before allowing recompilation of decompiled files. Open BGLCOMP.XSD (located in the same path of BGLCOMP.EXE) with your favorite text editor (don't open it with applications like WORD or WORDPAD - use NOTEPAD.EXE, instead) and do the changes as shown below:

<xs:complexType name="ctVor">
    <xs:sequence>
        <xs:element name="Dme" type="ctDme" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="VisualModel" type="ctVisualModel" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="lat" form="unqualified" type="stLatitude" />
    <xs:attribute name="lon" form="unqualified" type="stLongitude" />
    <xs:attribute name="alt" form="unqualified" type="stAltitude" />
    <xs:attribute name="type" form="unqualified" type="stVorType" />
    <xs:attribute name="frequency" form="unqualified" type="stFrequencyMhz" />
    <xs:attribute name="magvar" form="unqualified" type="stAngle" />
    <xs:attribute name="region" form="unqualified" type="stString2" />
    <xs:attribute name="ident" form="unqualified" type="stString5" />
    <xs:attribute name="name" form="unqualified" type="stString48" />
    <xs:attribute name="nav" form="unqualified" type="stBool" />
    <xs:attribute name="dmeOnly" form="unqualified" type="stBool" />
    <xs:attribute name="dme" form="unqualified" type="stBool" />
</xs:complexType>

The above won't allow to compile VOR. Replace with below (missing range attribute):

<xs:complexType name="ctVor">
    <xs:sequence>
        <xs:element name="Dme" type="ctDme" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="VisualModel" type="ctVisualModel" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="lat" form="unqualified" type="stLatitude" />
    <xs:attribute name="lon" form="unqualified" type="stLongitude" />
    <xs:attribute name="alt" form="unqualified" type="stAltitude" />
    <xs:attribute name="type" form="unqualified" type="stVorType" />
    <xs:attribute name="frequency" form="unqualified" type="stFrequencyMhz" />
    <xs:attribute name="magvar" form="unqualified" type="stAngle" />
    <xs:attribute name="region" form="unqualified" type="stString2" />
    <xs:attribute name="ident" form="unqualified" type="stString5" />
    <xs:attribute name="name" form="unqualified" type="stString48" />
    <xs:attribute name="range" form="unqualified" type="stDistance" />

    <xs:attribute name="nav" form="unqualified" type="stBool" />
    <xs:attribute name="dmeOnly" form="unqualified" type="stBool" />
    <xs:attribute name="dme" form="unqualified" type="stBool" />
</xs:complexType>

Changes to ctSceneryObject to allow compile BiasXYZ parameters:

<xs:complexType name="ctSceneryObject">
    <xs:sequence>
        <xs:element name="LibraryObject" type="ctLibraryObject" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="Effect" type="ctEffect" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="Trigger" type="ctTrigger" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="Windsock" type="ctWindsock" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="AttachedObject" type="ctAttachedObject" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="GenericBuilding" type="ctGenericBuilding" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="lat" form="unqualified" type="stLatitude" />
    <xs:attribute name="lon" form="unqualified" type="stLongitude" />
    <xs:attribute name="alt" form="unqualified" type="stAltitude" />
    <xs:attribute name="altitudeIsAgl" form="unqualified" type="stBool" />
    <xs:attribute name="pitch" form="unqualified" type="stAngle" />
    <xs:attribute name="bank" form="unqualified" type="stAngle" />
    <xs:attribute name="heading" form="unqualified" type="stHeading" />
    <xs:attribute name="imageComplexity" form="unqualified" type="stComplexity" />
</xs:complexType>

Replace with:
<xs:complexType name="ctSceneryObject">
    <xs:sequence>
        <xs:element name="BiasXYZ" type="ctBias" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="LibraryObject" type="ctLibraryObject" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="Effect" type="ctEffect" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="Trigger" type="ctTrigger" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="Windsock" type="ctWindsock" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="AttachedObject" type="ctAttachedObject" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="GenericBuilding" type="ctGenericBuilding" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="lat" form="unqualified" type="stLatitude" />
    <xs:attribute name="lon" form="unqualified" type="stLongitude" />
    <xs:attribute name="alt" form="unqualified" type="stAltitude" />
    <xs:attribute name="altitudeIsAgl" form="unqualified" type="stBool" />
    <xs:attribute name="pitch" form="unqualified" type="stAngle" />
    <xs:attribute name="bank" form="unqualified" type="stAngle" />
    <xs:attribute name="heading" form="unqualified" type="stHeading" />
    <xs:attribute name="imageComplexity" form="unqualified" type="stComplexity" />
</xs:complexType>

Changes to ctTaxiwayPath to allow compile TaxiwayPath properly:

<xs:complexType name="ctTaxiwayPath">
    <xs:attribute name="start" form="unqualified" type="xs:nonNegativeInteger" />
    <xs:attribute name="end" form="unqualified" type="xs:nonNegativeInteger" />
    <xs:attribute name="type" form="unqualified" type="stTaxiwayPathType" />
    <xs:attribute name="surface" form="unqualified" type="stSurface" />
    <xs:attribute name="width" form="unqualified" type="stDistance" />
    <xs:attribute name="weightLimit" form="unqualified" type="xs:nonNegativeInteger" />
    <xs:attribute name="name" form="unqualified" type="xs:nonNegativeInteger" />
    <xs:attribute name="centerLine" form="unqualified" type="stBool" />
    <xs:attribute name="centerLineLighted" form="unqualified" type="stBool" />
    <xs:attribute name="leftEdgeLighted" form="unqualified" type="stBool" />
    <xs:attribute name="rightEdgeLighted" form="unqualified" type="stBool" />
    <xs:attribute name="leftEdge" form="unqualified" type="stTaxiwayEdgeType" />
    <xs:attribute name="rightEdge" form="unqualified" type="stTaxiwayEdgeType" />
    <xs:attribute name="number" form="unqualified" type="stRunwayNumber" />
    <xs:attribute name="designator" form="unqualified" type="stDesignator" />
</xs:complexType>


Replace with:
<xs:complexType name="ctTaxiwayPath">
    <xs:attribute name="start" form="unqualified" type="xs:nonNegativeInteger" />
    <xs:attribute name="end" form="unqualified" type="xs:nonNegativeInteger" />
    <xs:attribute name="type" form="unqualified" type="stTaxiwayPathType" />
    <xs:attribute name="surface" form="unqualified" type="stSurface" />
    <xs:attribute name="width" form="unqualified" type="stDistance" />
    <xs:attribute name="weightLimit" form="unqualified" type="xs:nonNegativeInteger" />
    <xs:attribute name="name" form="unqualified" type="xs:nonNegativeInteger" />
    <xs:attribute name="centerLine" form="unqualified" type="stBool" />
    <xs:attribute name="drawSurface" form="unqualified" type="stBool" />
    <xs:attribute name="drawDetail" form="unqualified" type="stBool" />
    <xs:attribute name="centerLineLighted" form="unqualified" type="stBool" />
    <xs:attribute name="leftEdgeLighted" form="unqualified" type="stBool" />
    <xs:attribute name="rightEdgeLighted" form="unqualified" type="stBool" />
    <xs:attribute name="leftEdge" form="unqualified" type="stTaxiwayEdgeType" />
    <xs:attribute name="rightEdge" form="unqualified" type="stTaxiwayEdgeType" />
    <xs:attribute name="number" form="unqualified" type="stRunwayNumber" />
    <xs:attribute name="designator" form="unqualified" type="stDesignator" />
</xs:complexType>




USAGE
For those people not very acquainted with command line programs, I have made a Windows Explorer version: open your BGLXML folder and double click on the XMLSHELL.EXE icon. This will allow you to drive the command line version, BGLXML.EXE, through the GUI. Otherwise, BGLXML is a command line executable which works in a character mode window. To use it under Window 9x or NT/XP you have to open a command prompt box, and change to the directory you extracted the distribution archive. Ex: suppose if you have extracted it into c:\bglxml. Open the command prompt box and the issue the command: CHDIR C:\BGLXML. (to have a great aid with command line mode applications I suggest you try 4DOS or 4NT, available from JPSOFT). Then, type BGLXML.EXE if you are under Windows or BGLXMLD.EXE if you are under DOS. BGLXML has several parameters (in fact, it does nothing if it's launched alone) which are:

-t - this means terse mode. If this parameter is omitted then the XML output will contain several information about each decoded object (just experiment to understand what I mean)

-d - print lat/lon info as DD/MM/SS instead of decimal degrees. Most objects have latitude and longitude parameters, for example:

<SceneryObject lat="66 30 00" lon="-23 20 00" ... > - this is a scenery object with latitude and longitude in DD/MM/SS and is a result of a decompilation made with the d switch. If the switch weren't applied then it would be <SceneryObject lat="66.50" lon="-23.33" ... >

-m - print range in nautical miles (default is in meters). Many objects have a range parameter, such as VOR or NDB. a <range="35000" ...> (35000 meters) would be the result of a decompilation  made without the m switch. Otherwise it would be  <range="18.88M" ...>

-f - print altitude in feet (default is in meters). Many objects have an altitude parameter, such as VOR, AIRPORTS and RUNWAYS. a <alt="800" ...> (800 meters) would be the result of a decompilation  made without the f switch. Otherwise it would be  <alt="2624.64F" ...>

-h - type BGLXML.EXE -h to obtain additional help on command line switches.

Switches may be specified separately (e.g -t -m -f) or they may be included all together in a single string ( e.g. -dmf)

The other parameters have not a switch and mean, in order, the input BGL file to decode and the XML output to write. The output file parameter may be omitted, in this case the output file will be created in the same path of input file, with XML extension.

Partial decode switches:

if you don't want to extract all object files from a BGL but instead you want to extract only those interesting you, then you may apply Partial decode function. How it works: first you define a circle having a central latitude, a central longitude and a radius; then, BGLXML measures the distance between each object's latitude and longitude and the central latitude/central longitude of  our circle. If the distance is more than our circle radius, then the object won't be decompiled.

-n - this switch specifies the central latitude of our circle. Argument may be in decimal degrees format or it may also be specified using SCASM notation (dd:mm:ss). If latitude is south, prepend a S before argument (Examples: -n45.6 -nS41.8 -n22:33:58 -nS51:40:56.5)

-e - this switch specifies the central longitude of our circle. Argument may be in decimal degrees format or it may also be specified using SCASM notation (dd:mm:ss). If longitude is west, prepend a W before argument (Examples: -e45.6 -eW41.8 -e22:33:58 -eW51:40:56.5)
-r - this switch specifies the radius (in kilometers) of our circle (example: -r15 - circle has a 15 kms radius).

Several usage samples:

BGLXML.EXE "c:\my bgls\myfile.bgl" - this will produce an output file such as "c:\my bgls\myfile.xml"

BGLXML.EXE "c:\my bgls\myfile.bgl" "c:\my xmls\myfile.xml" - this will produce a file named myfile.xml into c:\my xmls

BGLXML.EXE -t -f -m -d "c:\my bgls\myfile.bgl" "c:\my xmls\myfile.xml" - this will produce a file named myfile.xml into c:\my xmls - a terse output will be written, with lat/lon as DD/MM/SS, altitudes in feet, ranges in NM

BGLXML.EXE "c:\my bgls\myfile.bgl" "c:\my xmls\myfile.xml" -tmfd - same as above (switches may be stuffed before or after file names)

BGLXML.EXE "c:\my bgls\myfile.bgl" "c:\my xmls\myfile.xml" -tmfd -n41.564 -e5.6562 -r10 - only decode those objects which are closer than 10 kilometers to N41.564, E5.6562


SUPPORT and BUG REPORTS

Support (as well as bug reports) may be obtained into the Super Flight Planner forum. There are several ways to subscribe and follow forum's topic:

  • By World Wide Web. You can read and post messages to list using your WEB explorer.
  • By Sending a subscription message to super-fp-subscribe@yahoogroups.com. Type "subscribe" (without quotes) on first line of message body. By this way, you will get SFP Mail List messages along with your E-Mail. You may then read and write messages to list using your favorite E-Mail reader.

Besides, if you wish to visit my home page, go to http://www.cpinf.net - this is the place to get program updates, besides of classic WEB file library, such as www.flightsim.com or www.avsim.com


KNOW ISSUES AND LIMITATIONS


BGL FILES DEALT BY BGLXML
File Prefix
Contain
AP*.BGL
Airport and terminal NAVAID
AT*.BGL
Routes, way-points, GeoPol's and Boundaries
NV*.BGL
VOR and NDB
OB*.BGL
Buildings and other scenery objects

Besides, there are BGL files named as cities (EX: SANFRAN.BGL,PARIS.BGL, etc.) These files contain three-dimensional Objects and they are also dealt by BGLXML - MDL files are extracted from them (MDL files are those files which are converted from GMax using Microsoft MakeMDL)


CHANGES
For a list of changes, addition and bug fixes, please see HYSTORY.TXT.

HAVE FUN,

Alex