1manprojects / one_Sgp4

C# SGP4 orbit prediction Library
MIT License
60 stars 14 forks source link

Error in One_Sgp4.ParserTLE.parseTle function #24

Closed mhmdscin closed 3 years ago

mhmdscin commented 3 years ago

Describe the bug I was using your library for a long time and it was working like a charm. Today I encounter an error in this function in my program, while I haven't change anything

To Reproduce

ln1="1 40069U 14037A   20316.10616772 -.00000018  00000+0  11185-4 0  9995"
ln2="2 40069  98.4875 347.9908 0005143 206.3045 153.7872 14.20677273329034"
satName="METEOR-M 2"
Dim tleData As Tle = ParserTLE.parseTle(ln1, ln2, satName)

This raise an exception :

System.IO.InvalidDataException
HResult=0x80131501
Message=Data contained parse error(s).
Source=One_Sgp4

StackTrace:
     at One_Sgp4.ParserTLE.parseTle(String tleLine1, String tleLine2, String tleName)
     This exception was originally thrown at this call stack:
     string.Substring(int, int)
     One_Sgp4.ParserTLE.parseTle(string, string, string)
Inner Exception 1:
     ArgumentOutOfRangeException: Length cannot be less than zero.
     Parameter name: length

Version:

Additional context I have downloaded the tle data from here: https://celestrak.com/NORAD/elements/weather.txt

the issue can also be reproduce with following data: METEOR-M 2
1 40069U 14037A 20316.66959948 -.00000019 00000+0 10591-4 0 9992 2 40069 98.4874 348.5318 0005172 204.5397 155.5535 14.20677290329111

edetoc commented 3 years ago

I'm facing the same "Data contained parse error(s)." exception today too for the ISS. No change in my code since a while. This was working great until now. I'm also getting the TLE for the ISS from celestrak.com:

ISS (ZARYA)
1 25544U 98067A 20316.41516162 .00001589 00000+0 36499-4 0 9995 2 25544 51.6454 339.9628 0001882 94.8340 265.2864 15.49409479254842

System.IO.InvalidDataException HResult=0x80131501 Message=Data contained parse error(s). Source=One_Sgp4 StackTrace: at One_Sgp4.ParserTLE.parseTle(String tleLine1, String tleLine2, String tleName) at One_Sgp4.ParserTLE.ParseFile(String filename, String satName) at OneSGP4UWP.MainPage.d__13.MoveNext() in C:\DEV\Repos\OneSGP4UWP\OneSGP4UWP\MainPage.xaml.cs:line 219

This exception was originally thrown at this call stack: [External Code]

Inner Exception 1: ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length

1manprojects commented 3 years ago

An Exeption is being triggered here since the first line of the TLE-Data does not match the expected format. The Parser expects the following formating. 1 NNNNNC NNNNNAAA NNNNN.NNNNNNNN +.NNNNNNNN +NNNNN-N +NNNNN-N N NNNNN The Drag-Term (position 54-61) should be +NNNNN-N However, for the TLE provided in this Issue has a plus Symbol +NNNNN+N thus an exeption is caused while parsing.

I will expand the Parser to handle 00000+0 inputs in the first TLE line. I will close this issue as soon as a new version is pushed.

1manprojects commented 3 years ago

New Release version 1.0.13 has been publisched to NuGet and Github.