Class CurrentWeatherInfo
java.lang.Object
de.kaffeemitkoffein.tinyweatherforecastgermany.CurrentWeatherInfo
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final Stringstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCity(Context context) getConditionFromHourlyCondition(RawWeatherInfo rawWeatherInfo, int start, int stop) Gets the most significant condition form the interval specified, or calculates it from other itemsgetConditionFromHourlySignificantCondition(RawWeatherInfo rawWeatherInfo, int start, int stop) static IntegergetMostSignificantCondition(ArrayList<Integer> conditions) longgetWhenNewServerDataExpected(Context context) getWindForecast(int number) static StringinterpolateConditionFromHigherIntervals(int position, RawWeatherInfo rawWeatherInfo) Searches for a significant weather condition across multiple time intervals using a hierarchical lookup strategy.booleanisNewServerDataExpected(Context context) Checks if new Mosmix data can be expected on the DWD server.static StringiteratePositions(String[] stringArray, int position, int limit) setSunDurationFromClouds(Weather.WeatherInfo weatherInfo) Calculates actual sun duration in seconds based on cloud cover percentage and sunrise/sunset times.void
-
Field Details
-
EMPTY_TAG
- See Also:
-
MOSMIX_UPDATE_INTERVAL
public static final int MOSMIX_UPDATE_INTERVAL- See Also:
-
MOSMIX_PUBLICATION_DELAY
public static final int MOSMIX_PUBLICATION_DELAY- See Also:
-
DMO_UPDATE_INTERVAL
public static final int DMO_UPDATE_INTERVAL- See Also:
-
DMO_PUBLICATION_DELAY
public static final int DMO_PUBLICATION_DELAY- See Also:
-
-
Constructor Details
-
CurrentWeatherInfo
public CurrentWeatherInfo() -
CurrentWeatherInfo
-
-
Method Details
-
setToEmpty
public void setToEmpty() -
getCity
-
getWindForecast
-
setSunDurationFromClouds
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
-
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 evaluaterawWeatherInfo- 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
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
-
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
-