Skip to content

Commit

Permalink
V1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
GewoonJaap committed Jul 11, 2021
1 parent 7f9dd5b commit f1d2f57
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Config/ModelMatching.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"Boeing 737-7K2": "Airbus A320 Neo",
"Cessna F152": "Cessna 172P Skyhawk G1000",
"C172": "Cessna 172P Skyhawk G1000",
"C152": "Cessna 172P Skyhawk G1000",
"Cessna 182S Skylane": "Cessna 172P Skyhawk G1000",
"Cessna 182N Skylane": "Cessna 172P Skyhawk G1000",
"Cessna 172M Skyhawk": "Cessna 172P Skyhawk G1000",
Expand Down Expand Up @@ -47,6 +48,7 @@
"Boeing 777-F1H": "Boeing 787-10",
"Boeing 777-F": "Boeing 787-10",
"Boeing 757-256": "Boeing 787-10",
"B789": "Boeing 787-10",
"Boeing 787-8 Dreamliner": "Boeing 787-10",
"Boeing 787-9 Dreamliner": "Boeing 787-10",
"Boeing 787-10 Dreamliner": "Boeing 787-10",
Expand All @@ -65,6 +67,7 @@
"Boeing 747-4B5F(ER)": "Boeing 747-8i",
"Boeing 747-867(F)": "Boeing 747-8i",
"Boeing 747-830": "Boeing 747-8i",
"B744": "Boeing 747-8i",
"B748": "Boeing 747-8i",
"Boeing 747-8F": "Boeing 747-8i",
"Boeing 747-8i": "Boeing 747-8i",
Expand Down Expand Up @@ -101,6 +104,7 @@
"Pilatus PC-12/47E": "TBM 930",
"Piper PA-46-M600": "TBM 930",
"Piper PA-46-M500": "TBM 930",
"Piper PA-46-500TP": "TBM 930",
"TBM 930": "TBM 930",
"TBM 930 Default": "TBM 930 Asobo",
"Beech F33A Bonanza": "Bonanza G36",
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
// You can specify all the values or you can default the Build and Revision Numbers by using the '*'
// as shown below: [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.8.0.0")]
[assembly: AssemblyFileVersion("1.9.0.0")]
4 changes: 2 additions & 2 deletions Util/LiveTrafficHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void SetObjectId(uint requestId, uint objectId)

private void ParsePlaneData(JObject planeData)
{
List<String> flightRadarIds = new List<string>();
List<string> flightRadarIds = new List<string>();
foreach (JProperty property in planeData.Properties())
{
//Determine if object is a plane, we only want planes from the api, not the other stat keys ;)
Expand All @@ -72,7 +72,7 @@ private void ParsePlaneData(JObject planeData)
double longitude = (double)property.Value[2];
double latitude = (double)property.Value[1];
int heading = (int)property.Value[3];
double altimeter = (int)property.Value[4] * 0.3048;
double altimeter = (int) property.Value[4];// * 0.3048;
int speed = (int)property.Value[5];
string callsign = (string)property.Value[16];
bool isGrounded = (bool)property.Value[14];
Expand Down
18 changes: 13 additions & 5 deletions Util/ModelMatching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public static string MatchModel(string modelCode, string model, string airline,
matchedModel = installedAddons.FirstOrDefault(addon => addon.ModelCode == modelCode)?.Title ?? "Airbus A320 Neo Asobo";
}

if (TryFindAircraft(models, installedAddons, matchedModel, airline, icaoAirline) != null)
if (TryFindAircraft(models, installedAddons, matchedModel, airline, icaoAirline, modelCode) != null)
{
matchedModel = TryFindAircraft(models, installedAddons, matchedModel, airline, icaoAirline);
matchedModel = TryFindAircraft(models, installedAddons, matchedModel, airline, icaoAirline, modelCode);
}
else if (airline.Contains("(") && TryFindAircraft(models, installedAddons, matchedModel, airline.Split('(')[0].Trim(), icaoAirline) != null)
else if (airline.Contains("(") && TryFindAircraft(models, installedAddons, matchedModel, airline.Split('(')[0].Trim(), icaoAirline, modelCode) != null)
{
matchedModel = TryFindAircraft(models, installedAddons, matchedModel, airline.Split('(')[0].Trim(), icaoAirline);
matchedModel = TryFindAircraft(models, installedAddons, matchedModel, airline.Split('(')[0].Trim(), icaoAirline, modelCode);
}
else
{
Expand All @@ -42,7 +42,7 @@ public static string MatchModel(string modelCode, string model, string airline,
return matchedModel;
}

private static string TryFindAircraft(JObject models, List<Addon> installedAddons, string model, string airline, string icao)
private static string TryFindAircraft(JObject models, List<Addon> installedAddons, string model, string airline, string icao, string modelcode)
{
string foundAircraft = null;

Expand All @@ -62,6 +62,14 @@ private static string TryFindAircraft(JObject models, List<Addon> installedAddon
{
foundAircraft = installedAddons.First(addon => addon.Title.StartsWith(model) && addon.Icao_Airline == icao).Title;
}
else if (installedAddons.FirstOrDefault(addon => addon.Title.StartsWith(modelcode) && (addon.Title.Contains(icao) || addon.Title.Contains(airline))) != null)
{
foundAircraft = installedAddons.First(addon => addon.Title.StartsWith(modelcode) && (addon.Title.Contains(icao) || addon.Title.Contains(airline))).Title;
}
else if (installedAddons.FirstOrDefault(addon => string.Equals(addon.ModelCode, modelcode, StringComparison.CurrentCultureIgnoreCase) && (addon.Title.Contains(icao) || addon.Title.Contains(airline))) != null)
{
foundAircraft = installedAddons.First(addon => string.Equals(addon.ModelCode, modelcode, StringComparison.CurrentCultureIgnoreCase) && (addon.Title.Contains(icao) || addon.Title.Contains(airline))).Title;
}

return foundAircraft;
}
Expand Down

0 comments on commit f1d2f57

Please sign in to comment.