Skip to content

Commit

Permalink
Fixed missing navaids in tabs Airport -> Nearest and added missin…
Browse files Browse the repository at this point in the history
…g links to navaids.
  • Loading branch information
albar965 committed Mar 12, 2024
1 parent 8fe5d7a commit 7461ed3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ or below for the full changelog from 2.8.12.

* Hotfix to avoid error message `Caught exception: Invalid lat/long format`
when loading the new MSFS PLN files with `*` as degree sign, as used since 3.0.4.
* Fixed missing navaids in tabs `Airport` -> `Nearest` and added missing links to navaids.

----

Expand Down
44 changes: 28 additions & 16 deletions src/common/htmlinfobuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,22 +589,20 @@ void HtmlInfoBuilder::nearestMapObjectsTextRow(const MapAirport& airport, HtmlBu
// Create table row ==========================
html.tr(QColor());

if(airportCol)
{
// Airports have no type and link is on name
html.td(displayIdent, ahtml::BOLD);
html.tdF(ahtml::ALIGN_RIGHT).a(name, url, ahtml::LINK_NO_UL).tdEnd();
}
QString displayText;
if(name.isEmpty())
displayText = displayIdent;
else
{
displayText = tr("%1 (%2)").arg(name).arg(displayIdent);

html.tdF(ahtml::ALIGN_LEFT).a(displayText, url, ahtml::LINK_NO_UL).tdEnd();

if(!airportCol)
// Navaid type
html.td(type, ahtml::BOLD);
html.td(displayIdent, ahtml::BOLD);
html.tdF(ahtml::ALIGN_RIGHT).a(name, url, ahtml::LINK_NO_UL).tdEnd();
}

if(frequencyCol)
html.td(freq, ahtml::ALIGN_RIGHT);
html.td(freq, ahtml::ALIGN_CENTER);

html.td(courseTextFromTrue(bearingTrue, magVar), ahtml::ALIGN_RIGHT | ahtml::NO_ENTITIES).
td(Unit::distMeter(distance, false), ahtml::ALIGN_RIGHT).
Expand All @@ -622,12 +620,11 @@ bool HtmlInfoBuilder::nearestMapObjectsText(const MapAirport& airport, HtmlBuild
// Create table header ==========================
html.tr(QColor());

html.th(tr("Name") % tr(" ") % tr("Ident"));

if(!airportCol)
html.th(tr("Type"));

html.th(tr("Ident")).
th(tr("Name"));

if(frequencyCol)
// Only for navaids
html.th(tr("Frequency\nkHz/MHz"));
Expand All @@ -637,10 +634,10 @@ bool HtmlInfoBuilder::nearestMapObjectsText(const MapAirport& airport, HtmlBuild
trEnd();

// Go through mixed list of map objects ============================================
int row = 1;
int row = 0;
for(const map::MapBase *baseNav : *nearestNav)
{
if(row++ > maxRows)
if(row > maxRows)
// Stop at max
break;

Expand All @@ -654,29 +651,44 @@ bool HtmlInfoBuilder::nearestMapObjectsText(const MapAirport& airport, HtmlBuild

// Omit center airport used as reference
if(apSim.isValid() && apSim.id != airport.id)
{
nearestMapObjectsTextRow(airport, html, QString(), apSim.displayIdent(), apSim.name, QString(), &apSim, apSim.magvar,
frequencyCol, airportCol);
row++;
}
}

const map::MapVor *vor = baseNav->asPtr<map::MapVor>();
if(vor != nullptr)
{
nearestMapObjectsTextRow(airport, html, map::vorType(*vor), vor->ident, vor->name, locale.toString(vor->frequency / 1000., 'f', 2),
vor, vor->magvar, frequencyCol, airportCol);
row++;
}

const map::MapNdb *ndb = baseNav->asPtr<map::MapNdb>();
if(ndb != nullptr)
{
nearestMapObjectsTextRow(airport, html, tr("NDB"), ndb->ident, ndb->name, locale.toString(ndb->frequency / 100., 'f', 1),
ndb, ndb->magvar, frequencyCol, airportCol);
row++;
}

const map::MapWaypoint *waypoint = baseNav->asPtr<map::MapWaypoint>();
if(waypoint != nullptr)
{
nearestMapObjectsTextRow(airport, html, tr("Waypoint"), waypoint->ident, QString(), QString(), waypoint, waypoint->magvar,
frequencyCol, airportCol);
row++;
}

const map::MapIls *ils = baseNav->asPtr<map::MapIls>();
if(ils != nullptr && !ils->isAnyGlsRnp())
{
nearestMapObjectsTextRow(airport, html, map::ilsType(*ils, true /* gs */, true /* dme */, tr(", ")), ils->ident, ils->name,
ils->freqMHzLocale(), ils, ils->magvar, frequencyCol, airportCol);
row++;
}
}
html.tableEnd();
return true;
Expand Down
4 changes: 3 additions & 1 deletion src/query/mapquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ map::MapResultIndex *MapQuery::nearestNavaidsInternal(const Pos& pos, float dist
query::fetchObjectsForRect(rect, ilsByRectQuery, [ =, &ilsRes](atools::sql::SqlQuery *query) -> void {
MapIls obj;
mapTypesFactory->fillIls(query->record(), obj);
ilsRes.append(obj);

if(!obj.isAnyGlsRnp())
ilsRes.append(obj);
});
maptools::removeByDistance(ilsRes, pos, atools::geo::nmToMeter(maxIlsDist));
maptools::sortByDistance(ilsRes, pos);
Expand Down

0 comments on commit 7461ed3

Please sign in to comment.