Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Cannot parse "eop_finals.txt" file #29

Closed
barissaydag opened this issue Oct 18, 2017 · 5 comments
Closed

BUG: Cannot parse "eop_finals.txt" file #29

barissaydag opened this issue Oct 18, 2017 · 5 comments

Comments

@barissaydag
Copy link

barissaydag commented Oct 18, 2017

Hi,

I think atoi and int.Parse functions are implemented differently in C and C#. C# doesn't like to parse empty strings, and doesn't stop when it sees space. Therefore, I am getting invalid number exception in load_dpsi_deps. I worked around with below (crude) changes:

double.Parse(s.Substring(99), ...
to
double.Parse(s.Substring(99, 8).Trim() == "" ? "0" : s.Substring(99, 8).Trim(), ....

Here are the full changes:

while ((s = fp.ReadLine()) != null) {
                mjd = (int) double.Parse(s.Substring(7, 5));  // here
                if (mjd + TJDOFS <= swed.eop_tjd_end)
                    continue;
                if (n >= Sweph.SWE_DATA_DPSI_DEPS)
                    return;
                /* are data in one-day steps? */
                if (mjdsv > 0 && mjd - mjdsv != 1) {
                    /* no error, as we do have data; however, if this file is usefull,
                     * then swed.eop_dpsi_loaded will be set to 2 */
                    swed.eop_dpsi_loaded = -3;
                    fp.Dispose();
                    return;
                }
				/* dpsi, deps Bulletin B */
				dpsi = double.Parse(s.Substring(168, 8).Trim() == "" ? "0" : s.Substring(168, 8).Trim(), CultureInfo.InvariantCulture);
                deps = double.Parse(s.Substring(178, 8).Trim() == "" ? "0" : s.Substring(178, 8).Trim(), CultureInfo.InvariantCulture);
                if (dpsi == 0) {
					/* try dpsi, deps Bulletin A */
					dpsi = double.Parse(s.Substring(99, 8).Trim() == "" ? "0" : s.Substring(99, 8).Trim(), CultureInfo.InvariantCulture);
                    deps = double.Parse(**s.Substring(118, 8).Trim() == "" ? "0" : s.Substring(118, 8).Trim()**, CultureInfo.InvariantCulture);
                }
@ygrenier
Copy link
Owner

Hi,

Thanks for the issue report.

Yes atoi/atof don't have same behavior than int.Parse()/double.Parse(). Normally I was implemented these functions perhaps I missed use them.

I need two things for the test:

  • where can I find the "eop_finals.txt" file ?
  • which code I need to invoke the loading of this file ?

Regards,

@barissaydag
Copy link
Author

I am soooo sorry, I completely forgot responding you. Yet I was checking Nuget for updates and bug fixes! I uploaded files...

Thanks again for your help.

eop_1962_today.txt
eop_finals.txt

@ygrenier
Copy link
Owner

No problem, this happen to me :)

I'll try to fix some bugs (#29, #30) this WE.

@ygrenier
Copy link
Owner

This issue if fixed with the 2.6.0.23 version.

@barissaydag
Copy link
Author

I confirm that it is fixed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants