Skip to content

Commit

Permalink
Merge pull request #32 from 1manprojects/Omm_support
Browse files Browse the repository at this point in the history
added support for omm
  • Loading branch information
1manprojects authored Feb 16, 2024
2 parents df7884f + dbaab92 commit 7be248c
Show file tree
Hide file tree
Showing 18 changed files with 1,394 additions and 35 deletions.
14 changes: 14 additions & 0 deletions OneSGP4_Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ class Program
{
static void Main(string[] args)
{
/*
* Parse OMM (Orbit Mean-Elements Message)
*
string testpath = "path/to/omm.xml";
Parse OMM (Orbit Mean-Elements Message)
XmlDocument doc = new XmlDocument();
doc.Load(testpath);
List<Omm> OmmList = ParserOMM.Parse(doc);
Calculate Satellite Position and Speed
One_Sgp4.Sgp4 sgp4Propagator = new Sgp4(OmmList[0], Sgp4.wgsConstant.WGS_84);
*/

//Parse three line element
Tle tleISS = ParserTLE.parseTle(
"1 25544U 98067A 19364.04305556 -.00001219 00000-0 -13621-4 0 9993",
Expand Down
11 changes: 6 additions & 5 deletions One_Sgp4/One_Sgp4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net6.0;net5.0;net48;netcoreapp3.1</TargetFrameworks>
<Version>1.0.15</Version>
<PackageReleaseNotes>Added .net 5 .net 6 netcoreapp3. and net48 builds</PackageReleaseNotes>
<AssemblyVersion>1.0.15.0</AssemblyVersion>
<TargetFrameworks>netstandard2.1;netstandard2.0;net8,net6.0;net5.0;net48;netcoreapp3.1</TargetFrameworks>
<Version>1.1.0</Version>
<PackageReleaseNotes>Added ability to Parse OMM messages
Added .NET 8.0 Support</PackageReleaseNotes>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<PackageLicenseExpression />
<PackageLicenseFile>license.txt</PackageLicenseFile>
<FileVersion>1.0.15.0</FileVersion>
<FileVersion>1.1.0.0</FileVersion>
<Product>One_Sgp4</Product>
<PackageId>One_Sgp4</PackageId>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
Expand Down
154 changes: 154 additions & 0 deletions One_Sgp4/omm/Omm.cs
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;
}


}
}
40 changes: 40 additions & 0 deletions One_Sgp4/omm/OmmBase.cs
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;

Check warning on line 6 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.id' is never used
private static string model;

Check warning on line 7 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.model' is never used
private static string name;
private static string refFrame;
private static string timeSystem;

Check warning on line 10 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.timeSystem' is never used
private double ascendingNode;

Check warning on line 11 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.ascendingNode' is never used

Check warning on line 11 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.ascendingNode' is never used
private Enum.satClass classification;

Check warning on line 12 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.classification' is never used
private double dragTerm;
private double eccentricity;

Check warning on line 14 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.eccentricity' is never used

Check warning on line 14 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.eccentricity' is never used
private string ElementSet;

Check warning on line 15 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.ElementSet' is never used

Check warning on line 15 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.ElementSet' is never used
private int ElementSetNr;

private double ephemeris;

private EpochTime epoch;
private double firstMeanMotion;

Check warning on line 21 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.firstMeanMotion' is never used

Check warning on line 21 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.firstMeanMotion' is never used
private double inclination;
private double meanAnomoly;

Check warning on line 23 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.meanAnomoly' is never used

Check warning on line 23 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.meanAnomoly' is never used
private double meanMotion;

Check warning on line 24 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

Field 'OmmBase.meanMotion' is never assigned to, and will always have its default value 0

Check warning on line 24 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

Field 'OmmBase.meanMotion' is never assigned to, and will always have its default value 0
private string noradCatId;

Check warning on line 25 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.noradCatId' is never used
private double pareicenter;

Check warning on line 26 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.pareicenter' is never used
private double revAtEpoch;
private double secondMeanMotion;

Check warning on line 28 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.secondMeanMotion' is never used

Check warning on line 28 in One_Sgp4/omm/OmmBase.cs

View workflow job for this annotation

GitHub Actions / build

The field 'OmmBase.secondMeanMotion' is never used

public EpochTime getEpochTime()
{
return epoch;
}

public double getMeanMotion()
{
return meanMotion;
}
}
}
93 changes: 93 additions & 0 deletions One_Sgp4/omm/ParserOMM.cs
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"));
}
}

}
}
Loading

0 comments on commit 7be248c

Please sign in to comment.