Open alhamri opened 2 years ago
The error happens, because on the calculation of Astronomical.correctedHourAngle for sunrise with the coordinates given, the value passed to calculate degree is -1.0000000008014773. This is impossible to achieve hence error occurs.
The error happens, because on the calculation of Astronomical.correctedHourAngle for sunrise with the coordinates given, the value passed to calculate degree is -1.0000000008014773. This is impossible to achieve hence error occurs.
yes the bug is there. I tried to solve it in the plugin by checking the value passed to acos function: if it is less than -1, assign -1 to the value if it is greater than 1, assign 1 to the value.
snippet code (before changing):
final term1 = sin(radians(h0)) -
(sin(radians(coordinates.latitude)) * sin(radians(delta2)));
final term2 = cos(radians(coordinates.latitude)) * cos(radians(delta2));
final H0 = degrees(acos(term1 / term2));
final m = afterTransit ? m0 + (H0 / 360) : m0 - (H0 / 360);
snippet code (after changing):
final term1 = sin(radians(h0)) -
(sin(radians(coordinates.latitude)) * sin(radians(delta2)));
final term2 = cos(radians(coordinates.latitude)) * cos(radians(delta2));
var y = term1 / term2;
if(y < -1.0) y = -1.0;
if(y > 1.0) y = 1.0;
final H0 = degrees(acos(y));
final m = afterTransit ? m0 + (H0 / 360) : m0 - (H0 / 360);
the exception is gone and it worked as expected, but i am not sure if the time given is correct or not?
Have you found a solution? At the moment, the library throws an exception if the latitude is greater than 73 degrees
final term1 = sin(radians(h0)) - (sin(radians(coordinates.latitude)) sin(radians(delta2))); final term2 = cos(radians(coordinates.latitude)) cos(radians(delta2)); var y = term1 / term2; if(y < -1.0) y = -1.0; if(y > 1.0) y = 1.0; final H0 = degrees(acos(y)); final m = afterTransit ? m0 + (H0 / 360) : m0 - (H0 / 360);
Changes are causing tests to fail!
Describe the bug latitude values between (-67.5944046 and -90) and between (65.9277379 and 90) throw Unhandled exception!
To Reproduce minimum code that reproduce the error:
Expected behavior should output the actual time of the giving parameters.
but it throws an error:
run flutter doctor:
Environment(please complete the following information):