コード例 #1
0
        private BigFloat getCosineSunLocalHour(BigFloat sunTrueLong, Zenith zenith)
        {
            BigFloat sinSunDeclination    = getSinOfSunDeclination(sunTrueLong);
            BigFloat cosineSunDeclination = getCosineOfSunDeclination(sinSunDeclination);

            BigFloat zenithInRads = convertDegreesToRadians(zenith.degrees());
            BigFloat cosineZenith = BigFloat.valueOf(Math.Cos(zenithInRads.doubleValue()));
            BigFloat sinLatitude  = BigFloat.valueOf(Math.Sin(convertDegreesToRadians(location.getLatitude()).doubleValue()));
            BigFloat cosLatitude  = BigFloat.valueOf(Math.Cos(convertDegreesToRadians(location.getLatitude()).doubleValue()));

            BigFloat sinDeclinationTimesSinLat = sinSunDeclination.Multiply(sinLatitude);
            BigFloat dividend = cosineZenith.Subtract(sinDeclinationTimesSinLat);
            BigFloat divisor  = cosineSunDeclination.Multiply(cosLatitude);

            return(setScale(divideBy(dividend, divisor)));
        }
コード例 #2
0
        private BigFloat computeSolarEventTime(Zenith solarZenith, Calendar date, bool isSunrise)
        {
            date.setTimeZone(this.timeZone);
            BigFloat longitudeHour = getLongitudeHour(date, isSunrise);

            BigFloat meanAnomaly        = getMeanAnomaly(longitudeHour);
            BigFloat sunTrueLong        = getSunTrueLongitude(meanAnomaly);
            BigFloat cosineSunLocalHour = getCosineSunLocalHour(sunTrueLong, solarZenith);

            if ((cosineSunLocalHour.doubleValue() < -1.0) || (cosineSunLocalHour.doubleValue() > 1.0))
            {
                return(null);
            }

            BigFloat sunLocalHour  = getSunLocalHour(cosineSunLocalHour, isSunrise);
            BigFloat localMeanTime = getLocalMeanTime(sunTrueLong, longitudeHour, sunLocalHour);
            BigFloat localTime     = getLocalTime(localMeanTime, date);

            return(localTime);
        }
コード例 #3
0
 /**
  * Computes the sunrise time for the given zenith at the given date.
  *
  * @param solarZenith
  *            <code>Zenith</code> enum corresponding to the type of sunrise to compute.
  * @param date
  *            <code>Calendar</code> object representing the date to compute the sunrise for.
  * @return the sunrise time as a calendar or null for no sunrise
  */
 public Calendar computeSunriseCalendar(Zenith solarZenith, Calendar date)
 {
     return(getLocalTimeAsCalendar(computeSolarEventTime(solarZenith, date, true), date));
 }
コード例 #4
0
 /**
  * Computes the sunrise time for the given zenith at the given date.
  *
  * @param solarZenith
  *            <code>Zenith</code> enum corresponding to the type of sunrise to compute.
  * @param date
  *            <code>Calendar</code> object representing the date to compute the sunrise for.
  * @return the sunrise time, in HH:MM format (24-hour clock), 00:00 if the sun does not rise on the given
  *         date.
  */
 public String computeSunriseTime(Zenith solarZenith, Calendar date)
 {
     return(getLocalTimeAsString(computeSolarEventTime(solarZenith, date, true)));
 }