• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX Help with BGL compression algorithms

Messages
5
Country
portugal
Hey there,

I'm developing this tool to extract land class info from worldlc.bgl. It is available currently in https://github.com/rafaeldamasceno/BGLConverter.

However, some TRQ1 records have LZ1 compression, for which the wiki only provides some pseudocode algorithm.

I've tried implementing it in C# but I don't seem to be having great success. Currently it is trying to output to an out of bounds index, which I assume is because I'm reading the bits in a bad order. I've tried messing with the endianness of the bits and input bytes, but I don't seem to find the right one.

I also assume I'll have trouble with the double compression ones, since they all seem to require an output size and I have no idea how to calculate the intermediate value.

Any help is appreciated. Thank you!
 
Last edited:
Messages
284
Country
us-newyork
Hi Rafael,

I'll consider releasing a reusable lib for the decompression for the non-PTC types. The bgldec lib should be able to tackle worldlc as-is. I can't release the code directly for PTC compression, however PTC is only used in DEM and Aerial imagery formats.
 
Messages
5
Country
portugal
Hi Rafael,

I'll consider releasing a reusable lib for the decompression for the non-PTC types. The bgldec lib should be able to tackle worldlc as-is. I can't release the code directly for PTC compression, however PTC is only used in DEM and Aerial imagery formats.
Hello! Since bgldec works so nicely and outputs binary files as well, I think I'll have no need for my own tool anymore. It would be interesting to know what was wrong with my LZ1 implementation, though :p
 
Messages
284
Country
us-newyork
My code is in raw C and works a little differently so I'm not 100% sure what's wrong with yours. The core of the algorithm looks mostly correct, there are some things like:

C#:
 if (flag == 1)
 {
     var output = BitListToByte(ReadBits(7)) + 0x80;
 }

This should be an | 0x80 (the others are + 0x40 and 0x140 correctly)

Code:
else
{
    _sequenceLength = BitListToInt(ReadBits(nbBitsToRead)) + 1 + (2 ^ nbBitsToRead);
}

Here it is doing a bitwise XOR, your probably mean to do a power, and it is base 1:

C:
length = (1 << num_bits) + LZReadNextNBits(bit_pool, num_bits) + 1;

If that doesn't do it, may be something with the way you are handling the bit pool.

I'll clean it up and post it.
 
Messages
284
Country
us-newyork
I have decided to start open sourcing some of my work as a shared module, starting with the BGL decompression routines:


I am working towards open-sourcing all of bgldec and then internals to some of my other tools.
 
Messages
7,450
Country
us-illinois
Outstanding, Sean; many thanks for your meticulous work and for helping us all better understand- and utilize- this esoteric aspect of FS Development. :)

GaryGB
 
Top