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 class
Weather.Clouds
static class
Weather.DisplayLayout
static class
Weather.DistanceDisplayUnit
static class
Weather.RiseSetTimes
static class
Weather.SimpleDateFormats
static class
Weather.Units
static class
Weather.WeatherInfo
class
Weather.WeatherItem
static class
Weather.WeatherLocation
static class
Weather.WeatherLocationFinder
static class
Weather.WindData
static class
Weather.WindDisplayType
static class
Weather.WindDisplayUnit
-
Field Summary
Fields Modifier and Type Field Description static int
DATA_SIZE
static int
DELTA_T
static double
KelvinConstant
static int
MILLIS_IN_HOUR
static int
PROB_OF_PRECIPITATION_ITEM_COUNT
static 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 float
getApproxMoonPositionOnSky(Weather.WeatherLocation weatherLocation, long time)
Determines the approximate position of the moon on the sky based on rise and set times.static float
getApproxSunPositionOnSky(Weather.WeatherLocation weatherLocation, long time)
Determines the approximate position of the sun on the sky based on sunrise and sunset times.static long
getCivilTwilightEvening(Weather.WeatherLocation weatherLocation, long time)
static long
getCivilTwilightEvening(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
static long
getCivilTwilightEvening(Astronomy.Riseset riseset, long time)
static long
getCivilTwilightMorning(Weather.WeatherLocation weatherLocation, long time)
static long
getCivilTwilightMorning(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
static long
getCivilTwilightMorning(Astronomy.Riseset riseset, long time)
static CurrentWeatherInfo
getCurrentWeatherInfo(Context context)
static java.lang.String
GetDateString(java.text.SimpleDateFormat simpleDateFormat, long time)
static long
getMidnightTime(long time)
static double
getMoonPhase(long time)
Calculates the moon phase from the current time.static double
getMoonPhaseDay(long time)
Calculates the moon day from the current time.static int
getMoonPhaseInDegrees(long time)
Calculates the moon phase from the current time.static long
getMoonRiseInUTC(Weather.WeatherLocation weatherLocation, long time)
static long
getMoonRiseInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
static long
getMoonRiseInUTC(Astronomy.Riseset riseset, long time)
static Astronomy.Riseset
getMoonRiseset(Weather.WeatherLocation weatherLocation, long time)
static long
getMoonSetInUTC(Weather.WeatherLocation weatherLocation, long time)
static long
getMoonSetInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
static long
getMoonSetInUTC(Astronomy.Riseset riseset, long time)
static long
getNextMidnightTime(long time)
static long
getPollingTime(Context context)
static Astronomy.Riseset
getRiseset(Weather.WeatherLocation weatherLocation, long time)
static java.text.SimpleDateFormat
getSimpleDateFormat(int format)
static long
getSunriseInUTC(Weather.WeatherLocation weatherLocation, long time)
static long
getSunriseInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
static long
getSunriseInUTC(Astronomy.Riseset riseset, long time)
static long
getSunsetInUTC(Weather.WeatherLocation weatherLocation, long time)
static long
getSunsetInUTC(Weather.WeatherLocation weatherLocation, Weather.WeatherInfo weatherInfo)
static long
getSunsetInUTC(Astronomy.Riseset riseset, long time)
static java.lang.String
getWindString(Context context, CurrentWeatherInfo weatherCard)
static java.lang.String
getWindUnitString(int type)
static boolean
hasCurrentWeatherInfo(Context context)
static boolean
hasUVHIData(Context context)
static boolean
isDaytime(Weather.WeatherLocation weatherLocation, long time)
static boolean
isMoonTime(Weather.WeatherLocation weatherLocation, long time)
static boolean
isSunriseInIntervalUTC(Astronomy.Riseset riseset, long start, long stop)
static boolean
isSunsetInIntervalUTC(Astronomy.Riseset riseset, long start, long stop)
static void
sanitizeDatabase(Context context)
static boolean
suitableNetworkAvailable(Context context)
static java.lang.String
toFullDateTimeString(long time)
static java.lang.String
toHourMinuteString(long time)
static boolean
usePreciseIsDaytime(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)
-
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)
-
-