org.n52.operation.cropmodeling
Class JulianTime

java.lang.Object
  extended by org.n52.operation.cropmodeling.JulianTime
All Implemented Interfaces:
java.lang.Cloneable

public class JulianTime
extends java.lang.Object
implements java.lang.Cloneable

JulianTime class

Java implementation from the original .NET class

Author:
willem nieuwenhuis

Field Summary
protected  double currentJulianTime
          JulianTime currentJulianTime field
 
Constructor Summary
JulianTime(double latitude, java.util.Calendar dt)
          construct a juliantTime based on latitude and a Java Calendar object
JulianTime(double latitude, int year, double time)
          constructs a JulianTime based on latitude, the year and the time.
 
Method Summary
static JulianTime add(JulianTime time1, double time2)
          adds two juliant times.
 JulianTime clone()
           
static JulianTime divide(JulianTime time1, double divider)
          divide a julianTime by a number of hours.
static boolean eq(JulianTime time1, JulianTime time2)
          compares two juliantimes.
 boolean equals(java.lang.Object obj)
           
 double getAtLatitude()
           
 java.util.Date getCurrentDateTime()
          return the juliantime as Java Date object
 int getCurrentJulianDay()
          get the juliant day of this juliant moment
 double getDayLength()
          calculates the length of the day for this JulianTime taking the latitude into account
 int getHalfDayIndex()
          calculates the halfdayindex of a certain Juliantime.
 int getYear()
           
 double getYearHours()
           
 int hashCode()
           
static boolean ineq(JulianTime time1, JulianTime time2)
          compares two juliantimes.
static boolean less(JulianTime time1, JulianTime time2)
          compares two juliantimes.
static boolean lesseq(JulianTime time1, JulianTime time2)
          compares two juliantimes.
static boolean more(JulianTime time1, JulianTime time2)
          compares two juliantimes.
static boolean moreeq(JulianTime time1, JulianTime time2)
          compares two juliantimes.
 void setAtLatitude(double newLat)
           
 void setYear(int newYear)
           
 void setYearHours(double newTime)
          set number of hours since 0 hrs 1-januari
static JulianTime subtract(JulianTime time1, double time2)
          substracts a number of hours from a julianTime.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

currentJulianTime

protected double currentJulianTime
JulianTime currentJulianTime field

Constructor Detail

JulianTime

public JulianTime(double latitude,
                  int year,
                  double time)
constructs a JulianTime based on latitude, the year and the time.

Parameters:
latitude - latitude in degrees
year - year of the moment
time - number of hours since the 0 hours 1-januari that year

JulianTime

public JulianTime(double latitude,
                  java.util.Calendar dt)
construct a juliantTime based on latitude and a Java Calendar object

Parameters:
latitude - latitude in degrees
dt - current year, month, day, hours, minutes, second wrapped in a Calendar
Method Detail

getDayLength

public double getDayLength()
calculates the length of the day for this JulianTime taking the latitude into account

Returns:
length of day in hours

clone

public JulianTime clone()
Overrides:
clone in class java.lang.Object

add

public static JulianTime add(JulianTime time1,
                             double time2)
adds two juliant times. It will not honor year boundaries

Parameters:
time1 - Juliant time to be increased
time2 - number of hours to be added to the julianTime
Returns:
new incremented time

subtract

public static JulianTime subtract(JulianTime time1,
                                  double time2)
substracts a number of hours from a julianTime. It will not honor year boundaries

Parameters:
time1 - JulianTime to be decreased
time2 - number of hours to be substracted
Returns:
the new juliant time

divide

public static JulianTime divide(JulianTime time1,
                                double divider)
divide a julianTime by a number of hours. It will not honor year boundaries

Parameters:
time1 - JulianTime to be divided
divider - number of hours to divide by
Returns:
the new juliant time

less

public static boolean less(JulianTime time1,
                           JulianTime time2)
compares two juliantimes. It will honor year boundaries

Parameters:
time1 -
time2 -
Returns:
true if time1 lies before time2

lesseq

public static boolean lesseq(JulianTime time1,
                             JulianTime time2)
compares two juliantimes. It will honor year boundaries Times are considered equal if they differ by less than one second

Parameters:
time1 -
time2 -
Returns:
true if time1 lies before or is equal to time2

more

public static boolean more(JulianTime time1,
                           JulianTime time2)
compares two juliantimes. It will honor year boundaries

Parameters:
time1 -
time2 -
Returns:
true if time1 lies after time2

moreeq

public static boolean moreeq(JulianTime time1,
                             JulianTime time2)
compares two juliantimes. It will honor year boundaries Times are considered equal if they differ by less than one second

Parameters:
time1 -
time2 -
Returns:
true if time1 lies after or is equal to time2

eq

public static boolean eq(JulianTime time1,
                         JulianTime time2)
compares two juliantimes. It will honor year boundaries The times are considered equal if they differ by less than one second

Parameters:
time1 -
time2 -
Returns:
true if time1 is equal to time2

ineq

public static boolean ineq(JulianTime time1,
                           JulianTime time2)
compares two juliantimes. It will honor year boundaries Times are considered equal if they differ by less than one second

Parameters:
time1 -
time2 -
Returns:
true if time1 is not equal to time2

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getCurrentJulianDay

public int getCurrentJulianDay()
get the juliant day of this juliant moment

Returns:
juliant day

getAtLatitude

public double getAtLatitude()
Returns:
the latitude for this juliant time

setAtLatitude

public void setAtLatitude(double newLat)
Parameters:
newLat - the new latitude for this juliant time

getHalfDayIndex

public int getHalfDayIndex()
calculates the halfdayindex of a certain Juliantime. The halfdayindex is an index that identifies intervals even index between 2pm and the next sunrise and odd from sunrise to next 2pm The index runs over a year, 2 * 366 + 1 = 733 at most. It starts at 0 before the sunrise on 1-st january, hence min(index) = 0, max(index) < 733 Sunrise and 2pm have the index of the interval to their right

Returns:
the halfdayindex

getYearHours

public double getYearHours()
Returns:
number of hours since 0 hrs 1-januari

setYearHours

public void setYearHours(double newTime)
set number of hours since 0 hrs 1-januari

Parameters:
newTime - the new time

getYear

public int getYear()
Returns:
the year of this juliant time

setYear

public void setYear(int newYear)
Parameters:
newYear - the new year for this juliant time

getCurrentDateTime

public java.util.Date getCurrentDateTime()
return the juliantime as Java Date object

Returns:
the date

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object