mikereedell / sunrisesunsetlib-java

Library for computing the sunrise/sunset from GPS coordinates and a date, in Java.
http://mikereedell.github.com/sunrisesunsetlib-java/
Apache License 2.0
299 stars 69 forks source link

Wrong calculation #10

Open TheNephilim88 opened 10 years ago

TheNephilim88 commented 10 years ago

Hello,

strangewise I get wrong results for sunset, set of civil blue hour on 21. june 2014 for the location 50.93311 - 11.58336.

Only on this day the *set times are miscalculated by 6 hours.

Usually sunset should be around 21:31, but it calculates 15:31 (for official zenith).

When I switch the "isSunRise"-param for the getLongitudeHour-function to "true" it calculates correctly - but I dont think that its a good idea to set isSunRise-param to true for sunset-values :D

Can anyone help fix the bug? Why does it only occur on this day and this location? If I use a location not far away from this, it calculates correctly.

MenoData commented 6 years ago

Seems to be a bug. For reproducibility (test code):

    Location location = new Location(50.93311, 11.58336);
    SolarEventCalculator calc = new SolarEventCalculator(location, "Europe/Berlin");
    GregorianCalendar eventDate = new GregorianCalendar(2014, Calendar.JUNE, 21);
    eventDate.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
    String actual = calc.computeSunsetTime(Zenith.OFFICIAL, eventDate);
    System.out.println("mike-reedell=>" + actual); // 15:31

I could also verify that the day before and the day after produce correct times (21:31 and 21:32). And indeed, choosing the longitude 11.0 instead of 11.58336 also "solves" the problem.