]> git.mxchange.org Git - flightgear.git/blob - src/WeatherCM/FGGlobalWeatherDatabase.h
Updates by Christian Mayer.
[flightgear.git] / src / WeatherCM / FGGlobalWeatherDatabase.h
1 /*****************************************************************************
2
3  Header:       FGGlobalWeatherDatabase.h        
4  Author:       Christian Mayer
5  Date started: 28.05.99
6
7  ---------- Copyright (C) 1999  Christian Mayer (vader@t-online.de) ----------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 FUNCTIONAL DESCRIPTION
27 ------------------------------------------------------------------------------
28 Database for the global weather
29 This database is only called by the local database and by the weather
30 simulator driving this database
31
32 HISTORY
33 ------------------------------------------------------------------------------
34 28.05.1999 Christian Mayer      Created
35 16.06.1999 Durk Talsma          Portability for Linux
36 20.06.1999 Christian Mayer      added lots of consts
37 30.06.1999 Christian Mayer      STL portability
38 *****************************************************************************/
39
40 /****************************************************************************/
41 /* SENTRY                                                                   */
42 /****************************************************************************/
43 #ifndef FGGlobalWeatherDatabase_H
44 #define FGGlobalWeatherDatabase_H
45
46 /****************************************************************************/
47 /* INCLUDES                                                                 */
48 /****************************************************************************/
49 #include "FGPhysicalProperties.h"
50 #include "FGPhysicalProperty.h"
51 #include <Include/compiler.h>
52 #include <vector>
53 #include STL_IOSTREAM
54                 
55 /****************************************************************************/
56 /* DEFINES                                                                  */
57 /****************************************************************************/
58 FG_USING_STD(vector);
59 FG_USING_STD(iostream);
60 FG_USING_NAMESPACE(std);
61
62 enum FGGlobalWeatherDatabaseStatus {
63     FGGlobalWeatherDatabase_not_used,
64     FGGlobalWeatherDatabase_switched_off,
65     FGGlobalWeatherDatabase_only_static,
66     FGGlobalWeatherDatabase_working
67 };
68
69 class FGGlobalWeatherDatabase;
70 ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
71
72 /****************************************************************************/
73 /* CLASS DECLARATION                                                        */
74 /****************************************************************************/
75 class FGGlobalWeatherDatabase
76 {
77 private:
78 protected:
79     FGGlobalWeatherDatabaseStatus DatabaseStatus;
80     FGPhysicalProperties2DVector database;
81
82 public:
83     /************************************************************************/
84     /* Constructor and Destructor                                           */
85     /************************************************************************/
86     FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus& s = FGGlobalWeatherDatabase_not_used);
87     ~FGGlobalWeatherDatabase();
88
89     /************************************************************************/
90     /* Get the physical properties on the specified point p                 */
91     /************************************************************************/
92     FGPhysicalProperties get(const Point2D& p) const;
93     inline FGPhysicalProperty get(const Point3D& p) const {return FGPhysicalProperty(get(Point2D(p)), p.elev());}
94
95     /************************************************************************/
96     /* update the database. Since the last call we had dt seconds           */
97     /************************************************************************/
98     void update(const WeatherPrecition& dt);
99
100     /************************************************************************/
101     /* Add a physical property on the specified point p                     */
102     /************************************************************************/
103     void add(const Point2D& p, const FGPhysicalProperties& x);
104     inline void add(const FGPhysicalProperties2D& x) {database.push_back(x);}
105
106     /************************************************************************/
107     /* Change the closest physical property to p. If p is further away than */
108     /* tolerance I'm returning false otherwise true                         */
109     /************************************************************************/
110     bool change(const FGPhysicalProperties2D& p, const WeatherPrecition& tolerance = 0.0000001);
111
112     /************************************************************************/
113     /* Get all stored points in the circle around p with the radius r, but  */
114     /* at least min points.                                                 */
115     /************************************************************************/
116     FGPhysicalProperties2DVector getAll(const Point2D& p, const WeatherPrecition& r, const unsigned int& min = 0);
117
118     /************************************************************************/
119     /* get/set the operating status of the database                         */
120     /************************************************************************/
121     FGGlobalWeatherDatabaseStatus getDatabaseStatus(void) const { return DatabaseStatus; }
122     void setDatabaseStatus(const FGGlobalWeatherDatabaseStatus& s) { DatabaseStatus = s; }
123
124     /************************************************************************/
125     /* Dump the whole database                                              */
126     /************************************************************************/
127     //friend istream& operator>> ( istream&, Point3D& );
128     friend ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
129
130 };
131
132 inline ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p )
133 {
134     //out << "Database status: " << DatabaseStatus << "\n";
135     out << "Database number of entries: " << p.database.size() << "\n";
136
137     for (FGPhysicalProperties2DVector::const_iterator it = p.database.begin(); it != p.database.end(); it++)
138         out << "Next entry: " << *it;
139
140     return out;
141 }
142
143 /****************************************************************************/
144 #endif /*FGGlobalWeatherDatabase_H*/