Skip to content

Commit

Permalink
Merge pull request #160 from Nikolai558/development
Browse files Browse the repository at this point in the history
Releasing 2.6.8
  • Loading branch information
Nikolai558 authored Sep 12, 2023
2 parents 05b3e72 + b58ebe5 commit e4fc461
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# CHANGELOG

---
- ## Version 2.6.8
- Bug #159 - vERAM to Geojson conversion input string error.
- Some facilities were getting an error when converting vERAM files to Geojson.
- The error was caused by defaults in their vERAM files having filter values
that were blank. ex. 'filters=""'. If this is the case, FE-Buddy will still
create a default inside the geojson, however the filter will just be blank.
- ex. filter = [].
- It will also place a message inside the log file, so users should just be
able to "find" WARNING messages and fix their file as needed.

- ## Version 2.6.7
- Bug #156 - vERAM to Geojson conversion defaults fixed.
- Geojson files had multiple instances of default values inside one file.
Expand Down
39 changes: 28 additions & 11 deletions FeBuddyLibrary/DataAccess/GeoJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ private int[] getFilters(GeoMapObject geoMapObject, string xsiType)
break;
}

foreach (string filter in filtersString.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','))
foreach (string filter in filtersString.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries))
{
if (!string.IsNullOrWhiteSpace(filter) && !filters.Contains(int.Parse(filter)))
{
Expand All @@ -936,7 +936,7 @@ private List<string> createDefaultFileNames(GeoMapObject geoMapObject, string di
if (geoMapObject.LineDefaults != null)
{
if (geoMapObject.LineDefaults.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty) == "") return output;
foreach (var filter in Array.ConvertAll(geoMapObject.LineDefaults.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','), s => int.Parse(s)))
foreach (var filter in Array.ConvertAll(geoMapObject.LineDefaults.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s)))
{
filterDir = "FILTER " + filter.ToString().PadLeft(2, '0');
fileName = $"{filterDir}__TDM {geoMapObject.TdmOnly.ToString()[0]}__{geoMapObject.LineDefaults.ToString().Replace(" Defaults: ", "__")}";
Expand All @@ -948,7 +948,7 @@ private List<string> createDefaultFileNames(GeoMapObject geoMapObject, string di
if (geoMapObject.SymbolDefaults != null)
{
if (geoMapObject.SymbolDefaults.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty) == "") return output;
foreach (var filter in Array.ConvertAll(geoMapObject.SymbolDefaults.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','), s => int.Parse(s)))
foreach (var filter in Array.ConvertAll(geoMapObject.SymbolDefaults.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s)))
{
filterDir = "FILTER " + filter.ToString().PadLeft(2, '0');
fileName = $"{filterDir}__TDM {geoMapObject.TdmOnly.ToString()[0]}__{geoMapObject.SymbolDefaults.ToString().Replace(" Defaults: ", "__")}";
Expand All @@ -959,7 +959,7 @@ private List<string> createDefaultFileNames(GeoMapObject geoMapObject, string di
if (geoMapObject.TextDefaults != null)
{
if (geoMapObject.TextDefaults.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty) == "") return output;
foreach (var filter in Array.ConvertAll(geoMapObject.TextDefaults.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','), s => int.Parse(s)))
foreach (var filter in Array.ConvertAll(geoMapObject.TextDefaults.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s)))
{
filterDir = "FILTER " + filter.ToString().PadLeft(2, '0');
fileName = $"{filterDir}__TDM {geoMapObject.TdmOnly.ToString()[0]}__{geoMapObject.TextDefaults.ToString().Replace(" Defaults: ", "__")}";
Expand Down Expand Up @@ -1054,7 +1054,7 @@ private List<string> CreateElementFileNames(GeoMapObject geoMapObject, string di
else
{
// Custom Override filters
int[] AllFilterGroups = Array.ConvertAll(element.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','), s => int.Parse(s));
int[] AllFilterGroups = Array.ConvertAll(element.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s));

if (AllFilterGroups.Length > 1) // Custom Override filters have more than one Filter
{
Expand Down Expand Up @@ -1321,12 +1321,17 @@ public void WriteGeoMapGeoJson(string dirPath, GeoMapSet geo)
{
isLineDefaults = true,
bcg = geoMapObject.LineDefaults?.Bcg ?? null,
filters = Array.ConvertAll(geoMapObject.LineDefaults?.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(',') ?? new string[] { }, s => int.Parse(s)),
filters = Array.ConvertAll(geoMapObject.LineDefaults?.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries) ?? new string[] { }, s => int.Parse(s)),
style = geoMapObject.LineDefaults?.Style ?? null,
thickness = geoMapObject.LineDefaults?.Thickness ?? null,
}
};

if (AllLinesDefaults.properties.filters.Count() == 0 && AllLinesDefaults.properties.bcg != null)
{
geoMapObjectLog.AppendLine($"\t\t\t WARNING: Line Defaults are missing fillters. If the features in this file do NOT have overriding filter properties, the object will NOT be displayed in CRC.");
}

foreach (Element element in geoMapObject.Elements.Element)
{
switch (element.XsiType)
Expand All @@ -1350,11 +1355,17 @@ public void WriteGeoMapGeoJson(string dirPath, GeoMapSet geo)
{
isSymbolDefaults = true,
bcg = geoMapObject.SymbolDefaults?.Bcg ?? null,
filters = Array.ConvertAll(geoMapObject.SymbolDefaults?.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(',') ?? new string[] { }, s => int.Parse(s)),
filters = Array.ConvertAll(geoMapObject.SymbolDefaults?.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries) ?? new string[] { }, s => int.Parse(s)),
style = geoMapObject.SymbolDefaults?.Style ?? null,
size = geoMapObject.SymbolDefaults?.Size ?? null,
}
};

if (defaultFeature.properties.filters.Count() == 0 && defaultFeature.properties.bcg != null)
{
geoMapObjectLog.AppendLine($"\t\t\t WARNING: Symbol Defaults are missing fillters. If the features in this file do NOT have overriding filter properties, the object will NOT be displayed in CRC.");
}

geojson.features.Add(defaultFeature);
}

Expand All @@ -1381,14 +1392,20 @@ public void WriteGeoMapGeoJson(string dirPath, GeoMapSet geo)
{
isTextDefaults = true,
bcg = geoMapObject.TextDefaults?.Bcg ?? null,
filters = Array.ConvertAll(geoMapObject.TextDefaults?.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(',') ?? new string[] { }, s => int.Parse(s)),
filters = Array.ConvertAll(geoMapObject.TextDefaults?.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries) ?? new string[] { }, s => int.Parse(s)),
size = geoMapObject.TextDefaults?.Size ?? null,
underline = geoMapObject.TextDefaults?.Underline ?? null,
opaque = geoMapObject.TextDefaults?.Opaque ?? null,
xOffset = geoMapObject.TextDefaults?.XOffset ?? null,
yOffset = geoMapObject.TextDefaults?.YOffset ?? null,
}
};

if (defaultFeature.properties.filters.Count() == 0 && defaultFeature.properties.bcg != null)
{
geoMapObjectLog.AppendLine($"\t\t\t WARNING: Text Defaults are missing fillters. If the features in this file do NOT have overriding filter properties, the object will NOT be displayed in CRC.");
}

geojson.features.Add(defaultFeature);
}

Expand Down Expand Up @@ -1621,7 +1638,7 @@ private Properties CreateProperties(Element element)
{
Properties elem_properties = new Properties();

if (element.Filters != null && !string.IsNullOrWhiteSpace(element.Filters)) { elem_properties.filters = Array.ConvertAll(element.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','), s => int.Parse(s)); }
if (element.Filters != null && !string.IsNullOrWhiteSpace(element.Filters)) { elem_properties.filters = Array.ConvertAll(element.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s)); }
if (element.Style != null) { elem_properties.style = element.Style; }
if (element.Bcg != null) { elem_properties.bcg = element.Bcg; }
if (element.Thickness != null) { elem_properties.thickness = element.Thickness; }
Expand Down Expand Up @@ -1780,7 +1797,7 @@ private Feature CreateTextFeature(Element element)
{
Properties elem_properties = new Properties();

if (element.Filters != null && !string.IsNullOrWhiteSpace(element.Filters)) { elem_properties.filters = Array.ConvertAll(element.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','), s => int.Parse(s)); }
if (element.Filters != null && !string.IsNullOrWhiteSpace(element.Filters)) { elem_properties.filters = Array.ConvertAll(element.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s)); }
if (element.Style != null) { elem_properties.style = element.Style; }
if (element.Bcg != null) { elem_properties.bcg = element.Bcg; }
if (element.Size != null) { elem_properties.size = element.Size; }
Expand Down Expand Up @@ -1828,7 +1845,7 @@ private Feature CreateSymbolFeature(Element element)

// Array.ConvertAll(symbolDefaults.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','), s => int.Parse(s));

if (element.Filters != null && !string.IsNullOrWhiteSpace(element.Filters)) { elem_properties.filters = Array.ConvertAll(element.Filters.Replace(" ", string.Empty).Replace("\t", string.Empty).Split(','), s => int.Parse(s)); }
if (element.Filters != null && !string.IsNullOrWhiteSpace(element.Filters)) { elem_properties.filters = Array.ConvertAll(element.Filters.Replace("\t", string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s)); }
if (element.Style != null && !string.IsNullOrWhiteSpace(element.Style)) { elem_properties.style = element.Style; }
if (element.Size != null) { elem_properties.size = element.Size; }

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.7</Version>
<Version>2.6.8</Version>
<Copyright>Copyright © 2023 Nikolas Boling, Kyle Sanders</Copyright>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>FE_BUDDY_icon.ico</ApplicationIcon>
Expand Down

0 comments on commit e4fc461

Please sign in to comment.