1 /*****************************************************************************
3 Header: FGGlobalWeatherDatabase.h
4 Author: Christian Mayer
7 ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
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
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
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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
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
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 *****************************************************************************/
40 /****************************************************************************/
42 /****************************************************************************/
43 #ifndef FGGlobalWeatherDatabase_H
44 #define FGGlobalWeatherDatabase_H
46 /****************************************************************************/
48 /****************************************************************************/
49 #include "FGPhysicalProperties.h"
50 #include "FGPhysicalProperty.h"
51 #include <Include/compiler.h>
55 /****************************************************************************/
57 /****************************************************************************/
59 FG_USING_STD(iostream);
60 FG_USING_NAMESPACE(std);
62 enum FGGlobalWeatherDatabaseStatus {
63 FGGlobalWeatherDatabase_not_used,
64 FGGlobalWeatherDatabase_switched_off,
65 FGGlobalWeatherDatabase_only_static,
66 FGGlobalWeatherDatabase_working
69 class FGGlobalWeatherDatabase;
70 ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
72 /****************************************************************************/
73 /* CLASS DECLARATION */
74 /****************************************************************************/
75 class FGGlobalWeatherDatabase
79 FGGlobalWeatherDatabaseStatus DatabaseStatus;
80 FGPhysicalProperties2DVector database;
83 /************************************************************************/
84 /* Constructor and Destructor */
85 /************************************************************************/
86 FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus& s = FGGlobalWeatherDatabase_not_used);
87 ~FGGlobalWeatherDatabase();
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());}
95 /************************************************************************/
96 /* update the database. Since the last call we had dt seconds */
97 /************************************************************************/
98 void update(const WeatherPrecition& dt);
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);}
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);
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);
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; }
124 /************************************************************************/
125 /* Dump the whole database */
126 /************************************************************************/
127 //friend istream& operator>> ( istream&, Point3D& );
128 friend ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
132 inline ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p )
134 //out << "Database status: " << DatabaseStatus << "\n";
135 out << "Database number of entries: " << p.database.size() << "\n";
137 for (FGPhysicalProperties2DVector::const_iterator it = p.database.begin(); it != p.database.end(); it++)
138 out << "Next entry: " << *it;
143 /****************************************************************************/
144 #endif /*FGGlobalWeatherDatabase_H*/