1 /*****************************************************************************
2 * Copyright (C) 2007-2008 by Shawn Starr <shawn.starr@rogers.com> *
3 * Copyright (C) 2008 by Teemu Rytilahti <tpr@d5k.net> *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Library General Public *
7 * License as published by the Free Software Foundation; either *
8 * version 2 of the License, or (at your option) any later version. *
10 * This library is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * Library General Public License for more details. *
15 * You should have received a copy of the GNU Library General Public License *
16 * along with this library; see the file COPYING.LIB. If not, write to *
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301, USA. *
19 *****************************************************************************/
21 /* Meteorological formula class */
23 #ifndef _WEATHERUTILS_H
24 #define _WEATHERUTILS_H
26 #include "ion_export.h"
28 namespace WeatherUtils
31 // Enumerations for unit types
32 enum Unit
{ NoUnit
= 0, Celsius
, Fahrenheit
, Kelvin
, KilometersAnHour
, MetersPerSecond
, MilesAnHour
, Kilopascals
,
33 InchesHG
, Millibars
, Hectopascals
, Centimeters
, Millimeters
, Inches
,
34 Knots
, Beaufort
, Kilometers
, Miles
40 * Convert from unit to another. See WeatherUtils::Unit for available units.
41 * @param value float to convert
42 * @param srcUnit from which unit to convert
43 * @param destUnit to which unit to convert
44 * @return converted value
46 ION_EXPORT
float convert(float value
, int srcUnit
, int destUnit
);
49 * Returns a string presentation of of WeatherUtils::Unit. Set plain to true in case you don't want a localized version of it.
50 * @param unit unit to convert.
51 * @param plain if true, returned string is not localized. defaults to false.
52 * @return a string presentation of WeatherUtils::Unit. Empty string if called for invalid unit.
54 ION_EXPORT QString
getUnitString(int unit
, bool plain
= false);
57 * Converts wind/sun direction given in degrees to the nearest cardinal direction.
58 * @param degrees wind direction in degrees.
59 * @return a cardinal if available, empty string on error.
61 ION_EXPORT QString
degreesToCardinal(float degrees
);
66 int knotsToBeaufort(float knots
);
67 int milesToBeaufort(float miles
);
68 int kilometersToBeaufort(float km
);
69 int metersPerSecondToBeaufort(float ms
);
71 } // WeatherUtils namespace