Debian Codegraph @

libgweather/gweather-info.h

raw symbols SCIP
1 /* gweather-info.h - Weather information data
2 *
3 * SPDX-FileCopyrightText: The GWeather authors
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #pragma once
8
9 #if !(defined(IN_GWEATHER_H) || defined(GWEATHER_COMPILATION))
10 #error "gweather-weather.h must not be included individually, include gweather.h instead"
11 #endif
12
13 #include <libgweather/gweather-enums.h>
14 #include <libgweather/gweather-location.h>
15 #include <libgweather/gweather-version.h>
16
17 G_BEGIN_DECLS
18
19 /**
20 * GWeatherProvider:
21 * @GWEATHER_PROVIDER_NONE: no provider, no weather information available
22 * @GWEATHER_PROVIDER_METAR: METAR office, providing current conditions worldwide
23 * @GWEATHER_PROVIDER_IWIN: US weather office (old API), providing 7 days of forecast
24 * @GWEATHER_PROVIDER_MET_NO: MET.no service, worldwide but requires attribution and a subscription to the [API users mailing-list](https://lists.met.no/mailman/listinfo/api-users).
25 * @GWEATHER_PROVIDER_OWM: OpenWeatherMap, worldwide and possibly more reliable, but requires attribution and is limited in the number of queries
26 * @GWEATHER_PROVIDER_NWS: US weather office (new API), providing 7 days of hourly forecast (available since 4.2)
27 * @GWEATHER_PROVIDER_ALL: enable all available providers
28 */
29 typedef enum { /*< flags, underscore_name=gweather_provider >*/
30 GWEATHER_PROVIDER_NONE = 0,
31 GWEATHER_PROVIDER_METAR = 1,
32 GWEATHER_PROVIDER_IWIN = 1 << 2,
33 GWEATHER_PROVIDER_MET_NO = 1 << 3,
34 GWEATHER_PROVIDER_OWM = 1 << 4,
35 GWEATHER_PROVIDER_NWS = 1 << 5,
36 GWEATHER_PROVIDER_ALL = (GWEATHER_PROVIDER_METAR | GWEATHER_PROVIDER_IWIN | GWEATHER_PROVIDER_MET_NO | GWEATHER_PROVIDER_OWM | GWEATHER_PROVIDER_NWS)
37 } GWeatherProvider;
38
39 #define GWEATHER_TYPE_INFO (gweather_info_get_type ())
40
41 GWEATHER_AVAILABLE_IN_ALL
42 G_DECLARE_FINAL_TYPE (GWeatherInfo, gweather_info, GWEATHER, INFO, GObject)
43
44 GWEATHER_AVAILABLE_IN_ALL
45 void gweather_info_store_cache (void);
46
47 GWEATHER_AVAILABLE_IN_ALL
48 GWeatherInfo * gweather_info_new (GWeatherLocation *location);
49 GWEATHER_AVAILABLE_IN_ALL
50 void gweather_info_update (GWeatherInfo *info);
51 GWEATHER_AVAILABLE_IN_ALL
52 void gweather_info_abort (GWeatherInfo *info);
53
54 GWEATHER_AVAILABLE_IN_ALL
55 GWeatherProvider gweather_info_get_enabled_providers (GWeatherInfo *info);
56 GWEATHER_AVAILABLE_IN_ALL
57 void gweather_info_set_enabled_providers (GWeatherInfo *info,
58 GWeatherProvider providers);
59
60 GWEATHER_AVAILABLE_IN_ALL
61 const char * gweather_info_get_application_id (GWeatherInfo *info);
62 GWEATHER_AVAILABLE_IN_ALL
63 void gweather_info_set_application_id (GWeatherInfo *info,
64 const char *application_id);
65
66 GWEATHER_AVAILABLE_IN_ALL
67 const char * gweather_info_get_contact_info (GWeatherInfo *info);
68 GWEATHER_AVAILABLE_IN_ALL
69 void gweather_info_set_contact_info (GWeatherInfo *info,
70 const char *contact_info);
71
72 GWEATHER_AVAILABLE_IN_ALL
73 gboolean gweather_info_is_valid (GWeatherInfo *info);
74 GWEATHER_AVAILABLE_IN_ALL
75 gboolean gweather_info_network_error (GWeatherInfo *info);
76
77 GWEATHER_AVAILABLE_IN_ALL
78 const GWeatherLocation * gweather_info_get_location (GWeatherInfo *info);
79 GWEATHER_AVAILABLE_IN_ALL
80 void gweather_info_set_location (GWeatherInfo *info,
81 GWeatherLocation *location);
82 GWEATHER_AVAILABLE_IN_ALL
83 char * gweather_info_get_location_name (GWeatherInfo *info);
84 GWEATHER_AVAILABLE_IN_ALL
85 char * gweather_info_get_update (GWeatherInfo *info);
86 GWEATHER_AVAILABLE_IN_ALL
87 char * gweather_info_get_sky (GWeatherInfo *info);
88 GWEATHER_AVAILABLE_IN_ALL
89 char * gweather_info_get_conditions (GWeatherInfo *info);
90
91 GWEATHER_AVAILABLE_IN_ALL
92 char * gweather_info_get_temp (GWeatherInfo *info);
93 GWEATHER_AVAILABLE_IN_ALL
94 char * gweather_info_get_temp_min (GWeatherInfo *info);
95 GWEATHER_AVAILABLE_IN_ALL
96 char * gweather_info_get_temp_max (GWeatherInfo *info);
97 GWEATHER_AVAILABLE_IN_ALL
98 char * gweather_info_get_dew (GWeatherInfo *info);
99 GWEATHER_AVAILABLE_IN_ALL
100 char * gweather_info_get_humidity (GWeatherInfo *info);
101 GWEATHER_AVAILABLE_IN_ALL
102 char * gweather_info_get_wind (GWeatherInfo *info);
103 GWEATHER_AVAILABLE_IN_ALL
104 char * gweather_info_get_pressure (GWeatherInfo *info);
105 GWEATHER_AVAILABLE_IN_ALL
106 char * gweather_info_get_visibility (GWeatherInfo *info);
107 GWEATHER_AVAILABLE_IN_ALL
108 char * gweather_info_get_apparent (GWeatherInfo *info);
109 GWEATHER_AVAILABLE_IN_ALL
110 char * gweather_info_get_sunrise (GWeatherInfo *info);
111 GWEATHER_AVAILABLE_IN_ALL
112 char * gweather_info_get_sunset (GWeatherInfo *info);
113 GWEATHER_AVAILABLE_IN_ALL
114 GSList * gweather_info_get_forecast_list (GWeatherInfo *info);
115 GWEATHER_AVAILABLE_IN_ALL
116 const char * gweather_info_get_attribution (GWeatherInfo *info);
117
118 GWEATHER_AVAILABLE_IN_ALL
119 char * gweather_info_get_temp_summary (GWeatherInfo *info);
120 GWEATHER_AVAILABLE_IN_ALL
121 char * gweather_info_get_weather_summary (GWeatherInfo *info);
122
123 GWEATHER_AVAILABLE_IN_ALL
124 const char * gweather_info_get_icon_name (GWeatherInfo *info);
125 GWEATHER_AVAILABLE_IN_ALL
126 const char * gweather_info_get_symbolic_icon_name (GWeatherInfo *info);
127
128 GWEATHER_AVAILABLE_IN_ALL
129 int gweather_info_next_sun_event (GWeatherInfo *info);
130 GWEATHER_AVAILABLE_IN_ALL
131 gboolean gweather_info_is_daytime (GWeatherInfo *info);
132
133 /* values retrieving functions */
134
135 /**
136 * GWeatherWindDirection:
137 * @GWEATHER_WIND_INVALID: value not available
138 * @GWEATHER_WIND_VARIABLE: variable throughout the day
139 * @GWEATHER_WIND_N: north
140 * @GWEATHER_WIND_NNE: north-north-east
141 * @GWEATHER_WIND_NE: north-east
142 * @GWEATHER_WIND_ENE: east-north-east
143 * @GWEATHER_WIND_E: east
144 * @GWEATHER_WIND_ESE: east-south-east
145 * @GWEATHER_WIND_SE: south-east
146 * @GWEATHER_WIND_SSE: south-south-east
147 * @GWEATHER_WIND_S: south
148 * @GWEATHER_WIND_SSW: south-south-west
149 * @GWEATHER_WIND_SW: south-west
150 * @GWEATHER_WIND_WSW: west-south-west
151 * @GWEATHER_WIND_W: west
152 * @GWEATHER_WIND_WNW: west-north-west
153 * @GWEATHER_WIND_NW: north-west
154 * @GWEATHER_WIND_NNW: north-north-west
155 * @GWEATHER_WIND_LAST: maximum value for the enumeration
156 *
157 * The direction of the prevailing wind. Composite values
158 * such as north-north-east indicate a direction between the
159 * two component value (north and north-east).
160 */
161 typedef enum { /*< underscore_name=gweather_wind_direction >*/
162 GWEATHER_WIND_INVALID = -1,
163 GWEATHER_WIND_VARIABLE,
164 GWEATHER_WIND_N,
165 GWEATHER_WIND_NNE,
166 GWEATHER_WIND_NE,
167 GWEATHER_WIND_ENE,
168 GWEATHER_WIND_E,
169 GWEATHER_WIND_ESE,
170 GWEATHER_WIND_SE,
171 GWEATHER_WIND_SSE,
172 GWEATHER_WIND_S,
173 GWEATHER_WIND_SSW,
174 GWEATHER_WIND_SW,
175 GWEATHER_WIND_WSW,
176 GWEATHER_WIND_W,
177 GWEATHER_WIND_WNW,
178 GWEATHER_WIND_NW,
179 GWEATHER_WIND_NNW,
180 GWEATHER_WIND_LAST
181 } GWeatherWindDirection;
182
183 GWEATHER_AVAILABLE_IN_ALL
184 const char * gweather_wind_direction_to_string (GWeatherWindDirection wind);
185 GWEATHER_AVAILABLE_IN_ALL
186 const char * gweather_wind_direction_to_string_full (GWeatherWindDirection wind,
187 GWeatherFormatOptions options);
188
189 /**
190 * GWeatherSky:
191 * @GWEATHER_SKY_INVALID: value not available
192 * @GWEATHER_SKY_CLEAR: sky completely clear, no clouds visible
193 * @GWEATHER_SKY_BROKEN: sky mostly clear, few clouds
194 * @GWEATHER_SKY_SCATTERED: sky mostly clear, patches of clouds
195 * @GWEATHER_SKY_FEW: few clouds, sky cloudy but patches of sky visible
196 * @GWEATHER_SKY_OVERCAST: sky completely clouded, sun not visible
197 * @GWEATHER_SKY_LAST: the maximum value for the enumeration
198 *
199 * The sky and cloud visibility. In general it is discouraged to
200 * use this value directly to compute the forecast icon: applications
201 * should instead use gweather_info_get_icon_name() or
202 * gweather_info_get_symbolic_icon_name().
203 */
204 typedef enum { /*< underscore_name=gweather_sky >*/
205 GWEATHER_SKY_INVALID = -1,
206 GWEATHER_SKY_CLEAR,
207 GWEATHER_SKY_BROKEN,
208 GWEATHER_SKY_SCATTERED,
209 GWEATHER_SKY_FEW,
210 GWEATHER_SKY_OVERCAST,
211 GWEATHER_SKY_LAST
212 } GWeatherSky;
213
214 GWEATHER_AVAILABLE_IN_ALL
215 const char * gweather_sky_to_string (GWeatherSky sky);
216 GWEATHER_AVAILABLE_IN_ALL
217 const char * gweather_sky_to_string_full (GWeatherSky sky,
218 GWeatherFormatOptions options);
219
220 /**
221 * GWeatherConditionPhenomenon:
222 * @GWEATHER_PHENOMENON_INVALID: value not available
223 * @GWEATHER_PHENOMENON_NONE: no significant phenomenon
224 *
225 * The current or forecasted significant phenomenon.
226 */
227 typedef enum { /*< underscore_name=gweather_phenomenon >*/
228 GWEATHER_PHENOMENON_INVALID = -1,
229
230 GWEATHER_PHENOMENON_NONE,
231
232 GWEATHER_PHENOMENON_DRIZZLE,
233 GWEATHER_PHENOMENON_RAIN,
234 GWEATHER_PHENOMENON_SNOW,
235 GWEATHER_PHENOMENON_SNOW_GRAINS,
236 GWEATHER_PHENOMENON_ICE_CRYSTALS,
237 GWEATHER_PHENOMENON_ICE_PELLETS,
238 GWEATHER_PHENOMENON_HAIL,
239 GWEATHER_PHENOMENON_SMALL_HAIL,
240 GWEATHER_PHENOMENON_UNKNOWN_PRECIPITATION,
241
242 GWEATHER_PHENOMENON_MIST,
243 GWEATHER_PHENOMENON_FOG,
244 GWEATHER_PHENOMENON_SMOKE,
245 GWEATHER_PHENOMENON_VOLCANIC_ASH,
246 GWEATHER_PHENOMENON_SAND,
247 GWEATHER_PHENOMENON_HAZE,
248 GWEATHER_PHENOMENON_SPRAY,
249 GWEATHER_PHENOMENON_DUST,
250
251 GWEATHER_PHENOMENON_SQUALL,
252 GWEATHER_PHENOMENON_SANDSTORM,
253 GWEATHER_PHENOMENON_DUSTSTORM,
254 GWEATHER_PHENOMENON_FUNNEL_CLOUD,
255 GWEATHER_PHENOMENON_TORNADO,
256 GWEATHER_PHENOMENON_DUST_WHIRLS,
257
258 GWEATHER_PHENOMENON_LAST
259 } GWeatherConditionPhenomenon;
260
261 /**
262 * GWeatherConditionQualifier:
263 * @GWEATHER_QUALIFIER_INVALID: value not available
264 * @GWEATHER_QUALIFIER_NONE: no qualifier for the phenomenon
265 * @GWEATHER_QUALIFIER_VICINITY: phenomenon happening in the proximity of the
266 * location, not in the actual location
267 * @GWEATHER_QUALIFIER_LIGHT: phenomenon is light or predicted to be light
268 * @GWEATHER_QUALIFIER_MODERATE: phenomenon is moderate or predicted to be
269 * moderate
270 * @GWEATHER_QUALIFIER_HEAVY: phenomenon is heavy or predicted to be heavy
271 * @GWEATHER_QUALIFIER_SHALLOW: shallow fog (only valid with
272 * %GWEATHER_PHENOMENON_FOG)
273 * @GWEATHER_QUALIFIER_PATCHES: patches of fog (only valid with
274 * %GWEATHER_PHENOMENON_FOG)
275 * @GWEATHER_QUALIFIER_PARTIAL: partial fog (only valid with
276 * %GWEATHER_PHENOMENON_FOG)
277 * @GWEATHER_QUALIFIER_THUNDERSTORM: phenomenon will be a thunderstorm and/or
278 * will include lightning
279 * @GWEATHER_QUALIFIER_BLOWING: phenomenon is blowing (valid with
280 * %GWEATHER_PHENOMENON_SNOW, %GWEATHER_PHENOMENON_SAND,
281 * %GWEATHER_PHENOMENON_SPRAY, %GWEATHER_PHENOMENON_DUST)
282 * @GWEATHER_QUALIFIER_SHOWERS: phenomenon is heavy and involves showers
283 * @GWEATHER_QUALIFIER_DRIFTING: phenomenon is moving across (valid with
284 * %GWEATHER_PHENOMENON_SAND and %GWEATHER_PHENOMENON_DUST)
285 * @GWEATHER_QUALIFIER_FREEZING: phenomenon is freezing and involves ice
286 * @GWEATHER_QUALIFIER_LAST: maximum value of the enumeration
287 *
288 * An additional modifier applied to a #GWeatherConditionPhenomenon to
289 * describe the current or forecasted weather conditions.
290 *
291 * The exact meaning of each qualifier is described at
292 * http://www.weather.com/glossary/ and
293 * http://www.crh.noaa.gov/arx/wx.tbl.php
294 */
295 typedef enum { /*< underscore_name=gweather_qualifier >*/
296 GWEATHER_QUALIFIER_INVALID = -1,
297
298 GWEATHER_QUALIFIER_NONE,
299
300 GWEATHER_QUALIFIER_VICINITY,
301
302 GWEATHER_QUALIFIER_LIGHT,
303 GWEATHER_QUALIFIER_MODERATE,
304 GWEATHER_QUALIFIER_HEAVY,
305 GWEATHER_QUALIFIER_SHALLOW,
306 GWEATHER_QUALIFIER_PATCHES,
307 GWEATHER_QUALIFIER_PARTIAL,
308 GWEATHER_QUALIFIER_THUNDERSTORM,
309 GWEATHER_QUALIFIER_BLOWING,
310 GWEATHER_QUALIFIER_SHOWERS,
311 GWEATHER_QUALIFIER_DRIFTING,
312 GWEATHER_QUALIFIER_FREEZING,
313
314 GWEATHER_QUALIFIER_LAST
315 } GWeatherConditionQualifier;
316
317 /**
318 * GWeatherMoonPhase:
319 *
320 * The current phase of the moon, represented as degrees,
321 * where 0 is the new moon, 90 is the first quarter, etc.
322 */
323 typedef double GWeatherMoonPhase;
324
325 /**
326 * GWeatherMoonLatitude:
327 *
328 * The moon declension, in degrees.
329 */
330 typedef double GWeatherMoonLatitude;
331
332 GWEATHER_AVAILABLE_IN_ALL
333 gboolean gweather_info_get_value_update (GWeatherInfo *info,
334 time_t *value);
335 GWEATHER_AVAILABLE_IN_ALL
336 gboolean gweather_info_get_value_sky (GWeatherInfo *info,
337 GWeatherSky *sky);
338 GWEATHER_AVAILABLE_IN_ALL
339 gboolean gweather_info_get_value_conditions (GWeatherInfo *info,
340 GWeatherConditionPhenomenon *phenomenon,
341 GWeatherConditionQualifier *qualifier);
342 GWEATHER_AVAILABLE_IN_ALL
343 gboolean gweather_info_get_value_temp (GWeatherInfo *info,
344 GWeatherTemperatureUnit unit,
345 double *value);
346 GWEATHER_AVAILABLE_IN_ALL
347 gboolean gweather_info_get_value_temp_min (GWeatherInfo *info,
348 GWeatherTemperatureUnit unit,
349 double *value);
350 GWEATHER_AVAILABLE_IN_ALL
351 gboolean gweather_info_get_value_temp_max (GWeatherInfo *info,
352 GWeatherTemperatureUnit unit,
353 double *value);
354 GWEATHER_AVAILABLE_IN_ALL
355 gboolean gweather_info_get_value_dew (GWeatherInfo *info,
356 GWeatherTemperatureUnit unit,
357 double *value);
358 GWEATHER_AVAILABLE_IN_ALL
359 gboolean gweather_info_get_value_apparent (GWeatherInfo *info,
360 GWeatherTemperatureUnit unit,
361 double *value);
362 GWEATHER_AVAILABLE_IN_ALL
363 gboolean gweather_info_get_value_wind (GWeatherInfo *info,
364 GWeatherSpeedUnit unit,
365 double *speed,
366 GWeatherWindDirection *direction);
367 GWEATHER_AVAILABLE_IN_ALL
368 gboolean gweather_info_get_value_pressure (GWeatherInfo *info,
369 GWeatherPressureUnit unit,
370 double *value);
371 GWEATHER_AVAILABLE_IN_ALL
372 gboolean gweather_info_get_value_visibility (GWeatherInfo *info,
373 GWeatherDistanceUnit unit,
374 double *value);
375 GWEATHER_AVAILABLE_IN_ALL
376 gboolean gweather_info_get_value_sunrise (GWeatherInfo *info,
377 time_t *value);
378 GWEATHER_AVAILABLE_IN_ALL
379 gboolean gweather_info_get_value_sunset (GWeatherInfo *info,
380 time_t *value);
381 GWEATHER_AVAILABLE_IN_ALL
382 gboolean gweather_info_get_value_moonphase (GWeatherInfo *info,
383 GWeatherMoonPhase *value,
384 GWeatherMoonLatitude *lat);
385 GWEATHER_AVAILABLE_IN_ALL
386 gboolean gweather_info_get_upcoming_moonphases (GWeatherInfo *info,
387 time_t *phases);
388
389 typedef struct _GWeatherConditions GWeatherConditions;
390
391 /**
392 * GWeatherConditions:
393 * @significant: %TRUE if the struct contains usable data, %FALSE otherwise
394 * @phenomenon: the main weather phenomenon
395 * @qualifier: a modifier for @phenomenon
396 *
397 * A convenient way to describe the current or forecast
398 * weather phenomenon, if significant, and its associated
399 * modifier. If the value is not significant, the weather conditions
400 * are described by gweather_info_get_sky() instead.
401 *
402 * In general it is discouraged to use this value directly to compute
403 * the forecast icon: applications should instead use
404 * gweather_info_get_icon_name() or
405 * gweather_info_get_symbolic_icon_name().
406 */
407 struct _GWeatherConditions {
408 gboolean significant;
409 GWeatherConditionPhenomenon phenomenon;
410 GWeatherConditionQualifier qualifier;
411 };
412
413 GWEATHER_AVAILABLE_IN_ALL
414 const char * gweather_conditions_to_string (GWeatherConditions *conditions);
415 GWEATHER_AVAILABLE_IN_ALL
416 const char * gweather_conditions_to_string_full (GWeatherConditions *conditions,
417 GWeatherFormatOptions options);
418
419 GWEATHER_AVAILABLE_IN_ALL
420 GWeatherTemperatureUnit gweather_temperature_unit_to_real (GWeatherTemperatureUnit unit);
421
422 GWEATHER_AVAILABLE_IN_ALL
423 const char * gweather_speed_unit_to_string (GWeatherSpeedUnit unit);
424
425 G_END_DECLS