org.itc.idv.math
Class SunriseSunsetCollector

java.lang.Object
  extended by org.itc.idv.math.SunriseSunsetCollector

public class SunriseSunsetCollector
extends java.lang.Object

Helper class for calculating sunsrise/sunset pairs. The sunset/sunrise times are calculated geometrically; the influence of the atmosphere as well as the diameter of the sun are not taken into account.

The times calculated are in utc and converted to Calendar objects; the Calendar objects use "GMT+0" as timezone, no daylight savings.

Author:
Willem Nieuwenhuis

Constructor Summary
SunriseSunsetCollector(java.util.List<java.util.Calendar> dates)
          Initialize the SunriseSunsetCollector with a list of dates to calculate the sunsrise/sunset pairs for.
 
Method Summary
 java.util.List<java.util.Calendar> calculate(double lat, double lon)
          Calculate sunrise and sunset times at the location (Lat, lon)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SunriseSunsetCollector

public SunriseSunsetCollector(java.util.List<java.util.Calendar> dates)
Initialize the SunriseSunsetCollector with a list of dates to calculate the sunsrise/sunset pairs for.

Parameters:
dates - The initial dates; The only information extracted from the Calendar objects is the d-m-y fields, time and timezone are not considered
Method Detail

calculate

public java.util.List<java.util.Calendar> calculate(double lat,
                                                    double lon)
Calculate sunrise and sunset times at the location (Lat, lon)

The calculation of the sunrise/sunset pairs is done based on the following logic: if the list contains 1 date, or more than 2 dates then for each date the pair is calculated. If the list contains 2 dates, they are considered the begin and end date of a range and sunrise/sunset pairs are calculated for both dates as well as for all dates in between.

Returns:
a list of sunrise/sunset time pairs