mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-04-05 17:39:39 -04:00
Fix barycentre naming logic
This commit is contained in:
parent
7a7c110b45
commit
cacaa98033
@ -67,10 +67,36 @@ namespace Observatory.Explorer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string IncrementOrdinal(string ordinal)
|
||||||
|
{
|
||||||
|
char ordChar = ordinal.ToCharArray().Last();
|
||||||
|
|
||||||
|
if (new char[] {'Z', '9'}.Contains(ordChar))
|
||||||
|
{
|
||||||
|
ordinal = IncrementOrdinal(ordinal.Length == 1 ? " " : String.Empty + ordinal[..^1]);
|
||||||
|
ordChar = (char)(ordChar - 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ordinal[..^1] + (char)(ordChar + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string DecrementOrdinal(string ordinal)
|
||||||
|
{
|
||||||
|
char ordChar = ordinal.ToCharArray().Last();
|
||||||
|
|
||||||
|
if (new char[] { 'A', '0' }.Contains(ordChar))
|
||||||
|
{
|
||||||
|
ordinal = DecrementOrdinal(ordinal[..^1]);
|
||||||
|
ordChar = (char)(ordChar + 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ordinal[..^1] + (char)(ordChar - 1);
|
||||||
|
}
|
||||||
|
|
||||||
public Scan ConvertBarycentre(ScanBaryCentre barycentre, Scan childScan)
|
public Scan ConvertBarycentre(ScanBaryCentre barycentre, Scan childScan)
|
||||||
{
|
{
|
||||||
string childAffix = childScan.BodyName
|
string childAffix = childScan.BodyName
|
||||||
.Replace(childScan.StarSystem, string.Empty);
|
.Replace(childScan.StarSystem, string.Empty).Trim();
|
||||||
|
|
||||||
string baryName;
|
string baryName;
|
||||||
|
|
||||||
@ -82,20 +108,18 @@ namespace Observatory.Explorer
|
|||||||
bool lowChild = childScan.BodyID - barycentre.BodyID == 1;
|
bool lowChild = childScan.BodyID - barycentre.BodyID == 1;
|
||||||
|
|
||||||
string baryAffix;
|
string baryAffix;
|
||||||
|
|
||||||
// Barycentre ordinal always labelled as low before high, e.g. "AB"
|
// Barycentre ordinal always labelled as low before high, e.g. "AB"
|
||||||
if (lowChild)
|
if (lowChild)
|
||||||
{
|
{
|
||||||
baryAffix = new string(new char[] { childOrdinal, (char)(childOrdinal + 1) });
|
baryAffix = childAffix + "-" + IncrementOrdinal(childAffix);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
baryAffix = new string(new char[] { (char)(childOrdinal - 1), childOrdinal });
|
baryAffix = DecrementOrdinal(childAffix) + "-" + childAffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
baryAffix = childAffix.Replace(childOrdinal.ToString(), baryAffix);
|
baryName = barycentre.StarSystem + " " + baryAffix;
|
||||||
|
|
||||||
baryName = barycentre.StarSystem + baryAffix;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user