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