1 /*****************************************************************************
3 Header: FGGlobalWeatherDatabase.h
4 Author: Christian Mayer
7 -------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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 11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
40 19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
41 and lots of wee code cleaning
42 *****************************************************************************/
44 /****************************************************************************/
46 /****************************************************************************/
47 #ifndef FGGlobalWeatherDatabase_H
48 #define FGGlobalWeatherDatabase_H
50 /****************************************************************************/
52 /****************************************************************************/
57 #include <Include/compiler.h>
64 #include "FGPhysicalProperties.h"
65 #include "FGPhysicalProperty.h"
67 /****************************************************************************/
69 /****************************************************************************/
71 #ifndef FG_HAVE_NATIVE_SGI_COMPILERS
72 FG_USING_STD(iostream);
74 FG_USING_NAMESPACE(std);
76 enum FGGlobalWeatherDatabaseStatus {
77 FGGlobalWeatherDatabase_not_used,
78 FGGlobalWeatherDatabase_switched_off,
79 FGGlobalWeatherDatabase_only_static,
80 FGGlobalWeatherDatabase_working
83 class FGGlobalWeatherDatabase;
84 ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
86 /****************************************************************************/
87 /* CLASS DECLARATION */
88 /****************************************************************************/
89 class FGGlobalWeatherDatabase
93 FGGlobalWeatherDatabaseStatus DatabaseStatus;
94 FGPhysicalProperties2DVector database;
97 /************************************************************************/
98 /* Constructor and Destructor */
99 /************************************************************************/
100 FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus s = FGGlobalWeatherDatabase_not_used);
101 ~FGGlobalWeatherDatabase();
103 /************************************************************************/
104 /* Get the physical properties on the specified point p */
105 /************************************************************************/
106 FGPhysicalProperties get(const sgVec2& p) const;
107 FGPhysicalProperty get(const sgVec3& p) const
110 sgSetVec2( temp, p[0], p[1] );
112 return FGPhysicalProperty( get(temp), p[3] );
115 /************************************************************************/
116 /* update the database. Since the last call we had dt seconds */
117 /************************************************************************/
118 void update(const WeatherPrecision dt);
120 /************************************************************************/
121 /* Add a physical property on the specified point p */
122 /************************************************************************/
123 void add(const sgVec2& p, const FGPhysicalProperties& x);
124 void add(const FGPhysicalProperties2D& x)
126 database.push_back(x);
129 /************************************************************************/
130 /* Change the closest physical property to p. If p is further away than */
131 /* tolerance I'm returning false otherwise true */
132 /************************************************************************/
133 bool change(const FGPhysicalProperties2D& p, const WeatherPrecision tolerance = 0.0000001);
135 /************************************************************************/
136 /* Get all stored points in the circle around p with the radius r, but */
137 /* at least min points. */
138 /************************************************************************/
139 FGPhysicalProperties2DVector getAll(const sgVec2& p, const WeatherPrecision r, const unsigned int min = 0);
140 FGPhysicalProperties2DVector getAll(const sgVec3& p, const WeatherPrecision r, const unsigned int min = 0)
143 sgSetVec2(temp, p[0], p[1]);
145 return getAll(temp, r, min);
148 /************************************************************************/
149 /* get/set the operating status of the database */
150 /************************************************************************/
151 FGGlobalWeatherDatabaseStatus getDatabaseStatus(void) const { return DatabaseStatus; }
152 void setDatabaseStatus(const FGGlobalWeatherDatabaseStatus& s) { DatabaseStatus = s; }
154 /************************************************************************/
155 /* Dump the whole database */
156 /************************************************************************/
157 friend ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
161 inline ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p )
163 //out << "Database status: " << DatabaseStatus << "\n";
164 out << "Database number of entries: " << p.database.size() << "\n";
166 for (FGPhysicalProperties2DVector::const_iterator it = p.database.begin(); it != p.database.end(); it++)
167 out << "Next entry: " << *it;
172 /****************************************************************************/
173 #endif /*FGGlobalWeatherDatabase_H*/