Skip to content

Commit

Permalink
Merge pull request #157 from Nikolai558/development
Browse files Browse the repository at this point in the history
Releasing 2.6.7
  • Loading branch information
Nikolai558 authored Sep 12, 2023
2 parents 239683a + 1bab7d9 commit eb8672d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 18 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG

---
- ## Version 2.6.7
- Bug #156 - vERAM to Geojson conversion defaults fixed.
- CRC AIRAC Weather Station File now inlcudes the full name of the station.

- ## Version 2.6.6
- Geojson Output format by Filters no longer duplicate files that were
assined multiple filter indexes.
Expand Down
74 changes: 60 additions & 14 deletions FeBuddyLibrary/DataAccess/GeoJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,9 +1295,9 @@ public void WriteGeoMapGeoJson(string dirPath, GeoMapSet geo)
geoMapObjectLog.AppendLine($"\n\n\tDescription: {geoMapObject.Description}");
geoMapObjectLog.AppendLine($"\t\tTDM: {geoMapObject.TdmOnly}");

if (geoMapObject.LineDefaults?.ToString() != null) { geoMapObjectLog.AppendLine("\t\t" + geoMapObject.LineDefaults?.ToString());}
if (geoMapObject.TextDefaults?.ToString() != null) { geoMapObjectLog.AppendLine("\t\t" + geoMapObject.TextDefaults?.ToString());}
if (geoMapObject.SymbolDefaults?.ToString() != null) { geoMapObjectLog.AppendLine("\t\t" + geoMapObject.SymbolDefaults?.ToString());}
if (geoMapObject.LineDefaults?.ToString() != null) { geoMapObjectLog.AppendLine("\t\t" + geoMapObject.LineDefaults?.ToString() + $"__Filters {geoMapObject.LineDefaults?.Filters.ToString() ?? "None"}");}
if (geoMapObject.TextDefaults?.ToString() != null) { geoMapObjectLog.AppendLine("\t\t" + geoMapObject.TextDefaults?.ToString() + $"__Filters {geoMapObject.TextDefaults?.Filters.ToString() ?? "None"}");}
if (geoMapObject.SymbolDefaults?.ToString() != null) { geoMapObjectLog.AppendLine("\t\t" + geoMapObject.SymbolDefaults?.ToString() + $"__Filters {geoMapObject.SymbolDefaults?.Filters.ToString() ?? "None"}");}

string fileName = geoMapObject.Description + ".geojson";
fileName = MakeValidFileName(fileName);
Expand Down Expand Up @@ -1416,21 +1416,18 @@ public void WriteGeoMapGeoJson(string dirPath, GeoMapSet geo)
int totalFeatureCount = geojson.features.Count();
bool shouldAddDefaults = true;

if (totalFeatureCount <= 3)
for (int i = 0; i < totalFeatureCount; i++)
{
for (int i = 0; i < totalFeatureCount; i++)
if ((geojson.features[i].properties.isLineDefaults ?? false))
{
if (!(geojson.features[i].properties.isLineDefaults ?? true))
{
shouldAddDefaults = false;
break;
}
}
if (shouldAddDefaults)
{
geojson.features.Add(AllLinesDefaults);
shouldAddDefaults = false;
break;
}
}
if (shouldAddDefaults)
{
geojson.features.Add(AllLinesDefaults);
}

geojson.features.Add(item);
}
Expand Down Expand Up @@ -1459,6 +1456,8 @@ public void WriteGeoMapGeoJson(string dirPath, GeoMapSet geo)
//geojson.features.AddRange(inFile.features);
}

geojson = CleanGeoJson(geojson);

string jsonString = JsonConvert.SerializeObject(geojson, new JsonSerializerSettings { Formatting = Formatting.None, NullValueHandling = NullValueHandling.Ignore });

//jsonString = PostProcess(jsonString);
Expand All @@ -1475,6 +1474,53 @@ public void WriteGeoMapGeoJson(string dirPath, GeoMapSet geo)
File.WriteAllText(Path.Combine(dirPath, "GeoMapObject Properties.txt"), geoMapObjectLog.ToString());
}

private FeatureCollection CleanGeoJson(FeatureCollection geojson)
{
FeatureCollection cleaned = new FeatureCollection();
FeatureCollection output = new FeatureCollection();
Dictionary<string, bool> addedDefaults = new Dictionary<string, bool>() { { "LineDefaults", false }, { "TextDefaults", false }, { "SymbolDefaults", false } };

foreach (var feature in geojson.features)
{
bool addFeature = true;
bool isDefaults = false;
if (feature.properties.isLineDefaults ?? false)
{
addFeature = !addedDefaults["LineDefaults"];
addedDefaults["LineDefaults"] = true;
isDefaults = true;
}

if (feature.properties.isTextDefaults ?? false)
{
addFeature = !addedDefaults["TextDefaults"];
addedDefaults["TextDefaults"] = true;
isDefaults = true;
}

if (feature.properties.isSymbolDefaults ?? false)
{
addFeature = !addedDefaults["SymbolDefaults"];
addedDefaults["SymbolDefaults"] = true;
isDefaults = true;
}

if (addFeature && !isDefaults)
{
cleaned.features.Add(feature);
}

if (addFeature && isDefaults)
{
output.features.Add(feature);
}
}

output.features.AddRange(cleaned.features);

return output;
}

private string GetUniqueFileName(string originalPath)
{
string directory = Path.GetDirectoryName(originalPath);
Expand Down
8 changes: 5 additions & 3 deletions FeBuddyLibrary/DataAccess/GetAptData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ private void ParseAndWriteWxStation(string effectiveDate)
string metarDataFilepath = $"{GlobalConfig.tempPath}\\{effectiveDate}_NWS-WX-STATIONS.xml";
string outputFilepath = $"{GlobalConfig.outputDirectory}\\VRC\\[LABELS].sct2";
Dictionary<string, List<double>> stationInfo = new Dictionary<string, List<double>>();
Dictionary<string, string> stationNames = new Dictionary<string, string>();
Dictionary<string, List<string>> aptInfo = new Dictionary<string, List<string>>();
StringBuilder sb = new StringBuilder();

Expand All @@ -230,9 +231,10 @@ private void ParseAndWriteWxStation(string effectiveDate)
foreach (XElement xElement in metarXML.Descendants("station"))
{
string id = xElement.Element("station_id").Value;
string name = xElement.Element("station_name").Value;
double lat = Convert.ToDouble(xElement.Element("latitude").Value);
double lon = Convert.ToDouble(xElement.Element("longitude").Value);

stationNames.Add(id, name);
stationInfo.Add(id, new List<double> { lat, lon });
}

Expand All @@ -259,7 +261,7 @@ private void ParseAndWriteWxStation(string effectiveDate)
sb.AppendLine(labelLineToBeAdded);
symbolFeature.geometry.coordinates = new List<dynamic>() { stationInfo[metar_id][1], stationInfo[metar_id][0] };
textFeature.geometry.coordinates = new List<dynamic>() { stationInfo[metar_id][1], stationInfo[metar_id][0] };
textFeature.properties.text = new string[] { metar_id };
textFeature.properties.text = new string[] { metar_id + " " + aptInfo[metar_id][0].Replace('"', '-') };

symbolAllFeatures.Add(symbolFeature);
textAllFeatures.Add(textFeature);
Expand Down Expand Up @@ -296,7 +298,7 @@ private void ParseAndWriteWxStation(string effectiveDate)

symbolFeature.geometry.coordinates = new List<dynamic>() { stationInfo[metar_id][1], stationInfo[metar_id][0] };
textFeature.geometry.coordinates = new List<dynamic>() { stationInfo[metar_id][1], stationInfo[metar_id][0] };
textFeature.properties.text = new string[] { metar_id };
textFeature.properties.text = new string[] { metar_id + " " + aptInfo[metar_id.Substring(1)][0].Replace('"', '-') };

symbolAllFeatures.Add(symbolFeature);
textAllFeatures.Add(textFeature);
Expand Down
2 changes: 1 addition & 1 deletion FeBuddyWinFormUI/FeBuddyWinFormUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<AssemblyName>FE-BUDDY</AssemblyName>
<Version>2.6.6</Version>
<Version>2.6.7</Version>
<Copyright>Copyright © 2023 Nikolas Boling, Kyle Sanders</Copyright>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>FE_BUDDY_icon.ico</ApplicationIcon>
Expand Down

0 comments on commit eb8672d

Please sign in to comment.