]> git.mxchange.org Git - simgear.git/blob - simgear/timing/timezone.h
Alas. Fix #pragma magic for GCC <= 4.5.
[simgear.git] / simgear / timing / timezone.h
1 /* -*- Mode: C++ -*- *****************************************************
2  * timezone.h
3  * Written by Durk Talsma. Started July 1999.
4  *
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.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  *
19  **************************************************************************/
20
21 /** \file timezone.h
22  *
23  * Provides SGTimeZone and SGTimeZoneContainer
24  *
25  */
26
27 #ifndef _TIMEZONE_H_
28 #define _TIMEZONE_H_
29
30 #include <string>
31 #include <vector>
32
33 #include <simgear/math/SGMath.hxx>
34 #include <simgear/math/SGGeod.hxx>
35
36 /**
37  * SGTimeZone stores the timezone centerpoint,
38  * as well as the countrycode and the timezone descriptor. The latter is 
39  * used in order to get the local time. 
40  *
41  */
42
43 class SGTimeZone
44 {
45
46 private:
47
48   SGVec3d centerpoint; // centre of timezone, in cartesian coordinates
49   std::string countryCode;
50   std::string descriptor;
51
52 public:
53
54     /**
55      * Build a timezone object with a specifed latitude, longitude, country
56      * code, and descriptor
57      * @param pt centerpoint
58      * @param cc country code
59      * @param desc descriptor
60      */
61     SGTimeZone(const SGGeod& pt, char* cc, char* desc);
62
63     /**
64      * Build a timezone object from a textline in zone.tab
65      * @param infoString the textline from zone.tab
66      */
67     SGTimeZone(const char *infoString);
68
69     /**
70      * The copy constructor
71      * @param other the source object
72      */
73     SGTimeZone(const SGTimeZone &other);
74   
75     /**
76      * Return the descriptor string
77      * @return descriptor string (char array)
78      */
79     const char * getDescription() { return descriptor.c_str(); };
80     
81     const SGVec3d& cartCenterpoint() const
82     {
83       return centerpoint;
84     }
85 };
86
87 /**
88  * SGTimeZoneContainer 
89  */
90
91 class SGTimeZoneContainer
92 {
93 public:
94   SGTimeZoneContainer(const char *filename);
95   ~SGTimeZoneContainer();
96   
97   SGTimeZone* getNearest(const SGGeod& ref) const;
98   
99 private:
100   typedef std::vector<SGTimeZone*> TZVec;
101   TZVec zones;
102 };
103
104
105
106 #endif // _TIMEZONE_H_