Remove * and @ lines
This commit is contained in:
@ -23,26 +23,41 @@ internal class Complete
|
|||||||
public Summary Summary { get; }
|
public Summary Summary { get; }
|
||||||
public ReadOnlyCollection<Point> Points { get; }
|
public ReadOnlyCollection<Point> Points { get; }
|
||||||
|
|
||||||
public static Complete? Get(Shared.Logistics logistics, List<FileInfo> fileInfoCollection, ReadOnlyCollection<string> lines)
|
private static ReadOnlyCollection<string> FilterLines(ReadOnlyCollection<string> collection)
|
||||||
|
{
|
||||||
|
List<string> results = new();
|
||||||
|
foreach (string line in collection)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(line) || line is "*" or "@")
|
||||||
|
continue;
|
||||||
|
if (line.Length < 3 || line[0] is not '*' and not '@' || line[1] != ' ')
|
||||||
|
results.Add(line);
|
||||||
|
else
|
||||||
|
results.Add(line.Substring(2));
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Complete? Get(Shared.Logistics logistics, List<FileInfo> fileInfoCollection, ReadOnlyCollection<string> collection)
|
||||||
{
|
{
|
||||||
Complete? result;
|
Complete? result;
|
||||||
Constant constant = new();
|
Constant constant = new();
|
||||||
ReadOnlyCollection<string> collection = new(lines);
|
ReadOnlyCollection<string> lines = FilterLines(collection);
|
||||||
if (collection.Count <= constant.Take)
|
if (collection.Count <= constant.Take)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Header? header = Header.Get(constant, collection);
|
Header? header = Header.Get(constant, lines);
|
||||||
if (header is null)
|
if (header is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Summary? summary = SummarySegment.Get(constant, collection);
|
Summary? summary = SummarySegment.Get(constant, lines);
|
||||||
if (summary is null)
|
if (summary is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReadOnlyCollection<Point> points = Point.GetCollection(constant, collection) ?? throw new NullReferenceException(nameof(summary));
|
ReadOnlyCollection<Point> points = Point.GetCollection(constant, lines) ?? throw new NullReferenceException(nameof(summary));
|
||||||
if (points.Count == 0)
|
if (points.Count == 0)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
|
@ -3,7 +3,7 @@ namespace Adaptation.FileHandlers.pcl;
|
|||||||
internal class Constant
|
internal class Constant
|
||||||
{
|
{
|
||||||
|
|
||||||
public int Take { get; } = 12;
|
public int Take { get; } = 11;
|
||||||
public string Site { get; } = "Site: ";
|
public string Site { get; } = "Site: ";
|
||||||
public string Multiple { get; } = "MULTIPLE";
|
public string Multiple { get; } = "MULTIPLE";
|
||||||
public string SummaryLine { get; } = "SUMMARY A A";
|
public string SummaryLine { get; } = "SUMMARY A A";
|
||||||
|
@ -71,8 +71,9 @@ internal class Point
|
|||||||
string[] segments;
|
string[] segments;
|
||||||
string[] segmentsB;
|
string[] segmentsB;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
bool foundB = false;
|
|
||||||
string[] segmentsC;
|
string[] segmentsC;
|
||||||
|
bool foundB = false;
|
||||||
|
int x = constant.Take - 2;
|
||||||
List<string> sites = new();
|
List<string> sites = new();
|
||||||
for (int i = 0; i < lines.Count; i++)
|
for (int i = 0; i < lines.Count; i++)
|
||||||
{
|
{
|
||||||
@ -107,24 +108,24 @@ internal class Point
|
|||||||
segments = s.Split(new string[] { "(", ",", ")" }, StringSplitOptions.None);
|
segments = s.Split(new string[] { "(", ",", ")" }, StringSplitOptions.None);
|
||||||
if (segments.Length < 2)
|
if (segments.Length < 2)
|
||||||
break;
|
break;
|
||||||
segmentsB = lines[i + 10].Split(' ');
|
segmentsB = lines[i + x].Split(' ');
|
||||||
if (segmentsB.Length < 2)
|
if (segmentsB.Length < 2)
|
||||||
break;
|
break;
|
||||||
point = new(segments[0].Trim(),
|
point = new(site: segments[0].Trim(),
|
||||||
segments[1].Trim(),
|
x: segments[1].Trim(),
|
||||||
segments[2].Trim(),
|
y: segments[2].Trim(),
|
||||||
nAvg: lines[i + 2].Trim(),
|
nAvg: lines[i + 1].Trim(),
|
||||||
nsl: lines[i + 3].Trim(),
|
nsl: lines[i + 2].Trim(),
|
||||||
vd: lines[i + 4].Trim(),
|
vd: lines[i + 3].Trim(),
|
||||||
flatZ: lines[i + 5].Trim(),
|
flatZ: lines[i + 4].Trim(),
|
||||||
rhoAvg: lines[i + 6].Trim(),
|
rhoAvg: lines[i + 5].Trim(),
|
||||||
rhosl: lines[i + 7].Trim(),
|
rhosl: lines[i + 6].Trim(),
|
||||||
phase: lines[i + 8].Trim(),
|
phase: lines[i + 7].Trim(),
|
||||||
grade: lines[i + 9].Trim(),
|
grade: lines[i + 8].Trim(),
|
||||||
xLeft: segmentsB[0],
|
xLeft: segmentsB[0],
|
||||||
xRight: segmentsB[1],
|
xRight: segmentsB[1],
|
||||||
bottomY: lines[i + 11].Trim(),
|
bottomY: lines[i + 10].Trim(),
|
||||||
topY: lines[i + 12].Trim());
|
topY: lines[i + 11].Trim());
|
||||||
results.Add(point);
|
results.Add(point);
|
||||||
i += constant.Take;
|
i += constant.Take;
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,12 @@ internal class SummarySegment
|
|||||||
[JsonPropertyName("Navg")] public string NAvg { get; }
|
[JsonPropertyName("Navg")] public string NAvg { get; }
|
||||||
[JsonPropertyName("Nsl")] public string Nsl { get; }
|
[JsonPropertyName("Nsl")] public string Nsl { get; }
|
||||||
[JsonPropertyName("Vd")] public string Vd { get; }
|
[JsonPropertyName("Vd")] public string Vd { get; }
|
||||||
[JsonPropertyName("@ Flat Z")] public string FlatZ { get; }
|
[JsonPropertyName("Flat Z")] public string FlatZ { get; }
|
||||||
[JsonPropertyName("Rhoavg")] public string RhoAvg { get; }
|
[JsonPropertyName("Rhoavg")] public string RhoAvg { get; }
|
||||||
[JsonPropertyName("Rhosl")] public string Rhosl { get; }
|
[JsonPropertyName("Rhosl")] public string Rhosl { get; }
|
||||||
[JsonPropertyName("Phase")] public string Phase { get; }
|
[JsonPropertyName("Phase")] public string Phase { get; }
|
||||||
[JsonPropertyName("Grade")] public string Grade { get; }
|
[JsonPropertyName("Grade")] public string Grade { get; }
|
||||||
[JsonPropertyName("@ Rs")] public string Rs { get; }
|
[JsonPropertyName("Rs")] public string Rs { get; }
|
||||||
|
|
||||||
public static SummarySegment Get() =>
|
public static SummarySegment Get() =>
|
||||||
new(string.Empty,
|
new(string.Empty,
|
||||||
@ -64,6 +64,7 @@ internal class SummarySegment
|
|||||||
string[] segments;
|
string[] segments;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
string[] segmentsB;
|
string[] segmentsB;
|
||||||
|
List<string> names = new();
|
||||||
Dictionary<string, string> keyValuePairs = new();
|
Dictionary<string, string> keyValuePairs = new();
|
||||||
Dictionary<string, string> keyValuePairsB = new();
|
Dictionary<string, string> keyValuePairsB = new();
|
||||||
Dictionary<string, string> keyValuePairsC = new();
|
Dictionary<string, string> keyValuePairsC = new();
|
||||||
@ -81,11 +82,14 @@ internal class SummarySegment
|
|||||||
foreach (JsonProperty jsonProperty in jsonProperties)
|
foreach (JsonProperty jsonProperty in jsonProperties)
|
||||||
{
|
{
|
||||||
segments = line.Split(new string[] { $"{jsonProperty.Name}:", $"{jsonProperty.Name} :" }, StringSplitOptions.None);
|
segments = line.Split(new string[] { $"{jsonProperty.Name}:", $"{jsonProperty.Name} :" }, StringSplitOptions.None);
|
||||||
if (segments.Length < 2 || (!line.StartsWith(jsonProperty.Name) && !line.StartsWith($"@ {jsonProperty.Name}")))
|
if (segments.Length < 2 || !line.StartsWith(jsonProperty.Name))
|
||||||
continue;
|
continue;
|
||||||
segmentsB = segments[1].Trim().Split(' ');
|
segmentsB = segments[1].Trim().Split(' ');
|
||||||
if (segmentsB.Length < 3)
|
if (segmentsB.Length < 3)
|
||||||
continue;
|
continue;
|
||||||
|
if (names.Contains(jsonProperty.Name))
|
||||||
|
continue;
|
||||||
|
names.Add(jsonProperty.Name);
|
||||||
keyValuePairs.Add(jsonProperty.Name, segmentsB[0]);
|
keyValuePairs.Add(jsonProperty.Name, segmentsB[0]);
|
||||||
keyValuePairsB.Add(jsonProperty.Name, segmentsB[1]);
|
keyValuePairsB.Add(jsonProperty.Name, segmentsB[1]);
|
||||||
keyValuePairsC.Add(jsonProperty.Name, segmentsB[2]);
|
keyValuePairsC.Add(jsonProperty.Name, segmentsB[2]);
|
||||||
|
Reference in New Issue
Block a user