]> git.mxchange.org Git - simgear.git/blob - simgear/metar/MetarStation.h
Patch from Erik Hofman:
[simgear.git] / simgear / metar / MetarStation.h
1 // Class encapulating the metar station information
2 //
3 // METAR station information is kept in this file:
4 //   http://www.nws.noaa.gov/pub/stninfo/nsd_cccc.gz
5 //   http://www.nws.noaa.gov/pub/stninfo/nsd_cccc.txt
6
7
8 #ifndef _MetarStation_
9 #define _MetarStation_
10
11 #include <simgear/compiler.h>
12
13 #include STL_IOSTREAM
14 #include STL_STRING
15 #include <vector>
16 #include <map>
17
18 #include <simgear/math/point3d.hxx>
19 #include <simgear/math/polar3d.hxx>
20
21 SG_USING_STD(string);
22 SG_USING_STD(vector);
23 SG_USING_STD(map);
24
25 class CMetarStationDB;
26
27 class CMetarStation
28 {
29         // Attributes
30 private:
31         std::string m_ID;
32         unsigned long m_number;
33         std::string m_name;
34         std::string m_state;
35         std::string m_country;
36         int m_region;
37         Point3D m_locationPolar;
38         Point3D m_upperLocationPolar;
39         Point3D m_locationCart;
40         Point3D m_upperLocationCart;
41         int m_altitude;
42         int m_upperAltitude;
43         char m_pFlag;
44         
45         // Operations
46 private:
47         double decodeDMS( char *b );
48
49
50
51         CMetarStation( 
52                 char *s );
53                         // Constructor
54
55         ~CMetarStation()
56         {
57         }
58                         // Destructor
59
60 public:
61         std::string &ID() { return m_ID; }
62         unsigned long number() { return m_number; }
63         std::string &name() { return m_name; }
64         std::string &state() { return m_state; }
65         std::string &country() { return m_country; }
66         int region() { return m_region; }
67         unsigned int Altitude() { //Returns the stations height above MSL in M.
68                         return m_altitude;}
69         Point3D &locationPolar() { return m_locationPolar; }
70         Point3D &upperLocationPolar() { return m_upperLocationPolar; }
71         Point3D &locationCart() { return m_locationCart; }
72         Point3D &upperLocationCart() { return m_upperLocationCart; }
73         char pFlag() { return m_pFlag; }
74                         // Get attributes
75
76     friend ostream& operator << ( ostream&, const CMetarStation& );
77         void dump();
78         
79
80         
81
82 private:
83         CMetarStation(
84                 const CMetarStation &rNewObj );
85                         // Copy constructor.  Not implemented.
86
87         CMetarStation &operator =(
88                 const CMetarStation &rObj );
89                         // Assignment operator.  Not implemented.
90
91         friend class CMetarStationDB;
92 };
93
94
95 class CMetarStationDB 
96 {
97
98  private:
99     std::string databasePath;  //The path of the database file.
100     std::map<std::string , CMetarStation *> METAR_Stations;
101     CMetarStation * bestStation;
102
103  public:
104      CMetarStation *find( std::string stationID );
105      CMetarStation * find( Point3D locationCart );
106      CMetarStationDB(const char * dbFile);
107      ~CMetarStationDB();
108 };
109
110 #endif