1 /*  Copyright (c) 2003-2014 Xfce Development Team
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __WEATHER_DATA_H__
20 #define __WEATHER_DATA_H__
21 
22 G_BEGIN_DECLS
23 
24 typedef enum {
25     ALTITUDE,
26     LATITUDE,
27     LONGITUDE,
28     TEMPERATURE,
29     PRESSURE,
30     WIND_SPEED,
31     WIND_BEAUFORT,
32     WIND_DIRECTION,
33     WIND_DIRECTION_DEG,
34     HUMIDITY,
35     DEWPOINT,
36     APPARENT_TEMPERATURE,
37     CLOUDS_LOW,
38     CLOUDS_MID,
39     CLOUDS_HIGH,
40     CLOUDINESS,
41     FOG,
42     PRECIPITATION,
43     SYMBOL
44 } data_types;
45 
46 typedef enum {
47     CELSIUS,
48     FAHRENHEIT
49 } units_temperature;
50 
51 typedef enum {
52     HECTOPASCAL,
53     INCH_MERCURY,
54     PSI,
55     TORR
56 } units_pressure;
57 
58 typedef enum {
59     KMH,
60     MPH,
61     MPS,
62     FTS,
63     KNOTS
64 } units_windspeed;
65 
66 typedef enum {
67     MILLIMETERS,
68     INCHES
69 } units_precipitation;
70 
71 typedef enum {
72     METERS,
73     FEET
74 } units_altitude;
75 
76 typedef enum {
77     WINDCHILL_HEATINDEX,
78     WINDCHILL_HUMIDEX,
79     STEADMAN,
80     QUAYLE_STEADMAN
81 } apparent_temp_models;
82 
83 typedef enum {
84     MORNING,
85     AFTERNOON,
86     EVENING,
87     NIGHT
88 } daytime;
89 
90 typedef struct {
91     gint temperature;
92     gint apparent_temperature;
93     gint pressure;
94     gint windspeed;
95     gint precipitation;
96     gint altitude;
97 } units_config;
98 
99 
100 gdouble string_to_double(const gchar *str,
101                          gdouble backup);
102 
103 gchar *double_to_string(gdouble val,
104                         const gchar *format);
105 
106 gchar *format_date(time_t t,
107                    gchar *format,
108                    gboolean local);
109 
110 gboolean timeslice_is_interval(xml_time *timeslice);
111 
112 gchar *get_data(const xml_time *timeslice,
113                 const units_config *units,
114                 data_types type,
115                 gboolean round,
116                 gboolean night_time);
117 
118 const gchar *get_unit(const units_config *units,
119                       data_types type);
120 
121 gboolean is_night_time(const xml_astro *astro);
122 
123 time_t time_calc(struct tm time_tm,
124                  gint year,
125                  gint mon,
126                  gint day,
127                  gint hour,
128                  gint min,
129                  gint sec);
130 
131 time_t time_calc_hour(struct tm time_tm,
132                       gint hours);
133 
134 time_t time_calc_day(struct tm time_tm,
135                      gint days);
136 
137 gint xml_astro_compare(gconstpointer a,
138                        gconstpointer b);
139 
140 gint xml_time_compare(gconstpointer a,
141                       gconstpointer b);
142 
143 void merge_astro(GArray *astrodata,
144                  const xml_astro *astro);
145 
146 void astrodata_clean(GArray *astrodata);
147 
148 void merge_timeslice(xml_weather *wd,
149                      const xml_time *timeslice);
150 
151 xml_time *get_current_conditions(const xml_weather *wd);
152 
153 xml_time *make_current_conditions(xml_weather *wd,
154                                   time_t now_t);
155 
156 time_t day_at_midnight(time_t day_t,
157                        const gint add_days);
158 
159 xml_astro *get_astro_data_for_day(const GArray *astrodata,
160                                   const gint day);
161 
162 GArray *get_point_data_for_day(xml_weather *wd,
163                                const gint day);
164 
165 xml_time *make_forecast_data(xml_weather *wd,
166                              GArray *daydata,
167                              gint day,
168                              daytime dt);
169 
170 G_END_DECLS
171 
172 #endif
173