Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix-airport-creation' into release/1.2.x
Browse files Browse the repository at this point in the history
LeoKle committed Mar 15, 2024
2 parents 016907c + d3cf9cf commit dfd7ccf
Showing 4 changed files with 65 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vs/
.vscode/
build/
out/
27 changes: 27 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "Release",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": ["msvc_x86"],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": ["msvc_x86"],
"variables": []
}
]
}
32 changes: 32 additions & 0 deletions helper/String.h
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

#include <string>
#include <vector>
#include <algorithm>

namespace vacdm {
namespace helper {
@@ -83,6 +84,37 @@ namespace vacdm {

return value.substr(begin, range);
}

/**
* @brief find the first occurrence of a 4-letter ICAO code
* @param[in] value the string to find the ICAO in
* @return the ICAO or "" if none was found
*/
static auto findIcao(std::string input) -> std::string {
#pragma warning(disable : 4244)
std::transform(input.begin(), input.end(), input.begin(),
::toupper);
#pragma warning(default : 4244)

// Find the first occurrence of a 4-letter ICAO code
std::size_t found =
input.find_first_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

while (found != std::string::npos) {
// Check if the substring starting from the found position is
// 4 characters long
if (input.substr(found, 4).length() == 4) {
return input.substr(found, 4);
}

// Continue searching for the next uppercase letter
found = input.find_first_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
found + 1);
}

// Return an empty string if no valid ICAO code is found
return "";
}
};
}
}
3 changes: 2 additions & 1 deletion vACDM.cpp
Original file line number Diff line number Diff line change
@@ -112,7 +112,8 @@ void vACDM::OnAirportRunwayActivityChanged() {
EuroScopePlugIn::CSectorElement rwy;
for (rwy = this->SectorFileElementSelectFirst(EuroScopePlugIn::SECTOR_ELEMENT_RUNWAY); true == rwy.IsValid();
rwy = this->SectorFileElementSelectNext(rwy, EuroScopePlugIn::SECTOR_ELEMENT_RUNWAY)) {
auto airport = trim(rwy.GetAirportName());

auto airport = helper::String::findIcao(trim(rwy.GetAirportName()));

if (true == rwy.IsElementActive(true, 0)) {
if (m_activeRunways.find(airport) == m_activeRunways.end())

0 comments on commit dfd7ccf

Please sign in to comment.