Skip to content

Commit

Permalink
Adapted BGL reading code to MSFS 2024
Browse files Browse the repository at this point in the history
This commit shows all required changes to read MSFS 2024 navdata from BGL files. It does not include
refactoring, SimConnect changes and changes to the database writing code.

It does not cover airports and procedures which are read through SimConnect using SimConnectLoader
and SimConnectWriter classes.

Added new types and records and adapted code to changed structures.
Fixed issue where extra ramps and gates were not recognized as gates or ramps.
albar965/littlenavmap#1198
  • Loading branch information
albar965 committed Dec 23, 2024
1 parent d775841 commit f41e121
Show file tree
Hide file tree
Showing 27 changed files with 330 additions and 146 deletions.
18 changes: 18 additions & 0 deletions src/fs/bgl/ap/approachleg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,24 @@ QString ApproachLeg::altDescriptorToString(leg::AltDescriptor altDescr)
return "INVALID";
}

QString ApproachLeg::speedDescriptorToString(leg::SpeedDescriptor speedDescr)
{
switch(speedDescr)
{
case leg::UNKNOWN_SPEED:
case leg::AT:
return QString();

case leg::AT_OR_ABOVE:
return "+";

case leg::AT_OR_BELOW:
return "-";
}
qWarning().nospace().noquote() << "Invalid approach altitude descriptor " << speedDescr;
return "INVALID";
}

QString ApproachLeg::turnDirToString(leg::TurnDirection turnDir)
{
switch(turnDir)
Expand Down
10 changes: 9 additions & 1 deletion src/fs/bgl/ap/approachleg.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,15 @@ enum TurnDirection
BOTH = 3
};

}
enum SpeedDescriptor
{
UNKNOWN_SPEED = 0,
AT = 1,
AT_OR_ABOVE = 2,
AT_OR_BELOW = 3,
};

}
/*
* Approach or transition leg. Not an actual record since it does not contain a header or size.
*/
Expand Down Expand Up @@ -296,6 +303,7 @@ class ApproachLeg
static QString legTypeToString(atools::fs::bgl::leg::Type type, const QString& src, bool warn);
static QString altDescriptorToString(atools::fs::bgl::leg::AltDescriptor altDescr);
static QString turnDirToString(atools::fs::bgl::leg::TurnDirection turnDir);
static QString speedDescriptorToString(leg::SpeedDescriptor speedDescr); /* Only MSFS 2024 via SimConnect */

private:
friend QDebug operator<<(QDebug out, const ApproachLeg& record);
Expand Down
24 changes: 12 additions & 12 deletions src/fs/bgl/ap/com.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ namespace bgl {
namespace com {
enum ComType
{
APPROACH = 0x0008,
ASOS = 0x000D,
NONE = 0x0000,
ATIS = 0x0001,
AWOS = 0x000C,
CENTER = 0x000A,
CLEARANCE = 0x0007,
CLEARANCE_PRE_TAXI = 0x000E,
MULTICOM = 0x0002,
UNICOM = 0x0003,
CTAF = 0x0004,
DEPARTURE = 0x0009,
FSS = 0x000B,
GROUND = 0x0005,
MULTICOM = 0x0002,
NONE = 0x0000,
REMOTE_CLEARANCE_DELIVERY = 0x000F,
TOWER = 0x0006,
UNICOM = 0x0003,
CLEARANCE = 0x0007,
APPROACH = 0x0008,
DEPARTURE = 0x0009,
CENTER = 0x000A,
FSS = 0x000B,
AWOS = 0x000C,
ASOS = 0x000D,
CLEARANCE_PRE_TAXI = 0x000E, // MSFS: CPT
REMOTE_CLEARANCE_DELIVERY = 0x000F, // MSFS: GCO

APPROACH_P3D_V5 = 0x0708,
ASOS_P3D_V5 = 0x070D,
Expand Down
7 changes: 7 additions & 0 deletions src/fs/bgl/ap/parking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ QString Parking::parkingTypeToStr(ap::ParkingType type)

case ap::GATE_EXTRA:
return "GE";

case ap::MSFS_2024_UNKNOWN:
return "UNKN";
}
qWarning().nospace().noquote() << "Invalid parking type " << type;
return "INVALID";
Expand Down Expand Up @@ -361,6 +364,8 @@ bool Parking::isGate() const
return true;
else if(type == ap::GATE_HEAVY)
return true;
else if(type == ap::GATE_EXTRA)
return true;

return false;
}
Expand All @@ -375,6 +380,8 @@ bool Parking::isGaRamp() const
return true;
else if(type == ap::RAMP_GA_LARGE)
return true;
else if(type == ap::RAMP_GA_EXTRA)
return true;

return false;
}
Expand Down
35 changes: 18 additions & 17 deletions src/fs/bgl/ap/parking.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,24 @@ namespace ap {

enum ParkingType
{
UNKNOWN = 0x0,
RAMP_GA = 0x1,
RAMP_GA_SMALL = 0x2,
RAMP_GA_MEDIUM = 0x3,
RAMP_GA_LARGE = 0x4,
RAMP_CARGO = 0x5,
RAMP_MIL_CARGO = 0x6,
RAMP_MIL_COMBAT = 0x7,
GATE_SMALL = 0x8,
GATE_MEDIUM = 0x9,
GATE_HEAVY = 0xa,
DOCK_GA = 0xb,
FUEL = 0xc,
VEHICLES = 0xd,

RAMP_GA_EXTRA = 0xe,
GATE_EXTRA = 0xf
UNKNOWN = 0x00,
RAMP_GA = 0x01,
RAMP_GA_SMALL = 0x02,
RAMP_GA_MEDIUM = 0x03,
RAMP_GA_LARGE = 0x04,
RAMP_CARGO = 0x05,
RAMP_MIL_CARGO = 0x06,
RAMP_MIL_COMBAT = 0x07,
GATE_SMALL = 0x08,
GATE_MEDIUM = 0x09,
GATE_HEAVY = 0x0a,
DOCK_GA = 0x0b,
FUEL = 0x0c,
VEHICLES = 0x0d,

RAMP_GA_EXTRA = 0x0e,
GATE_EXTRA = 0x0f,
MSFS_2024_UNKNOWN = 0x10 // Unknown parking type. Most likely a gate
};

enum PushBack
Expand Down
14 changes: 10 additions & 4 deletions src/fs/bgl/ap/start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@ QString Start::startTypeToStr(start::StartType type)
{
switch(type)
{
case atools::fs::bgl::start::RUNWAY:
case start::RUNWAY:
return "R";

case atools::fs::bgl::start::WATER:
case start::WATER:
return "W";

case atools::fs::bgl::start::HELIPAD:
case start::HELIPAD:
return "H";

case start::TRACK:
return "T";

case start::UNKNOWN:
return "UNKNOWN";
}
qWarning().nospace().noquote() << "Invalid START type " << type;
return "INVALID";
Expand All @@ -51,7 +57,7 @@ Start::Start(const NavDatabaseOptions *options, BinaryStream *stream)
runwayDesignator = flags & 0x0f;
type = static_cast<start::StartType>((flags >> 4) & 0xf);
position = BglPosition(stream, true, 1000.f);
heading = stream->readFloat(); // TODO wiki heading is float degrees
heading = stream->readFloat(); // Heading is float degrees
}

Start::~Start()
Expand Down
4 changes: 3 additions & 1 deletion src/fs/bgl/ap/start.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ namespace bgl {
namespace start {
enum StartType
{
UNKNOWN = 0,
RUNWAY = 1,
WATER = 2,
HELIPAD = 3 // TOOD fix in wiki
HELIPAD = 3,
TRACK = 4 /* MSFS 2024 */
};

} // namespace start
Expand Down
26 changes: 13 additions & 13 deletions src/fs/bgl/ap/taxipath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,25 @@ QString TaxiPath::pathTypeToString(taxipath::Type type)
{
switch(type)
{
case atools::fs::bgl::taxipath::VEHICLE:
return "V";

case atools::fs::bgl::taxipath::UNKNOWN:
case taxipath::VEHICLE:
case taxipath::ROAD:
case taxipath::PAINTEDLINE:
case taxipath::UNKNOWN:
return "UNKNOWN";

case atools::fs::bgl::taxipath::TAXI:
case taxipath::TAXI:
return "T";

case atools::fs::bgl::taxipath::RUNWAY:
case taxipath::RUNWAY:
return "R";

case atools::fs::bgl::taxipath::PARKING:
case taxipath::PARKING:
return "P";

case atools::fs::bgl::taxipath::PATH:
case taxipath::PATH:
return "PT";

case atools::fs::bgl::taxipath::CLOSED:
case taxipath::CLOSED:
return "C";
}
qWarning().nospace().noquote() << "Invalid taxi path type " << type;
Expand All @@ -113,16 +113,16 @@ QString TaxiPath::edgeTypeToString(taxipath::EdgeType type)
{
switch(type)
{
case atools::fs::bgl::taxipath::NONE:
case taxipath::NONE:
return "NONE";

case atools::fs::bgl::taxipath::SOLID:
case taxipath::SOLID:
return "SOLID";

case atools::fs::bgl::taxipath::DASHED:
case taxipath::DASHED:
return "DASHED";

case atools::fs::bgl::taxipath::SOLID_DASHED:
case taxipath::SOLID_DASHED:
return "SOLID_DASHED";
}
qWarning().nospace().noquote() << "Invalid taxi path edge type " << type;
Expand Down
4 changes: 3 additions & 1 deletion src/fs/bgl/ap/taxipath.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ enum Type
PARKING = 3,
PATH = 4,
CLOSED = 5,
VEHICLE = 6 // TODO add wiki
VEHICLE = 6,
ROAD = 7, /* MSFS 2024 */
PAINTEDLINE = 8 /* MSFS 2024 */
};

enum EdgeType
Expand Down
35 changes: 29 additions & 6 deletions src/fs/bgl/bglfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void BglFile::handleBoundaries(BinaryStream *bs)
Record rec(options, bs);
rec::RecordType type = rec.getId<rec::RecordType>();

if(type == rec::BOUNDARY)
if(type == rec::BOUNDARY || type == rec::BOUNDARY_MSFS2024)
{
rec.seekToStart();
const Record *r = createRecord<Boundary>(bs, &boundaries);
Expand Down Expand Up @@ -263,6 +263,7 @@ void BglFile::readRecords(BinaryStream *bs, const atools::fs::scenery::SceneryAr
bool msfsNavigraphNavdata = area.isMsfsNavigraphNavdata();
createFlags.setFlag(bgl::AIRPORT_MSFS_NAVIGRAPH_NAVDATA, msfsNavigraphNavdata);
createFlags.setFlag(bgl::AIRPORT_MSFS_DUMMY, area.isNavdata());
FsPaths::SimulatorType sim = options->getSimulatorType();

// There should be no duplicate airport idents in the file. Otherwise bail out of reading this file.
QHash<QString, int> airportIdentCount;
Expand Down Expand Up @@ -293,7 +294,8 @@ void BglFile::readRecords(BinaryStream *bs, const atools::fs::scenery::SceneryAr
switch(type)
{
case section::AIRPORT:
if(options->isIncludedNavDbObject(type::AIRPORT))
// Do not read airports from MSFS 2024. These are fetched via SimConnect.
if(sim != FsPaths::MSFS_2024 && options->isIncludedNavDbObject(type::AIRPORT))
{
// Will return null if ICAO is excluded in configuration
// Read airport and all subrecords, like runways, com, approaches, waypoints and so on
Expand Down Expand Up @@ -331,38 +333,59 @@ void BglFile::readRecords(BinaryStream *bs, const atools::fs::scenery::SceneryAr
break;

case section::AIRPORT_ALT:
qWarning() << "Found alternate airport ID";
if(options->isIncludedNavDbObject(type::AIRPORT))
qWarning() << Q_FUNC_INFO << "Found alternate airport ID";
if(sim != FsPaths::MSFS_2024 && options->isIncludedNavDbObject(type::AIRPORT))
rec = createRecord<Airport>(bs, &airports, bgl::NO_CREATE_FLAGS);
break;

case section::NAME_LIST:
rec = createRecord<Namelist>(bs, &namelists);
// Do not read airports/namelists from MSFS 2024. These are fetched via SimConnect.
if(sim != FsPaths::MSFS_2024)
rec = createRecord<Namelist>(bs, &namelists);
break;

case section::P3D_TACAN:
rec = createRecord<Tacan>(bs, &tacans);
// TACAN secion type overlaps with a MSFS 2024 section type
if(sim != FsPaths::MSFS_2024)
rec = createRecord<Tacan>(bs, &tacans);
break;

case section::ILS_VOR:
// Read VOR, VORDME, DME. Also TACAN for MSFS 2024
// Do not read from MSFS 2020 Navigraph extension
if(!msfsNavigraphNavdata)
{
rec = handleIlsVor(bs);
if(options->isVerbose() && rec != nullptr)
qDebug() << Q_FUNC_INFO << "ILS_VOR" << hex << rec->getId();
}
break;

case section::NDB:
// Do not read from MSFS 2020 Navigraph extension
if(options->isIncludedNavDbObject(type::NDB) && !msfsNavigraphNavdata)
{
rec = createRecord<Ndb>(bs, &ndbs);
if(options->isVerbose() && rec != nullptr)
qDebug() << Q_FUNC_INFO << "NDB" << hex << rec->getId();
}
break;

case section::MARKER:
// Do not read from MSFS 2020 Navigraph extension
if(options->isIncludedNavDbObject(type::MARKER) && !msfsNavigraphNavdata)
rec = createRecord<Marker>(bs, &marker);
break;

case section::WAYPOINT:
// Do not read from MSFS 2020 Navigraph extension
if(options->isIncludedNavDbObject(type::WAYPOINT) && !msfsNavigraphNavdata)
{
// Read waypoints and airways
rec = createRecord<Waypoint>(bs, &waypoints);
if(options->isVerbose() && rec != nullptr)
qDebug() << Q_FUNC_INFO << "WAYPOINT" << hex << rec->getId();
}
break;

// MSFS sections not found yet
Expand Down
Loading

0 comments on commit f41e121

Please sign in to comment.