Skip to content

Commit dbaab92

Browse files
author
reed
committed
added support for omm
1 parent df7884f commit dbaab92

18 files changed

+1394
-35
lines changed

OneSGP4_Example/Program.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ class Program
88
{
99
static void Main(string[] args)
1010
{
11+
/*
12+
* Parse OMM (Orbit Mean-Elements Message)
13+
*
14+
string testpath = "path/to/omm.xml";
15+
Parse OMM (Orbit Mean-Elements Message)
16+
XmlDocument doc = new XmlDocument();
17+
doc.Load(testpath);
18+
List<Omm> OmmList = ParserOMM.Parse(doc);
19+
20+
Calculate Satellite Position and Speed
21+
22+
One_Sgp4.Sgp4 sgp4Propagator = new Sgp4(OmmList[0], Sgp4.wgsConstant.WGS_84);
23+
*/
24+
1125
//Parse three line element
1226
Tle tleISS = ParserTLE.parseTle(
1327
"1 25544U 98067A 19364.04305556 -.00001219 00000-0 -13621-4 0 9993",

One_Sgp4/One_Sgp4.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
</PropertyGroup>
1919

2020
<PropertyGroup>
21-
<TargetFrameworks>netstandard2.1;netstandard2.0;net6.0;net5.0;net48;netcoreapp3.1</TargetFrameworks>
22-
<Version>1.0.15</Version>
23-
<PackageReleaseNotes>Added .net 5 .net 6 netcoreapp3. and net48 builds</PackageReleaseNotes>
24-
<AssemblyVersion>1.0.15.0</AssemblyVersion>
21+
<TargetFrameworks>netstandard2.1;netstandard2.0;net8,net6.0;net5.0;net48;netcoreapp3.1</TargetFrameworks>
22+
<Version>1.1.0</Version>
23+
<PackageReleaseNotes>Added ability to Parse OMM messages
24+
Added .NET 8.0 Support</PackageReleaseNotes>
25+
<AssemblyVersion>1.1.0.0</AssemblyVersion>
2526
<PackageLicenseExpression />
2627
<PackageLicenseFile>license.txt</PackageLicenseFile>
27-
<FileVersion>1.0.15.0</FileVersion>
28+
<FileVersion>1.1.0.0</FileVersion>
2829
<Product>One_Sgp4</Product>
2930
<PackageId>One_Sgp4</PackageId>
3031
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>

One_Sgp4/omm/Omm.cs

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
namespace One_Sgp4.omm
2+
{
3+
public class Omm
4+
{
5+
private string name;
6+
private string id;
7+
private string timeSystem;
8+
private string refFrame;
9+
private string centerName;
10+
private string model;
11+
12+
private EpochTime epoch;
13+
private double meanMotion;
14+
private double eccentricity;
15+
private double inclination;
16+
private double ascendingNode;
17+
private double pareicenter;
18+
private double meanAnomoly;
19+
20+
private double ephemeris;
21+
private Enum.satClass classification;
22+
private string noradCatId;
23+
private int elementSet;
24+
private double revAtEpoch;
25+
private double dragTerm;
26+
private double firstMeanMotion;
27+
private double secondMeanMotion;
28+
29+
public Omm(string name, string id, string timeSystem, string refFrame, string centerName, string model, EpochTime epoch, double meanMotion, double eccentricity, double inclination, double ascendingNode, double pareicenter, double meanAnomoly, double ephemeris, Enum.satClass classification, string noradCatId, int elementSet, double revAtEpoch, double dragTerm, double firstMeanMotion, double secondMeanMotion)
30+
{
31+
this.name = name;
32+
this.id = id;
33+
this.timeSystem = timeSystem;
34+
this.refFrame = refFrame;
35+
this.centerName = centerName;
36+
this.model = model;
37+
38+
this.epoch = epoch;
39+
this.meanMotion = meanMotion;
40+
this.eccentricity = eccentricity;
41+
this.inclination = inclination;
42+
this.ascendingNode = ascendingNode;
43+
this.pareicenter = pareicenter;
44+
this.meanAnomoly = meanAnomoly;
45+
46+
this.ephemeris = ephemeris;
47+
this.classification = classification;
48+
this.noradCatId = noradCatId;
49+
this.elementSet = elementSet;
50+
this.revAtEpoch = revAtEpoch;
51+
this.dragTerm = dragTerm;
52+
this.firstMeanMotion = firstMeanMotion;
53+
this.secondMeanMotion = secondMeanMotion;
54+
}
55+
56+
public double getMeanMotion()
57+
{
58+
return meanMotion;
59+
}
60+
61+
public EpochTime getEpochTime()
62+
{
63+
return epoch;
64+
}
65+
66+
public double getMeanAnomoly()
67+
{
68+
return meanAnomoly;
69+
}
70+
71+
public double getEphemeris()
72+
{
73+
return ephemeris;
74+
}
75+
76+
public int getClassification()
77+
{
78+
return (int)classification;
79+
}
80+
81+
public string getName()
82+
{
83+
return name;
84+
}
85+
86+
public string getId()
87+
{
88+
return id;
89+
}
90+
91+
public string getTimeSystem()
92+
{
93+
return timeSystem;
94+
}
95+
96+
public string getRefFrame()
97+
{
98+
return refFrame;
99+
}
100+
101+
public string getCenterName()
102+
{
103+
return centerName;
104+
}
105+
106+
public string getModel()
107+
{
108+
return model;
109+
}
110+
111+
public double getEccentricity()
112+
{
113+
return eccentricity;
114+
}
115+
public double getInclination()
116+
{
117+
return inclination;
118+
}
119+
public double getAscendingNode()
120+
{
121+
return ascendingNode;
122+
}
123+
public double getPareicenter()
124+
{
125+
return pareicenter;
126+
}
127+
public string getNoradCatId()
128+
{
129+
return noradCatId;
130+
}
131+
public int getElementSet()
132+
{
133+
return elementSet;
134+
}
135+
public double getRevAtEpoch()
136+
{
137+
return revAtEpoch;
138+
}
139+
public double getDragTerm()
140+
{
141+
return dragTerm;
142+
}
143+
public double getFirstMeanMotion()
144+
{
145+
return firstMeanMotion;
146+
}
147+
public double getSecondMeanMotion()
148+
{
149+
return secondMeanMotion;
150+
}
151+
152+
153+
}
154+
}

One_Sgp4/omm/OmmBase.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace One_Sgp4.omm
2+
{
3+
public class OmmBase
4+
{
5+
private static string centerName;
6+
private static string id;
7+
private static string model;
8+
private static string name;
9+
private static string refFrame;
10+
private static string timeSystem;
11+
private double ascendingNode;
12+
private Enum.satClass classification;
13+
private double dragTerm;
14+
private double eccentricity;
15+
private string ElementSet;
16+
private int ElementSetNr;
17+
18+
private double ephemeris;
19+
20+
private EpochTime epoch;
21+
private double firstMeanMotion;
22+
private double inclination;
23+
private double meanAnomoly;
24+
private double meanMotion;
25+
private string noradCatId;
26+
private double pareicenter;
27+
private double revAtEpoch;
28+
private double secondMeanMotion;
29+
30+
public EpochTime getEpochTime()
31+
{
32+
return epoch;
33+
}
34+
35+
public double getMeanMotion()
36+
{
37+
return meanMotion;
38+
}
39+
}
40+
}

One_Sgp4/omm/ParserOMM.cs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.IO;
5+
using System.Xml;
6+
using System.Xml.Linq;
7+
8+
namespace One_Sgp4.omm
9+
{
10+
public class ParserOMM
11+
{
12+
/**
13+
* \brief ParserOMM class
14+
*
15+
* This class handles the reading and converting of OMM XML Format to the TLE Class information
16+
*/
17+
18+
public static List<Omm> Parse(XmlDocument ommDocument)
19+
{
20+
XmlNamespaceManager namespaces = new XmlNamespaceManager(ommDocument.NameTable);
21+
namespaces.AddNamespace("ns", "http://www.w3.org/2001/XMLSchema-instance");
22+
23+
List<Omm> omms = new List<Omm>();
24+
XmlNodeList ommXmlItems = ommDocument.GetElementsByTagName("omm");
25+
26+
for (int i = 0; i < ommXmlItems.Count; i++)
27+
{
28+
XmlNode ommItem = ommXmlItems.Item(i);
29+
30+
XmlNode tleMetaDataNode = ommItem.SelectSingleNode("body/segment/metadata");
31+
XmlNode tleMeanElementsNode = ommItem.SelectSingleNode("body/segment/data/meanElements");
32+
XmlNode tleParametersNode = ommItem.SelectSingleNode("body/segment/data/tleParameters");
33+
34+
//metadata
35+
string name = tleMetaDataNode.SelectSingleNode("OBJECT_NAME", namespaces).InnerText;
36+
string noradId = tleMetaDataNode.SelectSingleNode("OBJECT_ID").InnerText;
37+
string timeSystem = tleMetaDataNode.SelectSingleNode("TIME_SYSTEM").InnerText;
38+
string refFrame = tleMetaDataNode.SelectSingleNode("REF_FRAME").InnerText;
39+
string centerName = tleMetaDataNode.SelectSingleNode("CENTER_NAME").InnerText;
40+
string model = tleMetaDataNode.SelectSingleNode("MEAN_ELEMENT_THEORY").InnerText;
41+
42+
//meanElements
43+
EpochTime epochTime = parseOmmEpoch(tleMeanElementsNode.SelectSingleNode("EPOCH").InnerText, timeSystem.Equals("UTC"));
44+
45+
double meanMotion = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("MEAN_MOTION").InnerText);
46+
double eccentricity = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("ECCENTRICITY").InnerText);
47+
double inclination = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("INCLINATION").InnerText);
48+
double ascendingNode = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("RA_OF_ASC_NODE").InnerText);
49+
double pareicenter = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("ARG_OF_PERICENTER").InnerText);
50+
double meanAnomoly = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("MEAN_ANOMALY").InnerText);
51+
52+
//tleParameters
53+
double ephemeris = parseStringToDouble(tleParametersNode.SelectSingleNode("EPHEMERIS_TYPE").InnerText);
54+
Enum.satClass classification = ParserTLE.parseClassification(tleParametersNode.SelectSingleNode("CLASSIFICATION_TYPE").InnerText);
55+
string noradCatId = tleParametersNode.SelectSingleNode("NORAD_CAT_ID").InnerText;
56+
int elementSetNr = Int32.Parse(tleParametersNode.SelectSingleNode("ELEMENT_SET_NO").InnerText);
57+
double revAtEpoch = parseStringToDouble(tleParametersNode.SelectSingleNode("REV_AT_EPOCH").InnerText);
58+
double dragTerm = parseStringToDouble(tleParametersNode.SelectSingleNode("BSTAR").InnerText);
59+
double firstMeanMotion = parseStringToDouble(tleParametersNode.SelectSingleNode("MEAN_MOTION_DOT").InnerText);
60+
double secondMeanMotion = parseStringToDouble(tleParametersNode.SelectSingleNode("MEAN_MOTION_DDOT").InnerText);
61+
62+
omms.Add(new Omm(name, noradId, timeSystem, refFrame, centerName, model,
63+
epochTime, meanMotion, eccentricity, inclination, ascendingNode, pareicenter, meanAnomoly,
64+
ephemeris, classification, noradCatId, elementSetNr, revAtEpoch, dragTerm, firstMeanMotion, secondMeanMotion));
65+
66+
}
67+
68+
return omms;
69+
}
70+
71+
public static EpochTime parseOmmEpoch(string ommString, bool utc)
72+
{
73+
if (utc)
74+
{
75+
ommString = ommString + "Z";
76+
}
77+
DateTime dt = DateTime.ParseExact(ommString, "yyyy-MM-ddTHH:mm:ss.ffffffZ", CultureInfo.InvariantCulture);
78+
return new EpochTime(dt);
79+
}
80+
81+
private static double parseStringToDouble(string rawValue)
82+
{
83+
if (rawValue.StartsWith("."))
84+
{
85+
return Double.Parse(("0" + rawValue), CultureInfo.GetCultureInfo("en-US"));
86+
} else
87+
{
88+
return Double.Parse(rawValue, CultureInfo.GetCultureInfo("en-US"));
89+
}
90+
}
91+
92+
}
93+
}

0 commit comments

Comments
 (0)