Class CurrentWeatherInfo

java.lang.Object
de.kaffeemitkoffein.tinyweatherforecastgermany.CurrentWeatherInfo

public class CurrentWeatherInfo extends Object
  • Field Details

  • Constructor Details

    • CurrentWeatherInfo

      public CurrentWeatherInfo()
    • CurrentWeatherInfo

      public CurrentWeatherInfo(Context context, RawWeatherInfo rawWeatherInfo)
  • Method Details

    • setToEmpty

      public void setToEmpty()
    • getCity

      public String getCity(Context context)
    • getWindForecast

      public ArrayList<Weather.WindData> getWindForecast(int number)
    • setSunDurationFromClouds

      public Integer setSunDurationFromClouds(Weather.WeatherInfo weatherInfo)
      Calculates actual sun duration in seconds based on cloud cover percentage and sunrise/sunset times. This method estimates the duration of direct sunlight during the forecast hour by reducing the theoretical maximum sunshine duration (3600 seconds) by the cloud cover percentage. The calculation accounts for three scenarios: 1. Hour contains sunrise: sun duration from sunrise until end of hour, reduced by cloud cover 2. Hour contains sunset: sun duration from start of hour until sunset, reduced by cloud cover 3. Full daytime hour (between sunrise and sunset): full hour duration, reduced by cloud cover 4. Nighttime hour: returns null (no sun duration possible) Cloud cover reduction formula: duration * ((100 - cloudCoverPercent) / 100) This implements the assumption that cloud cover reduces effective solar radiation proportionally.
      Parameters:
      weatherInfo - the Weather.WeatherInfo object containing cloud cover percentage and timestamp. Must have clouds value set for calculation to proceed.
      Returns:
      the calculated sun duration in seconds (0-3600 for daytime hours, null for nighttime or if clouds unavailable)
    • iteratePositions

      public static String iteratePositions(String[] stringArray, int position, int limit)
    • interpolateConditionFromHigherIntervals

      public static String interpolateConditionFromHigherIntervals(int position, RawWeatherInfo rawWeatherInfo)
      Searches for a significant weather condition across multiple time intervals using a hierarchical lookup strategy. This method attempts to find a weather condition code from progressively wider time windows when the current timepoint lacks a condition value. The search strategy follows this priority order: 1. ww (1h): Significant weather at current timepoint (highest priority, most specific) 2. WPc31 + ww3 (3h): Optional significant weather during last 3 hours 3. WPc61 + W1W2 (6h): Optional significant weather during last 6 hours 4. WPch1 (12h): Optional significant weather during last 12 hours 5. WPcd1 (24h): Optional significant weather during last 24 hours (lowest priority, most general) Each condition data array is searched using iteratePositions which returns the first non-null value found within the search range. This ensures that more recent/specific weather conditions take precedence over older/general ones. Data source: DWD MOSMIX API provides these fields from forecasts at different temporal resolutions. Weather condition codes follow WMO standards (e.g., 0=clear sky, 1=high clouds, 60=rain, etc.)
      Parameters:
      position - the index in the weather forecast array (0-249) for the timepoint to evaluate
      rawWeatherInfo - the RawWeatherInfo object containing weather arrays from DWD MOSMIX API
      Returns:
      a weather condition code string if found in any interval, null if no condition found in any of the five search intervals
    • getConditionFromHourlyCondition

      public Integer getConditionFromHourlyCondition(RawWeatherInfo rawWeatherInfo, int start, int stop)
      Gets the most significant condition form the interval specified, or calculates it from other items
      Parameters:
      rawWeatherInfo -
      start -
      stop -
      Returns:
      true if condition could be determined, otherwise false
    • getConditionFromHourlySignificantCondition

      public Integer getConditionFromHourlySignificantCondition(RawWeatherInfo rawWeatherInfo, int start, int stop)
    • getMostSignificantCondition

      public static Integer getMostSignificantCondition(ArrayList<Integer> conditions)
    • isNewServerDataExpected

      public boolean isNewServerDataExpected(Context context)
      Checks if new Mosmix data can be expected on the DWD server.
      Returns:
      true, if new data can be expected.
    • getWhenNewServerDataExpected

      public long getWhenNewServerDataExpected(Context context)
    • getHumanReadableIssueTime

      public String getHumanReadableIssueTime()