--- /dev/null
+/*****************************************************************************
+
+ Module: FGAirPressureItem.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: FGMicroWeather
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Operator< definition for the item
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGAirPressureItem.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
--- /dev/null
+/*****************************************************************************
+
+ Header: FGAirPressureItem.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Air pressure item that is stored in the micro weather class
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+08.06.1999 Christian Mayer Added international air preasure formula
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGAirPressureItem_H
+#define FGAirPressureItem_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGWeatherDefs.h"
+#include <math.h>
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+class FGAirPressureItem;
+FGAirPressureItem operator-(const FGAirPressureItem& arg);
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/* NOTE: The value stored in 'value' is the air preasure that we'd have at */
+/* an altitude of 0.0 The correct airpreasure at the stored altitude */
+/* gets calulated when getValue() is called. */
+/****************************************************************************/
+class FGAirPressureItem
+{
+private:
+ WeatherPrecition value;
+protected:
+public:
+
+ FGAirPressureItem(const WeatherPrecition& v) {value = v;}
+ FGAirPressureItem() {value = FG_WEATHER_DEFAULT_AIRPRESSURE;}
+
+ //WeatherPrecition getValue(WeatherPrecition alt) { return value * pow(1.0 - 0.0065*alt/288.0, 5.255); };
+
+ WeatherPrecition getValue(const WeatherPrecition& alt) const
+ {
+ return (WeatherPrecition)((value / 101325.0) *
+ (
+ 1.01325e5 + alt * (-1.19459535223623e1 + alt * (5.50461110007561e-4 + alt * (-1.13574703113648e-8 + alt * 8.61601726143988e-14)))
+ ));
+ };
+
+ FGAirPressureItem& operator*=(const WeatherPrecition& arg);
+ FGAirPressureItem& operator+=(const FGAirPressureItem& arg);
+ FGAirPressureItem& operator-=(const FGAirPressureItem& arg);
+
+ friend FGAirPressureItem operator-(const FGAirPressureItem& arg);
+};
+
+inline FGAirPressureItem& FGAirPressureItem::operator*= (const WeatherPrecition& arg)
+{
+ value *= arg;
+ return *this;
+}
+
+inline FGAirPressureItem& FGAirPressureItem::operator+= (const FGAirPressureItem& arg)
+{
+ value += arg.value;
+ return *this;
+}
+
+inline FGAirPressureItem& FGAirPressureItem::operator-= (const FGAirPressureItem& arg)
+{
+ value -= arg.value;
+ return *this;
+}
+
+inline FGAirPressureItem operator-(const FGAirPressureItem& arg)
+{
+ return FGAirPressureItem(-arg.value);
+}
+
+/****************************************************************************/
+#endif /*FGAirPressureItem_H*/
+
+
+
+
+
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGCloud.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Header for the cloud class
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGCloud_H
+#define FGCloud_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGWeatherFeature.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGCloud:FGWeatherFeature
+{
+private:
+protected:
+public:
+};
+
+/****************************************************************************/
+#endif /*FGCloud_H*/
\ No newline at end of file
--- /dev/null
+/*****************************************************************************
+
+ Module: FGCloudItem.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: FGMicroWeather
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Operator< definition for the item
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGCloudItem.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+bool operator<(const FGCloudItem& arg1, const FGCloudItem& arg2)
+{
+ return arg1.alt < arg2.alt;
+}
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGCloudItem.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Air pressure item that is stored in the micro weather class
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGCloudItem_H
+#define FGCloudItem_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGWeatherDefs.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGCloudItem
+{
+private:
+protected:
+public:
+ WeatherPrecition value;
+ WeatherPrecition alt;
+
+ FGCloudItem(const WeatherPrecition& a, const WeatherPrecition& v) {alt = a; value = v;}
+ FGCloudItem(const WeatherPrecition& v) {alt = 0.0; value = v;}
+ FGCloudItem() {alt = 0.0; value = FG_WEATHER_DEFAULT_AIRPRESSURE;}
+
+ friend bool operator<(const FGCloudItem& arg1, const FGCloudItem& arg2);
+};
+
+/****************************************************************************/
+#endif /*FGCloudItem_H*/
\ No newline at end of file
--- /dev/null
+/*****************************************************************************
+
+ Module: FGGlobalWeatherDatabase.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: main program
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Database for the global weather
+This database is only called by the local database and by the weather
+simulator driving this database
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGGlobalWeatherDatabase.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+
+/****************************************************************************/
+/* Interpolate p which lies inside the triangle x1, x2, x3 */
+/* */
+/* x3\ Do this by calulating q and linear interpolate its */
+/* |\ \ value as it's laying between x1 and x2. */
+/* | \ \ Then interpolate p as it lays between p and x3 */
+/* | \ \ */
+/* | p \ Advantages: p has exactly the value of a corner */
+/* | \ \ when it's laying on it. */
+/* | \ \ If p isn't in the triangle the algoritm */
+/* x1------q------x2 extrapolates it's value */
+/****************************************************************************/
+template<class P, class V>
+V triangle_interpolate(const P& x1, const V& v1, const P& x2, const V& v2, const P& x3, const V& v3, const P& p)
+{
+ P q;
+ V q_value;
+
+ q = x1 + (x2 - x1)*( ((x3-x1).x()*(x1-x2).y() - (x1-x2).x()*(x3-x1).y())/((p-x3).x()*(x2-x1).y() - (x2-x1).x()*(p-x3).y()) );
+
+ q_value = v1 + (v2 - v1) * (x1.distance3D(q) / x1.distance3D(x2));
+
+ return q_value + (v3 - q_value) * (q.distance3D(p) / q.distance3D(x3));
+}
+
+/****************************************************************************/
+/* Constructor and Destructor */
+/****************************************************************************/
+FGGlobalWeatherDatabase::FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus& s)
+{
+ DatabaseStatus = s;
+}
+
+FGGlobalWeatherDatabase::~FGGlobalWeatherDatabase()
+{
+}
+
+/****************************************************************************/
+/* Get the physical properties on the specified point p */
+/* do this by interpolating between the 3 closest points */
+/****************************************************************************/
+FGPhysicalProperties FGGlobalWeatherDatabase::get(const Point2D& p) const
+{
+ WeatherPrecition distance[3]; //store the 3 closest distances
+ FGPhysicalProperties2DVectorConstIt iterator[3]; //and the coresponding iterators
+ WeatherPrecition d;
+
+ distance[0] = 9.46e15; //init with a distance that every calculated
+ distance[1] = 9.46e15; //distance is guranteed to be shorter as
+ distance[2] = 9.46e15; //9.46e15 metres are 1 light year...
+
+ for (FGPhysicalProperties2DVectorConstIt it=database.begin(); it!=database.end(); it++)
+ { //go through the whole database
+ d = it->p.distance2Dsquared(p);
+
+ if (d<distance[0])
+ {
+ distance[2] = distance[1]; distance[1] = distance[0]; distance[0] = d;
+ iterator[2] = iterator[1]; iterator[1] = iterator[0]; iterator[0] = it;
+ //NOTE: The last line causes a warning that an unitialiced variable
+ //is used. You can ignore this warning here.
+ }
+ else if (d<distance[1])
+ {
+ distance[2] = distance[1]; distance[1] = d;
+ iterator[2] = iterator[1]; iterator[1] = it;
+ }
+ else if (d<distance[2])
+ {
+ distance[2] = d;
+ iterator[2] = it;
+ }
+ }
+
+ //now I've got the closest entry in xx[0], the 2nd closest in xx[1] and the
+ //3rd in xx[2];
+
+ //interpolate now:
+ return triangle_interpolate(
+ iterator[0]->p, (FGPhysicalProperties)*iterator[0],
+ iterator[1]->p, (FGPhysicalProperties)*iterator[1],
+ iterator[2]->p, (FGPhysicalProperties)*iterator[2], p);
+}
+
+/****************************************************************************/
+/* update the database. Since the last call we had dt seconds */
+/****************************************************************************/
+void FGGlobalWeatherDatabase::update(const WeatherPrecition& dt)
+{
+ // I've got nothing to update here (yet...)
+}
+
+/****************************************************************************/
+/* Add a physical property on the specified point p */
+/****************************************************************************/
+void FGGlobalWeatherDatabase::add(const Point2D& p, const FGPhysicalProperties& x)
+{
+ FGPhysicalProperties2D e;
+
+ e.p = p;
+
+ e.Wind = x.Wind;
+ e.Turbulence = x.Turbulence;
+ e.Temperature = x.Temperature;
+ e.AirPressure = x.AirPressure;
+ e.VaporPressure = x.VaporPressure;
+
+ e.Clouds = x.Clouds;
+ e.SnowRainIntensity = x.SnowRainIntensity;
+ e.snowRainType = x.snowRainType;
+ e.LightningProbability = x.LightningProbability;
+
+ database.push_back(e);
+}
+
+/****************************************************************************/
+/* Change the closest physical property to p. If p is further away than */
+/* tolerance I'm returning false otherwise true */
+/****************************************************************************/
+bool FGGlobalWeatherDatabase::change(const FGPhysicalProperties2D& p, const WeatherPrecition& tolerance)
+{
+ for (FGPhysicalProperties2DVectorIt it = database.begin(); it != database.end(); it++)
+ {
+ if (it->p.distance3Dsquared(p.p) < (tolerance*tolerance))
+ { //assume that's my point
+ (*it) = p;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/****************************************************************************/
+/* Get all, but at least min, stored point in the circle around p with the */
+/* radius r */
+/****************************************************************************/
+FGPhysicalProperties2DVector FGGlobalWeatherDatabase::getAll(const Point2D& p, const WeatherPrecition& r, const unsigned int& min)
+{
+ FGPhysicalProperties2DVector ret_list;
+
+ if ((DatabaseStatus == FGGlobalWeatherDatabase_only_static)
+ ||(DatabaseStatus == FGGlobalWeatherDatabase_working) )
+ { //doest it make sense?
+
+ FGPhysicalProperties2DVectorIt *it; //store the closest entries
+ WeatherPrecition *d;
+ unsigned int act_it = 0;
+ int i;
+
+ it = new FGPhysicalProperties2DVectorIt[min+1];
+ d = new WeatherPrecition[min+1];
+
+ for (it[0]=database.begin(); it[act_it]!=database.end(); it[act_it]++)
+ { //go through the whole database
+ d[act_it] = it[act_it]->p.distance2Dsquared(p);
+
+ if (r >= d[act_it])
+ { //add it
+ ret_list.push_back(*it[act_it]);
+ }
+ else
+ {
+ if (act_it>0)
+ { //figure out if this distance belongs to the closest ones
+ WeatherPrecition dummy;
+ FGPhysicalProperties2DVectorIt dummyIt;
+
+ for (i = act_it++; i >= 0;)
+ {
+ if (d[i] >= d[--i])
+ {
+ act_it--;
+ break; //nope => stop
+ }
+
+ //swap both
+ dummy =d[i]; d[i] = d[i+1]; d[i+1] = dummy;
+ dummyIt = it[i]; it[i] = it[i+1]; it[i+1] = dummyIt;
+ }
+ }
+ }
+ }
+
+ if (ret_list.size()<min)
+ {
+ for(i = 0; (i < (min - ret_list.size())) && (ret_list.size() < database.size()); i++)
+ ret_list.push_back(*it[i]);
+ }
+
+ delete d;
+ delete it;
+ }
+
+ return ret_list;
+}
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGGlobalWeatherDatabase.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Database for the global weather
+This database is only called by the local database and by the weather
+simulator driving this database
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+30.06.1999 Christian Mayer STL portability
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGGlobalWeatherDatabase_H
+#define FGGlobalWeatherDatabase_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGPhysicalProperties.h"
+#include "FGPhysicalProperty.h"
+#include <Include/compiler.h>
+#include <vector>
+#include STL_IOSTREAM
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+FG_USING_STD(vector);
+FG_USING_STD(iostream);
+FG_USING_NAMESPACE(std);
+
+enum FGGlobalWeatherDatabaseStatus {
+ FGGlobalWeatherDatabase_not_used,
+ FGGlobalWeatherDatabase_switched_off,
+ FGGlobalWeatherDatabase_only_static,
+ FGGlobalWeatherDatabase_working
+};
+
+class FGGlobalWeatherDatabase;
+ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGGlobalWeatherDatabase
+{
+private:
+protected:
+ FGGlobalWeatherDatabaseStatus DatabaseStatus;
+ FGPhysicalProperties2DVector database;
+
+public:
+ /************************************************************************/
+ /* Constructor and Destructor */
+ /************************************************************************/
+ FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus& s = FGGlobalWeatherDatabase_not_used);
+ ~FGGlobalWeatherDatabase();
+
+ /************************************************************************/
+ /* Get the physical properties on the specified point p */
+ /************************************************************************/
+ FGPhysicalProperties get(const Point2D& p) const;
+ inline FGPhysicalProperty get(const Point3D& p) const {return FGPhysicalProperty(get(Point2D(p)), p.elev());}
+
+ /************************************************************************/
+ /* update the database. Since the last call we had dt seconds */
+ /************************************************************************/
+ void update(const WeatherPrecition& dt);
+
+ /************************************************************************/
+ /* Add a physical property on the specified point p */
+ /************************************************************************/
+ void add(const Point2D& p, const FGPhysicalProperties& x);
+ inline void add(const FGPhysicalProperties2D& x) {database.push_back(x);}
+
+ /************************************************************************/
+ /* Change the closest physical property to p. If p is further away than */
+ /* tolerance I'm returning false otherwise true */
+ /************************************************************************/
+ bool change(const FGPhysicalProperties2D& p, const WeatherPrecition& tolerance = 0.0000001);
+
+ /************************************************************************/
+ /* Get all stored points in the circle around p with the radius r, but */
+ /* at least min points. */
+ /************************************************************************/
+ FGPhysicalProperties2DVector getAll(const Point2D& p, const WeatherPrecition& r, const unsigned int& min = 0);
+
+ /************************************************************************/
+ /* get/set the operating status of the database */
+ /************************************************************************/
+ FGGlobalWeatherDatabaseStatus getDatabaseStatus(void) const { return DatabaseStatus; }
+ void setDatabaseStatus(const FGGlobalWeatherDatabaseStatus& s) { DatabaseStatus = s; }
+
+ /************************************************************************/
+ /* Dump the whole database */
+ /************************************************************************/
+ //friend istream& operator>> ( istream&, Point3D& );
+ friend ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
+
+};
+
+inline ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p )
+{
+ //out << "Database status: " << DatabaseStatus << "\n";
+ out << "Database number of entries: " << p.database.size() << "\n";
+
+ for (FGPhysicalProperties2DVector::const_iterator it = p.database.begin(); it != p.database.end(); it++)
+ out << "Next entry: " << *it;
+
+ return out;
+}
+
+/****************************************************************************/
+#endif /*FGGlobalWeatherDatabase_H*/
\ No newline at end of file
--- /dev/null
+/*****************************************************************************
+
+ Module: FGLocalWeatherDatabase.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: main program
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Database for the local weather
+This database is the only one that gets called from FG
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGLocalWeatherDatabase.h"
+#include "FGVoronoi.h"
+#include "fg_constants.h"
+
+#include <Aircraft/aircraft.hxx>
+#include <Include/fg_constants.h>
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+
+/****************************************************************************/
+/* return the index (better: ID) of the area with point p */
+/****************************************************************************/
+unsigned int FGLocalWeatherDatabase::AreaWith(const Point2D& p) const
+{
+
+ for (FGMicroWeatherList::size_type i = 0; i != WeatherAreas.size(); i++)
+ {
+ if (WeatherAreas[i].hasPoint(p) == true)
+ return i+1;
+ }
+
+ return 0; //nothing found
+}
+
+/****************************************************************************/
+/* make tiles out of points on a 2D plane */
+/****************************************************************************/
+void FGLocalWeatherDatabase::tileLocalWeather(const FGPhysicalProperties2DVector& EntryList)
+{
+ FGVoronoiInputList input;
+
+ for (FGPhysicalProperties2DVector::const_iterator it1 = EntryList.begin(); it1 != EntryList.end(); it1++)
+ input.push_back(FGVoronoiInput(it1->p, *it1));
+
+ FGVoronoiOutputList output = Voronoiate(input);
+
+ for (FGVoronoiOutputList::iterator it2 = output.begin(); it2 != output.end(); it2++)
+ WeatherAreas.push_back(FGMicroWeather(it2->value, it2->boundary));
+}
+
+/****************************************************************************/
+/* Constructor and Destructor */
+/****************************************************************************/
+FGLocalWeatherDatabase* FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 0;
+FGLocalWeatherDatabase *WeatherDatabase;
+
+FGLocalWeatherDatabase::FGLocalWeatherDatabase(const Point3D& posititon, const WeatherPrecition& visibility, const DatabaseWorkingType& type)
+{
+ cerr << "Initializing FGLocalWeatherDatabase\n";
+ cerr << "-----------------------------------\n";
+
+ if (theFGLocalWeatherDatabase)
+ {
+ //FG_LOG( FG_GENERAL, FG_ALERT, "Error: only one local weather allowed" );
+ cerr << "Error: only one local weather allowed";
+ exit(-1);
+ }
+
+ setWeatherVisibility(visibility);
+ //WeatherVisibility = visibility;
+ DatabaseStatus = type;
+ global = 0; //just get sure...
+ last_known_position = posititon;
+
+
+ theFGLocalWeatherDatabase = this;
+
+ switch(DatabaseStatus)
+ {
+ case use_global:
+ {
+ global = new FGGlobalWeatherDatabase; //initialize GlobalDatabase
+ global->setDatabaseStatus(FGGlobalWeatherDatabase_working);
+ tileLocalWeather(global->getAll(posititon, WeatherVisibility, 3));
+ }
+ break;
+
+ case distant:
+ cerr << "FGLocalWeatherDatabase error: Distant database isn't implemented yet!\n";
+ cerr << " using random mode instead!\n";
+ case random:
+ case manual:
+ case default_mode:
+ {
+ vector<Point2D> emptyList;
+ WeatherAreas.push_back(FGMicroWeather(FGPhysicalProperties2D(), emptyList)); //in these cases I've only got one tile
+ }
+ break;
+
+ default:
+ cerr << "FGLocalWeatherDatabase error: Unknown database type specified!\n";
+ };
+}
+
+FGLocalWeatherDatabase::~FGLocalWeatherDatabase()
+{
+ //Tidying up:
+
+ //delete every stored area
+ WeatherAreas.erase(WeatherAreas.begin(), WeatherAreas.end());
+
+ //delete global database if necessary
+ if (DatabaseStatus == use_global)
+ delete global;
+}
+
+/****************************************************************************/
+/* reset the whole database */
+/****************************************************************************/
+void FGLocalWeatherDatabase::reset(const DatabaseWorkingType& type)
+{
+ //delete global database if necessary
+ if ((DatabaseStatus == use_global) && (type != use_global))
+ delete global;
+
+ DatabaseStatus = type;
+ if (DatabaseStatus == use_global)
+ tileLocalWeather(global->getAll(last_known_position, WeatherVisibility, 3));
+
+ //delete every stored area
+ WeatherAreas.erase(WeatherAreas.begin(), WeatherAreas.end());
+}
+
+/****************************************************************************/
+/* update the database. Since the last call we had dt seconds */
+/****************************************************************************/
+void FGLocalWeatherDatabase::update(const WeatherPrecition& dt)
+{
+ if (DatabaseStatus==use_global)
+ global->update(dt);
+}
+
+void FGLocalWeatherDatabase::update(const Point3D& p) //position has changed
+{
+ last_known_position = p;
+ //cerr << "****\nupdate inside\n";
+ //cerr << "Parameter: " << p << "\n";
+ //cerr << "****\n";
+}
+
+void FGLocalWeatherDatabase::update(const Point3D& p, const WeatherPrecition& dt) //time and/or position has changed
+{
+ last_known_position = p;
+
+ if (DatabaseStatus==use_global)
+ global->update(dt);
+}
+
+/****************************************************************************/
+/* Get the physical properties on the specified point p out of the database */
+/****************************************************************************/
+FGPhysicalProperty FGLocalWeatherDatabase::get(const Point3D& p) const
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ return WeatherAreas[a-1].get(p.elev());
+ else //point is outside => ask GlobalWeatherDatabase
+ return global->get(p);
+}
+
+WeatherPrecition FGLocalWeatherDatabase::getAirDensity(const Point3D& p) const
+{
+ FGPhysicalProperty dummy;
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ dummy = WeatherAreas[a-1].get(p.elev());
+ else //point is outside => ask GlobalWeatherDatabase
+ dummy = global->get(p);
+
+ return
+ (dummy.AirPressure*FG_WEATHER_DEFAULT_AIRDENSITY*FG_WEATHER_DEFAULT_TEMPERATURE) /
+ (dummy.Temperature*FG_WEATHER_DEFAULT_AIRPRESSURE);
+}
+
+
+/****************************************************************************/
+/* Add a weather feature at the point p and surrounding area */
+/****************************************************************************/
+void FGLocalWeatherDatabase::addWind(const FGWindItem& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].addWind(x);
+}
+
+void FGLocalWeatherDatabase::addTurbulence(const FGTurbulenceItem& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].addTurbulence(x);
+}
+
+void FGLocalWeatherDatabase::addTemperature(const FGTemperatureItem& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].addTemperature(x);
+}
+
+void FGLocalWeatherDatabase::addAirPressure(const FGAirPressureItem& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].addAirPressure(x);
+}
+
+void FGLocalWeatherDatabase::addVaporPressure(const FGVaporPressureItem& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].addVaporPressure(x);
+}
+
+void FGLocalWeatherDatabase::addCloud(const FGCloudItem& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].addCloud(x);
+}
+
+void FGLocalWeatherDatabase::setSnowRainIntensity(const WeatherPrecition& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].setSnowRainIntensity(x);
+}
+
+void FGLocalWeatherDatabase::setSnowRainType(const SnowRainType& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].setSnowRainType(x);
+}
+
+void FGLocalWeatherDatabase::setLightningProbability(const WeatherPrecition& x, const Point2D& p)
+{
+ unsigned int a = AreaWith(p);
+ if (a != 0)
+ WeatherAreas[a-1].setLightningProbability(x);
+}
+
+void FGLocalWeatherDatabase::addProperties(const FGPhysicalProperties2D& x)
+{
+ if (DatabaseStatus==use_global)
+ {
+ global->add(x);
+
+ //BAD, BAD, BAD thing I'm doing here: I'm adding to the global database a point that
+ //changes my voronoi diagram but I don't update it! instead I'm changing one local value
+ //that could be anywhere!!
+ //This only *might* work when the plane moves so far so fast that the diagram gets new
+ //calculated soon...
+ unsigned int a = AreaWith(x.p);
+ if (a != 0)
+ WeatherAreas[a-1].setStoredWeather(x);
+ }
+ else
+ {
+ unsigned int a = AreaWith(x.p);
+ if (a != 0)
+ WeatherAreas[a-1].setStoredWeather(x);
+ }
+}
+
+void FGLocalWeatherDatabase::setProperties(const FGPhysicalProperties2D& x)
+{
+ if (DatabaseStatus==use_global)
+ {
+ global->change(x);
+
+ //BAD, BAD, BAD thing I'm doing here: I'm adding to the global database a point that
+ //changes my voronoi diagram but I don't update it! Instead I'm changing one local value
+ //that could be anywhere!!
+ //This only *might* work when the plane moves so far so fast that the diagram gets newly
+ //calculated soon...
+ unsigned int a = AreaWith(x.p);
+ if (a != 0)
+ WeatherAreas[a-1].setStoredWeather(x);
+ }
+ else
+ {
+ unsigned int a = AreaWith(x.p);
+ if (a != 0)
+ WeatherAreas[a-1].setStoredWeather(x);
+ }
+}
+
+void fgUpdateWeatherDatabase(void)
+{
+ //cerr << "FGLocalWeatherDatabase::update()\n";
+ WeatherDatabase->update( Point3D(
+ current_aircraft.fdm_state->get_Latitude(),
+ current_aircraft.fdm_state->get_Longitude(),
+ current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER) );
+}
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGLocalWeatherDatabase.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Database for the local weather
+This database is the only one that gets called from FG
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+30.06.1999 Christian Mayer STL portability
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGLocalWeatherDatabase_H
+#define FGLocalWeatherDatabase_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+//This is only here for smoother code change. In the end the WD should be clean
+//of *any* OpenGL:
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
+#include "FGPhysicalProperties.h"
+#include "FGGlobalWeatherDatabase.h"
+#include "FGMicroWeather.h"
+#include "FGWeatherFeature.h"
+#include "FGWeatherDefs.h"
+#include <vector>
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+FG_USING_STD(vector);
+FG_USING_NAMESPACE(std);
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGLocalWeatherDatabase
+{
+private:
+protected:
+ FGGlobalWeatherDatabase *global; //point to the global database
+
+ typedef vector<FGMicroWeather> FGMicroWeatherList;
+ typedef FGMicroWeatherList::iterator FGMicroWeatherListIt;
+
+ typedef vector<Point2D> pointVector;
+ typedef vector<pointVector> tileVector;
+
+ /************************************************************************/
+ /* make tiles out of points on a 2D plane */
+ /************************************************************************/
+ void tileLocalWeather(const FGPhysicalProperties2DVector& EntryList);
+
+ FGMicroWeatherList WeatherAreas;
+
+ WeatherPrecition WeatherVisibility; //how far do I need to simulate the
+ //local weather? Unit: metres
+ Point3D last_known_position;
+
+public:
+ static FGLocalWeatherDatabase *theFGLocalWeatherDatabase;
+
+ enum DatabaseWorkingType {
+ use_global, //use global database for data
+ manual, //use only user inputs
+ distant, //use distant information, e.g. like LAN when used in
+ //a multiplayer environment
+ random, //generate weather randomly
+ default_mode //use only default values
+ };
+
+protected:
+ DatabaseWorkingType DatabaseStatus;
+
+ /************************************************************************/
+ /* return the index of the area with point p */
+ /************************************************************************/
+ unsigned int AreaWith(const Point2D& p) const;
+
+public:
+ /************************************************************************/
+ /* Constructor and Destructor */
+ /************************************************************************/
+ FGLocalWeatherDatabase(
+ const Point3D& posititon,
+ const WeatherPrecition& visibility = DEFAULT_WEATHER_VISIBILIY,
+ const DatabaseWorkingType& type = PREFERED_WORKING_TYPE);
+ ~FGLocalWeatherDatabase();
+
+ /************************************************************************/
+ /* reset the whole database */
+ /************************************************************************/
+ void reset(const DatabaseWorkingType& type = PREFERED_WORKING_TYPE);
+
+ /************************************************************************/
+ /* update the database. Since the last call we had dt seconds */
+ /************************************************************************/
+ void update(const WeatherPrecition& dt); //time has changed
+ void update(const Point3D& p); //position has changed
+ void update(const Point3D& p, const WeatherPrecition& dt); //time and/or position has changed
+
+ /************************************************************************/
+ /* Get the physical properties on the specified point p */
+ /************************************************************************/
+ FGPhysicalProperty get(const Point3D& p) const;
+ WeatherPrecition getAirDensity(const Point3D& p) const;
+
+ /************************************************************************/
+ /* Add a weather feature at the point p and surrounding area */
+ /************************************************************************/
+
+ void addWind(const FGWindItem& x, const Point2D& p);
+ void addTurbulence(const FGTurbulenceItem& x, const Point2D& p);
+ void addTemperature(const FGTemperatureItem& x, const Point2D& p);
+ void addAirPressure(const FGAirPressureItem& x, const Point2D& p);
+ void addVaporPressure(const FGVaporPressureItem& x, const Point2D& p);
+ void addCloud(const FGCloudItem& x, const Point2D& p);
+
+ void setSnowRainIntensity(const WeatherPrecition& x, const Point2D& p);
+ void setSnowRainType(const SnowRainType& x, const Point2D& p);
+ void setLightningProbability(const WeatherPrecition& x, const Point2D& p);
+
+ void addProperties(const FGPhysicalProperties2D& x); //add a property
+ void setProperties(const FGPhysicalProperties2D& x); //change a property
+
+ /************************************************************************/
+ /* get/set weather visibility */
+ /************************************************************************/
+ void setWeatherVisibility(const WeatherPrecition& visibility);
+ WeatherPrecition getWeatherVisibility(void) const;
+};
+
+extern FGLocalWeatherDatabase *WeatherDatabase;
+void fgUpdateWeatherDatabase(void);
+
+/****************************************************************************/
+/* get/set weather visibility */
+/****************************************************************************/
+void inline FGLocalWeatherDatabase::setWeatherVisibility(const WeatherPrecition& visibility)
+{
+ if (visibility >= MINIMUM_WEATHER_VISIBILIY)
+ WeatherVisibility = visibility;
+ else
+ WeatherVisibility = MINIMUM_WEATHER_VISIBILIY;
+
+ //This code doesn't belong here as this is the optical visibility and not
+ //the visibility of the weather database (that should be bigger...). The
+ //optical visibility should be calculated from the vapor pressure e.g.
+ //But for the sake of a smoother change from the old way to the new one...
+
+ GLfloat fog_exp_density;
+ GLfloat fog_exp2_density;
+
+ // for GL_FOG_EXP
+ fog_exp_density = -log(0.01 / WeatherVisibility);
+
+ // for GL_FOG_EXP2
+ fog_exp2_density = sqrt( -log(0.01) ) / WeatherVisibility;
+
+ // Set correct opengl fog density
+ xglFogf (GL_FOG_DENSITY, fog_exp2_density);
+
+ // FG_LOG( FG_INPUT, FG_DEBUG, "Fog density = " << w->fog_density );
+ //cerr << "FGLocalWeatherDatabase::setWeatherVisibility(" << visibility << "):\n";
+ //cerr << "Fog density = " << fog_exp_density << "\n";
+
+
+}
+
+WeatherPrecition inline FGLocalWeatherDatabase::getWeatherVisibility(void) const
+{
+ //cerr << "FGLocalWeatherDatabase::getWeatherVisibility() = " << WeatherVisibility << "\n";
+ return WeatherVisibility;
+}
+
+
+/****************************************************************************/
+#endif /*FGLocalWeatherDatabase_H*/
--- /dev/null
+/*****************************************************************************
+
+ Module: FGMicroWeather.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: FGLocalWeatherDatabase
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Handle the weather areas
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGMicroWeather.h"
+#include "fg_constants.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+FGMicroWeather::FGMicroWeather(const FGPhysicalProperties2D& p, const positionList& points)
+{
+ StoredWeather = p;
+ position = points;
+}
+
+FGMicroWeather::~FGMicroWeather()
+{
+}
+
+/****************************************************************************/
+/* Add the features to the micro weather */
+/* return succss */
+/****************************************************************************/
+void FGMicroWeather::addWind(const FGWindItem& x)
+{
+ StoredWeather.Wind.insert(x);
+}
+
+void FGMicroWeather::addTurbulence(const FGTurbulenceItem& x)
+{
+ StoredWeather.Turbulence.insert(x);
+}
+
+void FGMicroWeather::addTemperature(const FGTemperatureItem& x)
+{
+ StoredWeather.Temperature.insert(x);
+}
+
+void FGMicroWeather::addAirPressure(const FGAirPressureItem& x)
+{
+ cerr << "Error: caught attempt to add AirPressure which is logical wrong\n";
+ //StoredWeather.AirPressure.insert(x);
+}
+
+void FGMicroWeather::addVaporPressure(const FGVaporPressureItem& x)
+{
+ StoredWeather.VaporPressure.insert(x);
+}
+
+void FGMicroWeather::addCloud(const FGCloudItem& x)
+{
+ StoredWeather.Clouds.insert(x);
+}
+
+void FGMicroWeather::setSnowRainIntensity(const WeatherPrecition& x)
+{
+ StoredWeather.SnowRainIntensity = x;
+}
+
+void FGMicroWeather::setSnowRainType(const SnowRainType& x)
+{
+ StoredWeather.snowRainType = x;
+}
+
+void FGMicroWeather::setLightningProbability(const WeatherPrecition& x)
+{
+ StoredWeather.LightningProbability = x;
+}
+
+void FGMicroWeather::setStoredWeather(const FGPhysicalProperties2D& x)
+{
+ StoredWeather = x;
+}
+
+/****************************************************************************/
+/* return true if p is inside this micro weather */
+/* code stolen from $FG_ROOT/Simulator/Objects/fragment.cxx, which was */
+/* written by Curtis L. Olson - curt@me.umn.edu */
+/****************************************************************************/
+
+template <class T> //template to help with the calulation
+inline const int FG_SIGN(const T& x) {
+ return x < T(0) ? -1 : 1;
+}
+
+bool FGMicroWeather::hasPoint(const Point2D& p) const
+{
+ if (position.size()==0)
+ return true; //no border => this tile is infinite
+
+ if (position.size()==1)
+ return false; //a border on 1 point?!?
+
+ //when I'm here I've got at least 2 points
+
+ WeatherPrecition t;
+ signed char side1, side2;
+ const_positionListIt it = position.begin();
+ const_positionListIt it2 = it; it2++;
+
+ for (;;)
+ {
+
+ if (it2 == position.end())
+ break;
+
+ if (fabs(it->x() - it2->x()) >= FG_EPSILON)
+ {
+ t = (it->y() - it2->y()) / (it->x() - it2->x());
+ side1 = FG_SIGN (t * (StoredWeather.p.x() - it2->x()) + it2->y() - StoredWeather.p.y());
+ side2 = FG_SIGN (t * ( p.x() - it2->x()) + it2->y() - p.y());
+ if ( side1 != side2 )
+ return false; //cout << "failed side check\n";
+ }
+ else
+ {
+ t = (it->x() - it2->x()) / (it->y() - it2->y());
+ side1 = FG_SIGN (t * (StoredWeather.p.y() - it2->y()) + it2->x() - StoredWeather.p.x());
+ side2 = FG_SIGN (t * ( p.y() - it2->y()) + it2->x() - p.x());
+ if ( side1 != side2 )
+ return false; //cout << "failed side check\n";
+ }
+
+ it++; it2++;
+ }
+
+ return true;
+}
--- /dev/null
+/*****************************************************************************
+
+ Header: FGMicroWeather.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Store the single weather areas
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+30.06.1999 Christian Mayer STL portability
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGMicroWeather_H
+#define FGMicroWeather_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+//Include all the simulated weather features
+#include "FGCloud.h"
+#include "FGSnowRain.h"
+
+#include "FGAirPressureItem.h"
+#include "FGTemperatureItem.h"
+#include "FGWindItem.h"
+#include "FGTurbulenceItem.h"
+#include "FGVaporPressureItem.h"
+
+#include "FGWeatherDefs.h"
+#include "FGPhysicalProperties.h"
+#include "FGPhysicalProperty.h"
+#include <Voronoi/point2d.h>
+
+#include <set>
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+FG_USING_STD(set);
+FG_USING_NAMESPACE(std);
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGMicroWeather
+{
+private:
+protected:
+ typedef vector<Point2D> positionList;
+ typedef positionList::iterator positionListIt;
+ typedef positionList::const_iterator const_positionListIt;
+ positionList position; //the points that specify the outline of the
+ //micro weather (lat/lon)
+
+
+ FGPhysicalProperties2D StoredWeather; //property if nothing is specified
+
+public:
+ /************************************************************************/
+ /* Constructor and Destructor */
+ /************************************************************************/
+ FGMicroWeather(const FGPhysicalProperties2D& p, const positionList& points);
+ ~FGMicroWeather();
+
+ /************************************************************************/
+ /* Add a feature to the micro weather */
+ /************************************************************************/
+ void addWind(const FGWindItem& x);
+ void addTurbulence(const FGTurbulenceItem& x);
+ void addTemperature(const FGTemperatureItem& x);
+ void addAirPressure(const FGAirPressureItem& x);
+ void addVaporPressure(const FGVaporPressureItem& x);
+ void addCloud(const FGCloudItem& x);
+
+ void setSnowRainIntensity(const WeatherPrecition& x);
+ void setSnowRainType(const SnowRainType& x);
+ void setLightningProbability(const WeatherPrecition& x);
+
+ void setStoredWeather(const FGPhysicalProperties2D& x);
+
+ /************************************************************************/
+ /* get physical properties in the micro weather */
+ /* NOTE: I don't neet to speify a positon as the properties don't */
+ /* change in a micro weather */
+ /************************************************************************/
+ inline FGPhysicalProperty get(const WeatherPrecition& altitude) const
+ {
+ return FGPhysicalProperty(StoredWeather, altitude);
+ }
+
+ /************************************************************************/
+ /* return true if p is inside this micro weather */
+ /************************************************************************/
+ inline bool hasPoint(const Point3D& p) const { return hasPoint((Point2D) p); }
+ bool hasPoint(const Point2D& p) const;
+};
+
+/****************************************************************************/
+#endif /*FGMicroWeather_H*/
--- /dev/null
+/*****************************************************************************
+
+ Module: FGPhysicalProperties.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: main program
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Initialice the FGPhysicalProperties struct to something sensible(?)
+
+HISTORY
+------------------------------------------------------------------------------
+29.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGPhysicalProperties.h"
+#include "FGWeatherDefs.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+FGPhysicalProperties::FGPhysicalProperties()
+{
+ /************************************************************************/
+ /* This standart constructor fills the class with a standard weather */
+ /************************************************************************/
+
+ Wind.insert(FGWindItem(-1000.0, Point3D(0.0))); //no Wind by default
+ Wind.insert(FGWindItem(10000.0, Point3D(0.0))); //no Wind by default
+
+ Turbulence.insert(FGTurbulenceItem(-1000.0, Point3D(0.0))); //no Turbulence by default
+ Turbulence.insert(FGTurbulenceItem(10000.0, Point3D(0.0))); //no Turbulence by default
+
+ //Initialice with the CINA atmosphere
+ Temperature.insert(FGTemperatureItem( 0.0, (+15.0+273.16)));
+ Temperature.insert(FGTemperatureItem(11000.0, (-56.5+273.16)));
+ Temperature.insert(FGTemperatureItem(20000.0, (-56.5+273.16)));
+
+ AirPressure = FGAirPressureItem(101325.0);
+
+ VaporPressure.insert(FGVaporPressureItem( 0.0, FG_WEATHER_DEFAULT_VAPORPRESSURE)); //in Pa (I *only* accept SI!)
+ VaporPressure.insert(FGVaporPressureItem(10000.0, FG_WEATHER_DEFAULT_VAPORPRESSURE)); //in Pa (I *only* accept SI!)
+
+ //Clouds.insert(FGCloudItem()) => none
+ SnowRainIntensity = 0.0;
+ snowRainType = Rain;
+ LightningProbability = 0.0;
+}
+
+
+
+
--- /dev/null
+/*******-*- Mode: C++ -*-************************************************************
+
+ Header: FGPhysicalProperties.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Define the simulated physical properties of the weather
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer Changed struct to class
+20.06.1999 Christian Mayer added lots of consts
+30.06.1999 Christian Mayer STL portability
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGPhysicalProperties_H
+#define FGPhysicalProperties_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include <Include/compiler.h>
+#include <vector>
+#include <set>
+
+FG_USING_STD(vector);
+FG_USING_STD(set);
+FG_USING_NAMESPACE(std);
+
+#include <Math/point3d.hxx>
+#include <Voronoi/point2d.h>
+#include "FGWeatherDefs.h"
+
+#include "FGWindItem.h"
+#include "FGTurbulenceItem.h"
+#include "FGTemperatureItem.h"
+#include "FGAirPressureItem.h"
+#include "FGVaporPressureItem.h"
+
+#include "FGCloudItem.h"
+#include "FGSnowRain.h"
+
+class FGPhysicalProperties
+{
+public:
+ set<FGWindItem> Wind; //all Wind vectors
+ set<FGTurbulenceItem> Turbulence; //all Turbulence vectors
+ set<FGTemperatureItem> Temperature; //in deg. Kelvin (I *only* accept SI!)
+ FGAirPressureItem AirPressure; //in Pascal (I *only* accept SI!)
+ set<FGVaporPressureItem> VaporPressure; //in Pascal (I *only* accept SI!)
+
+ set<FGCloudItem> Clouds; //amount of covering and type
+ WeatherPrecition SnowRainIntensity; //this also stands for hail, snow,...
+ SnowRainType snowRainType;
+ WeatherPrecition LightningProbability;
+
+ FGPhysicalProperties(); //consructor to fill it with FG standart weather
+
+ //return values at specified altitudes
+ Point3D WindAt(const WeatherPrecition& a) const;
+ Point3D TurbulenceAt(const WeatherPrecition& a) const;
+ WeatherPrecition TemperatureAt(const WeatherPrecition& a) const;
+ WeatherPrecition AirPressureAt(const WeatherPrecition& a) const;
+ WeatherPrecition VaporPressureAt(const WeatherPrecition& a) const;
+
+ FGPhysicalProperties& operator = ( const FGPhysicalProperties& p );
+ FGPhysicalProperties& operator *= ( const WeatherPrecition& d );
+ FGPhysicalProperties& operator += ( const FGPhysicalProperties& p);
+ FGPhysicalProperties& operator -= ( const FGPhysicalProperties& p);
+};
+
+typedef vector<FGPhysicalProperties> FGPhysicalPropertiesVector;
+typedef FGPhysicalPropertiesVector::iterator FGPhysicalPropertiesVectorIt;
+typedef FGPhysicalPropertiesVector::const_iterator FGPhysicalPropertiesVectorConstIt;
+
+class FGPhysicalProperties2D;
+ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p );
+
+class FGPhysicalProperties2D : public FGPhysicalProperties
+{
+public:
+ Point2D p; //position of the property (lat/lon)
+ friend ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p );
+
+ FGPhysicalProperties2D() {}
+
+ FGPhysicalProperties2D(const FGPhysicalProperties& prop, const Point2D& pos)
+ {
+ Wind = prop.Wind; Turbulence = prop.Turbulence; Temperature = prop.Temperature;
+ AirPressure = prop.AirPressure; VaporPressure = prop.VaporPressure; p = pos;
+ }
+};
+
+typedef vector<FGPhysicalProperties2D> FGPhysicalProperties2DVector;
+typedef FGPhysicalProperties2DVector::iterator FGPhysicalProperties2DVectorIt;
+typedef FGPhysicalProperties2DVector::const_iterator FGPhysicalProperties2DVectorConstIt;
+
+inline ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p )
+{
+ out << "Position: " << p.p << "\nStored Wind: ";
+ for (set<FGWindItem>::const_iterator WindIt = p.Wind.begin(); WindIt != p.Wind.end(); WindIt++)
+ out << "(" << WindIt->getValue() << ") at " << WindIt->getAlt() << "m; ";
+
+ out << "\nStored Turbulence: ";
+ for (set<FGTurbulenceItem>::const_iterator TurbulenceIt = p.Turbulence.begin();
+ TurbulenceIt != p.Turbulence.end();
+ TurbulenceIt++)
+ out << "(" << TurbulenceIt->getValue() << ") at " << TurbulenceIt->getAlt() << "m; ";
+
+ out << "\nStored Temperature: ";
+ for (set<FGTemperatureItem>::const_iterator TemperatureIt = p.Temperature.begin();
+ TemperatureIt != p.Temperature.end();
+ TemperatureIt++)
+ out << TemperatureIt->getValue() << " at " << TemperatureIt->getAlt() << "m; ";
+
+ out << "\nStored AirPressure: ";
+ out << p.AirPressure.getValue(0) << " at " << 0 << "m; ";
+
+ out << "\nStored VaporPressure: ";
+ for (set<FGVaporPressureItem>::const_iterator VaporPressureIt = p.VaporPressure.begin();
+ VaporPressureIt != p.VaporPressure.end();
+ VaporPressureIt++)
+ out << VaporPressureIt->getValue() << " at " << VaporPressureIt->getAlt() << "m; ";
+
+ return out << "\n";
+}
+
+
+inline FGPhysicalProperties& FGPhysicalProperties::operator = ( const FGPhysicalProperties& p )
+{
+ Wind = p.Wind;
+ Turbulence = p.Turbulence;
+ Temperature = p.Temperature;
+ AirPressure = p.AirPressure;
+ VaporPressure = p.VaporPressure;
+ return *this;
+}
+
+inline FGPhysicalProperties& FGPhysicalProperties::operator *= ( const WeatherPrecition& d )
+{
+
+ for (set<FGWindItem>::iterator WindIt = Wind.begin();
+ WindIt != Wind.end();
+ WindIt++)
+ *WindIt *= d;
+
+ for (set<FGTurbulenceItem>::iterator TurbulenceIt = Turbulence.begin();
+ TurbulenceIt != Turbulence.end();
+ TurbulenceIt++)
+ *TurbulenceIt *= d;
+
+ for (set<FGTemperatureItem>::iterator TemperatureIt = Temperature.begin();
+ TemperatureIt != Temperature.end();
+ TemperatureIt++)
+ *TemperatureIt *= d;
+
+ AirPressure *= d;
+
+ for (set<FGVaporPressureItem>::iterator VaporPressureIt = VaporPressure.begin();
+ VaporPressureIt != VaporPressure.end();
+ VaporPressureIt++)
+ *VaporPressureIt *= d;
+
+ return *this;
+}
+
+inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysicalProperties& p)
+{
+ for (set<FGWindItem>::const_iterator WindIt = p.Wind.begin();
+ WindIt != p.Wind.end();
+ WindIt++ )
+ if (WindIt != Wind.upper_bound( FGWindItem(WindIt->getAlt(), Point3D(0)) ))
+ Wind.insert(*WindIt);
+ else
+ *(Wind.upper_bound( FGWindItem(WindIt->getAlt(), Point3D(0))) ) += WindIt->getValue();
+
+ for (set<FGTurbulenceItem>::const_iterator TurbulenceIt = p.Turbulence.begin();
+ TurbulenceIt != p.Turbulence.end();
+ TurbulenceIt++)
+ if (TurbulenceIt != Turbulence.upper_bound( FGTurbulenceItem(TurbulenceIt->getAlt(), Point3D(0)) ))
+ Turbulence.insert(*TurbulenceIt);
+ else
+ *(Turbulence.upper_bound( FGTurbulenceItem(TurbulenceIt->getAlt(), Point3D(0)) )) += TurbulenceIt->getValue();
+
+ for (set<FGTemperatureItem>::const_iterator TemperatureIt = p.Temperature.begin();
+ TemperatureIt != p.Temperature.end();
+ TemperatureIt++)
+ if (TemperatureIt != Temperature.upper_bound( FGTemperatureItem(TemperatureIt->getAlt(), 0.0) ))
+ Temperature.insert(*TemperatureIt);
+ else
+ *(Temperature.upper_bound( FGTemperatureItem(TemperatureIt->getAlt(), 0.0) )) += TemperatureIt->getValue();
+
+ AirPressure += p.AirPressure.getValue(0.0);
+
+ for (set<FGVaporPressureItem>::const_iterator VaporPressureIt = p.VaporPressure.begin();
+ VaporPressureIt != p.VaporPressure.end();
+ VaporPressureIt++)
+ if (VaporPressureIt != VaporPressure.upper_bound( FGVaporPressureItem(VaporPressureIt->getAlt(), 0.0) ))
+ VaporPressure.insert(*VaporPressureIt);
+ else
+ *(VaporPressure.upper_bound( FGVaporPressureItem(VaporPressureIt->getAlt(), 0.0) )) += VaporPressureIt->getValue();
+
+ return *this;
+}
+
+inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
+{
+
+ for (set<FGWindItem>::const_iterator WindIt = p.Wind.begin();
+ WindIt != p.Wind.end();
+ WindIt++)
+ if (WindIt != Wind.upper_bound( FGWindItem(WindIt->getAlt(), Point3D(0)) ))
+ Wind.insert(-(*WindIt));
+ else
+ *(Wind.upper_bound( FGWindItem(WindIt->getAlt(), Point3D(0)) )) -= WindIt->getValue();
+
+ for (set<FGTurbulenceItem>::const_iterator TurbulenceIt = p.Turbulence.begin();
+ TurbulenceIt != p.Turbulence.end();
+ TurbulenceIt++)
+ if (TurbulenceIt != Turbulence.upper_bound( FGTurbulenceItem(TurbulenceIt->getAlt(), Point3D(0)) ))
+ Turbulence.insert(-(*TurbulenceIt));
+ else
+ *(Turbulence.upper_bound( FGTurbulenceItem(TurbulenceIt->getAlt(), Point3D(0)) )) -= TurbulenceIt->getValue();
+
+ for (set<FGTemperatureItem>::const_iterator TemperatureIt = p.Temperature.begin();
+ TemperatureIt != p.Temperature.end();
+ TemperatureIt++)
+ if (TemperatureIt != Temperature.upper_bound( FGTemperatureItem(TemperatureIt->getAlt(), 0.0) ))
+ Temperature.insert(-(*TemperatureIt));
+ else
+ *(Temperature.upper_bound( FGTemperatureItem(TemperatureIt->getAlt(), 0.0) )) -= TemperatureIt->getValue();
+
+ AirPressure -= p.AirPressure.getValue(0.0);
+
+ for (set<FGVaporPressureItem>::const_iterator VaporPressureIt = p.VaporPressure.begin();
+ VaporPressureIt != p.VaporPressure.end();
+ VaporPressureIt++)
+ if (VaporPressureIt != VaporPressure.upper_bound( FGVaporPressureItem(VaporPressureIt->getAlt(), 0.0) ))
+ VaporPressure.insert(-(*VaporPressureIt));
+ else
+ *(VaporPressure.upper_bound( FGVaporPressureItem(VaporPressureIt->getAlt(), 0.0) )) -= VaporPressureIt->getValue();
+
+ return *this;
+}
+
+
+inline Point3D FGPhysicalProperties::WindAt(const WeatherPrecition& a) const
+{
+ set<FGWindItem>::const_iterator it = Wind.lower_bound(FGWindItem(a, Point3D(0)));
+ set<FGWindItem>::const_iterator it2 = it;
+ it--;
+
+ //now I've got it->alt < a < it2->alt so I can interpolate
+ return ( (it2->getValue() - it->getValue())/(it2->getAlt() - it->getAlt()) )*
+ (a - it2->getAlt()) +
+ it2->getValue();
+}
+
+inline Point3D FGPhysicalProperties::TurbulenceAt(const WeatherPrecition& a) const
+{
+ set<FGTurbulenceItem>::const_iterator it = Turbulence.lower_bound(FGTurbulenceItem(a, Point3D(0)));
+ set<FGTurbulenceItem>::const_iterator it2 = it;
+ it--;
+
+ //now I've got it->alt < a < it2->alt so I can interpolate
+ return ( (it2->getValue() - it->getValue() )/(it2->getAlt() - it->getAlt()) )*
+ (a - it2->getAlt())+ it2->getValue();
+}
+
+inline WeatherPrecition FGPhysicalProperties::TemperatureAt(const WeatherPrecition& a) const
+{
+ set<FGTemperatureItem>::const_iterator it = Temperature.lower_bound(FGTemperatureItem(a, 0));
+ set<FGTemperatureItem>::const_iterator it2 = it;
+ it--;
+
+ //now I've got it->alt < a < it2->alt so I can interpolate
+ return ( (it2->getValue() - it->getValue()) / (it2->getAlt() - it->getAlt()) )*
+ (a - it2->getAlt() )+ it2->getValue();
+}
+
+inline WeatherPrecition FGPhysicalProperties::AirPressureAt(const WeatherPrecition& a) const
+{
+ return AirPressure.getValue(a);
+}
+
+inline WeatherPrecition FGPhysicalProperties::VaporPressureAt(const WeatherPrecition& a) const
+{
+ set<FGVaporPressureItem>::const_iterator it = VaporPressure.lower_bound(FGVaporPressureItem(a, 0));
+ set<FGVaporPressureItem>::const_iterator it2 = it;
+ it--;
+
+ //now I've got it->alt < a < it2->alt so I can interpolate
+ return ( (it2->getValue() - it->getValue() ) / (it2->getAlt() - it->getAlt() ) ) *
+ (a - it2->getAlt() )+ it2->getValue();
+}
+
+
+inline FGPhysicalProperties operator * (const FGPhysicalProperties& a, const WeatherPrecition& b)
+{
+ return FGPhysicalProperties(a) *= b;
+}
+
+inline FGPhysicalProperties operator * (const WeatherPrecition& b, const FGPhysicalProperties& a)
+{
+ return FGPhysicalProperties(a) *= b;
+}
+
+inline FGPhysicalProperties operator + (const FGPhysicalProperties& a, const FGPhysicalProperties& b)
+{
+ return FGPhysicalProperties(a) += (FGPhysicalProperties)b;
+}
+
+inline FGPhysicalProperties operator - (const FGPhysicalProperties& a, const FGPhysicalProperties& b)
+{
+ return FGPhysicalProperties(a) -= (FGPhysicalProperties)b;
+}
+
+/****************************************************************************/
+#endif /*FGPhysicalProperties_H*/
+
--- /dev/null
+/*****************************************************************************
+
+ Module: FGPhysicalProperty.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: main program
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Initialice the FGPhysicalProperty struct to something sensible(?)
+
+HISTORY
+------------------------------------------------------------------------------
+29.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGPhysicalProperty.h"
+#include "FGWeatherDefs.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+FGPhysicalProperty::FGPhysicalProperty()
+{
+ Wind.setx(0.0); //Wind vector
+ Wind.sety(0.0); //Wind vector
+ Wind.setz(0.0); //Wind vector
+
+ Turbulence.setx(0.0); //Turbulence vector
+ Turbulence.sety(0.0); //Turbulence vector
+ Turbulence.setz(0.0); //Turbulence vector
+
+ Temperature = FG_WEATHER_DEFAULT_TEMPERATURE; //a nice warm day
+ AirPressure = FG_WEATHER_DEFAULT_AIRPRESSURE; //mbar, that's ground level
+ VaporPressure = FG_WEATHER_DEFAULT_VAPORPRESSURE; //that gives about 50% relatvie humidity
+}
+
+FGPhysicalProperty::FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecition& altitude)
+{
+ Wind = p.WindAt(altitude);
+ Turbulence = p.TurbulenceAt(altitude);
+ Temperature = p.TemperatureAt(altitude);
+ AirPressure = p.AirPressureAt(altitude);
+ VaporPressure = p.VaporPressureAt(altitude);
+}
+
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGPhysicalProperty.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Define the simulated physical property of the weather in one point
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer Changed struct to class
+20.06.1999 Christian Mayer added lots of consts
+30.06.1999 Christian Mayer STL portability
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGPhysicalProperty_H
+#define FGPhysicalProperty_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include <Include/compiler.h>
+#include <vector>
+FG_USING_STD(vector);
+FG_USING_NAMESPACE(std);
+
+#include <Math/point3d.hxx>
+#include <Voronoi/point2d.h>
+#include "FGWeatherDefs.h"
+#include "FGPhysicalProperties.h"
+
+/****************************************************************************/
+/* used for output: */
+/****************************************************************************/
+class FGPhysicalProperty
+{
+private:
+protected:
+public:
+ Point3D Wind; //Wind vector
+ Point3D Turbulence; //Turbulence vector
+ WeatherPrecition Temperature; //in deg. Kelvin (I *only* accept SI!)
+ WeatherPrecition AirPressure; //in Pascal (I *only* accept SI!)
+ WeatherPrecition VaporPressure; //in Pascal (I *only* accept SI!)
+
+ FGPhysicalProperty(); //consructor to fill it with FG standart weather
+ FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecition& altitude);
+
+ //allow calculations for easier handling such as interpolating
+ FGPhysicalProperty& operator = ( const FGPhysicalProperty& p ); // assignment of a Point3D
+ FGPhysicalProperty& operator += ( const FGPhysicalProperty& p ); // incrementation by a Point3D
+ FGPhysicalProperty& operator -= ( const FGPhysicalProperty& p ); // decrementation by a Point3D
+ FGPhysicalProperty& operator *= ( const double& d ); // multiplication by a constant
+ FGPhysicalProperty& operator /= ( const double& d ); // division by a constant
+
+ friend FGPhysicalProperty operator - (const FGPhysicalProperty& p); // -p1
+ friend bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
+};
+
+typedef vector<FGPhysicalProperty> FGPhysicalPropertyVector;
+typedef FGPhysicalPropertyVector::iterator FGPhysicalPropertyVectorIt;
+typedef FGPhysicalPropertyVector::const_iterator FGPhysicalPropertyVectorConstIt;
+
+class FGPhysicalProperty3D : public FGPhysicalProperty
+{
+private:
+protected:
+public:
+ Point3D p; //position of the property (lat/lon/alt)
+};
+
+typedef vector<FGPhysicalProperty3D> FGPhysicalProperty3DVector;
+typedef FGPhysicalProperty3DVector::iterator FGPhysicalProperty3DVectorIt;
+typedef FGPhysicalProperty3DVector::const_iterator FGPhysicalProperty3DVectorConstIt;
+
+inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProperty& p )
+{
+ Wind = p.Wind;
+ Turbulence = p.Turbulence;
+ Temperature = p.Temperature;
+ AirPressure = p.AirPressure;
+ VaporPressure = p.VaporPressure;
+ return *this;
+}
+
+inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalProperty& p )
+{
+ Wind += p.Wind;
+ Turbulence += p.Turbulence;
+ Temperature += p.Temperature;
+ AirPressure += p.AirPressure;
+ VaporPressure += p.VaporPressure;
+ return *this;
+}
+
+inline FGPhysicalProperty& FGPhysicalProperty::operator -= ( const FGPhysicalProperty& p )
+{
+ Wind -= p.Wind;
+ Turbulence -= p.Turbulence;
+ Temperature -= p.Temperature;
+ AirPressure -= p.AirPressure;
+ VaporPressure -= p.VaporPressure;
+ return *this;
+}
+
+inline FGPhysicalProperty& FGPhysicalProperty::operator *= ( const double& d )
+{
+ Wind *= d;
+ Turbulence *= d;
+ Temperature *= d;
+ AirPressure *= d;
+ VaporPressure *= d;
+ return *this;
+}
+
+inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double& d )
+{
+ Wind /= d;
+ Turbulence /= d;
+ Temperature /= d;
+ AirPressure /= d;
+ VaporPressure /= d;
+ return *this;
+}
+
+inline FGPhysicalProperty operator - (const FGPhysicalProperty& p)
+{
+ FGPhysicalProperty x;
+ x.Wind = -p.Wind;
+ x.Turbulence = -p.Turbulence;
+ x.Temperature = -p.Temperature;
+ x.AirPressure = -p.AirPressure;
+ x.VaporPressure = -p.VaporPressure;
+ return x;
+}
+
+inline bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
+{
+ return (
+ (a.Wind == b.Wind) &&
+ (a.Turbulence == b.Turbulence) &&
+ (a.Temperature == b.Temperature) &&
+ (a.AirPressure == b.AirPressure) &&
+ (a.VaporPressure == b.VaporPressure));
+}
+
+inline bool operator != (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
+{
+ return !(a == b);
+}
+
+inline FGPhysicalProperty operator + (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
+{
+ return FGPhysicalProperty(a) += b;
+}
+
+inline FGPhysicalProperty operator - (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
+{
+ return FGPhysicalProperty(a) -= b;
+}
+
+inline FGPhysicalProperty operator * (const FGPhysicalProperty& a, const WeatherPrecition& b)
+{
+ return FGPhysicalProperty(a) *= b;
+}
+
+inline FGPhysicalProperty operator * (const WeatherPrecition& b, const FGPhysicalProperty& a)
+{
+ return FGPhysicalProperty(a) *= b;
+}
+
+inline FGPhysicalProperty operator / (const FGPhysicalProperty& a, const WeatherPrecition& b)
+{
+ return FGPhysicalProperty(a) *= (1.0/b);
+}
+
+
+/****************************************************************************/
+#endif /*FGPhysicalProperty_H*/
--- /dev/null
+/*****************************************************************************
+
+ Header: FGSnowRain.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Header for the rain/snow/hail/... class
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGSnowRain_H
+#define FGSnowRain_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGWeatherFeature.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+typedef enum SnowRainType
+{
+ Rain,
+ Snow,
+ Hail,
+
+ usedRainSnowTypes
+};
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGSnowRain:FGWeatherFeature
+{
+private:
+protected:
+public:
+};
+
+/****************************************************************************/
+#endif /*FGSnowRain_H*/
\ No newline at end of file
--- /dev/null
+/*****************************************************************************
+
+ Module: FGTemperatureItem.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: FGMicroWeather
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Operator< definition for the item
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGTemperatureItem.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+bool operator<(const FGTemperatureItem& arg1, const FGTemperatureItem& arg2 )
+{
+ return arg1.alt < arg2.alt;
+}
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGTemperatureItem.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Temperature item that is stored in the micro weather class
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGTemperatureItem_H
+#define FGTemperatureItem_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGWeatherDefs.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+class FGTemperatureItem;
+FGTemperatureItem operator-(const FGTemperatureItem& arg);
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGTemperatureItem
+{
+private:
+ WeatherPrecition value;
+ WeatherPrecition alt;
+
+protected:
+public:
+
+ FGTemperatureItem(const WeatherPrecition& a, const WeatherPrecition& v) {alt = a; value = v;}
+ FGTemperatureItem(const WeatherPrecition& v) {alt = 0.0; value = v;}
+ FGTemperatureItem() {alt = 0.0; value = (WeatherPrecition)FG_WEATHER_DEFAULT_TEMPERATURE;}
+
+ WeatherPrecition getValue() const { return value; };
+ WeatherPrecition getAlt() const { return alt; };
+
+ FGTemperatureItem& operator*= (const WeatherPrecition& arg);
+ FGTemperatureItem& operator+= (const FGTemperatureItem& arg);
+ FGTemperatureItem& operator-= (const FGTemperatureItem& arg);
+
+ friend bool operator<(const FGTemperatureItem& arg1, const FGTemperatureItem& arg2 );
+ friend FGTemperatureItem operator-(const FGTemperatureItem& arg);
+
+};
+
+inline FGTemperatureItem& FGTemperatureItem::operator*= (const WeatherPrecition& arg)
+{
+ value *= arg;
+ return *this;
+}
+
+inline FGTemperatureItem& FGTemperatureItem::operator+= (const FGTemperatureItem& arg)
+{
+ value += arg.value;
+ return *this;
+}
+inline FGTemperatureItem& FGTemperatureItem::operator-= (const FGTemperatureItem& arg)
+{
+ value -= arg.value;
+ return *this;
+}
+
+
+inline FGTemperatureItem operator-(const FGTemperatureItem& arg)
+{
+ return FGTemperatureItem(arg.alt, -arg.value);
+}
+
+
+
+
+/****************************************************************************/
+#endif /*FGTemperatureItem_H*/
--- /dev/null
+/*****************************************************************************
+
+ Module: FGTurbulenceItem.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: FGMicroWeather
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Operator< definition for the item
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGTurbulenceItem.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+bool operator<(const FGTurbulenceItem& arg1, const FGTurbulenceItem& arg2)
+{
+ return arg1.alt < arg2.alt;
+}
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGTurbulenceItem.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+turbulence item that gets stored in the micro weather class
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGTurbulenceItem_H
+#define FGTurbulenceItem_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include <Math/point3d.hxx>
+#include "FGWeatherDefs.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+class FGTurbulenceItem;
+FGTurbulenceItem operator-(const FGTurbulenceItem& arg);
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGTurbulenceItem
+{
+private:
+ Point3D value;
+ WeatherPrecition alt;
+
+protected:
+public:
+ FGTurbulenceItem(const WeatherPrecition& a, const Point3D& v) {alt = a; value = v;}
+ FGTurbulenceItem(const Point3D& v) {alt = 0.0; value = v;}
+ FGTurbulenceItem() {alt = 0.0; value = Point3D(0.0);}
+
+ Point3D getValue() const { return value; };
+ WeatherPrecition getAlt() const { return alt; };
+
+ FGTurbulenceItem& operator*= (const WeatherPrecition& arg);
+ FGTurbulenceItem& operator+= (const FGTurbulenceItem& arg);
+ FGTurbulenceItem& operator-= (const FGTurbulenceItem& arg);
+
+ friend bool operator<(const FGTurbulenceItem& arg1, const FGTurbulenceItem& arg2 );
+ friend FGTurbulenceItem operator-(const FGTurbulenceItem& arg);
+
+};
+
+inline FGTurbulenceItem& FGTurbulenceItem::operator*= (const WeatherPrecition& arg)
+{
+ value *= arg;
+ return *this;
+}
+
+inline FGTurbulenceItem& FGTurbulenceItem::operator+= (const FGTurbulenceItem& arg)
+{
+ value += arg.value;
+ return *this;
+}
+
+inline FGTurbulenceItem& FGTurbulenceItem::operator-= (const FGTurbulenceItem& arg)
+{
+ value -= arg.value;
+ return *this;
+}
+
+inline FGTurbulenceItem operator-(const FGTurbulenceItem& arg)
+{
+ return FGTurbulenceItem(arg.alt, -arg.value);
+}
+
+/****************************************************************************/
+#endif /*FGTurbulenceItem_H*/
+
+
+
+
--- /dev/null
+/*****************************************************************************
+
+ Module: FGVaporPressureItem.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: FGMicroWeather
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Operator< definition for the item
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGVaporPressureItem.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+bool operator<(const FGVaporPressureItem& arg1, const FGVaporPressureItem& arg2 )
+{
+ return arg1.alt < arg2.alt;
+}
--- /dev/null
+/*****************************************************************************
+
+ Header: FGVaporPressureItem.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Vapor pressure item that is stored in the micro weather class
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGVaporPressureItem_H
+#define FGVaporPressureItem_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGWeatherDefs.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+class FGVaporPressureItem;
+FGVaporPressureItem operator-(const FGVaporPressureItem& arg);
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGVaporPressureItem
+{
+private:
+ WeatherPrecition value;
+ WeatherPrecition alt;
+
+protected:
+public:
+
+ FGVaporPressureItem(const WeatherPrecition& a, const WeatherPrecition& v) {alt = a; value = v;}
+ FGVaporPressureItem(const WeatherPrecition& v) {alt = 0.0; value = v;}
+ FGVaporPressureItem() {alt = 0.0; value = FG_WEATHER_DEFAULT_VAPORPRESSURE;}
+
+ WeatherPrecition getValue() const { return value; };
+ WeatherPrecition getAlt() const { return alt; };
+
+ FGVaporPressureItem& operator*= (const WeatherPrecition& arg);
+ FGVaporPressureItem& operator+= (const FGVaporPressureItem& arg);
+ FGVaporPressureItem& operator-= (const FGVaporPressureItem& arg);
+
+ friend bool operator<(const FGVaporPressureItem& arg1, const FGVaporPressureItem& arg2 );
+ friend FGVaporPressureItem operator-(const FGVaporPressureItem& arg);
+
+};
+
+inline FGVaporPressureItem& FGVaporPressureItem::operator*= (const WeatherPrecition& arg)
+{
+ value *= arg;
+ return *this;
+}
+inline FGVaporPressureItem& FGVaporPressureItem::operator+= (const FGVaporPressureItem& arg)
+{
+ value += arg.value;
+ return *this;
+}
+
+inline FGVaporPressureItem& FGVaporPressureItem::operator-= (const FGVaporPressureItem& arg)
+{
+ value -= arg.value;
+ return *this;
+}
+
+inline FGVaporPressureItem operator-(const FGVaporPressureItem& arg)
+{
+ return FGVaporPressureItem(arg.alt, -arg.value);
+}
+
+/****************************************************************************/
+#endif /*FGVaporPressureItem_H*/
--- /dev/null
+/*****************************************************************************
+
+ Module: FGVoronoi.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: main program
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+library for Voronoi Diagram calculation based on Steven Fortune 'Sweep2'
+FGVoronoi is the wraper to feed the voronoi calulation with a vetor of points
+and any class you want, as it uses templates
+NOTE: Sweep2 didn't free *any* memory. So I'm doing what I can, but that's not
+ good enough...
+
+HISTORY
+------------------------------------------------------------------------------
+30.05.99 Christian Mayer Created
+16.06.99 Durk Talsma Portability for Linux
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGVoronoi.h"
+#include <Voronoi/voronoi.h>
+#include <Voronoi/my_memory.h>
+
+extern "C" {
+#include <Voronoi/defs.h>
+
+//forward definitions
+void voronoi(int triangulate, struct Site *(*nextsite)());
+void geominit(void);
+void freeinit(struct Freelist *fl, int size);
+struct Site *nextone(void);
+bool readsites(PointList input);
+};
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+FGVoronoiOutputList Voronoiate(const FGVoronoiInputList& input)
+{
+ FGVoronoiOutputList ret_list;
+
+ PointList p2ds;
+
+ FGVoronoiInputList::iterator it1;
+
+ //get the points
+ for (it1 = (FGVoronoiInputList::iterator)input.begin(); it1 != input.end(); it1++)
+ {
+ p2ds.push_back(VoronoiPoint(it1->position.x(), it1->position.y()));
+ }
+
+ cl.clear(); //make sure that it's empty
+
+ if (readsites(p2ds) == false)
+ return ret_list;
+
+ freeinit(&sfl, sizeof *sites);
+ siteidx = 0;
+ geominit();
+ voronoi(triangulate, nextone);
+
+ _my_free();
+ /*free(sites); //to prevent a *big* memory leak...
+ free(ELhash); //Sweep2 didn't free *any* memory...
+ free(PQhash);*/
+
+ for (cellList::iterator it2 = cl.begin(); it2 != cl.end(); it2++)
+ {
+ it2->sort();
+ it2->strip();
+
+ //uncomment for debugging
+ //cout << *it2;
+
+ Point2DList boundary;
+
+ //copy points
+ PointList::iterator it3 = it2->boundary.begin();
+
+ if (it3->infinity == false)
+ boundary.push_back( *it3 );
+ else
+ {
+ Point2D direction_vector = *it3;
+ it3++;
+ boundary.push_back( (*it3) + direction_vector);
+ }
+
+ for (; it3 != it2->boundary.end(); it3++)
+ {
+ boundary.push_back( *it3 );
+
+ }
+
+ it3--;
+ if (it3->infinity == true)
+ {
+ Point2D direction_vector = *it3;
+ it3--;
+ Point2D value = *it3;
+ boundary.pop_back();
+ boundary.push_back(value + direction_vector);
+ }
+
+ ret_list.push_back(FGVoronoiOutput(boundary, input[it2->ID].value));
+
+ }
+
+ return ret_list;
+
+}
+
+extern "C"
+{
+
+/* return a single in-storage site */
+struct Site *nextone(void)
+{
+ struct Site *s;
+ if(siteidx < nsites)
+ {
+ s = &sites[siteidx];
+ siteidx ++;
+ return(s);
+ }
+ else
+ return( (struct Site *)NULL);
+}
+
+
+/* sort sites on y, then x, coord */
+//int scomp(const struct Point *s1, const struct Point *s2)
+int scomp(const void *s1, const void *s2)
+{
+ if(((Point*)s1) -> y < ((Point*)s2) -> y) return(-1);
+ if(((Point*)s1) -> y > ((Point*)s2) -> y) return(1);
+ if(((Point*)s1) -> x < ((Point*)s2) -> x) return(-1);
+ if(((Point*)s1) -> x > ((Point*)s2) -> x) return(1);
+ return(0);
+}
+
+
+
+/* read all sites, sort, and compute xmin, xmax, ymin, ymax */
+bool readsites(PointList input)
+{
+ int i;
+
+ if (input.size() == 0)
+ return false; //empty array
+
+ PointList::iterator It = input.begin();
+
+ nsites=0;
+ sites = (struct Site *) myalloc(4000*sizeof(*sites));
+
+ while(It != input.end())
+ {
+ sites[nsites].coord.x = It->x();
+ sites[nsites].coord.y = It->y();
+
+ sites[nsites].sitenbr = nsites;
+ sites[nsites].refcnt = 0;
+ nsites ++;
+ It++;
+
+ if (nsites % 4000 == 0)
+ sites = (struct Site *) my_realloc(sites,(nsites+4000)*sizeof(*sites));
+ };
+
+ qsort(sites, nsites, sizeof (*sites), scomp);
+ xmin=sites[0].coord.x;
+ xmax=sites[0].coord.x;
+
+ for(i=1; i<nsites; i+=1)
+ {
+ if(sites[i].coord.x < xmin)
+ xmin = sites[i].coord.x;
+ if(sites[i].coord.x > xmax)
+ xmax = sites[i].coord.x;
+ };
+
+ ymin = sites[0].coord.y;
+ ymax = sites[nsites-1].coord.y;
+
+ return true;
+}
+
+
+}
+
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGVoronoi.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+library for Voronoi Diagram calculation based on Steven Fortune 'Sweep2'
+FGVoronoi is the wraper to feed the voronoi calulation with a vetor of points
+and any class you want, as it uses templates
+NOTE: Sweep2 didn't free *any* memory. So I'm doing what I can, but that's not
+ good enough...
+
+HISTORY
+------------------------------------------------------------------------------
+30.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+30.06.1999 Christian Mayer STL portability
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGVoronoi_H
+#define FGVoronoi_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "compiler.h"
+#include <vector>
+#include <set>
+
+#include <Voronoi/point2d.h>
+#include "FGPhysicalProperties.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+FG_USING_STD(vector);
+FG_USING_STD(set);
+FG_USING_NAMESPACE(std);
+
+typedef vector<Point2D> Point2DList;
+
+struct FGVoronoiInput
+{
+ Point2D position;
+ FGPhysicalProperties2D value;
+
+ FGVoronoiInput(const Point2D& p, const FGPhysicalProperties2D& v) { position = p; value = v; }
+};
+
+struct FGVoronoiOutput
+{
+ Point2DList boundary;
+ FGPhysicalProperties2D value;
+
+ FGVoronoiOutput(const Point2DList& b, const FGPhysicalProperties2D& v) {boundary = b; value = v;};
+};
+
+typedef vector<FGVoronoiInput> FGVoronoiInputList;
+typedef vector<FGVoronoiOutput> FGVoronoiOutputList;
+
+/****************************************************************************/
+/* FUNCTION DECLARATION */
+/****************************************************************************/
+FGVoronoiOutputList Voronoiate(const FGVoronoiInputList& input);
+
+#endif /*FGVoronoi_H*/
+
+
+
+
+
+
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGWeatherDefs.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+definitions uses in most weather classes
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGWeatherDefs_H
+#define FGWeatherDefs_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+typedef float WeatherPrecition;
+
+//set the minimum visibility to get a at least half way realistic weather
+#define MINIMUM_WEATHER_VISIBILIY 10.0 /* metres */
+#define DEFAULT_WEATHER_VISIBILIY 32000.0 /* metres */
+//prefered way the database is working
+#define PREFERED_WORKING_TYPE default_mode
+
+#define FG_WEATHER_DEFAULT_TEMPERATURE (15.0+273.16) /*15°C or 288.16°K*/
+#define FG_WEATHER_DEFAULT_VAPORPRESSURE (0.0) /*in Pascal 1 Pa = N/m^2*/
+#define FG_WEATHER_DEFAULT_AIRPRESSURE (1013.25*100.0) /*in Pascal 1 Pa = N/m^2*/
+#define FG_WEATHER_DEFAULT_AIRDENSITY (1.22501) /*in kg/m^3*/
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+
+/****************************************************************************/
+#endif /*FGWeatherDefs_H*/
--- /dev/null
+/*****************************************************************************
+
+ Header: FGWeatherFeature.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Abstract class that every weather feature, such as wind layers, are derivated
+from
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+30.06.1999 Christian Mayer STL portability
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGWeatherFeature_H
+#define FGWeatherFeature_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include <Include/compiler.h>
+#include <vector>
+FG_USING_STD(vector);
+FG_USING_NAMESPACE(std);
+
+#include <Math/point3d.hxx>
+#include "FGWeatherDefs.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+enum LayerType {
+ fgWind,
+ fgTurbulence,
+ fgTemperature,
+ fgAirDensity,
+ fgCloud,
+ fgRain
+};
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGWeatherFeature
+{
+private:
+protected:
+ Point3D position; //middle of the feature in lat/lon/alt
+ WeatherPrecition minSize; //smalest size of the feature
+ //=> a disk is specifies
+
+ LayerType FeatureType;
+
+public:
+ LayerType getFeature(void) const { return FeatureType; }
+ bool isFeature(const LayerType& f) const {return (f == FeatureType);}
+};
+
+/****************************************************************************/
+#endif /*FGWeatherFeature_H*/
\ No newline at end of file
--- /dev/null
+/*****************************************************************************
+
+ Header: FGWeatherUtils.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Utilities for the weather calculation like converting formulas
+
+HISTORY
+------------------------------------------------------------------------------
+02.06.1999 Christian Mayer Created
+08.06.1999 Christian Mayer Changed sat_vp
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGWeatherUtils_H
+#define FGWeatherUtils_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include <math.h>
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+
+/****************************************************************************/
+/*assuming as given: */
+/* */
+/* t: temperature in °C */
+/* p: preasure in mbar */
+/* //abs_hum: absoloute humidity in g/m^3, */
+/* act_vp: actual vapor pressure pascal */
+/* */
+/* Calculated vaues: */
+/* //max_hum: maximum of humidity in g/m^3, */
+/* sat_vp: saturated vapor pressure in pascal */
+/* rel_hum: relative humidity in % */
+/* dp: dew point in °C */
+/* wb: approximate wetbulp in °C */
+/* */
+/* NOTE: Pascal is the SI unit for preasure and is defined as Pa = N/m^2 */
+/* 1 mbar = 1 hPa = 100 Pa */
+/* NOTE: °C isn't a SI unit, so I should use °K instead. But as all */
+/* formulas are given in °C and the weather database only uses */
+/* 'normal' temperatures, I've kept it in °C */
+/****************************************************************************/
+
+#define SAT_VP_CONST1 610.483125
+#define SAT_VP_CONST2 7.444072452
+#define SAT_VP_CONST3 235.3120919
+
+inline WeatherPrecition sat_vp(const WeatherPrecition& temp)
+{
+ //old:
+ //return 6.112 * pow( 10, (7.5*dp)/(237.7+dp) ); //in mbar
+
+ //new:
+ //advantages: return the result as SI unit pascal and the constants
+ //are choosen that the correct results are returned for 0°C, 20°C and
+ //100°C. By 100°C I'm now returning a preasure of 1013.25 hPa
+ return SAT_VP_CONST1 * pow( 10, (SAT_VP_CONST2*temp)/(SAT_VP_CONST3+temp) ); //in pascal
+}
+
+inline WeatherPrecition rel_hum(const WeatherPrecition& act_vp, const WeatherPrecition& sat_vp)
+{
+ return (act_vp / sat_vp) * 100; //in %
+}
+
+inline WeatherPrecition dp(const WeatherPrecition& sat_vp)
+{
+ return (SAT_VP_CONST3*log10(sat_vp/SAT_VP_CONST1))/(SAT_VP_CONST2-log10(sat_vp/SAT_VP_CONST1)); //in °C
+}
+
+inline WeatherPrecition wb(const WeatherPrecition& t, const WeatherPrecition& p, const WeatherPrecition& dp)
+{
+ WeatherPrecition e = sat_vp(dp);
+ WeatherPrecition tcur, tcvp, peq, diff;
+ WeatherPrecition tmin, tmax;
+
+ if (t > dp)
+ {
+ tmax = t;
+ tmin = dp;
+ }
+ else
+ {
+ tmax = dp;
+ tmin = t;
+ }
+
+ while (true)
+ {
+ tcur=(tmax+tmin)/2;
+ tcvp=sat_vp(tcur);
+
+ peq = 0.000660*(1+0.00155*tcur)*p*(t-tcur);
+
+ diff = peq-tcvp+e;
+
+ if (fabs(diff) < 0.01)
+ return tcur; //in °C
+
+ if (diff < 0)
+ tmax=tcur;
+ else
+ tmin=tcur;
+ };
+
+}
+
+inline WeatherPrecition Celsius(const WeatherPrecition& celsius)
+{
+ return celsius + 273.16; //Kelvin
+}
+
+inline WeatherPrecition Fahrenheit(const WeatherPrecition& fahrenheit)
+{
+ return (fahrenheit * 9.0 / 5.0) + 32.0 + 273.16; //Kelvin
+}
+
+inline WeatherPrecition Kelvin2Celsius(const WeatherPrecition& kelvin)
+{
+ return kelvin - 273.16; //Celsius
+}
+
+inline WeatherPrecition Kelvin2Fahrenheit(const WeatherPrecition& kelvin)
+{
+ return ((kelvin - 273.16) * 9.0 / 5.0) + 32.0; //Fahrenheit
+}
+
+inline WeatherPrecition Celsius2Fahrenheit(const WeatherPrecition& celsius)
+{
+ return (celsius * 9.0 / 5.0) + 32.0; //Fahrenheit
+}
+
+inline WeatherPrecition Fahrenheit2Celsius(const WeatherPrecition& fahrenheit)
+{
+ return (fahrenheit - 32.0) * 5.0 / 9.0; //Celsius
+}
+
+inline WeatherPrecition Torr2Pascal(const WeatherPrecition& torr)
+{
+ return (101325.0/760.0)*torr;
+}
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+
+/****************************************************************************/
+#endif /*FGWeatherUtils_H*/
\ No newline at end of file
--- /dev/null
+/*****************************************************************************
+
+ Module: FGWindItem.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: FGMicroWeather
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Operator< definition for the item
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGWindItem.h"
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+bool operator<(const FGWindItem& arg1, const FGWindItem& arg2)
+{
+ return arg1.alt < arg2.alt;
+}
+
--- /dev/null
+/*****************************************************************************
+
+ Header: FGWindItem.h
+ Author: Christian Mayer
+ Date started: 28.05.99
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+wind item that gets stored in the micro weather class
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.1999 Christian Mayer Created
+16.06.1999 Durk Talsma Portability for Linux
+20.06.1999 Christian Mayer added lots of consts
+*****************************************************************************/
+
+/****************************************************************************/
+/* SENTRY */
+/****************************************************************************/
+#ifndef FGWindItem_H
+#define FGWindItem_H
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include <Math/point3d.hxx>
+#include "FGWeatherDefs.h"
+
+/****************************************************************************/
+/* DEFINES */
+/****************************************************************************/
+class FGWindItem;
+FGWindItem operator-(const FGWindItem& arg);
+
+/****************************************************************************/
+/* CLASS DECLARATION */
+/****************************************************************************/
+class FGWindItem
+{
+private:
+ Point3D value;
+ WeatherPrecition alt;
+
+protected:
+public:
+
+ FGWindItem(const WeatherPrecition& a, const Point3D& v) {alt = a; value = v;}
+ FGWindItem(const Point3D& v) {alt = 0.0; value = v;}
+ FGWindItem() {alt = 0.0; value = Point3D(0.0);}
+
+ Point3D getValue() const { return value; };
+ WeatherPrecition getAlt() const { return alt; };
+
+ FGWindItem& operator*= (const WeatherPrecition& arg);
+ FGWindItem& operator+= (const FGWindItem& arg);
+ FGWindItem& operator-= (const FGWindItem& arg);
+
+ friend bool operator<(const FGWindItem& arg1, const FGWindItem& arg2);
+ friend FGWindItem operator-(const FGWindItem& arg);
+
+};
+
+inline FGWindItem& FGWindItem::operator*= (const WeatherPrecition& arg)
+{
+ value *= arg;
+ return *this;
+}
+
+inline FGWindItem& FGWindItem::operator+= (const FGWindItem& arg)
+{
+ value += arg.value;
+ return *this;
+}
+
+inline FGWindItem& FGWindItem::operator-= (const FGWindItem& arg)
+{
+ value -= arg.value;
+ return *this;
+}
+
+
+inline FGWindItem operator-(const FGWindItem& arg)
+{
+ return FGWindItem(arg.alt, -arg.value);
+}
+/****************************************************************************/
+#endif /*FGWindItem_H*/
--- /dev/null
+noinst_LIBRARIES = libWeatherCM.a
+
+libWeatherCM_a_SOURCES = \
+ FGAirPressureItem.cpp FGAirPressureItem.h \
+ FGCloud.h FGCloudItem.cpp FGCloudItem.h \
+ FGGlobalWeatherDatabase.cpp FGGlobalWeatherDatabase.h \
+ FGLocalWeatherDatabase.cpp FGLocalWeatherDatabase.h \
+ FGMicroWeather.cpp FGMicroWeather.h \
+ FGPhysicalProperties.cpp FGPhysicalProperties.h \
+ FGPhysicalProperty.cpp FGPhysicalProperty.h \
+ FGSnowRain.h \
+ FGTemperatureItem.cpp FGTemperatureItem.h \
+ FGTurbulenceItem.cpp FGTurbulenceItem.h \
+ FGVaporPressureItem.cpp FGVaporPressureItem.h \
+ FGVoronoi.cpp FGVoronoi.h \
+ FGWeatherDefs.h FGWeatherFeature.h FGWeatherUtils.h \
+ FGWindItem.cpp FGWindItem.h
+
+INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
--- /dev/null
+/*****************************************************************************
+
+ Module: test.cpp
+ Author: Christian Mayer
+ Date started: 28.05.99
+ Called by: command line
+
+ ---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+------------------------------------------------------------------------------
+Test program for the weather database
+
+HISTORY
+------------------------------------------------------------------------------
+28.05.99 CM Created
+*****************************************************************************/
+
+/****************************************************************************/
+/* INCLUDES */
+/****************************************************************************/
+#include "FGLocalWeatherDatabase.h"
+#include "FGGlobalWeatherDatabase.h"
+#include "LibVoronoi/FGVoronoi.h"
+#include "FGWeatherUtils.h"
+#include <time.h>
+#include STL_IOSTREAM
+#include <vector>
+
+/****************************************************************************/
+/********************************** CODE ************************************/
+/****************************************************************************/
+int main(void)
+{
+ //init local database:
+
+ FGLocalWeatherDatabase local(Point3D(0,0,0), 10000, FGLocalWeatherDatabase::use_global);
+ FGGlobalWeatherDatabase global(FGGlobalWeatherDatabase_working);
+
+ Point3D p(0);
+ Point2D p2d(0);
+ FGPhysicalProperties x;
+ FGPhysicalProperties2D x2d;
+ FGPhysicalProperties2DVector getAllvect;
+
+ cout << "\n**************** FGGlobalWeatherDatabase Test ****************\n";
+ x.Temperature.insert(FGTemperatureItem(100, Celsius(10)));
+ global.add(Point2D(5,5), x);
+
+ x.Temperature.insert(FGTemperatureItem(110, Celsius(-10)));
+ global.add(Point3D(10,10,10), x);
+
+ x2d.Temperature.insert(FGTemperatureItem(90, Celsius(-20)));
+ x2d.p = Point2D(10,5);
+
+ global.add(x2d);
+
+ getAllvect = global.getAll(p2d, 10000);
+ cout << "Returned size: " << getAllvect.size() << "\n";
+ getAllvect = global.getAll(p2d, 10000, 30);
+ cout << "Returned size: " << getAllvect.size() << "\n";
+ getAllvect = global.getAll(p, 10000);
+ cout << "Returned size: " << getAllvect.size() << "\n";
+ getAllvect = global.getAll(p, 10000, 3);
+ cout << "Returned size: " << getAllvect.size() << "\n";
+
+ cout << "Temperature: " << global.get(Point3D(5, 5, 100)).Temperature << "°C\n";
+ cout << "AirPressure at 0m: " << global.get(Point3D(5, 5, 0)).AirPressure << "\n";
+ cout << "AirPressure at 1000m: " << global.get(Point3D(5, 5, 1000)).AirPressure << "\n";
+
+ cout << global;
+
+
+ cout << "\n**************** FGMicroWeather Test ****************\n";
+ vector<Point2D> points;
+
+ points.push_back(Point2D(0.1, 0.1));
+ points.push_back(Point2D(0.9, 0.1));
+ points.push_back(Point2D(0.9, 0.9));
+ points.push_back(Point2D(0.1, 0.9));
+ points.push_back(Point2D(0.1, 0.1));
+
+ x2d.p = Point2D(0.4, 0.4);
+
+ FGMicroWeather micro(x2d, points);
+
+ cout << "hasPoint 0.5, 0.5: ";
+ if (micro.hasPoint(Point2D(0.5, 0.5)) == true)
+ cout << "true";
+ else
+ cout << "false";
+
+ cout << "\nhasPoint 0.9, 0.5: ";
+ if (micro.hasPoint(Point2D(0.9, 0.5)) == true)
+ cout << "true";
+ else
+ cout << "false";
+
+ cout << "\nhasPoint 1.5, 0.5: ";
+ if (micro.hasPoint(Point2D(1.5, 0.5)) == true)
+ cout << "true";
+ else
+ cout << "false";
+
+ cout << "\n";
+
+
+ cout << "\n**************** Voronoi Diagram Test ****************\n";
+ FGVoronoiInputList input;
+ FGVoronoiOutputList output;
+ FGVoronoiInput test(Point2D(0.0), FGPhysicalProperties2D());
+
+ test.position = Point2D(0.1,0.2);
+ input.push_back(test);
+
+ test.position = Point2D(0.8,0.9);
+ input.push_back(test);
+
+ test.position = Point2D(0.9,0.1);
+ input.push_back(test);
+
+ test.position = Point2D(0.6,0.4);
+ input.push_back(test);
+
+ test.position = Point2D(1.1,1.2);
+ input.push_back(test);
+
+ test.position = Point2D(1.8,1.9);
+ input.push_back(test);
+
+ test.position = Point2D(1.9,1.1);
+ input.push_back(test);
+
+ test.position = Point2D(1.6,1.4);
+ input.push_back(test);
+
+ test.position = Point2D(2.9,2.1);
+ input.push_back(test);
+
+ test.position = Point2D(2.6,2.4);
+ input.push_back(test);
+
+ output = Voronoiate(input);
+
+ cout << "\n";
+ for (FGVoronoiOutputList::iterator it=output.begin(); it!=output.end(); it++)
+ {
+ cout << "Cell start: ";
+ for (Point2DList::iterator it2= it->boundary.begin();it2!= it->boundary.end();it2++)
+ {
+ if (it2==it->boundary.begin())
+ cout << "(";
+ else
+ cout << "-(";
+
+ cout << *it2 << ")";
+ }
+ cout << "\n";
+ }
+
+ cout << "\n**************** Database Stress Test ****************\n";
+
+ time_t starttime, currenttime;
+ unsigned long count = 0;
+ unsigned long count2 = 0;
+ float xxx, yyy;
+ cout << "Filling Database... ";
+ time( &starttime );
+ for (count = 0; count < 5000; count++)
+ {
+ xxx = (rand()%36000)/100.0;
+ yyy = (rand()%18000)/100.0;
+
+ local.addProperties(FGPhysicalProperties2D(FGPhysicalProperties(), Point2D(xxx, yyy)));
+ }
+ local.addProperties(FGPhysicalProperties2D(FGPhysicalProperties(), Point3D(-10.0)));
+ local.addProperties(FGPhysicalProperties2D(FGPhysicalProperties(), Point3D(+10.0)));
+ local.addProperties(FGPhysicalProperties2D(FGPhysicalProperties(), Point3D(-100.0)));
+ local.addProperties(FGPhysicalProperties2D(FGPhysicalProperties(), Point3D(+100.0)));
+
+ time( ¤ttime );
+ cout << float(count)/float(currenttime - starttime) << "/s filling rate; ";
+ time( &starttime );
+
+ for (count = 0; count < 5; count++)
+ {
+ local.reset(FGLocalWeatherDatabase::use_global); //make sure I've got a current voronoi
+ }
+
+ time( ¤ttime );
+ cout << float(currenttime - starttime)/float(count) << "s resetting time; Done\n";
+ count = 0;
+
+ //for (;count<200;)
+ cout << "local.get() test: 10 seconds\n";
+ time( &starttime );
+ time( ¤ttime );
+ for (;currenttime<(starttime+10);)
+ {
+ time( ¤ttime );
+ count++;
+ local.get(Point3D(0.0));
+ }
+
+ cout << "Result: " << float(count) / float(currenttime-starttime) << "/s\n";
+
+ count = 0;
+ cout << "output = Voronoiate(input) test: 10 seconds\n";
+ time( &starttime );
+ time( ¤ttime );
+ for (;currenttime<(starttime+10);)
+ {
+ time( ¤ttime );
+ count++;
+ output = Voronoiate(input);
+ }
+
+ cout << "Result: " << float(count) / float(currenttime-starttime) << "/s\n";
+ cout << "Reference: 176800/s\n";
+
+ cout << "\n**************** Database Stress Test end ****************\n";
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+