Class Weather
- java.lang.Object
-
- de.kaffeemitkoffein.tinyweatherforecastgermany.Weather
-
public final class Weather extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWeather.Cloudsstatic classWeather.DisplayLayoutstatic classWeather.DistanceDisplayUnitstatic classWeather.RiseSetTimesstatic classWeather.SimpleDateFormatsstatic classWeather.Unitsstatic classWeather.WeatherInfoclassWeather.WeatherItemstatic classWeather.WeatherLocationstatic classWeather.WeatherLocationFinderstatic classWeather.WindDatastatic classWeather.WindDisplayTypestatic classWeather.WindDisplayUnit
-
Field Summary
Fields Modifier and Type Field Description static intDATA_SIZEstatic intDELTA_Tstatic doubleKelvinConstantstatic intMILLIS_IN_HOURstatic intPROB_OF_PRECIPITATION_ITEM_COUNTstatic java.lang.String[]SQL_COMMAND_QUERYTIMECOLUMN
-
Constructor Summary
Constructors Constructor Description Weather()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static floatgetApproxMoonPositionOnSky(Weather.WeatherLocation weatherLocation, long time)Determines the approximate position of the moon on the sky based on rise and set times.static floatgetApproxSunPositionOnSky(Weather.WeatherLocation weatherLocation, long time)Determines the approximate position of the sun on the sky based on sunrise and sunset times.static longgetCivilTwilightEvening(Weather.WeatherLocation weatherLocation, long time)static longgetCivilTwilightEvening(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)static longgetCivilTwilightEvening(Astronomy.Riseset riseset, long time)static longgetCivilTwilightMorning(Weather.WeatherLocation weatherLocation, long time)static longgetCivilTwilightMorning(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)static longgetCivilTwilightMorning(Astronomy.Riseset riseset, long time)static CurrentWeatherInfogetCurrentWeatherInfo(Context context)static java.lang.StringGetDateString(java.text.SimpleDateFormat simpleDateFormat, long time)static longgetMidnightTime(long time)static doublegetMoonPhase(long time)Calculates the moon phase from the current time.static doublegetMoonPhaseDay(long time)Calculates the moon day from the current time.static intgetMoonPhaseInDegrees(long time)Calculates the moon phase from the current time.static longgetMoonRiseInUTC(Weather.WeatherLocation weatherLocation, long time)static longgetMoonRiseInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)static longgetMoonRiseInUTC(Astronomy.Riseset riseset, long time)static Astronomy.RisesetgetMoonRiseset(Weather.WeatherLocation weatherLocation, long time)static longgetMoonSetInUTC(Weather.WeatherLocation weatherLocation, long time)static longgetMoonSetInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)static longgetMoonSetInUTC(Astronomy.Riseset riseset, long time)static longgetNextMidnightTime(long time)static longgetPollingTime(Context context)static Astronomy.RisesetgetRiseset(Weather.WeatherLocation weatherLocation, long time)static java.text.SimpleDateFormatgetSimpleDateFormat(int format)static longgetSunriseInUTC(Weather.WeatherLocation weatherLocation, long time)static longgetSunriseInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)static longgetSunriseInUTC(Astronomy.Riseset riseset, long time)static longgetSunsetInUTC(Weather.WeatherLocation weatherLocation, long time)static longgetSunsetInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)static longgetSunsetInUTC(Astronomy.Riseset riseset, long time)static java.lang.StringgetWindString(Context context, CurrentWeatherInfo weatherCard)static java.lang.StringgetWindUnitString(int type)static booleanhasCurrentWeatherInfo(Context context)static booleanhasUVHIData(Context context)static booleanisDaytime(Weather.WeatherLocation weatherLocation, long time)static booleanisMoonTime(Weather.WeatherLocation weatherLocation, long time)static booleanisSunriseInIntervalUTC(Astronomy.Riseset riseset, long start, long stop)static booleanisSunsetInIntervalUTC(Astronomy.Riseset riseset, long start, long stop)static voidremoveForecastsFromDatabase(Context context)static voidsanitizeDatabase(Context context)static booleansuitableNetworkAvailable(Context context)static java.lang.StringtoFullDateTimeString(long time)static java.lang.StringtoHourMinuteString(long time)static booleanusePreciseIsDaytime(Weather.WeatherLocation weatherLocation)Returns if a precise calculation of day/night time with the Astronomy class makes sense.
-
-
-
Field Detail
-
KelvinConstant
public static final double KelvinConstant
- See Also:
- Constant Field Values
-
MILLIS_IN_HOUR
public static final int MILLIS_IN_HOUR
- See Also:
- Constant Field Values
-
DELTA_T
public static final int DELTA_T
- See Also:
- Constant Field Values
-
PROB_OF_PRECIPITATION_ITEM_COUNT
public static final int PROB_OF_PRECIPITATION_ITEM_COUNT
- See Also:
- Constant Field Values
-
DATA_SIZE
public static final int DATA_SIZE
- See Also:
- Constant Field Values
-
SQL_COMMAND_QUERYTIMECOLUMN
public static final java.lang.String[] SQL_COMMAND_QUERYTIMECOLUMN
-
-
Method Detail
-
hasCurrentWeatherInfo
public static boolean hasCurrentWeatherInfo(Context context)
-
getCurrentWeatherInfo
public static CurrentWeatherInfo getCurrentWeatherInfo(Context context)
-
hasUVHIData
public static boolean hasUVHIData(Context context)
-
getPollingTime
public static long getPollingTime(Context context)
-
sanitizeDatabase
public static void sanitizeDatabase(Context context)
-
getRiseset
public static Astronomy.Riseset getRiseset(Weather.WeatherLocation weatherLocation, long time)
-
getMoonRiseset
public static Astronomy.Riseset getMoonRiseset(Weather.WeatherLocation weatherLocation, long time)
-
isMoonTime
public static boolean isMoonTime(Weather.WeatherLocation weatherLocation, long time)
-
getMidnightTime
public static long getMidnightTime(long time)
-
getNextMidnightTime
public static long getNextMidnightTime(long time)
-
getApproxMoonPositionOnSky
public static float getApproxMoonPositionOnSky(Weather.WeatherLocation weatherLocation, long time)
Determines the approximate position of the moon on the sky based on rise and set times. Note: to eliminate possible time shifts between rise sets of different days, in most cases this calculation is averaged over three hours.- Parameters:
weatherLocation- the location to calculate the value fortime- the time in UTC (milliseconds)- Returns:
- the approximate position, where 0 is rise and 1 is set. Returns -1 if the moon is not visible at the time.
-
getApproxSunPositionOnSky
public static float getApproxSunPositionOnSky(Weather.WeatherLocation weatherLocation, long time)
Determines the approximate position of the sun on the sky based on sunrise and sunset times. Note: to eliminate possible time shifts between rise sets of different days, in most cases this calculation is averaged over three hours.- Parameters:
weatherLocation- the location to calculate the value fortime- the time in UTC (milliseconds)- Returns:
- the approximate position, where 0 is sunrise, 0.5 is midday and 1 is sunset. Returns -1 if the sun is not visible at the time.
-
isDaytime
public static boolean isDaytime(Weather.WeatherLocation weatherLocation, long time)
-
usePreciseIsDaytime
public static boolean usePreciseIsDaytime(Weather.WeatherLocation weatherLocation)
Returns if a precise calculation of day/night time with the Astronomy class makes sense. It makes sense between a latutide of -65° to +65°, but not further south or north.- Parameters:
weatherLocation-- Returns:
-
getSunsetInUTC
public static long getSunsetInUTC(Astronomy.Riseset riseset, long time)
-
getSunsetInUTC
public static long getSunsetInUTC(Weather.WeatherLocation weatherLocation, long time)
-
getSunsetInUTC
public static long getSunsetInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
-
getSunriseInUTC
public static long getSunriseInUTC(Astronomy.Riseset riseset, long time)
-
getSunriseInUTC
public static long getSunriseInUTC(Weather.WeatherLocation weatherLocation, long time)
-
getSunriseInUTC
public static long getSunriseInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
-
getCivilTwilightMorning
public static long getCivilTwilightMorning(Astronomy.Riseset riseset, long time)
-
getCivilTwilightMorning
public static long getCivilTwilightMorning(Weather.WeatherLocation weatherLocation, long time)
-
getCivilTwilightMorning
public static long getCivilTwilightMorning(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
-
getCivilTwilightEvening
public static long getCivilTwilightEvening(Astronomy.Riseset riseset, long time)
-
getCivilTwilightEvening
public static long getCivilTwilightEvening(Weather.WeatherLocation weatherLocation, long time)
-
getCivilTwilightEvening
public static long getCivilTwilightEvening(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
-
getMoonRiseInUTC
public static long getMoonRiseInUTC(Astronomy.Riseset riseset, long time)
-
getMoonRiseInUTC
public static long getMoonRiseInUTC(Weather.WeatherLocation weatherLocation, long time)
-
getMoonRiseInUTC
public static long getMoonRiseInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
-
getMoonSetInUTC
public static long getMoonSetInUTC(Astronomy.Riseset riseset, long time)
-
getMoonSetInUTC
public static long getMoonSetInUTC(Weather.WeatherLocation weatherLocation, long time)
-
getMoonSetInUTC
public static long getMoonSetInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
-
getMoonPhaseDay
public static double getMoonPhaseDay(long time)
Calculates the moon day from the current time.- Parameters:
time- in milliseconds epoch time- Returns:
- day of the moon phase; range 0 - 29.53
-
getMoonPhase
public static double getMoonPhase(long time)
Calculates the moon phase from the current time.- Parameters:
time- in milliseconds epoch time- Returns:
- the moon phase; range 0 - 1, where 0 is new moon and 0.5 is full moon
-
getMoonPhaseInDegrees
public static int getMoonPhaseInDegrees(long time)
Calculates the moon phase from the current time.- Parameters:
time- in milliseconds epoch time- Returns:
- the moon phase in degrees; range 0 - 360, where 0 is new moon and 180 is full moon
-
isSunriseInIntervalUTC
public static boolean isSunriseInIntervalUTC(Astronomy.Riseset riseset, long start, long stop)
-
isSunsetInIntervalUTC
public static boolean isSunsetInIntervalUTC(Astronomy.Riseset riseset, long start, long stop)
-
toHourMinuteString
public static java.lang.String toHourMinuteString(long time)
-
toFullDateTimeString
public static java.lang.String toFullDateTimeString(long time)
-
getWindUnitString
public static java.lang.String getWindUnitString(int type)
-
getWindString
public static java.lang.String getWindString(Context context, CurrentWeatherInfo weatherCard)
-
removeForecastsFromDatabase
public static void removeForecastsFromDatabase(Context context)
-
getSimpleDateFormat
public static java.text.SimpleDateFormat getSimpleDateFormat(int format)
-
GetDateString
public static java.lang.String GetDateString(java.text.SimpleDateFormat simpleDateFormat, long time)
-
suitableNetworkAvailable
public static boolean suitableNetworkAvailable(Context context)
-
-