@@ -660,18 +660,27 @@ protected Date getDateFromTime(double time, SolarEvent solarEvent) {
660660 }
661661
662662 /**
663- * Returns the dip below the horizon before sunrise that matches the offset minutes on passed in as a parameter. For
664- * example passing in 72 minutes for a calendar set to the equinox in Jerusalem returns a value close to 16.1°
665- * Please note that this method is very slow and inefficient and should NEVER be used in a loop.
666- * @todo Improve efficiency of this method by not brute forcing the calculation.
663+ * Returns the sun's elevation (number of degrees) below the horizon before sunrise that matches the offset minutes
664+ * on passed in as a parameter. For example passing in 72 minutes for a calendar set to the equinox in Jerusalem
665+ * returns a value close to 16.1°.
667666 *
668667 * @param minutes
669- * offset
670- * @return the degrees below the horizon before sunrise that match the offset in minutes passed it as a parameter.
668+ * minutes before sunrise
669+ * @return the degrees below the horizon before sunrise that match the offset in minutes passed it as a parameter. If
670+ * the calculation can't be computed (no sunrise occurs on this day) a {@link Double#NaN} will be returned.
671+ * @deprecated This method is slow and inefficient and should NEVER be used in a loop. This method should be replaced
672+ * by calls to {@link AstronomicalCalculator#getSolarElevation(Calendar, GeoLocation)}. That method will
673+ * efficiently return the the solar elevation (the sun's position in degrees below (or above) the horizon)
674+ * at the given time even in the arctic when there is no sunrise.
675+ * @see AstronomicalCalculator#getSolarElevation(Calendar, GeoLocation)
671676 * @see #getSunsetSolarDipFromOffset(double)
672677 */
678+ @ Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version
673679 public double getSunriseSolarDipFromOffset (double minutes ) {
674680 Date offsetByDegrees = getSeaLevelSunrise ();
681+ if (offsetByDegrees == null ) {
682+ return Double .NaN ;
683+ }
675684 Date offsetByTime = getTimeOffset (getSeaLevelSunrise (), -(minutes * MINUTE_MILLIS ));
676685
677686 BigDecimal degrees = new BigDecimal (0 );
@@ -690,18 +699,27 @@ public double getSunriseSolarDipFromOffset(double minutes) {
690699 }
691700
692701 /**
693- * Returns the dip below the horizon after sunset that matches the offset minutes on passed in as a parameter. For
694- * example passing in 72 minutes for a calendar set to the equinox in Jerusalem returns a value close to 16.1°
695- * Please note that this method is very slow and inefficient and should NEVER be used in a loop.
696- * @todo Improve efficiency of this method by not brute forcing the calculation.
702+ * Returns the sun's elevation (number of degrees) below the horizon after sunset that matches the offset minutes
703+ * passed in as a parameter. For example passing in 72 minutes for a calendar set to the equinox in Jerusalem
704+ * returns a value close to 16.1°.
697705 *
698706 * @param minutes
699- * offset
700- * @return the degrees below the horizon after sunset that match the offset in minutes passed it as a parameter.
707+ * minutes after sunset
708+ * @return the degrees below the horizon after sunset that match the offset in minutes passed it as a parameter. If
709+ * the calculation can't be computed (no sunset occurs on this day) a {@link Double#NaN} will be returned.
710+ * @deprecated This method is slow and inefficient and should NEVER be used in a loop. This method should be replaced
711+ * by calls to {@link AstronomicalCalculator#getSolarElevation(Calendar, GeoLocation)}. That method will
712+ * efficiently return the the solar elevation (the sun's position in degrees below (or above) the horizon)
713+ * at the given time even in the arctic when there is no sunrise.
714+ * @see AstronomicalCalculator#getSolarElevation(Calendar, GeoLocation)
701715 * @see #getSunriseSolarDipFromOffset(double)
702716 */
717+ @ Deprecated // (forRemoval=false) // add back once Java 9 is the minimum supported version
703718 public double getSunsetSolarDipFromOffset (double minutes ) {
704719 Date offsetByDegrees = getSeaLevelSunset ();
720+ if (offsetByDegrees == null ) {
721+ return Double .NaN ;
722+ }
705723 Date offsetByTime = getTimeOffset (getSeaLevelSunset (), minutes * MINUTE_MILLIS );
706724 BigDecimal degrees = new BigDecimal (0 );
707725 BigDecimal incrementor = new BigDecimal ("0.001" );
0 commit comments