-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
added support for omm
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
namespace One_Sgp4.omm | ||
{ | ||
public class Omm | ||
{ | ||
private string name; | ||
private string id; | ||
private string timeSystem; | ||
private string refFrame; | ||
private string centerName; | ||
private string model; | ||
|
||
private EpochTime epoch; | ||
private double meanMotion; | ||
private double eccentricity; | ||
private double inclination; | ||
private double ascendingNode; | ||
private double pareicenter; | ||
private double meanAnomoly; | ||
|
||
private double ephemeris; | ||
private Enum.satClass classification; | ||
private string noradCatId; | ||
private int elementSet; | ||
private double revAtEpoch; | ||
private double dragTerm; | ||
private double firstMeanMotion; | ||
private double secondMeanMotion; | ||
|
||
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) | ||
{ | ||
this.name = name; | ||
this.id = id; | ||
this.timeSystem = timeSystem; | ||
this.refFrame = refFrame; | ||
this.centerName = centerName; | ||
this.model = model; | ||
|
||
this.epoch = epoch; | ||
this.meanMotion = meanMotion; | ||
this.eccentricity = eccentricity; | ||
this.inclination = inclination; | ||
this.ascendingNode = ascendingNode; | ||
this.pareicenter = pareicenter; | ||
this.meanAnomoly = meanAnomoly; | ||
|
||
this.ephemeris = ephemeris; | ||
this.classification = classification; | ||
this.noradCatId = noradCatId; | ||
this.elementSet = elementSet; | ||
this.revAtEpoch = revAtEpoch; | ||
this.dragTerm = dragTerm; | ||
this.firstMeanMotion = firstMeanMotion; | ||
this.secondMeanMotion = secondMeanMotion; | ||
} | ||
|
||
public double getMeanMotion() | ||
{ | ||
return meanMotion; | ||
} | ||
|
||
public EpochTime getEpochTime() | ||
{ | ||
return epoch; | ||
} | ||
|
||
public double getMeanAnomoly() | ||
{ | ||
return meanAnomoly; | ||
} | ||
|
||
public double getEphemeris() | ||
{ | ||
return ephemeris; | ||
} | ||
|
||
public int getClassification() | ||
{ | ||
return (int)classification; | ||
} | ||
|
||
public string getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public string getId() | ||
{ | ||
return id; | ||
} | ||
|
||
public string getTimeSystem() | ||
{ | ||
return timeSystem; | ||
} | ||
|
||
public string getRefFrame() | ||
{ | ||
return refFrame; | ||
} | ||
|
||
public string getCenterName() | ||
{ | ||
return centerName; | ||
} | ||
|
||
public string getModel() | ||
{ | ||
return model; | ||
} | ||
|
||
public double getEccentricity() | ||
{ | ||
return eccentricity; | ||
} | ||
public double getInclination() | ||
{ | ||
return inclination; | ||
} | ||
public double getAscendingNode() | ||
{ | ||
return ascendingNode; | ||
} | ||
public double getPareicenter() | ||
{ | ||
return pareicenter; | ||
} | ||
public string getNoradCatId() | ||
{ | ||
return noradCatId; | ||
} | ||
public int getElementSet() | ||
{ | ||
return elementSet; | ||
} | ||
public double getRevAtEpoch() | ||
{ | ||
return revAtEpoch; | ||
} | ||
public double getDragTerm() | ||
{ | ||
return dragTerm; | ||
} | ||
public double getFirstMeanMotion() | ||
{ | ||
return firstMeanMotion; | ||
} | ||
public double getSecondMeanMotion() | ||
{ | ||
return secondMeanMotion; | ||
} | ||
|
||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace One_Sgp4.omm | ||
{ | ||
public class OmmBase | ||
{ | ||
private static string centerName; | ||
private static string id; | ||
private static string model; | ||
private static string name; | ||
private static string refFrame; | ||
private static string timeSystem; | ||
private double ascendingNode; | ||
Check warning on line 11 in One_Sgp4/omm/OmmBase.cs GitHub Actions / build
|
||
private Enum.satClass classification; | ||
private double dragTerm; | ||
private double eccentricity; | ||
Check warning on line 14 in One_Sgp4/omm/OmmBase.cs GitHub Actions / build
|
||
private string ElementSet; | ||
Check warning on line 15 in One_Sgp4/omm/OmmBase.cs GitHub Actions / build
|
||
private int ElementSetNr; | ||
|
||
private double ephemeris; | ||
|
||
private EpochTime epoch; | ||
private double firstMeanMotion; | ||
Check warning on line 21 in One_Sgp4/omm/OmmBase.cs GitHub Actions / build
|
||
private double inclination; | ||
private double meanAnomoly; | ||
Check warning on line 23 in One_Sgp4/omm/OmmBase.cs GitHub Actions / build
|
||
private double meanMotion; | ||
Check warning on line 24 in One_Sgp4/omm/OmmBase.cs GitHub Actions / build
|
||
private string noradCatId; | ||
private double pareicenter; | ||
private double revAtEpoch; | ||
private double secondMeanMotion; | ||
Check warning on line 28 in One_Sgp4/omm/OmmBase.cs GitHub Actions / build
|
||
|
||
public EpochTime getEpochTime() | ||
{ | ||
return epoch; | ||
} | ||
|
||
public double getMeanMotion() | ||
{ | ||
return meanMotion; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Xml; | ||
using System.Xml.Linq; | ||
|
||
namespace One_Sgp4.omm | ||
{ | ||
public class ParserOMM | ||
{ | ||
/** | ||
* \brief ParserOMM class | ||
* | ||
* This class handles the reading and converting of OMM XML Format to the TLE Class information | ||
*/ | ||
|
||
public static List<Omm> Parse(XmlDocument ommDocument) | ||
{ | ||
XmlNamespaceManager namespaces = new XmlNamespaceManager(ommDocument.NameTable); | ||
namespaces.AddNamespace("ns", "http://www.w3.org/2001/XMLSchema-instance"); | ||
|
||
List<Omm> omms = new List<Omm>(); | ||
XmlNodeList ommXmlItems = ommDocument.GetElementsByTagName("omm"); | ||
|
||
for (int i = 0; i < ommXmlItems.Count; i++) | ||
{ | ||
XmlNode ommItem = ommXmlItems.Item(i); | ||
|
||
XmlNode tleMetaDataNode = ommItem.SelectSingleNode("body/segment/metadata"); | ||
XmlNode tleMeanElementsNode = ommItem.SelectSingleNode("body/segment/data/meanElements"); | ||
XmlNode tleParametersNode = ommItem.SelectSingleNode("body/segment/data/tleParameters"); | ||
|
||
//metadata | ||
string name = tleMetaDataNode.SelectSingleNode("OBJECT_NAME", namespaces).InnerText; | ||
string noradId = tleMetaDataNode.SelectSingleNode("OBJECT_ID").InnerText; | ||
string timeSystem = tleMetaDataNode.SelectSingleNode("TIME_SYSTEM").InnerText; | ||
string refFrame = tleMetaDataNode.SelectSingleNode("REF_FRAME").InnerText; | ||
string centerName = tleMetaDataNode.SelectSingleNode("CENTER_NAME").InnerText; | ||
string model = tleMetaDataNode.SelectSingleNode("MEAN_ELEMENT_THEORY").InnerText; | ||
|
||
//meanElements | ||
EpochTime epochTime = parseOmmEpoch(tleMeanElementsNode.SelectSingleNode("EPOCH").InnerText, timeSystem.Equals("UTC")); | ||
|
||
double meanMotion = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("MEAN_MOTION").InnerText); | ||
double eccentricity = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("ECCENTRICITY").InnerText); | ||
double inclination = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("INCLINATION").InnerText); | ||
double ascendingNode = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("RA_OF_ASC_NODE").InnerText); | ||
double pareicenter = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("ARG_OF_PERICENTER").InnerText); | ||
double meanAnomoly = parseStringToDouble(tleMeanElementsNode.SelectSingleNode("MEAN_ANOMALY").InnerText); | ||
|
||
//tleParameters | ||
double ephemeris = parseStringToDouble(tleParametersNode.SelectSingleNode("EPHEMERIS_TYPE").InnerText); | ||
Enum.satClass classification = ParserTLE.parseClassification(tleParametersNode.SelectSingleNode("CLASSIFICATION_TYPE").InnerText); | ||
string noradCatId = tleParametersNode.SelectSingleNode("NORAD_CAT_ID").InnerText; | ||
int elementSetNr = Int32.Parse(tleParametersNode.SelectSingleNode("ELEMENT_SET_NO").InnerText); | ||
double revAtEpoch = parseStringToDouble(tleParametersNode.SelectSingleNode("REV_AT_EPOCH").InnerText); | ||
double dragTerm = parseStringToDouble(tleParametersNode.SelectSingleNode("BSTAR").InnerText); | ||
double firstMeanMotion = parseStringToDouble(tleParametersNode.SelectSingleNode("MEAN_MOTION_DOT").InnerText); | ||
double secondMeanMotion = parseStringToDouble(tleParametersNode.SelectSingleNode("MEAN_MOTION_DDOT").InnerText); | ||
|
||
omms.Add(new Omm(name, noradId, timeSystem, refFrame, centerName, model, | ||
epochTime, meanMotion, eccentricity, inclination, ascendingNode, pareicenter, meanAnomoly, | ||
ephemeris, classification, noradCatId, elementSetNr, revAtEpoch, dragTerm, firstMeanMotion, secondMeanMotion)); | ||
|
||
} | ||
|
||
return omms; | ||
} | ||
|
||
public static EpochTime parseOmmEpoch(string ommString, bool utc) | ||
{ | ||
if (utc) | ||
{ | ||
ommString = ommString + "Z"; | ||
} | ||
DateTime dt = DateTime.ParseExact(ommString, "yyyy-MM-ddTHH:mm:ss.ffffffZ", CultureInfo.InvariantCulture); | ||
return new EpochTime(dt); | ||
} | ||
|
||
private static double parseStringToDouble(string rawValue) | ||
{ | ||
if (rawValue.StartsWith(".")) | ||
{ | ||
return Double.Parse(("0" + rawValue), CultureInfo.GetCultureInfo("en-US")); | ||
} else | ||
{ | ||
return Double.Parse(rawValue, CultureInfo.GetCultureInfo("en-US")); | ||
} | ||
} | ||
|
||
} | ||
} |