Remove the old WeatherCM module.
This commit is contained in:
parent
74ae756473
commit
25290c4467
48 changed files with 10 additions and 5966 deletions
19
configure.ac
19
configure.ac
|
@ -70,18 +70,6 @@ fi
|
|||
AM_CONDITIONAL(ENABLE_MPLAYER_AS, test "x$with_multiplayer" != "xno")
|
||||
|
||||
|
||||
# Specify if we want to use WeatherCM instead of FGEnvironment.
|
||||
# default to with_weathercm=no
|
||||
AC_ARG_WITH(weathercm, [ --with-weathercm Use WeatherCM instead of FGEnvironment])
|
||||
if test "x$with_weathercm" = "xyes" ; then
|
||||
echo "Building with WeatherCM"
|
||||
AC_DEFINE([FG_WEATHERCM], 1,
|
||||
[Define to build with Christian Mayer's weather code])
|
||||
else
|
||||
echo "Building with FGEnvironment"
|
||||
fi
|
||||
AM_CONDITIONAL(ENABLE_WEATHERCM, test "x$with_weathercm" = "xyes")
|
||||
|
||||
dnl Thread related checks
|
||||
AC_ARG_WITH(threads, [ --with-threads Include tile loading threads [default=no]])
|
||||
if test "x$with_threads" = "xyes"; then
|
||||
|
@ -522,7 +510,6 @@ AC_CONFIG_FILES([ \
|
|||
src/Sound/Makefile \
|
||||
src/Systems/Makefile \
|
||||
src/Time/Makefile \
|
||||
src/WeatherCM/Makefile \
|
||||
tests/Makefile \
|
||||
utils/Makefile \
|
||||
utils/TerraSync/Makefile \
|
||||
|
@ -548,12 +535,6 @@ fi
|
|||
echo -n "Automake version: "
|
||||
automake --version | head -1
|
||||
|
||||
if test "x$with_weathercm" != "x"; then
|
||||
echo "WeatherCM instead of FGEnvironment: $with_weathercm"
|
||||
else
|
||||
echo "Using FGEnvironment"
|
||||
fi
|
||||
|
||||
if test "x$with_multiplayer" != "xno"; then
|
||||
echo "Building with multiplayer support"
|
||||
fi
|
||||
|
|
|
@ -34,12 +34,8 @@
|
|||
# include <dirent.h> // for directory reading
|
||||
#endif
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||
#else
|
||||
# include <Environment/environment_mgr.hxx>
|
||||
# include <Environment/environment.hxx>
|
||||
#endif
|
||||
#include <Environment/environment_mgr.hxx>
|
||||
#include <Environment/environment.hxx>
|
||||
|
||||
#include "AIMgr.hxx"
|
||||
#include "AILocalTraffic.hxx"
|
||||
|
@ -379,19 +375,10 @@ void FGAIMgr::GenerateSimpleAirportTraffic(string ident, double min_dist) {
|
|||
|
||||
// Check that the visibility is OK for IFR operation.
|
||||
double visibility;
|
||||
#ifdef FG_WEATHERCM
|
||||
//sgVec3 position = { aptpos.lat(), aptpos.lon(), aptpos.elev() };
|
||||
//FGPhysicalProperty stationweather = WeatherDatabase->get(position);
|
||||
#else
|
||||
FGEnvironment stationweather =
|
||||
((FGEnvironmentMgr *)globals->get_subsystem("environment"))
|
||||
->getEnvironment(aptpos.lat(), aptpos.lon(), aptpos.elev()); // TODO - check whether this should take ft or m for elev.
|
||||
#endif
|
||||
#ifdef FG_WEATHERCM
|
||||
visibility = fgGetDouble("/environment/visibility-m");
|
||||
#else
|
||||
visibility = stationweather.get_visibility_m();
|
||||
#endif
|
||||
// Technically we can do VFR down to 1 mile (1600m) but that's pretty murky!
|
||||
//cout << "vis = " << visibility << '\n';
|
||||
if(visibility < 3000) return;
|
||||
|
|
|
@ -28,12 +28,8 @@
|
|||
#include <simgear/math/polar3d.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||
#else
|
||||
# include <Environment/environment_mgr.hxx>
|
||||
# include <Environment/environment.hxx>
|
||||
#endif
|
||||
#include <Environment/environment_mgr.hxx>
|
||||
#include <Environment/environment.hxx>
|
||||
|
||||
|
||||
#include <GUI/gui.h>
|
||||
|
@ -555,37 +551,11 @@ double FGApproach::round_alt( const bool hl, double alt ) {
|
|||
void FGApproach::get_active_runway() {
|
||||
//cout << "Entering FGApproach::get_active_runway()\n";
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
sgVec3 position = { lat, lon, elev };
|
||||
FGPhysicalProperty stationweather = WeatherDatabase->get(position);
|
||||
#else
|
||||
FGEnvironment stationweather =
|
||||
((FGEnvironmentMgr *)globals->get_subsystem("environment"))
|
||||
->getEnvironment(lat, lon, elev);
|
||||
#endif
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
//Set the heading to into the wind
|
||||
double wind_x = stationweather.Wind[0];
|
||||
double wind_y = stationweather.Wind[1];
|
||||
|
||||
double speed = sqrt( wind_x*wind_x + wind_y*wind_y ) * SG_METER_TO_NM / (60.0*60.0);
|
||||
double hdg;
|
||||
|
||||
//If no wind use 270degrees
|
||||
if(speed == 0) {
|
||||
hdg = 270;
|
||||
} else {
|
||||
// //normalize the wind to get the direction
|
||||
//wind_x /= speed; wind_y /= speed;
|
||||
|
||||
hdg = - atan2 ( wind_x, wind_y ) * SG_RADIANS_TO_DEGREES ;
|
||||
if (hdg < 0.0)
|
||||
hdg += 360.0;
|
||||
}
|
||||
#else
|
||||
double hdg = stationweather.get_wind_from_heading_deg();
|
||||
#endif
|
||||
|
||||
FGRunway runway;
|
||||
if ( globals->get_runways()->search( ident, int(hdg), &runway) ) {
|
||||
|
|
|
@ -36,12 +36,8 @@ SG_USING_STD(cout);
|
|||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||
#else
|
||||
# include <Environment/environment_mgr.hxx>
|
||||
# include <Environment/environment.hxx>
|
||||
#endif
|
||||
#include <Environment/environment_mgr.hxx>
|
||||
#include <Environment/environment.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
@ -102,14 +98,9 @@ void FGATIS::UpdateTransmission() {
|
|||
int hours;
|
||||
// int minutes;
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
sgVec3 position = { lat, lon, elev };
|
||||
FGPhysicalProperty stationweather = WeatherDatabase->get(position);
|
||||
#else
|
||||
FGEnvironment stationweather =
|
||||
((FGEnvironmentMgr *)globals->get_subsystem("environment"))
|
||||
->getEnvironment(lat, lon, elev);
|
||||
#endif
|
||||
|
||||
transmission = "";
|
||||
|
||||
|
@ -139,11 +130,7 @@ void FGATIS::UpdateTransmission() {
|
|||
|
||||
// Get the temperature
|
||||
int temp;
|
||||
#ifdef FG_WEATHERCM
|
||||
temp = int(stationweather.Temperature - 273.15);
|
||||
#else
|
||||
temp = (int)stationweather.get_temperature_degc();
|
||||
#endif
|
||||
|
||||
// HACK ALERT - at the moment the new environment subsystem returns bogus temperatures
|
||||
// FIXME - take out this hack when this gets fixed upstream
|
||||
|
@ -162,11 +149,7 @@ void FGATIS::UpdateTransmission() {
|
|||
transmission += " degrees_Celsius";
|
||||
|
||||
// Get the visibility
|
||||
#ifdef FG_WEATHERCM
|
||||
visibility = fgGetDouble("/environment/visibility-m");
|
||||
#else
|
||||
visibility = stationweather.get_visibility_m();
|
||||
#endif
|
||||
sprintf(buf, "%i", int(visibility/1600));
|
||||
transmission += " / Visibility ";
|
||||
tempstr1 = buf;
|
||||
|
@ -198,48 +181,9 @@ void FGATIS::UpdateTransmission() {
|
|||
|
||||
// Get the pressure / altimeter
|
||||
|
||||
#ifndef FG_WEATHERCM
|
||||
double altimeter = stationweather.get_pressure_sea_level_inhg();
|
||||
sprintf(buf, "%.2f", altimeter);
|
||||
transmission += " / Altimeter ";
|
||||
tempstr1 = buf;
|
||||
transmission += ConvertNumToSpokenDigits(tempstr1);
|
||||
#endif
|
||||
|
||||
// Based on the airport-id and wind get the active runway
|
||||
//FGRunway *r;
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
//Set the heading to into the wind
|
||||
double wind_x = stationweather.Wind[0];
|
||||
double wind_y = stationweather.Wind[1];
|
||||
|
||||
double speed = sqrt( wind_x*wind_x + wind_y*wind_y ) * SG_METER_TO_NM / (60.0*60.0);
|
||||
double hdg;
|
||||
|
||||
//If no wind use 270degrees
|
||||
if(speed == 0) {
|
||||
hdg = 270;
|
||||
transmission += " / Winds_light_and_variable";
|
||||
} else {
|
||||
// //normalize the wind to get the direction
|
||||
//wind_x /= speed; wind_y /= speed;
|
||||
|
||||
hdg = - atan2 ( wind_x, wind_y ) * SG_RADIANS_TO_DEGREES ;
|
||||
if (hdg < 0.0)
|
||||
hdg += 360.0;
|
||||
|
||||
//add a description of the wind to the transmission
|
||||
char buf5[10];
|
||||
char buf6[10];
|
||||
sprintf(buf5, "%i", int(speed));
|
||||
sprintf(buf6, "%i", int(hdg));
|
||||
tempstr1 = buf5;
|
||||
tempstr2 = buf6;
|
||||
transmission = transmission + " / Winds " + ConvertNumToSpokenDigits(tempstr1) + " knots from "
|
||||
+ ConvertNumToSpokenDigits(tempstr2) + " degrees";
|
||||
}
|
||||
#else
|
||||
double speed = stationweather.get_wind_speed_kt();
|
||||
double hdg = stationweather.get_wind_from_heading_deg();
|
||||
if (speed == 0) {
|
||||
|
@ -257,7 +201,6 @@ void FGATIS::UpdateTransmission() {
|
|||
transmission = transmission + " / Winds " + ConvertNumToSpokenDigits(tempstr1) + " knots from "
|
||||
+ ConvertNumToSpokenDigits(tempstr2) + " degrees";
|
||||
}
|
||||
#endif
|
||||
|
||||
string rwy_no = globals->get_runways()->search(ident, int(hdg));
|
||||
if(rwy_no != "NN") {
|
||||
|
|
|
@ -45,9 +45,6 @@ HISTORY
|
|||
#include <simgear/constants.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#ifdef FG_WEATHERCM
|
||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||
#endif
|
||||
|
||||
#include "BalloonSim.h"
|
||||
|
||||
|
@ -171,35 +168,10 @@ void balloon::update()
|
|||
/* later, but currently was my main concern to get it going... */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
sgVec3 v;
|
||||
|
||||
FGPhysicalProperty wdbpos = WeatherDatabase->get(position);
|
||||
|
||||
//get the current wind velocity and store it in v
|
||||
//Point3D temp = wdbpos.Wind;
|
||||
//sgSetVec3(v, temp.x(), temp.y(), temp.z());
|
||||
sgCopyVec3(v, wdbpos.Wind );
|
||||
|
||||
sgSubVec3(v, velocity);
|
||||
float speed = sgLengthVec3(v);
|
||||
|
||||
// calculate the density of the gas inside
|
||||
double rho = wdbpos.AirPressure / (287.14 * T);
|
||||
|
||||
// calculate the mass of the air
|
||||
double mAir = rho * balloon_envelope_volume;
|
||||
|
||||
// loss of energy by cooling down:
|
||||
float k = 1.0 / (1.0/4.8 + 1.0/(4.8+3.4*speed) + l_of_the_envelope/lambda);
|
||||
float Q = k * balloon_envelope_area * (dt/3600.0) * (wdbpos.Temperature - T); //(dt/3600.0) = time since last call in hours
|
||||
|
||||
#else
|
||||
// I realy don't think there is a solution for this without WeatherCM
|
||||
// but this is a hack, and it's working -- EMH
|
||||
double mAir = 0;
|
||||
float Q = 0;
|
||||
#endif
|
||||
|
||||
// gain of energy by heating:
|
||||
if (fuel_left > 0.0) //but only with some fuel left ;-)
|
||||
|
@ -228,10 +200,6 @@ void balloon::update()
|
|||
sgVec3 fTotal, fFriction, fLift;
|
||||
|
||||
sgScaleVec3(fTotal, gravity_vector, mTotal);
|
||||
#ifdef FG_WEATHERCM
|
||||
sgScaleVec3(fFriction, v, cw_envelope * wind_facing_area_of_balloon * WeatherDatabase->getAirDensity(position) * speed / 2.0); //wind resistance
|
||||
sgScaleVec3(fLift, gravity_vector, -balloon_envelope_volume * wdbpos.AirPressure / (287.14 * wdbpos.Temperature));
|
||||
#endif
|
||||
|
||||
sgAddVec3(fTotal, fLift);
|
||||
sgAddVec3(fTotal, fFriction);
|
||||
|
|
|
@ -250,9 +250,6 @@ void FGJSBsim::init()
|
|||
// Explicitly call the superclass's
|
||||
// init method first.
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
Atmosphere->UseInternal();
|
||||
#else
|
||||
if (fgGetBool("/environment/params/control-fdm-atmosphere")) {
|
||||
Atmosphere->UseExternal();
|
||||
Atmosphere->SetExTemperature(
|
||||
|
@ -269,7 +266,6 @@ void FGJSBsim::init()
|
|||
} else {
|
||||
Atmosphere->UseInternal();
|
||||
}
|
||||
#endif
|
||||
|
||||
fgic->SetVnorthFpsIC( wind_from_north->getDoubleValue() );
|
||||
fgic->SetVeastFpsIC( wind_from_east->getDoubleValue() );
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
if ENABLE_WEATHERCM
|
||||
WEATHER_LIBS = $(top_builddir)/src/WeatherCM/libWeatherCM.a
|
||||
else
|
||||
WEATHER_LIBS = $(top_builddir)/src/Environment/libEnvironment.a
|
||||
endif
|
||||
|
||||
if ENABLE_MPLAYER_AS
|
||||
MPLAYER_LIBS = $(top_builddir)/src/MultiPlayer/libMultiPlayer.a
|
||||
else
|
||||
|
@ -82,7 +76,7 @@ fgfs_LDADD = \
|
|||
$(top_builddir)/src/Replay/libReplay.a \
|
||||
$(top_builddir)/src/Systems/libSystems.a \
|
||||
$(top_builddir)/src/Time/libTime.a \
|
||||
$(WEATHER_LIBS) \
|
||||
$(top_builddir)/src/Environment/libEnvironment.a \
|
||||
$(CLOUD3D_LIBS) \
|
||||
-lsgroute -lsgsky -lsgsound -lsgephem -lsgmaterial -lsgtgdb -lsgmodel \
|
||||
-lsgtiming -lsgio -lsgscreen -lsgmath -lsgbucket -lsgprops -lsgdebug \
|
||||
|
|
|
@ -119,11 +119,7 @@
|
|||
#include <MultiPlayer/multiplayrxmgr.hxx>
|
||||
#endif
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||
#else
|
||||
# include <Environment/environment_mgr.hxx>
|
||||
#endif
|
||||
#include <Environment/environment_mgr.hxx>
|
||||
|
||||
#include "fg_init.hxx"
|
||||
#include "fg_io.hxx"
|
||||
|
@ -1553,49 +1549,7 @@ bool fgInitSubsystems() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialize the weather modeling subsystem
|
||||
#ifdef FG_WEATHERCM
|
||||
// Initialize the WeatherDatabase
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Creating LocalWeatherDatabase");
|
||||
sgVec3 position;
|
||||
sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
|
||||
current_aircraft.fdm_state->get_Longitude(),
|
||||
current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER );
|
||||
double init_vis = fgGetDouble("/environment/visibility-m");
|
||||
|
||||
FGLocalWeatherDatabase::DatabaseWorkingType working_type;
|
||||
|
||||
if (!strcmp(fgGetString("/environment/weather/working-type"), "internet"))
|
||||
{
|
||||
working_type = FGLocalWeatherDatabase::use_internet;
|
||||
} else {
|
||||
working_type = FGLocalWeatherDatabase::default_mode;
|
||||
}
|
||||
|
||||
if ( init_vis > 0 ) {
|
||||
FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
|
||||
new FGLocalWeatherDatabase( position,
|
||||
globals->get_fg_root(),
|
||||
working_type,
|
||||
init_vis );
|
||||
} else {
|
||||
FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
|
||||
new FGLocalWeatherDatabase( position,
|
||||
globals->get_fg_root(),
|
||||
working_type );
|
||||
}
|
||||
|
||||
// cout << theFGLocalWeatherDatabase << endl;
|
||||
// cout << "visibility = "
|
||||
// << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
|
||||
|
||||
WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
|
||||
|
||||
// register the periodic update of the weather
|
||||
globals->get_event_mgr()->add( "weather update",
|
||||
&fgUpdateWeatherDatabase, 30000);
|
||||
#else
|
||||
globals->add_subsystem("environment", new FGEnvironmentMgr);
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -37,11 +37,7 @@
|
|||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Time/tmp.hxx>
|
||||
#include <FDM/UIUCModel/uiuc_aircraftdir.h>
|
||||
#ifdef FG_WEATHERCM
|
||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||
#else
|
||||
# include <Environment/environment.hxx>
|
||||
#endif // FG_WEATHERCM
|
||||
#include <Environment/environment.hxx>
|
||||
|
||||
#include <GUI/gui.h>
|
||||
|
||||
|
@ -51,12 +47,6 @@
|
|||
SG_USING_STD(istream);
|
||||
SG_USING_STD(ostream);
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
static double getWindNorth ();
|
||||
static double getWindEast ();
|
||||
static double getWindDown ();
|
||||
#endif // FG_WEATHERCM
|
||||
|
||||
static bool winding_ccw = true; // FIXME: temporary
|
||||
|
||||
static bool fdm_data_logging = false; // FIXME: temporary
|
||||
|
@ -383,95 +373,6 @@ getHeadingMag ()
|
|||
return magheading;
|
||||
}
|
||||
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
|
||||
/**
|
||||
* Get the current visibility (meters).
|
||||
*/
|
||||
static double
|
||||
getVisibility ()
|
||||
{
|
||||
return WeatherDatabase->getWeatherVisibility();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current visibility (meters).
|
||||
*/
|
||||
static void
|
||||
setVisibility (double visibility)
|
||||
{
|
||||
WeatherDatabase->setWeatherVisibility(visibility);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current wind north velocity (feet/second).
|
||||
*/
|
||||
static double
|
||||
getWindNorth ()
|
||||
{
|
||||
return current_aircraft.fdm_state->get_V_north_airmass();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current wind north velocity (feet/second).
|
||||
*/
|
||||
static void
|
||||
setWindNorth (double speed)
|
||||
{
|
||||
current_aircraft.fdm_state
|
||||
->set_Velocities_Local_Airmass(speed, getWindEast(), getWindDown());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current wind east velocity (feet/second).
|
||||
*/
|
||||
static double
|
||||
getWindEast ()
|
||||
{
|
||||
return current_aircraft.fdm_state->get_V_east_airmass();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current wind east velocity (feet/second).
|
||||
*/
|
||||
static void
|
||||
setWindEast (double speed)
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_INFO,, "Set wind-east to " << speed );
|
||||
current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
|
||||
speed,
|
||||
getWindDown());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current wind down velocity (feet/second).
|
||||
*/
|
||||
static double
|
||||
getWindDown ()
|
||||
{
|
||||
return current_aircraft.fdm_state->get_V_down_airmass();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current wind down velocity (feet/second).
|
||||
*/
|
||||
static void
|
||||
setWindDown (double speed)
|
||||
{
|
||||
current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
|
||||
getWindEast(),
|
||||
speed);
|
||||
}
|
||||
|
||||
#endif // FG_WEATHERCM
|
||||
|
||||
static long
|
||||
getWarp ()
|
||||
{
|
||||
|
@ -584,18 +485,6 @@ FGProperties::bind ()
|
|||
// Orientation
|
||||
fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
|
||||
|
||||
// Environment
|
||||
#ifdef FG_WEATHERCM
|
||||
fgTie("/environment/visibility-m", getVisibility, setVisibility);
|
||||
fgSetArchivable("/environment/visibility-m");
|
||||
fgTie("/environment/wind-from-north-fps", getWindNorth, setWindNorth);
|
||||
fgSetArchivable("/environment/wind-from-north-fps");
|
||||
fgTie("/environment/wind-from-east-fps", getWindEast, setWindEast);
|
||||
fgSetArchivable("/environment/wind-from-east-fps");
|
||||
fgTie("/environment/wind-from-down-fps", getWindDown, setWindDown);
|
||||
fgSetArchivable("/environment/wind-from-down-fps");
|
||||
#endif
|
||||
|
||||
fgTie("/environment/magnetic-variation-deg", getMagVar);
|
||||
fgTie("/environment/magnetic-dip-deg", getMagDip);
|
||||
|
||||
|
@ -625,13 +514,6 @@ FGProperties::unbind ()
|
|||
fgUntie("/orientation/heading-magnetic-deg");
|
||||
|
||||
// Environment
|
||||
#ifdef FG_WEATHERCM
|
||||
fgUntie("/environment/visibility-m");
|
||||
fgUntie("/environment/wind-from-north-fps");
|
||||
fgUntie("/environment/wind-from-east-fps");
|
||||
fgUntie("/environment/wind-from-down-fps");
|
||||
#endif
|
||||
|
||||
fgUntie("/environment/magnetic-variation-deg");
|
||||
fgUntie("/environment/magnetic-dip-deg");
|
||||
|
||||
|
|
|
@ -119,10 +119,6 @@ glPointParameterfvProc glPointParameterfvPtr = 0;
|
|||
bool glPointParameterIsSupported = false;
|
||||
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
# include <WeatherCM/FGLocalWeatherDatabase.h>
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
# include <console.h> // -dw- for command line dialog
|
||||
#endif
|
||||
|
|
|
@ -98,18 +98,6 @@ fgSetupWind (double min_hdg, double max_hdg, double speed, double gust)
|
|||
min_hdg);
|
||||
fgSetDouble("/environment/config/aloft/entry[2]/wind-speed-kt",
|
||||
speed);
|
||||
|
||||
#ifdef FG_WEATHERCM
|
||||
// convert to fps
|
||||
speed *= SG_NM_TO_METER * SG_METER_TO_FEET * (1.0/3600);
|
||||
while (min_hdg > 360)
|
||||
min_hdg -= 360;
|
||||
while (min_hdg <= 0)
|
||||
min_hdg += 360;
|
||||
min_hdg *= SGD_DEGREES_TO_RADIANS;
|
||||
fgSetDouble("/environment/wind-from-north-fps", speed * cos(dir));
|
||||
fgSetDouble("/environment/wind-from-east-fps", speed * sin(dir));
|
||||
#endif // FG_WEATHERCM
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
if ENABLE_WEATHERCM
|
||||
WEATHER_DIR = WeatherCM
|
||||
else
|
||||
WEATHER_DIR = Environment
|
||||
endif
|
||||
|
||||
if ENABLE_MPLAYER_AS
|
||||
MPLAYER_DIRS = MultiPlayer
|
||||
else
|
||||
|
@ -18,6 +12,7 @@ SUBDIRS = \
|
|||
Autopilot \
|
||||
Cockpit \
|
||||
Controls \
|
||||
Environment \
|
||||
FDM \
|
||||
GUI \
|
||||
Input \
|
||||
|
@ -34,5 +29,4 @@ SUBDIRS = \
|
|||
Sound \
|
||||
Systems \
|
||||
Time \
|
||||
$(WEATHER_DIR) \
|
||||
Main
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
|
@ -1,49 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGAirPressureItem.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
Called by: FGMicroWeather
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGAirPressureItem.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
|
@ -1,130 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGAirPressureItem.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
15.12.1999 Christian Mayer changed the air pressure calculation to a much
|
||||
more realistic formula. But as I need for that
|
||||
the temperature I moved the code to
|
||||
FGPhysicalProperties
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGAirPressureItem_H
|
||||
#define FGAirPressureItem_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include <math.h>
|
||||
|
||||
#include "FGWeatherDefs.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 in FGPhyiscalProperties as I need to know the */
|
||||
/* temperatures at the different altitudes for that. */
|
||||
/****************************************************************************/
|
||||
class FGAirPressureItem
|
||||
{
|
||||
private:
|
||||
WeatherPrecision value; //that's the airpressure at 0 metres
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
||||
FGAirPressureItem(const WeatherPrecision v) {value = v; }
|
||||
FGAirPressureItem() {value = FG_WEATHER_DEFAULT_AIRPRESSURE;}
|
||||
|
||||
WeatherPrecision getValue() const
|
||||
{
|
||||
return value;
|
||||
};
|
||||
|
||||
void setValue(WeatherPrecision p)
|
||||
{
|
||||
value = p;
|
||||
};
|
||||
|
||||
FGAirPressureItem& operator*=(const WeatherPrecision arg);
|
||||
FGAirPressureItem& operator+=(const FGAirPressureItem& arg);
|
||||
FGAirPressureItem& operator-=(const FGAirPressureItem& arg);
|
||||
|
||||
friend FGAirPressureItem operator-(const FGAirPressureItem& arg);
|
||||
};
|
||||
|
||||
inline FGAirPressureItem& FGAirPressureItem::operator*= (const WeatherPrecision 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*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGCloud.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGCloud_H
|
||||
#define FGCloud_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGWeatherFeature.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGCloud:FGWeatherFeature
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
public:
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGCloud_H*/
|
|
@ -1,51 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGCloudItem.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
Called by: FGMicroWeather
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
09.10.1999 Christian Mayer changed CloudItem on Durks request
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGCloudItem.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGCloudItem.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
------------------------------------------------------------------------------
|
||||
Cloud 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
|
||||
09.10.1999 Christian Mayer changed CloudItem on Durks request
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGCloudItem_H
|
||||
#define FGCloudItem_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGWeatherDefs.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGCloudItem
|
||||
{
|
||||
private:
|
||||
WeatherPrecision thickness;
|
||||
WeatherPrecision density;
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
||||
FGCloudItem(const WeatherPrecision t, const WeatherPrecision d) {thickness = t; density = d;}
|
||||
FGCloudItem() {thickness = 0.0; density = 0.0;}
|
||||
|
||||
WeatherPrecision getThickness(void) const { return thickness; }
|
||||
WeatherPrecision getDensity (void) const { return density; }
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGCloudItem_H*/
|
|
@ -1,446 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGLocalWeatherDatabase.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
Called by: main program
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
14.12.1999 Christian Mayer Changed the internal structure to use Dave
|
||||
Eberly's spherical interpolation code. This
|
||||
stops our dependancy on the (ugly) voronoi
|
||||
code and simplyfies the code structure a lot.
|
||||
07.05.2000 Tony Peden Added functionality to get the weather data
|
||||
on 'the bus'
|
||||
18.05.2000 Christian Mayer Minor clean-ups. Changed the code to use
|
||||
FGWeatherUtils.h for unit conversion
|
||||
18.07.2001 Christian Mayer Added the posibility to limit the amount of
|
||||
stations for a faster init.
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include <Aircraft/aircraft.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
|
||||
#include "FGLocalWeatherDatabase.h"
|
||||
|
||||
#include "FGWeatherParse.h"
|
||||
|
||||
#include "FGWeatherUtils.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
FGLocalWeatherDatabase* FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 0;
|
||||
FGLocalWeatherDatabase *WeatherDatabase;
|
||||
|
||||
void FGLocalWeatherDatabase::init( const WeatherPrecision visibility,
|
||||
const DatabaseWorkingType type,
|
||||
const string &root )
|
||||
{
|
||||
cerr << "Initializing FGLocalWeatherDatabase\n";
|
||||
cerr << "-----------------------------------\n";
|
||||
|
||||
if (theFGLocalWeatherDatabase)
|
||||
{
|
||||
cerr << "Error: only one local weather allowed";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
setWeatherVisibility(visibility);
|
||||
|
||||
DatabaseStatus = type;
|
||||
database_logic = 0; //just get sure...
|
||||
|
||||
Thunderstorm = false;
|
||||
//I don't need to set theThunderstorm as Thunderstorm == false
|
||||
|
||||
switch(DatabaseStatus)
|
||||
{
|
||||
case use_global:
|
||||
{
|
||||
cerr << "Error: there's no global database anymore!\n";
|
||||
exit(-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case use_internet:
|
||||
{
|
||||
FGWeatherParse *parsed_data = new FGWeatherParse();
|
||||
sgVec2 *p;
|
||||
unsigned int *f;
|
||||
string path_to_weather = root + "/weather/current.txt.gz";
|
||||
parsed_data->input( path_to_weather.c_str() );
|
||||
unsigned int n = parsed_data->stored_stations();
|
||||
int m = fgGetInt("/environment/weather/max-stations", -1);
|
||||
|
||||
if ( ( m < 0 ) || ( m > n ) )
|
||||
{
|
||||
m = n;
|
||||
|
||||
p = new sgVec2[n];
|
||||
f = new unsigned int[n];
|
||||
|
||||
// fill the database
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
{
|
||||
f[i] = i;
|
||||
database_data[i] = parsed_data->getFGPhysicalProperties(i);
|
||||
parsed_data->getPosition(i, p[i]);
|
||||
|
||||
if ( (i%100) == 0)
|
||||
cerr << ".";
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // we have to limit the amount of stations
|
||||
|
||||
//store the "distance" between the station and the current
|
||||
//position. As the distance is calculated from the lat/lon
|
||||
//values it's not worth much - but it's good enough for
|
||||
//comparison
|
||||
map<float, unsigned int> squared_distance;
|
||||
sgVec2 cur_pos;
|
||||
|
||||
cur_pos[0] = cache->last_known_position[0];
|
||||
cur_pos[1] = cache->last_known_position[1];
|
||||
|
||||
unsigned int i;
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
sgVec2 pos;
|
||||
parsed_data->getPosition(i, pos);
|
||||
squared_distance[sgDistanceSquaredVec2(cur_pos, pos)] = i;
|
||||
}
|
||||
|
||||
p = new sgVec2 [m];
|
||||
f = new unsigned int[m];
|
||||
|
||||
map<float, unsigned int>::const_iterator ci;
|
||||
ci = squared_distance.begin();
|
||||
|
||||
// fill the database
|
||||
for ( i = 0; i < m; i++ )
|
||||
{
|
||||
f[i] = i;
|
||||
database_data.push_back( parsed_data->getFGPhysicalProperties(ci->second) );
|
||||
parsed_data->getPosition(ci->second, p[i]);
|
||||
|
||||
if ( (i%100) == 0)
|
||||
cerr << ".";
|
||||
|
||||
ci++;
|
||||
}
|
||||
}
|
||||
|
||||
// free the memory of the parsed data to ease the required memory
|
||||
// for the very memory consuming spherical interpolation
|
||||
delete parsed_data;
|
||||
|
||||
//and finally init the interpolation
|
||||
cerr << "\nInitialiating Interpolation. (2-3 minutes on a PII-350 for ca. 3500 stations)\n";
|
||||
database_logic = new SphereInterpolate(m, p, f);
|
||||
|
||||
//and free my allocations:
|
||||
delete[] p;
|
||||
delete[] f;
|
||||
cerr << "Finished weather init.\n";
|
||||
|
||||
}
|
||||
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:
|
||||
{
|
||||
double x[2] = {0.0, 0.0}; //make an standard weather that's the same at the whole world
|
||||
double y[2] = {0.0, 0.0}; //make an standard weather that's the same at the whole world
|
||||
double z[2] = {1.0, -1.0}; //make an standard weather that's the same at the whole world
|
||||
unsigned int f[2] = {0, 0};
|
||||
database_data.push_back( FGPhysicalProperties() ); // == database_date[0]
|
||||
database_logic = new SphereInterpolate(2,x,y,z,f);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "FGLocalWeatherDatabase error: Unknown database type specified!\n";
|
||||
};
|
||||
|
||||
cache->latitude_deg = fgGetNode("/position/latitude-deg" );
|
||||
cache->longitude_deg = fgGetNode("/position/longitude-deg");
|
||||
cache->altitude_ft = fgGetNode("/position/altitude-ft" );
|
||||
|
||||
}
|
||||
|
||||
void FGLocalWeatherDatabase::bind()
|
||||
{
|
||||
fgTie("/environment/weather/wind-north-mps", this, &FGLocalWeatherDatabase::get_wind_north);
|
||||
fgTie("/environment/weather/wind-east-mps", this, &FGLocalWeatherDatabase::get_wind_east);
|
||||
fgTie("/environment/weather/wind-up-mps", this, &FGLocalWeatherDatabase::get_wind_up);
|
||||
fgTie("/environment/weather/temperature-K", this, &FGLocalWeatherDatabase::get_temperature);
|
||||
fgTie("/environment/weather/air-pressure-Pa", this, &FGLocalWeatherDatabase::get_air_pressure);
|
||||
fgTie("/environment/weather/vapor-pressure-Pa", this, &FGLocalWeatherDatabase::get_vapor_pressure);
|
||||
fgTie("/environment/weather/air-density", this, &FGLocalWeatherDatabase::get_air_density);
|
||||
|
||||
|
||||
SGPropertyNode * station_nodes = fgGetNode("/environment/weather");
|
||||
if (station_nodes == 0) {
|
||||
cerr << "No weatherstations (/environment/weather)!!";
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for(vector<FGPhysicalProperties>::iterator it = database_data.begin(); it != database_data.end(); it++)
|
||||
{
|
||||
SGPropertyNode * station = station_nodes->getNode("station", index, true);
|
||||
|
||||
station -> tie("air-pressure-Pa",
|
||||
SGRawValueMethods<FGAirPressureItem,WeatherPrecision>(
|
||||
database_data[0].AirPressure,
|
||||
&FGAirPressureItem::getValue,
|
||||
&FGAirPressureItem::setValue)
|
||||
,false);
|
||||
|
||||
int i;
|
||||
for( i = 0; i < database_data[index].Wind.size(); i++)
|
||||
{
|
||||
SGPropertyNode * wind = station->getNode("wind", i, true);
|
||||
wind -> tie("north-mps",
|
||||
SGRawValueMethodsIndexed<FGPhysicalProperties,WeatherPrecision>(
|
||||
database_data[index], i,
|
||||
&FGPhysicalProperties::getWind_x,
|
||||
&FGPhysicalProperties::setWind_x)
|
||||
,false);
|
||||
wind -> tie("east-mps",
|
||||
SGRawValueMethodsIndexed<FGPhysicalProperties,WeatherPrecision>(
|
||||
database_data[index], i,
|
||||
&FGPhysicalProperties::getWind_y,
|
||||
&FGPhysicalProperties::setWind_y)
|
||||
,false);
|
||||
wind -> tie("up-mps",
|
||||
SGRawValueMethodsIndexed<FGPhysicalProperties,WeatherPrecision>(
|
||||
database_data[index], i,
|
||||
&FGPhysicalProperties::getWind_z,
|
||||
&FGPhysicalProperties::setWind_z)
|
||||
,false);
|
||||
wind -> tie("altitude-m",
|
||||
SGRawValueMethodsIndexed<FGPhysicalProperties,WeatherPrecision>(
|
||||
database_data[index], i,
|
||||
&FGPhysicalProperties::getWind_a,
|
||||
&FGPhysicalProperties::setWind_a)
|
||||
,false);
|
||||
}
|
||||
|
||||
for( i = 0; i < database_data[index].Temperature.size(); i++)
|
||||
{
|
||||
SGPropertyNode * temperature = station->getNode("temperature", i, true);
|
||||
temperature -> tie("value-K",
|
||||
SGRawValueMethodsIndexed<FGPhysicalProperties,WeatherPrecision>(
|
||||
database_data[index], i,
|
||||
&FGPhysicalProperties::getTemperature_x,
|
||||
&FGPhysicalProperties::setTemperature_x)
|
||||
,false);
|
||||
temperature -> tie("altitude-m",
|
||||
SGRawValueMethodsIndexed<FGPhysicalProperties,WeatherPrecision>(
|
||||
database_data[index], i,
|
||||
&FGPhysicalProperties::getTemperature_a,
|
||||
&FGPhysicalProperties::setTemperature_a)
|
||||
,false);
|
||||
}
|
||||
|
||||
for( i = 0; i < database_data[index].VaporPressure.size(); i++)
|
||||
{
|
||||
SGPropertyNode * vaporpressure = station->getNode("vapor-pressure", i, true);
|
||||
vaporpressure -> tie("value-Pa",
|
||||
SGRawValueMethodsIndexed<FGPhysicalProperties,WeatherPrecision>(
|
||||
database_data[index], i,
|
||||
&FGPhysicalProperties::getVaporPressure_x,
|
||||
&FGPhysicalProperties::setVaporPressure_x)
|
||||
,false);
|
||||
vaporpressure -> tie("altitude-m",
|
||||
SGRawValueMethodsIndexed<FGPhysicalProperties,WeatherPrecision>(
|
||||
database_data[index], i,
|
||||
&FGPhysicalProperties::getVaporPressure_a,
|
||||
&FGPhysicalProperties::setVaporPressure_a)
|
||||
,false);
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
void FGLocalWeatherDatabase::unbind()
|
||||
{
|
||||
fgUntie("/environment/weather/wind-north-mps");
|
||||
fgUntie("/environment/weather/wind-east-mps");
|
||||
fgUntie("/environment/weather/wind-up-mps");
|
||||
fgUntie("/environment/weather/temperature-K");
|
||||
fgUntie("/environment/weather/air-pressure-Pa");
|
||||
fgUntie("/environment/weather/vapor-pressure-Pa");
|
||||
fgUntie("/environment/weather/air-density");
|
||||
}
|
||||
|
||||
FGLocalWeatherDatabase::~FGLocalWeatherDatabase()
|
||||
{
|
||||
//Tidying up:
|
||||
delete database_logic;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* reset the whole database */
|
||||
/****************************************************************************/
|
||||
void FGLocalWeatherDatabase::reset(const DatabaseWorkingType type)
|
||||
{
|
||||
cerr << "FGLocalWeatherDatabase::reset isn't supported yet\n";
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* update the database. Since the last call we had dt seconds */
|
||||
/****************************************************************************/
|
||||
void FGLocalWeatherDatabase::update(const WeatherPrecision dt)
|
||||
{
|
||||
//if (DatabaseStatus==use_global)
|
||||
// global->update(dt);
|
||||
}
|
||||
|
||||
void FGLocalWeatherDatabase::update(const sgVec3& p) //position has changed
|
||||
{
|
||||
//uncomment this when you are using the GlobalDatabase
|
||||
/*
|
||||
cerr << "****\nupdate(p) inside\n";
|
||||
cerr << "Parameter: " << p[0] << "/" << p[1] << "/" << p[2] << "\n";
|
||||
cerr << FGPhysicalProperties2D(get(p2d), p2d);
|
||||
cerr << "****\n";
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void FGLocalWeatherDatabase::update(const sgVec3& p, const WeatherPrecision dt) //time and/or position has changed
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Get the physical properties on the specified point p out of the database */
|
||||
/****************************************************************************/
|
||||
FGPhysicalProperty FGLocalWeatherDatabase::get(const sgVec3& p) const
|
||||
{
|
||||
// check for bogous altitudes. Dunno why, but FGFS want's to know the
|
||||
// weather at an altitude of roughly -3000 meters...
|
||||
if (p[2] < -500.0f)
|
||||
return FGPhysicalProperty(DatabaseEvaluate(p), -500.0f);
|
||||
|
||||
return FGPhysicalProperty(DatabaseEvaluate(p), p[2]);
|
||||
}
|
||||
|
||||
#ifdef macintosh
|
||||
/* fix a problem with mw compilers in that they don't know the
|
||||
difference between the next two methods. Since the first one
|
||||
doesn't seem to be used anywhere, I commented it out. This is
|
||||
supposed to be fixed in the forthcoming CodeWarrior Release
|
||||
6. */
|
||||
#else
|
||||
FGPhysicalProperties FGLocalWeatherDatabase::get(const sgVec2& p) const
|
||||
{
|
||||
return DatabaseEvaluate(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
WeatherPrecision FGLocalWeatherDatabase::getAirDensity(const sgVec3& p) const
|
||||
{
|
||||
FGPhysicalProperty dummy(DatabaseEvaluate(p), p[2]);
|
||||
|
||||
return
|
||||
(dummy.AirPressure*FG_WEATHER_DEFAULT_AIRDENSITY*FG_WEATHER_DEFAULT_TEMPERATURE) /
|
||||
(dummy.Temperature*FG_WEATHER_DEFAULT_AIRPRESSURE);
|
||||
}
|
||||
|
||||
|
||||
void FGLocalWeatherDatabase::setSnowRainIntensity(const WeatherPrecision x, const sgVec2& p)
|
||||
{
|
||||
/* not supported yet */
|
||||
}
|
||||
|
||||
void FGLocalWeatherDatabase::setSnowRainType(const SnowRainType x, const sgVec2& p)
|
||||
{
|
||||
/* not supported yet */
|
||||
}
|
||||
|
||||
void FGLocalWeatherDatabase::setLightningProbability(const WeatherPrecision x, const sgVec2& p)
|
||||
{
|
||||
/* not supported yet */
|
||||
}
|
||||
|
||||
void FGLocalWeatherDatabase::setProperties(const FGPhysicalProperties2D& x)
|
||||
{
|
||||
/* not supported yet */
|
||||
}
|
||||
|
||||
void fgUpdateWeatherDatabase(void)
|
||||
{
|
||||
sgVec3 position;
|
||||
|
||||
sgSetVec3(position,
|
||||
current_aircraft.fdm_state->get_Latitude(),
|
||||
current_aircraft.fdm_state->get_Longitude(),
|
||||
current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER);
|
||||
|
||||
WeatherDatabase->update( position );
|
||||
|
||||
// get the data on 'the bus' for the FDM
|
||||
|
||||
/* FGPhysicalProperty porperty = WeatherDatabase->get(position);
|
||||
|
||||
current_aircraft.fdm_state->set_Static_temperature( Kelvin2Rankine(porperty.Temperature) );
|
||||
current_aircraft.fdm_state->set_Static_pressure( Pascal2psf(porperty.AirPressure) );
|
||||
|
||||
current_aircraft.fdm_state->set_Density( SIdensity2JSBsim( Density(porperty.AirPressure, porperty.Temperature) ) );
|
||||
|
||||
#define MSTOFPS 3.2808 //m/s to ft/s
|
||||
current_aircraft.fdm_state->set_Velocities_Local_Airmass(porperty.Wind[1]*MSTOFPS,
|
||||
porperty.Wind[0]*MSTOFPS,
|
||||
porperty.Wind[2]*MSTOFPS); */
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,357 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGLocalWeatherDatabase.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
14.12.1999 Christian Mayer Changed the internal structure to use Dave
|
||||
Eberly's spherical interpolation code. This
|
||||
stops our dependancy on the (ugly) voronoi
|
||||
code and simplyfies the code structure a lot.
|
||||
18.07.2001 Christian Mayer Added the posibility to limit the amount of
|
||||
stations for a faster init.
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGLocalWeatherDatabase_H
|
||||
#define FGLocalWeatherDatabase_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include <vector>
|
||||
#include STL_STRING
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include "sphrintp.h"
|
||||
|
||||
#include "FGPhysicalProperties.h"
|
||||
#include "FGPhysicalProperty.h"
|
||||
|
||||
#include "FGWeatherFeature.h"
|
||||
#include "FGWeatherDefs.h"
|
||||
#include "FGThunderstorm.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_STD(string);
|
||||
SG_USING_NAMESPACE(std);
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
struct _FGLocalWeatherDatabaseCache
|
||||
{
|
||||
sgVec3 last_known_position;
|
||||
//sgVec3 current_position;
|
||||
SGPropertyNode *latitude_deg;
|
||||
SGPropertyNode *longitude_deg;
|
||||
SGPropertyNode *altitude_ft;
|
||||
FGPhysicalProperty last_known_property;
|
||||
};
|
||||
|
||||
class FGLocalWeatherDatabase : public FGSubsystem
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
SphereInterpolate *database_logic;
|
||||
vector<FGPhysicalProperties> database_data;
|
||||
#ifndef macintosh
|
||||
FGPhysicalProperties DatabaseEvaluate(const sgVec2& p) const
|
||||
{
|
||||
sgVec2 p_converted = {p[0]*(SGD_2PI/360.0),
|
||||
p[1]*(SGD_2PI/360.0)};
|
||||
EvaluateData d = database_logic->Evaluate(p_converted);
|
||||
return database_data[d.index[0]]*d.percentage[0] +
|
||||
database_data[d.index[1]]*d.percentage[1] +
|
||||
database_data[d.index[2]]*d.percentage[2] ;
|
||||
}
|
||||
#endif
|
||||
FGPhysicalProperties DatabaseEvaluate(const sgVec3& p) const
|
||||
{
|
||||
sgVec3 p_converted = {p[0]*(SGD_2PI/360.0),
|
||||
p[1]*(SGD_2PI/360.0),
|
||||
p[2] };
|
||||
EvaluateData d = database_logic->Evaluate(p_converted);
|
||||
return database_data[d.index[0]]*d.percentage[0] +
|
||||
database_data[d.index[1]]*d.percentage[1] +
|
||||
database_data[d.index[2]]*d.percentage[2] ;
|
||||
}
|
||||
|
||||
typedef vector<sgVec2> pointVector;
|
||||
typedef vector<pointVector> tileVector;
|
||||
|
||||
/************************************************************************/
|
||||
/* make tiles out of points on a 2D plane */
|
||||
/************************************************************************/
|
||||
WeatherPrecision WeatherVisibility; //how far do I need to simulate the
|
||||
//local weather? Unit: metres
|
||||
|
||||
_FGLocalWeatherDatabaseCache *cache;
|
||||
inline void check_cache_for_update(void) const;
|
||||
|
||||
bool Thunderstorm; //is there a thunderstorm near by?
|
||||
FGThunderstorm *theThunderstorm; //pointer to the thunderstorm.
|
||||
|
||||
public:
|
||||
/************************************************************************/
|
||||
/* for tieing them to the property system */
|
||||
/************************************************************************/
|
||||
inline WeatherPrecision get_wind_north() const;
|
||||
inline WeatherPrecision get_wind_east() const;
|
||||
inline WeatherPrecision get_wind_up() const;
|
||||
inline WeatherPrecision get_temperature() const;
|
||||
inline WeatherPrecision get_air_pressure() const;
|
||||
inline WeatherPrecision get_vapor_pressure() const;
|
||||
inline WeatherPrecision get_air_density() const;
|
||||
|
||||
static FGLocalWeatherDatabase *theFGLocalWeatherDatabase;
|
||||
|
||||
enum DatabaseWorkingType {
|
||||
use_global, //use global database for data !!obsolete!!
|
||||
use_internet, //use the weather data that came from the internet
|
||||
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
|
||||
};
|
||||
|
||||
DatabaseWorkingType DatabaseStatus;
|
||||
|
||||
void init( const WeatherPrecision visibility,
|
||||
const DatabaseWorkingType type,
|
||||
const string &root );
|
||||
|
||||
/************************************************************************/
|
||||
/* Constructor and Destructor */
|
||||
/************************************************************************/
|
||||
FGLocalWeatherDatabase(
|
||||
const sgVec3& position,
|
||||
const string& root,
|
||||
const DatabaseWorkingType type = PREFERED_WORKING_TYPE,
|
||||
const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILITY)
|
||||
{
|
||||
cache = new _FGLocalWeatherDatabaseCache;
|
||||
sgCopyVec3( cache->last_known_position, position );
|
||||
|
||||
init( visibility, type, root );
|
||||
|
||||
theFGLocalWeatherDatabase = this;
|
||||
}
|
||||
|
||||
FGLocalWeatherDatabase(
|
||||
const WeatherPrecision position_lat,
|
||||
const WeatherPrecision position_lon,
|
||||
const WeatherPrecision position_alt,
|
||||
const string& root,
|
||||
const DatabaseWorkingType type = PREFERED_WORKING_TYPE,
|
||||
const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILITY)
|
||||
{
|
||||
cache = new _FGLocalWeatherDatabaseCache;
|
||||
sgSetVec3( cache->last_known_position, position_lat, position_lon, position_alt );
|
||||
|
||||
init( visibility, type, root );
|
||||
|
||||
theFGLocalWeatherDatabase = this;
|
||||
}
|
||||
|
||||
~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 WeatherPrecision dt); //time has changed
|
||||
void update(const sgVec3& p); //position has changed
|
||||
void update(const sgVec3& p, const WeatherPrecision dt); //time and/or position has changed
|
||||
|
||||
/************************************************************************/
|
||||
/* define methods requited for FGSubsystem */
|
||||
/************************************************************************/
|
||||
virtual void init () { /* do nothing; that's done in the constructor */ };
|
||||
virtual void bind ();
|
||||
virtual void unbind ();
|
||||
virtual void update (int dt) { update((float) dt); };
|
||||
|
||||
/************************************************************************/
|
||||
/* Get the physical properties on the specified point p */
|
||||
/************************************************************************/
|
||||
#ifdef macintosh
|
||||
/* fix a problem with mw compilers in that they don't know the
|
||||
difference between the next two methods. Since the first one
|
||||
doesn't seem to be used anywhere, I commented it out. This is
|
||||
supposed to be fixed in the forthcoming CodeWarrior Release
|
||||
6. */
|
||||
#else
|
||||
FGPhysicalProperties get(const sgVec2& p) const;
|
||||
#endif
|
||||
FGPhysicalProperty get(const sgVec3& p) const;
|
||||
|
||||
WeatherPrecision getAirDensity(const sgVec3& p) const;
|
||||
|
||||
/************************************************************************/
|
||||
/* Add a weather feature at the point p and surrounding area */
|
||||
/************************************************************************/
|
||||
// !! Adds aren't supported anymore !!
|
||||
|
||||
void setSnowRainIntensity (const WeatherPrecision x, const sgVec2& p);
|
||||
void setSnowRainType (const SnowRainType x, const sgVec2& p);
|
||||
void setLightningProbability(const WeatherPrecision x, const sgVec2& p);
|
||||
|
||||
void setProperties(const FGPhysicalProperties2D& x); //change a property
|
||||
|
||||
/************************************************************************/
|
||||
/* get/set weather visibility */
|
||||
/************************************************************************/
|
||||
void setWeatherVisibility(const WeatherPrecision visibility);
|
||||
WeatherPrecision getWeatherVisibility(void) const;
|
||||
|
||||
/************************************************************************/
|
||||
/* figure out if there's a thunderstorm that has to be taken care of */
|
||||
/************************************************************************/
|
||||
void updateThunderstorm(const float dt)
|
||||
{
|
||||
if (Thunderstorm == false)
|
||||
return;
|
||||
|
||||
theThunderstorm->update( dt );
|
||||
}
|
||||
};
|
||||
|
||||
extern FGLocalWeatherDatabase *WeatherDatabase;
|
||||
void fgUpdateWeatherDatabase(void);
|
||||
|
||||
/****************************************************************************/
|
||||
/* get/set weather visibility */
|
||||
/****************************************************************************/
|
||||
void inline FGLocalWeatherDatabase::setWeatherVisibility(const WeatherPrecision visibility)
|
||||
{
|
||||
if (visibility >= MINIMUM_WEATHER_VISIBILITY)
|
||||
WeatherVisibility = visibility;
|
||||
else
|
||||
WeatherVisibility = MINIMUM_WEATHER_VISIBILITY;
|
||||
}
|
||||
|
||||
WeatherPrecision inline FGLocalWeatherDatabase::getWeatherVisibility(void) const
|
||||
{
|
||||
return WeatherVisibility;
|
||||
}
|
||||
|
||||
inline void FGLocalWeatherDatabase::check_cache_for_update(void) const
|
||||
{
|
||||
if ( ( cache->last_known_position[0] == cache->latitude_deg->getFloatValue() ) &&
|
||||
( cache->last_known_position[1] == cache->longitude_deg->getFloatValue() ) &&
|
||||
( cache->last_known_position[2] == cache->altitude_ft->getFloatValue() * SG_FEET_TO_METER ) )
|
||||
return; //nothing to do
|
||||
|
||||
sgVec3 position = { cache->latitude_deg->getFloatValue(),
|
||||
cache->longitude_deg->getFloatValue(),
|
||||
cache->altitude_ft->getFloatValue() * SG_FEET_TO_METER };
|
||||
|
||||
sgCopyVec3(cache->last_known_position, position);
|
||||
cache->last_known_property = get(position);
|
||||
}
|
||||
|
||||
inline WeatherPrecision FGLocalWeatherDatabase::get_wind_north() const
|
||||
{
|
||||
check_cache_for_update();
|
||||
|
||||
return cache->last_known_property.Wind[0];
|
||||
}
|
||||
|
||||
inline WeatherPrecision FGLocalWeatherDatabase::get_wind_east() const
|
||||
{
|
||||
check_cache_for_update();
|
||||
|
||||
return cache->last_known_property.Wind[1];
|
||||
}
|
||||
|
||||
inline WeatherPrecision FGLocalWeatherDatabase::get_wind_up() const
|
||||
{
|
||||
check_cache_for_update();
|
||||
|
||||
return cache->last_known_property.Wind[2];
|
||||
}
|
||||
|
||||
inline WeatherPrecision FGLocalWeatherDatabase::get_temperature() const
|
||||
{
|
||||
check_cache_for_update();
|
||||
|
||||
return cache->last_known_property.Temperature;
|
||||
}
|
||||
|
||||
inline WeatherPrecision FGLocalWeatherDatabase::get_air_pressure() const
|
||||
{
|
||||
check_cache_for_update();
|
||||
|
||||
return cache->last_known_property.AirPressure;
|
||||
}
|
||||
|
||||
inline WeatherPrecision FGLocalWeatherDatabase::get_vapor_pressure() const
|
||||
{
|
||||
check_cache_for_update();
|
||||
|
||||
return cache->last_known_property.VaporPressure;
|
||||
}
|
||||
|
||||
inline WeatherPrecision FGLocalWeatherDatabase::get_air_density() const
|
||||
{
|
||||
// check_for_update();
|
||||
// not required, as the called functions will do that
|
||||
|
||||
return (get_air_pressure()*FG_WEATHER_DEFAULT_AIRDENSITY*FG_WEATHER_DEFAULT_TEMPERATURE) /
|
||||
(get_temperature()*FG_WEATHER_DEFAULT_AIRPRESSURE);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGLocalWeatherDatabase_H*/
|
|
@ -1,322 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGPhysicalProperties.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
Called by: main program
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGPhysicalProperties.h"
|
||||
#include "FGWeatherDefs.h"
|
||||
|
||||
#include "FGWeatherUtils.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
FGPhysicalProperties::FGPhysicalProperties()
|
||||
{
|
||||
sgVec3 zero;
|
||||
sgZeroVec3( zero );
|
||||
/************************************************************************/
|
||||
/* This standart constructor fills the class with a standard weather */
|
||||
/************************************************************************/
|
||||
|
||||
Wind[-1000.0] = FGWindItem(zero); //no Wind by default
|
||||
Wind[10000.0] = FGWindItem(zero); //no Wind by default
|
||||
|
||||
Turbulence[-1000.0] = FGTurbulenceItem(zero); //no Turbulence by default
|
||||
Turbulence[10000.0] = FGTurbulenceItem(zero); //no Turbulence by default
|
||||
|
||||
//Initialice with the CINA atmosphere
|
||||
Temperature[ 0.0] = +15.0 + 273.16;
|
||||
Temperature[11000.0] = -56.5 + 273.16;
|
||||
Temperature[20000.0] = -56.5 + 273.16;
|
||||
|
||||
AirPressure = FGAirPressureItem(101325.0);
|
||||
|
||||
VaporPressure[-1000.0] = FG_WEATHER_DEFAULT_VAPORPRESSURE; //in Pa (I *only* accept SI!)
|
||||
VaporPressure[10000.0] = FG_WEATHER_DEFAULT_VAPORPRESSURE; //in Pa (I *only* accept SI!)
|
||||
|
||||
//Clouds.insert(FGCloudItem()) => none
|
||||
SnowRainIntensity = 0.0;
|
||||
snowRainType = Rain;
|
||||
LightningProbability = 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
The Methods:
|
||||
|
||||
WeatherPrecision getWind_x( int number ) const;
|
||||
WeatherPrecision getWind_y( int number ) const;
|
||||
WeatherPrecision getWind_z( int number ) const;
|
||||
WeatherPrecision getWind_a( int number ) const;
|
||||
void setWind_x( int number, WeatherPrecision x);
|
||||
void setWind_y( int number, WeatherPrecision y);
|
||||
void setWind_z( int number, WeatherPrecision z);
|
||||
void setWind_a( int number, WeatherPrecision a);
|
||||
WeatherPrecision getTurbulence_x( int number ) const;
|
||||
WeatherPrecision getTurbulence_y( int number ) const;
|
||||
WeatherPrecision getTurbulence_z( int number ) const;
|
||||
WeatherPrecision getTurbulence_a( int number ) const;
|
||||
void setTurbulence_x( int number, WeatherPrecision x);
|
||||
void setTurbulence_y( int number, WeatherPrecision y);
|
||||
void setTurbulence_z( int number, WeatherPrecision z);
|
||||
void setTurbulence_a( int number, WeatherPrecision a);
|
||||
WeatherPrecision getTemperature_x( int number ) const;
|
||||
WeatherPrecision getTemperature_a( int number ) const;
|
||||
void setTemperature_x( int number, WeatherPrecision x);
|
||||
void setTemperature_a( int number, WeatherPrecision a);
|
||||
WeatherPrecision getVaporPressure_x( int number ) const;
|
||||
WeatherPrecision getVaporPressure_a( int number ) const;
|
||||
void setVaporPressure_x( int number, WeatherPrecision x);
|
||||
void setVaporPressure_a( int number, WeatherPrecision a);
|
||||
|
||||
are in the extra file FGPhysicalProperties_bind.cpp
|
||||
*/
|
||||
|
||||
unsigned int FGPhysicalProperties::getNumberOfCloudLayers(void) const
|
||||
{
|
||||
return Clouds.size();
|
||||
}
|
||||
|
||||
FGCloudItem FGPhysicalProperties::getCloudLayer(unsigned int nr) const
|
||||
{
|
||||
map<WeatherPrecision,FGCloudItem>::const_iterator CloudsIt = Clouds.begin();
|
||||
|
||||
//set the iterator to the 'nr'th entry
|
||||
for (; nr > 0; nr--)
|
||||
CloudsIt++;
|
||||
|
||||
return CloudsIt->second;
|
||||
}
|
||||
|
||||
ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p )
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, FGWindItem >::const_iterator wind_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||
|
||||
out << "Position: (" << p.p[0] << ", " << p.p[1] << ", " << p.p[2] << ")\n";
|
||||
|
||||
out << "Stored Wind: ";
|
||||
for (wind_iterator WindIt = p.Wind.begin();
|
||||
WindIt != p.Wind.end();
|
||||
WindIt++)
|
||||
out << "(" << WindIt->second.x() << ", " << WindIt->second.y() << ", " << WindIt->second.z() << ") m/s at (" << WindIt->first << ") m; ";
|
||||
out << "\n";
|
||||
|
||||
out << "Stored Turbulence: ";
|
||||
for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
|
||||
TurbulenceIt != p.Turbulence.end();
|
||||
TurbulenceIt++)
|
||||
out << "(" << TurbulenceIt->second.x() << ", " << TurbulenceIt->second.y() << ", " << TurbulenceIt->second.z() << ") m/s at (" << TurbulenceIt->first << ") m; ";
|
||||
out << "\n";
|
||||
|
||||
out << "Stored Temperature: ";
|
||||
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
||||
TemperatureIt != p.Temperature.end();
|
||||
TemperatureIt++)
|
||||
out << Kelvin2Celsius(TemperatureIt->second) << " degC at " << TemperatureIt->first << "m; ";
|
||||
out << "\n";
|
||||
|
||||
out << "Stored AirPressure: ";
|
||||
out << p.AirPressure.getValue()/100.0 << " hPa at " << 0.0 << "m; ";
|
||||
out << "\n";
|
||||
|
||||
out << "Stored VaporPressure: ";
|
||||
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
||||
VaporPressureIt != p.VaporPressure.end();
|
||||
VaporPressureIt++)
|
||||
out << VaporPressureIt->second/100.0 << " hPa at " << VaporPressureIt->first << "m; ";
|
||||
out << "\n";
|
||||
|
||||
return out << "\n";
|
||||
}
|
||||
|
||||
|
||||
inline double F(const WeatherPrecision factor, const WeatherPrecision a, const WeatherPrecision b, const WeatherPrecision r, const WeatherPrecision x)
|
||||
{
|
||||
const double c = 1.0 / (-b + a * r);
|
||||
return factor * c * ( 1.0 / (r + x) + a * c * log(fabs((r + x) * (b + a * x))) );
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::AirPressureAt(const WeatherPrecision x) const
|
||||
{
|
||||
const double rho0 = (AirPressure.getValue()*FG_WEATHER_DEFAULT_AIRDENSITY*FG_WEATHER_DEFAULT_TEMPERATURE)/(TemperatureAt(0)*FG_WEATHER_DEFAULT_AIRPRESSURE);
|
||||
const double G = 6.673e-11; //Gravity; in m^3 kg^-1 s^-2
|
||||
const double m = 5.977e24; //mass of the earth in kg
|
||||
const double r = 6368e3; //radius of the earth in metres
|
||||
const double factor = -(rho0 * TemperatureAt(0) * G * m) / AirPressure.getValue();
|
||||
|
||||
double a, b, FF = 0.0;
|
||||
|
||||
//ok, integrate from 0 to a now.
|
||||
if (Temperature.size() < 2)
|
||||
{ //take care of the case that there aren't enough points
|
||||
//actually this should be impossible...
|
||||
|
||||
if (Temperature.size() == 0)
|
||||
{
|
||||
cerr << "ERROR in FGPhysicalProperties: Air pressure at " << x << " metres altiude requested,\n";
|
||||
cerr << " but there isn't enough data stored! No temperature is aviable!\n";
|
||||
return FG_WEATHER_DEFAULT_AIRPRESSURE;
|
||||
}
|
||||
|
||||
//ok, I've got only one point. So I'm assuming that that temperature is
|
||||
//the same for all altitudes.
|
||||
a = 1;
|
||||
b = TemperatureAt(0);
|
||||
FF += F(factor, a, b, r, x );
|
||||
FF -= F(factor, a, b, r, 0.0);
|
||||
}
|
||||
else
|
||||
{ //I've got at least two entries now
|
||||
|
||||
//integrate 'backwards' by integrating the strip ]n,x] first, then ]n-1,n] ... to [0,n-m]
|
||||
|
||||
if (x>=0.0)
|
||||
{
|
||||
map<WeatherPrecision, WeatherPrecision>::const_iterator temp2 = Temperature.upper_bound(x);
|
||||
map<WeatherPrecision, WeatherPrecision>::const_iterator temp1 = temp2; temp1--;
|
||||
|
||||
if (temp1->first == x)
|
||||
{ //ignore that interval
|
||||
temp1--; temp2--;
|
||||
}
|
||||
|
||||
bool first_pass = true;
|
||||
while(true)
|
||||
{
|
||||
if (temp2 == Temperature.end())
|
||||
{
|
||||
//temp2 doesn't exist. So cheat by assuming that the slope is the
|
||||
//same as between the two earlier temperatures
|
||||
temp1--; temp2--;
|
||||
a = (temp2->second - temp1->second)/(temp2->first - temp1->first);
|
||||
b = temp1->second - a * temp1->first;
|
||||
temp1++; temp2++;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = (temp2->second - temp1->second)/(temp2->first - temp1->first);
|
||||
b = temp1->second - a * temp1->first;
|
||||
}
|
||||
|
||||
if (first_pass)
|
||||
{
|
||||
|
||||
FF += F(factor, a, b, r, x);
|
||||
first_pass = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
FF += F(factor, a, b, r, temp2->first);
|
||||
}
|
||||
|
||||
if (temp1->first>0.0)
|
||||
{
|
||||
FF -= F(factor, a, b, r, temp1->first);
|
||||
temp1--; temp2--;
|
||||
}
|
||||
else
|
||||
{
|
||||
FF -= F(factor, a, b, r, 0.0);
|
||||
return AirPressure.getValue() * exp(FF);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //ok x is smaller than 0.0, so do everything in reverse
|
||||
map<WeatherPrecision, WeatherPrecision>::const_iterator temp2 = Temperature.upper_bound(x);
|
||||
map<WeatherPrecision, WeatherPrecision>::const_iterator temp1 = temp2; temp1--;
|
||||
|
||||
bool first_pass = true;
|
||||
while(true)
|
||||
{
|
||||
if (temp2 == Temperature.begin())
|
||||
{
|
||||
//temp1 doesn't exist. So cheat by assuming that the slope is the
|
||||
//same as between the two earlier temperatures
|
||||
temp1 = Temperature.begin(); temp2++;
|
||||
a = (temp2->second - temp1->second)/(temp2->first - temp1->first);
|
||||
b = temp1->second - a * temp1->first;
|
||||
temp2--;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = (temp2->second - temp1->second)/(temp2->first - temp1->first);
|
||||
b = temp1->second - a * temp1->first;
|
||||
}
|
||||
|
||||
if (first_pass)
|
||||
{
|
||||
|
||||
FF += F(factor, a, b, r, x);
|
||||
first_pass = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
FF += F(factor, a, b, r, temp2->first);
|
||||
}
|
||||
|
||||
if (temp2->first<0.0)
|
||||
{
|
||||
FF -= F(factor, a, b, r, temp1->first);
|
||||
|
||||
if (temp2 == Temperature.begin())
|
||||
{
|
||||
temp1 = Temperature.begin(); temp2++;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp1++; temp2++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FF -= F(factor, a, b, r, 0.0);
|
||||
return AirPressure.getValue() * exp(FF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return AirPressure.getValue() * exp(FF);
|
||||
}
|
|
@ -1,416 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGPhysicalProperties.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
15.12.1999 Christian Mayer changed the air pressure calculation to a much
|
||||
more realistic formula. But as I need for that
|
||||
the temperature I moved the code to
|
||||
FGPhysicalProperties
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGPhysicalProperties_H
|
||||
#define FGPhysicalProperties_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include STL_IOSTREAM
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include "FGWeatherDefs.h"
|
||||
|
||||
#include "FGAirPressureItem.h"
|
||||
#include "FGWindItem.h"
|
||||
#include "FGTurbulenceItem.h"
|
||||
|
||||
#include "FGCloudItem.h"
|
||||
#include "FGSnowRain.h"
|
||||
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_STD(map);
|
||||
SG_USING_NAMESPACE(std);
|
||||
|
||||
/****************************************************************************/
|
||||
/* FOREWARD DEFINITIONS */
|
||||
/****************************************************************************/
|
||||
class FGPhysicalProperties2D;
|
||||
ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p );
|
||||
|
||||
class FGPhysicalProperties
|
||||
{
|
||||
public:
|
||||
typedef WeatherPrecision Altitude;
|
||||
|
||||
map<Altitude,FGWindItem> Wind; //all Wind vectors
|
||||
map<Altitude,FGTurbulenceItem> Turbulence; //all Turbulence vectors
|
||||
map<Altitude,WeatherPrecision> Temperature; //in deg. Kelvin (I *only* accept SI!)
|
||||
FGAirPressureItem AirPressure; //in Pascal (I *only* accept SI!)
|
||||
map<Altitude,WeatherPrecision> VaporPressure; //in Pascal (I *only* accept SI!)
|
||||
|
||||
map<Altitude,FGCloudItem> Clouds; //amount of covering and type
|
||||
|
||||
WeatherPrecision SnowRainIntensity; //this also stands for hail, snow,...
|
||||
SnowRainType snowRainType;
|
||||
WeatherPrecision LightningProbability; //in lightnings per second
|
||||
|
||||
FGPhysicalProperties(); //consructor to fill it with FG standart weather
|
||||
|
||||
//return values at specified altitudes
|
||||
void WindAt (sgVec3 ret, const WeatherPrecision a) const;
|
||||
void TurbulenceAt (sgVec3 ret, const WeatherPrecision a) const;
|
||||
WeatherPrecision TemperatureAt (const WeatherPrecision a) const;
|
||||
WeatherPrecision AirPressureAt (const WeatherPrecision x) const; //x is used here instead of a on purpose
|
||||
WeatherPrecision VaporPressureAt(const WeatherPrecision a) const;
|
||||
|
||||
//for easier access to the cloud stuff:
|
||||
unsigned int getNumberOfCloudLayers(void) const;
|
||||
FGCloudItem getCloudLayer(unsigned int nr) const;
|
||||
|
||||
FGPhysicalProperties& operator = ( const FGPhysicalProperties& p );
|
||||
FGPhysicalProperties& operator *= ( const WeatherPrecision d );
|
||||
FGPhysicalProperties& operator += ( const FGPhysicalProperties& p );
|
||||
FGPhysicalProperties& operator -= ( const FGPhysicalProperties& p );
|
||||
|
||||
//for easy binding to the property system
|
||||
WeatherPrecision getWind_x( int number ) const;
|
||||
WeatherPrecision getWind_y( int number ) const;
|
||||
WeatherPrecision getWind_z( int number ) const;
|
||||
WeatherPrecision getWind_a( int number ) const;
|
||||
void setWind_x( int number, WeatherPrecision x);
|
||||
void setWind_y( int number, WeatherPrecision y);
|
||||
void setWind_z( int number, WeatherPrecision z);
|
||||
void setWind_a( int number, WeatherPrecision a);
|
||||
WeatherPrecision getTurbulence_x( int number ) const;
|
||||
WeatherPrecision getTurbulence_y( int number ) const;
|
||||
WeatherPrecision getTurbulence_z( int number ) const;
|
||||
WeatherPrecision getTurbulence_a( int number ) const;
|
||||
void setTurbulence_x( int number, WeatherPrecision x);
|
||||
void setTurbulence_y( int number, WeatherPrecision y);
|
||||
void setTurbulence_z( int number, WeatherPrecision z);
|
||||
void setTurbulence_a( int number, WeatherPrecision a);
|
||||
WeatherPrecision getTemperature_x( int number ) const;
|
||||
WeatherPrecision getTemperature_a( int number ) const;
|
||||
void setTemperature_x( int number, WeatherPrecision x);
|
||||
void setTemperature_a( int number, WeatherPrecision a);
|
||||
WeatherPrecision getVaporPressure_x( int number ) const;
|
||||
WeatherPrecision getVaporPressure_a( int number ) const;
|
||||
void setVaporPressure_x( int number, WeatherPrecision x);
|
||||
void setVaporPressure_a( int number, WeatherPrecision a);
|
||||
};
|
||||
|
||||
class FGPhysicalProperties2D : public FGPhysicalProperties
|
||||
{
|
||||
public:
|
||||
sgVec2 p; //position of the property (lat/lon)
|
||||
friend ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p );
|
||||
|
||||
FGPhysicalProperties2D() {}
|
||||
|
||||
FGPhysicalProperties2D(const FGPhysicalProperties& prop, const sgVec2& pos)
|
||||
{
|
||||
Wind = prop.Wind;
|
||||
Turbulence = prop.Turbulence;
|
||||
Temperature = prop.Temperature;
|
||||
AirPressure = prop.AirPressure;
|
||||
VaporPressure = prop.VaporPressure;
|
||||
sgCopyVec2(p, pos);
|
||||
}
|
||||
};
|
||||
|
||||
typedef vector<FGPhysicalProperties> FGPhysicalPropertiesVector;
|
||||
typedef FGPhysicalPropertiesVector::iterator FGPhysicalPropertiesVectorIt;
|
||||
typedef FGPhysicalPropertiesVector::const_iterator FGPhysicalPropertiesVectorConstIt;
|
||||
|
||||
typedef vector<FGPhysicalProperties2D> FGPhysicalProperties2DVector;
|
||||
typedef FGPhysicalProperties2DVector::iterator FGPhysicalProperties2DVectorIt;
|
||||
typedef FGPhysicalProperties2DVector::const_iterator FGPhysicalProperties2DVectorConstIt;
|
||||
|
||||
|
||||
|
||||
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 WeatherPrecision d )
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, FGWindItem >::iterator wind_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::iterator turbulence_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::iterator scalar_iterator;
|
||||
|
||||
for (wind_iterator WindIt = Wind.begin();
|
||||
WindIt != Wind.end();
|
||||
WindIt++)
|
||||
WindIt->second*= d;
|
||||
|
||||
for (turbulence_iterator TurbulenceIt = Turbulence.begin();
|
||||
TurbulenceIt != Turbulence.end();
|
||||
TurbulenceIt++)
|
||||
TurbulenceIt->second *= d;
|
||||
|
||||
for (scalar_iterator TemperatureIt = Temperature.begin();
|
||||
TemperatureIt != Temperature.end();
|
||||
TemperatureIt++)
|
||||
TemperatureIt->second *= d;
|
||||
|
||||
AirPressure *= d;
|
||||
|
||||
for (scalar_iterator VaporPressureIt = VaporPressure.begin();
|
||||
VaporPressureIt != VaporPressure.end();
|
||||
VaporPressureIt++)
|
||||
VaporPressureIt->second *= d;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysicalProperties& p)
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, FGWindItem >::const_iterator wind_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||
|
||||
for (wind_iterator WindIt = p.Wind.begin();
|
||||
WindIt != p.Wind.end();
|
||||
WindIt++)
|
||||
if (!Wind.insert(*WindIt).second) //when it's not inserted => it's already existing
|
||||
Wind[WindIt->first] += WindIt->second; //=> add the value
|
||||
|
||||
for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
|
||||
TurbulenceIt != p.Turbulence.end();
|
||||
TurbulenceIt++)
|
||||
if (!Turbulence.insert(*TurbulenceIt).second)
|
||||
Turbulence[TurbulenceIt->first] += TurbulenceIt->second;
|
||||
|
||||
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
||||
TemperatureIt != p.Temperature.end();
|
||||
TemperatureIt++)
|
||||
if (!Temperature.insert(*TemperatureIt).second)
|
||||
Temperature[TemperatureIt->first] += TemperatureIt->second;
|
||||
|
||||
AirPressure += p.AirPressure.getValue();
|
||||
|
||||
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
||||
VaporPressureIt != p.VaporPressure.end();
|
||||
VaporPressureIt++)
|
||||
if (!VaporPressure.insert(*VaporPressureIt).second)
|
||||
VaporPressure[VaporPressureIt->first] += VaporPressureIt->second;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// slightly modified version that also makes the Mac happy
|
||||
inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, FGWindItem>::const_iterator wind_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||
|
||||
// types to replace make_pair
|
||||
typedef map<FGPhysicalProperties::Altitude, FGWindItem>::value_type wind_type;
|
||||
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::value_type turb_type;
|
||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::value_type weather_type;
|
||||
|
||||
for (wind_iterator WindIt = p.Wind.begin();
|
||||
WindIt != p.Wind.end();
|
||||
WindIt++)
|
||||
if (!Wind.insert( wind_type(WindIt->first, -WindIt->second) ).second)
|
||||
// when it's not inserted => it's already existing
|
||||
Wind[WindIt->first] -= WindIt->second; //=> substract the value
|
||||
|
||||
for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
|
||||
TurbulenceIt != p.Turbulence.end();
|
||||
TurbulenceIt++)
|
||||
if (!Turbulence.insert( turb_type(TurbulenceIt->first, -TurbulenceIt->second) ).second)
|
||||
Turbulence[TurbulenceIt->first] -= TurbulenceIt->second;
|
||||
|
||||
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
||||
TemperatureIt != p.Temperature.end();
|
||||
TemperatureIt++)
|
||||
if (!Temperature.insert( weather_type(TemperatureIt->first, -TemperatureIt->second) ).second)
|
||||
Temperature[TemperatureIt->first] -= TemperatureIt->second;
|
||||
|
||||
AirPressure -= p.AirPressure.getValue();
|
||||
|
||||
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
||||
VaporPressureIt != p.VaporPressure.end();
|
||||
VaporPressureIt++)
|
||||
if (!VaporPressure.insert( weather_type(VaporPressureIt->first, -VaporPressureIt->second) ).second)
|
||||
VaporPressure[VaporPressureIt->first] -= VaporPressureIt->second;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if 0 // old version
|
||||
inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, FGWindItem >::const_iterator wind_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
|
||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||
|
||||
for (wind_iterator WindIt = p.Wind.begin();
|
||||
WindIt != p.Wind.end();
|
||||
WindIt++)
|
||||
if (!Wind.insert( make_pair(WindIt->first, -WindIt->second) ).second) //when it's not inserted => it's already existing
|
||||
Wind[WindIt->first] -= WindIt->second; //=> substract the value
|
||||
|
||||
for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
|
||||
TurbulenceIt != p.Turbulence.end();
|
||||
TurbulenceIt++)
|
||||
if (!Turbulence.insert( make_pair(TurbulenceIt->first, -TurbulenceIt->second) ).second)
|
||||
Turbulence[TurbulenceIt->first] -= TurbulenceIt->second;
|
||||
|
||||
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
||||
TemperatureIt != p.Temperature.end();
|
||||
TemperatureIt++)
|
||||
if (!Temperature.insert( make_pair(TemperatureIt->first, -TemperatureIt->second) ).second)
|
||||
Temperature[TemperatureIt->first] -= TemperatureIt->second;
|
||||
|
||||
AirPressure -= p.AirPressure.getValue();
|
||||
|
||||
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
||||
VaporPressureIt != p.VaporPressure.end();
|
||||
VaporPressureIt++)
|
||||
if (!VaporPressure.insert( make_pair(VaporPressureIt->first, -VaporPressureIt->second) ).second)
|
||||
VaporPressure[VaporPressureIt->first] -= VaporPressureIt->second;
|
||||
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void FGPhysicalProperties::WindAt(sgVec3 ret, const WeatherPrecision a) const
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, FGWindItem>::const_iterator vector_iterator;
|
||||
|
||||
vector_iterator it = Wind.lower_bound(a);
|
||||
vector_iterator it2 = it;
|
||||
it--;
|
||||
|
||||
//now I've got it->alt < a < it2->alt so I can interpolate
|
||||
sgSubVec3(ret, *it2->second.getValue(), *it->second.getValue());
|
||||
sgScaleVec3(ret, (a - it2->first) / (it2->first - it->first));
|
||||
sgAddVec3(ret, *it2->second.getValue());
|
||||
}
|
||||
|
||||
inline void FGPhysicalProperties::TurbulenceAt(sgVec3 ret, const WeatherPrecision a) const
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator vector_iterator;
|
||||
|
||||
vector_iterator it = Turbulence.lower_bound(a);
|
||||
vector_iterator it2 = it;
|
||||
it--;
|
||||
|
||||
//now I've got it->alt < a < it2->alt so I can interpolate
|
||||
sgSubVec3(ret, *it2->second.getValue(), *it->second.getValue());
|
||||
sgScaleVec3(ret, (a - it2->first) / (it2->first - it->first));
|
||||
sgAddVec3(ret, *it2->second.getValue());
|
||||
}
|
||||
|
||||
inline WeatherPrecision FGPhysicalProperties::TemperatureAt(const WeatherPrecision a) const
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||
|
||||
scalar_iterator it = Temperature.lower_bound(a);
|
||||
scalar_iterator it2 = it;
|
||||
it--;
|
||||
|
||||
//now I've got it->alt < a < it2->alt so I can interpolate
|
||||
return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
|
||||
}
|
||||
|
||||
//inline WeatherPrecision FGPhysicalProperties::AirPressureAt(const WeatherPrecision x) const
|
||||
//moved to FGPhysicalProperties.cpp as it got too complex to inline
|
||||
|
||||
inline WeatherPrecision FGPhysicalProperties::VaporPressureAt(const WeatherPrecision a) const
|
||||
{
|
||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||
|
||||
scalar_iterator it = VaporPressure.lower_bound(a);
|
||||
scalar_iterator it2 = it;
|
||||
it--;
|
||||
|
||||
//now I've got it->alt < a < it2->alt so I can interpolate
|
||||
return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
|
||||
}
|
||||
|
||||
|
||||
inline FGPhysicalProperties operator * (FGPhysicalProperties a, const WeatherPrecision b)
|
||||
{
|
||||
return a *= b;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperties operator * (const WeatherPrecision b, FGPhysicalProperties a)
|
||||
{
|
||||
return a *= b;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperties operator + (FGPhysicalProperties a, const FGPhysicalProperties& b)
|
||||
{
|
||||
return a += b;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperties operator - (FGPhysicalProperties a, const FGPhysicalProperties& b)
|
||||
{
|
||||
return a -= b;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGPhysicalProperties_H*/
|
||||
|
|
@ -1,480 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGPhysicalProperties_bind.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 15.03.02
|
||||
Called by: main program
|
||||
|
||||
-------- Copyright (C) 2002 Christian Mayer (fgfs@christianmayer.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
|
||||
------------------------------------------------------------------------------
|
||||
15.03.2002 Christian Mayer Created
|
||||
*****************************************************************************/
|
||||
|
||||
#include "FGPhysicalProperties.h"
|
||||
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getWind_x( int number ) const
|
||||
{
|
||||
if (number >= Wind.size())
|
||||
{
|
||||
cerr << "Error: There are " << Wind.size() << " entries for wind, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,FGWindItem>::const_iterator it = Wind.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->second.x();
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setWind_x( int number, WeatherPrecision x)
|
||||
{
|
||||
if (number >= Wind.size())
|
||||
{
|
||||
cerr << "Error: There are " << Wind.size() << " entries for wind, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,FGWindItem>::iterator it = Wind.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->second.x( x );
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getWind_y( int number ) const
|
||||
{
|
||||
if (number >= Wind.size())
|
||||
{
|
||||
cerr << "Error: There are " << Wind.size() << " entries for wind, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,FGWindItem>::const_iterator it = Wind.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->second.y();
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setWind_y( int number, WeatherPrecision y)
|
||||
{
|
||||
if (number >= Wind.size())
|
||||
{
|
||||
cerr << "Error: There are " << Wind.size() << " entries for wind, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,FGWindItem>::iterator it = Wind.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->second.y( y );
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getWind_z( int number ) const
|
||||
{
|
||||
if (number >= Wind.size())
|
||||
{
|
||||
cerr << "Error: There are " << Wind.size() << " entries for wind, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,FGWindItem>::const_iterator it = Wind.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->second.z();
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setWind_z( int number, WeatherPrecision z)
|
||||
{
|
||||
if (number >= Wind.size())
|
||||
{
|
||||
cerr << "Error: There are " << Wind.size() << " entries for wind, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,FGWindItem>::iterator it = Wind.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->second.z( z );
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getWind_a( int number ) const
|
||||
{
|
||||
if (number >= Wind.size())
|
||||
{
|
||||
cerr << "Error: There are " << Wind.size() << " entries for wind, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,FGWindItem>::const_iterator it = Wind.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->first;
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setWind_a( int number, WeatherPrecision a)
|
||||
{
|
||||
if (number >= Wind.size())
|
||||
{
|
||||
cerr << "Error: There are " << Wind.size() << " entries for wind, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,FGWindItem>::iterator it = Wind.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->first;
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getTurbulence_x( int number ) const
|
||||
{
|
||||
if (number >= Turbulence.size())
|
||||
{
|
||||
cerr << "Error: There are " << Turbulence.size() << " entries for Turbulence, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,FGTurbulenceItem>::const_iterator it = Turbulence.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->second.x();
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setTurbulence_x( int number, WeatherPrecision x)
|
||||
{
|
||||
if (number >= Turbulence.size())
|
||||
{
|
||||
cerr << "Error: There are " << Turbulence.size() << " entries for Turbulence, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,FGTurbulenceItem>::iterator it = Turbulence.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->second.x( x );
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getTurbulence_y( int number ) const
|
||||
{
|
||||
if (number >= Turbulence.size())
|
||||
{
|
||||
cerr << "Error: There are " << Turbulence.size() << " entries for Turbulence, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,FGTurbulenceItem>::const_iterator it = Turbulence.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->second.y();
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setTurbulence_y( int number, WeatherPrecision y)
|
||||
{
|
||||
if (number >= Turbulence.size())
|
||||
{
|
||||
cerr << "Error: There are " << Turbulence.size() << " entries for Turbulence, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,FGTurbulenceItem>::iterator it = Turbulence.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->second.y( y );
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getTurbulence_z( int number ) const
|
||||
{
|
||||
if (number >= Turbulence.size())
|
||||
{
|
||||
cerr << "Error: There are " << Turbulence.size() << " entries for Turbulence, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,FGTurbulenceItem>::const_iterator it = Turbulence.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->second.z();
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setTurbulence_z( int number, WeatherPrecision z)
|
||||
{
|
||||
if (number >= Turbulence.size())
|
||||
{
|
||||
cerr << "Error: There are " << Turbulence.size() << " entries for Turbulence, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,FGTurbulenceItem>::iterator it = Turbulence.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->second.z( z );
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getTurbulence_a( int number ) const
|
||||
{
|
||||
if (number >= Turbulence.size())
|
||||
{
|
||||
cerr << "Error: There are " << Turbulence.size() << " entries for Turbulence, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,FGTurbulenceItem>::const_iterator it = Turbulence.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->first;
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setTurbulence_a( int number, WeatherPrecision a)
|
||||
{
|
||||
if (number >= Turbulence.size())
|
||||
{
|
||||
cerr << "Error: There are " << Turbulence.size() << " entries for Turbulence, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,FGTurbulenceItem>::iterator it = Turbulence.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->first;
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getTemperature_x( int number ) const
|
||||
{
|
||||
if (number >= Temperature.size())
|
||||
{
|
||||
cerr << "Error: There are " << Temperature.size() << " entries for Temperature, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,WeatherPrecision>::const_iterator it = Temperature.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setTemperature_x( int number, WeatherPrecision x)
|
||||
{
|
||||
if (number >= Temperature.size())
|
||||
{
|
||||
cerr << "Error: There are " << Temperature.size() << " entries for Temperature, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,WeatherPrecision>::iterator it = Temperature.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->second = x;
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getTemperature_a( int number ) const
|
||||
{
|
||||
if (number >= Temperature.size())
|
||||
{
|
||||
cerr << "Error: There are " << Temperature.size() << " entries for Temperature, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,WeatherPrecision>::const_iterator it = Temperature.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->first;
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setTemperature_a( int number, WeatherPrecision a)
|
||||
{
|
||||
if (number >= Temperature.size())
|
||||
{
|
||||
cerr << "Error: There are " << Temperature.size() << " entries for Temperature, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,WeatherPrecision>::iterator it = Temperature.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->first;
|
||||
}
|
||||
WeatherPrecision FGPhysicalProperties::getVaporPressure_x( int number ) const
|
||||
{
|
||||
if (number >= VaporPressure.size())
|
||||
{
|
||||
cerr << "Error: There are " << VaporPressure.size() << " entries for VaporPressure, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,WeatherPrecision>::const_iterator it = VaporPressure.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setVaporPressure_x( int number, WeatherPrecision x)
|
||||
{
|
||||
if (number >= VaporPressure.size())
|
||||
{
|
||||
cerr << "Error: There are " << Temperature.size() << " entries for VaporPressure, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,WeatherPrecision>::iterator it = VaporPressure.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->second = x;
|
||||
}
|
||||
|
||||
WeatherPrecision FGPhysicalProperties::getVaporPressure_a( int number ) const
|
||||
{
|
||||
if (number >= VaporPressure.size())
|
||||
{
|
||||
cerr << "Error: There are " << VaporPressure.size() << " entries for VaporPressure, but number " << number << " got requested!\n";
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
map<Altitude,WeatherPrecision>::const_iterator it = VaporPressure.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
return it->first;
|
||||
}
|
||||
|
||||
void FGPhysicalProperties::setVaporPressure_a( int number, WeatherPrecision a)
|
||||
{
|
||||
if (number >= VaporPressure.size())
|
||||
{
|
||||
cerr << "Error: There are " << VaporPressure.size() << " entries for VaporPressure, but number " << number << " got requested!\n";
|
||||
}
|
||||
|
||||
map<Altitude,WeatherPrecision>::iterator it = VaporPressure.begin();
|
||||
|
||||
while( number > 0)
|
||||
{
|
||||
it++;
|
||||
number--;
|
||||
}
|
||||
|
||||
it->first;
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGPhysicalProperty.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
Called by: main program
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGWeatherDefs.h"
|
||||
#include "FGPhysicalProperty.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
FGPhysicalProperty::FGPhysicalProperty()
|
||||
{
|
||||
sgZeroVec3(Wind); //Wind vector
|
||||
|
||||
sgZeroVec3(Turbulence); //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 WeatherPrecision altitude)
|
||||
{
|
||||
p.WindAt(Wind, altitude);
|
||||
p.TurbulenceAt(Turbulence, altitude);
|
||||
Temperature = p.TemperatureAt(altitude);
|
||||
AirPressure = p.AirPressureAt(altitude);
|
||||
VaporPressure = p.VaporPressureAt(altitude);
|
||||
}
|
||||
|
||||
|
|
@ -1,222 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGPhysicalProperty.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGPhysicalProperty_H
|
||||
#define FGPhysicalProperty_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include "FGWeatherDefs.h"
|
||||
#include "FGPhysicalProperties.h"
|
||||
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_NAMESPACE(std);
|
||||
|
||||
/****************************************************************************/
|
||||
/* used for output: */
|
||||
/****************************************************************************/
|
||||
class FGPhysicalProperty;
|
||||
bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
|
||||
|
||||
class FGPhysicalProperty
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
public:
|
||||
sgVec3 Wind; //Wind vector
|
||||
sgVec3 Turbulence; //Turbulence vector
|
||||
WeatherPrecision Temperature; //in deg. Kelvin (I *only* accept SI!)
|
||||
WeatherPrecision AirPressure; //in Pascal (I *only* accept SI!)
|
||||
WeatherPrecision VaporPressure; //in Pascal (I *only* accept SI!)
|
||||
|
||||
FGPhysicalProperty(); //consructor to fill it with FG standart weather
|
||||
FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecision altitude);
|
||||
|
||||
//allow calculations for easier handling such as interpolating
|
||||
FGPhysicalProperty& operator = ( const FGPhysicalProperty& p ); // assignment of a FGPhysicalProperty
|
||||
FGPhysicalProperty& operator += ( const FGPhysicalProperty& p ); // incrementation by a FGPhysicalProperty
|
||||
FGPhysicalProperty& operator -= ( const FGPhysicalProperty& p ); // decrementation by a FGPhysicalProperty
|
||||
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?
|
||||
};
|
||||
|
||||
class FGPhysicalProperty3D : public FGPhysicalProperty
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
public:
|
||||
sgVec3 p; //position of the property (lat/lon/alt)
|
||||
};
|
||||
|
||||
typedef vector<FGPhysicalProperty> FGPhysicalPropertyVector;
|
||||
typedef FGPhysicalPropertyVector::iterator FGPhysicalPropertyVectorIt;
|
||||
typedef FGPhysicalPropertyVector::const_iterator FGPhysicalPropertyVectorConstIt;
|
||||
|
||||
typedef vector<FGPhysicalProperty3D> FGPhysicalProperty3DVector;
|
||||
typedef FGPhysicalProperty3DVector::iterator FGPhysicalProperty3DVectorIt;
|
||||
typedef FGPhysicalProperty3DVector::const_iterator FGPhysicalProperty3DVectorConstIt;
|
||||
|
||||
inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProperty& p )
|
||||
{
|
||||
sgCopyVec3(Wind, p.Wind);
|
||||
sgCopyVec3(Turbulence, p.Turbulence);
|
||||
Temperature = p.Temperature;
|
||||
AirPressure = p.AirPressure;
|
||||
VaporPressure = p.VaporPressure;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalProperty& p )
|
||||
{
|
||||
sgAddVec3(Wind, p.Wind);
|
||||
sgAddVec3(Turbulence, p.Turbulence);
|
||||
Temperature += p.Temperature;
|
||||
AirPressure += p.AirPressure;
|
||||
VaporPressure += p.VaporPressure;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperty& FGPhysicalProperty::operator -= ( const FGPhysicalProperty& p )
|
||||
{
|
||||
sgSubVec3(Wind, p.Wind);
|
||||
sgSubVec3(Turbulence, p.Turbulence);
|
||||
Temperature -= p.Temperature;
|
||||
AirPressure -= p.AirPressure;
|
||||
VaporPressure -= p.VaporPressure;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperty& FGPhysicalProperty::operator *= ( const double d )
|
||||
{
|
||||
sgScaleVec3(Wind, d);
|
||||
sgScaleVec3(Turbulence, d);
|
||||
Temperature *= d;
|
||||
AirPressure *= d;
|
||||
VaporPressure *= d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double d )
|
||||
{
|
||||
sgScaleVec3(Wind, 1.0 / d);
|
||||
sgScaleVec3(Turbulence, 1.0 / d);
|
||||
Temperature /= d;
|
||||
AirPressure /= d;
|
||||
VaporPressure /= d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperty operator - (const FGPhysicalProperty& p)
|
||||
{
|
||||
FGPhysicalProperty x;
|
||||
sgNegateVec3(x.Wind, p.Wind);
|
||||
sgNegateVec3(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 (
|
||||
sgEqualVec3(a.Wind, b.Wind) &&
|
||||
sgEqualVec3(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 WeatherPrecision b)
|
||||
{
|
||||
return FGPhysicalProperty(a) *= b;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperty operator * (const WeatherPrecision b, const FGPhysicalProperty& a)
|
||||
{
|
||||
return FGPhysicalProperty(a) *= b;
|
||||
}
|
||||
|
||||
inline FGPhysicalProperty operator / (const FGPhysicalProperty& a, const WeatherPrecision b)
|
||||
{
|
||||
return FGPhysicalProperty(a) *= (1.0/b);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGPhysicalProperty_H*/
|
|
@ -1,75 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGSnowRain.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGSnowRain_H
|
||||
#define FGSnowRain_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGWeatherFeature.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
enum SnowRainType
|
||||
{
|
||||
Rain,
|
||||
Snow,
|
||||
Hail,
|
||||
|
||||
usedRainSnowTypes
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGSnowRain:FGWeatherFeature
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
public:
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGSnowRain_H*/
|
|
@ -1,52 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGTemperatureItem.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
bool operator<(const FGTemperatureItem& arg1, const FGTemperatureItem& arg2 )
|
||||
{
|
||||
return arg1.alt < arg2.alt;
|
||||
}
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
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
|
||||
10.10.1999 Christian Mayer added mutable for gcc 2.95 portability
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGTemperatureItem_H
|
||||
#define FGTemperatureItem_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGWeatherDefs.h"
|
||||
|
||||
// for the case that mutable isn't supported:
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
class FGTemperatureItem;
|
||||
FGTemperatureItem operator-(const FGTemperatureItem& arg);
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGTemperatureItem
|
||||
{
|
||||
private:
|
||||
mutable WeatherPrecision value;
|
||||
WeatherPrecision alt;
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
||||
FGTemperatureItem(const WeatherPrecision& a, const WeatherPrecision& v) {alt = a; value = v;}
|
||||
FGTemperatureItem(const WeatherPrecision& v) {alt = 0.0; value = v;}
|
||||
FGTemperatureItem() {alt = 0.0; value = (WeatherPrecision)FG_WEATHER_DEFAULT_TEMPERATURE;}
|
||||
|
||||
WeatherPrecision getValue() const { return value; };
|
||||
WeatherPrecision getAlt() const { return alt; };
|
||||
|
||||
void setAlt (WeatherPrecision x) { alt = x; }
|
||||
void setValue(WeatherPrecision x) { value = x; }
|
||||
|
||||
FGTemperatureItem& operator*= (const WeatherPrecision& 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 WeatherPrecision& 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*/
|
|
@ -1,117 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGThunderstorm.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 02.11.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
------------------------------------------------------------------------------
|
||||
Function that calls other parts of fg when a lightning has happened
|
||||
|
||||
HISTORY
|
||||
------------------------------------------------------------------------------
|
||||
02.11.1999 Christian Mayer Created
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include "FGThunderstorm.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
FGThunderstorm::FGThunderstorm(const float n, const float e, const float s, const float w, const float p, const unsigned int seed)
|
||||
{
|
||||
northBorder = n;
|
||||
eastBorder = e;
|
||||
southBorder = s;
|
||||
westBorder = w;
|
||||
|
||||
lightningProbability = p;
|
||||
currentProbability = 0.0;
|
||||
|
||||
switch(seed)
|
||||
{
|
||||
case 0:
|
||||
//a seed of 0 means that I have to initialize the seed myself
|
||||
srand( (unsigned)time( NULL ) );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
//a seed of 1 means that I must not initialize the seed
|
||||
break;
|
||||
|
||||
default:
|
||||
//any other seed means that I have to initialize with that seed
|
||||
srand( seed );
|
||||
}
|
||||
}
|
||||
|
||||
FGThunderstorm::~FGThunderstorm(void)
|
||||
{
|
||||
//I don't need to do anything
|
||||
}
|
||||
|
||||
void FGThunderstorm::update(const float dt)
|
||||
{
|
||||
//increase currentProbability by a value x that's 0.5 dt <= x <= 1.5 dt
|
||||
currentProbability += dt * ( 0.5 - (float(rand())/RAND_MAX) );
|
||||
|
||||
if (currentProbability > lightningProbability)
|
||||
{ //ok, I've got a lightning now
|
||||
|
||||
//figure out where the lightning is:
|
||||
sgVec2 lightningPosition;
|
||||
sgSetVec2(
|
||||
lightningPosition,
|
||||
southBorder + (northBorder - southBorder)*(float(rand())/RAND_MAX),
|
||||
westBorder + (eastBorder - westBorder )*(float(rand())/RAND_MAX)
|
||||
);
|
||||
|
||||
//call OpenGl:
|
||||
/* ... */
|
||||
|
||||
//call Sound:
|
||||
/* ... */
|
||||
|
||||
//call Radio module:
|
||||
/* ... */
|
||||
|
||||
currentProbability = 0.0; //and begin again
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGThunderstorm.h
|
||||
Author: Christian Mayer
|
||||
Date started: 02.11.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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 thunderstom class
|
||||
|
||||
HISTORY
|
||||
------------------------------------------------------------------------------
|
||||
02.11.1999 Christian Mayer Created
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGThunderstorm_H
|
||||
#define FGThunderstorm_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGThunderstorm
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
float northBorder;
|
||||
float eastBorder;
|
||||
float southBorder;
|
||||
float westBorder;
|
||||
|
||||
float lightningProbability; //in lightnings per second
|
||||
float currentProbability; //=0.0 directly after a lightning stroke and
|
||||
//gets increased over the time until it's
|
||||
//bigger than lightningProbability. When that
|
||||
//happens we've got a new lightning
|
||||
|
||||
public:
|
||||
FGThunderstorm(const float n, const float e, const float s, const float w, const float p, const unsigned int seed = 0);
|
||||
~FGThunderstorm(void);
|
||||
|
||||
void update(const float dt);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGThunderstorm_H*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGTurbulenceItem.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
Called by: FGMicroWeather
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGTurbulenceItem.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGTurbulenceItem.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
21.12.1999 Christian Mayer Added a fix for compatibility to gcc 2.8 which
|
||||
suggested by Oliver Delise
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGTurbulenceItem_H
|
||||
#define FGTurbulenceItem_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include "FGWeatherDefs.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
class FGTurbulenceItem;
|
||||
FGTurbulenceItem operator-(const FGTurbulenceItem& arg);
|
||||
|
||||
#if ( __GNU_C__ == 2 && __GNU_MAJOR__ < 9 )
|
||||
# define const_sgVec3 const sgVec3
|
||||
#else
|
||||
# define const_sgVec3 const sgVec3&
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGTurbulenceItem
|
||||
{
|
||||
private:
|
||||
sgVec3 value;
|
||||
|
||||
protected:
|
||||
public:
|
||||
FGTurbulenceItem(const_sgVec3 v) { sgCopyVec3(value, v);}
|
||||
FGTurbulenceItem() { sgZeroVec3(value); }
|
||||
|
||||
void getValue(sgVec3 ret) const { sgCopyVec3(ret, value); };
|
||||
const sgVec3* getValue(void) const { return &value; };
|
||||
|
||||
WeatherPrecision x(void) const { return value[0]; };
|
||||
WeatherPrecision y(void) const { return value[1]; };
|
||||
WeatherPrecision z(void) const { return value[2]; };
|
||||
|
||||
void x(const WeatherPrecision x) { value[0] = x; };
|
||||
void y(const WeatherPrecision y) { value[1] = y; };
|
||||
void z(const WeatherPrecision z) { value[2] = z; };
|
||||
|
||||
FGTurbulenceItem& operator*= (const WeatherPrecision arg);
|
||||
FGTurbulenceItem& operator+= (const FGTurbulenceItem& arg);
|
||||
FGTurbulenceItem& operator-= (const FGTurbulenceItem& arg);
|
||||
|
||||
friend FGTurbulenceItem operator-(const FGTurbulenceItem& arg);
|
||||
};
|
||||
|
||||
inline FGTurbulenceItem& FGTurbulenceItem::operator*= (const WeatherPrecision arg)
|
||||
{
|
||||
sgScaleVec3(value, arg);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGTurbulenceItem& FGTurbulenceItem::operator+= (const FGTurbulenceItem& arg)
|
||||
{
|
||||
sgAddVec3(value, *arg.getValue());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGTurbulenceItem& FGTurbulenceItem::operator-= (const FGTurbulenceItem& arg)
|
||||
{
|
||||
sgSubVec3(value, *arg.getValue());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGTurbulenceItem operator-(const FGTurbulenceItem& arg)
|
||||
{
|
||||
sgVec3 temp;
|
||||
|
||||
sgNegateVec3(temp, *arg.getValue());
|
||||
|
||||
return FGTurbulenceItem(temp);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGTurbulenceItem_H*/
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGVaporPressureItem.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
bool operator<(const FGVaporPressureItem& arg1, const FGVaporPressureItem& arg2 )
|
||||
{
|
||||
return arg1.alt < arg2.alt;
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
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
|
||||
10.10.1999 Christian Mayer added mutable for gcc 2.95 portability
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGVaporPressureItem_H
|
||||
#define FGVaporPressureItem_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGWeatherDefs.h"
|
||||
|
||||
//for the case that mutable isn't supported:
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
class FGVaporPressureItem;
|
||||
FGVaporPressureItem operator-(const FGVaporPressureItem& arg);
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGVaporPressureItem
|
||||
{
|
||||
private:
|
||||
mutable WeatherPrecision value;
|
||||
WeatherPrecision alt;
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
||||
FGVaporPressureItem(const WeatherPrecision& a, const WeatherPrecision& v) {alt = a; value = v;}
|
||||
FGVaporPressureItem(const WeatherPrecision& v) {alt = 0.0; value = v;}
|
||||
FGVaporPressureItem() {alt = 0.0; value = FG_WEATHER_DEFAULT_VAPORPRESSURE;}
|
||||
|
||||
WeatherPrecision getValue() const { return value; };
|
||||
WeatherPrecision getAlt() const { return alt; };
|
||||
|
||||
FGVaporPressureItem& operator*= (const WeatherPrecision& 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 WeatherPrecision& 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*/
|
|
@ -1,73 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGWeatherDefs.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGWeatherDefs_H
|
||||
#define FGWeatherDefs_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
typedef double WeatherPrecision;
|
||||
|
||||
//set the minimum visibility to get a at least half way realistic weather
|
||||
#define MINIMUM_WEATHER_VISIBILITY 10.0 /* metres */
|
||||
#define DEFAULT_WEATHER_VISIBILITY 32000.0 /* metres */
|
||||
//prefered way the database is working
|
||||
#define PREFERED_WORKING_TYPE default_mode
|
||||
// #define PREFERED_WORKING_TYPE use_internet
|
||||
|
||||
#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*/
|
|
@ -1,89 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGWeatherFeature.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGWeatherFeature_H
|
||||
#define FGWeatherFeature_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include "FGWeatherDefs.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
enum LayerType {
|
||||
fgWind,
|
||||
fgTurbulence,
|
||||
fgTemperature,
|
||||
fgAirDensity,
|
||||
fgCloud,
|
||||
fgRain
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGWeatherFeature
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
sgVec3 position; //middle of the feature in lat/lon/alt
|
||||
WeatherPrecision 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*/
|
|
@ -1,174 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGWeatherParse.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
Called by: FGMicroWeather
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
------------------------------------------------------------------------------
|
||||
Parse the weather that can be downloaded from
|
||||
|
||||
http://129.13.102.67/out/flight/yymmddhhdata.txt.gz
|
||||
|
||||
where yy stands for the year, mm for the month, dd for the day and hh for the
|
||||
hour.
|
||||
The columns are explained at
|
||||
|
||||
http://129.13.102.67/out/flight/kopf.txt
|
||||
|
||||
and a list of the stations can be found at
|
||||
|
||||
http://129.13.102.67/out/flight/wmoconv.txt.gz
|
||||
|
||||
Many thanks to Georg Mueller (Georg.Mueller@imk.fzk.de) of the
|
||||
|
||||
Institut fuer Meteorologie und Klimaforschung, Universitaet Karlsruhe
|
||||
|
||||
for makeking such a service aviable.
|
||||
You can also visit his homepage at http://www.wetterzentrale.de
|
||||
|
||||
HISTORY
|
||||
------------------------------------------------------------------------------
|
||||
18.10.1999 Christian Mayer Created
|
||||
14.12.1999 Christian Mayer minor internal changes
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include <simgear/constants.h>
|
||||
|
||||
#include "FGWeatherParse.h"
|
||||
#include "FGWeatherUtils.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
|
||||
FGWeatherParse::FGWeatherParse()
|
||||
{
|
||||
}
|
||||
|
||||
FGWeatherParse::~FGWeatherParse()
|
||||
{
|
||||
}
|
||||
|
||||
void FGWeatherParse::input(const char *file)
|
||||
{
|
||||
unsigned int nr = 0;
|
||||
|
||||
sg_gzifstream in;
|
||||
|
||||
cerr << "Parsing \"" << file << "\" for weather datas:\n";
|
||||
|
||||
in.open( file );
|
||||
|
||||
if (! in.is_open() )
|
||||
{
|
||||
cerr << "Couldn't find that file!\nExiting...\n";
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool skip = false;
|
||||
while ( in )
|
||||
{
|
||||
entry temp;
|
||||
|
||||
in >> temp.year;
|
||||
in >> temp.month;
|
||||
in >> temp.day;
|
||||
in >> temp.hour;
|
||||
in >> temp.station_number;
|
||||
in >> temp.lat;
|
||||
in >> temp.lon;
|
||||
in >> temp.x_wind;
|
||||
in >> temp.y_wind;
|
||||
in >> temp.temperature;
|
||||
in >> temp.dewpoint;
|
||||
in >> temp.airpressure;
|
||||
in >> temp.airpressure_history[0];
|
||||
in >> temp.airpressure_history[1];
|
||||
in >> temp.airpressure_history[2];
|
||||
in >> temp.airpressure_history[3];
|
||||
|
||||
for (unsigned int i = 0; i < weather_station.size(); i++)
|
||||
{
|
||||
if ((weather_station[i].lat == temp.lat) && (weather_station[i].lon == temp.lon))
|
||||
{
|
||||
// Two weatherstations are at the same positon
|
||||
// => averageing both
|
||||
|
||||
// just taking care of the stuff that metters for us
|
||||
weather_station[i].x_wind += temp.x_wind; weather_station[i].x_wind *= 0.5;
|
||||
weather_station[i].y_wind += temp.y_wind; weather_station[i].y_wind *= 0.5;
|
||||
weather_station[i].temperature += temp.temperature; weather_station[i].temperature *= 0.5;
|
||||
weather_station[i].dewpoint += temp.dewpoint; weather_station[i].dewpoint *= 0.5;
|
||||
weather_station[i].airpressure += temp.airpressure; weather_station[i].airpressure *= 0.5;
|
||||
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip == false)
|
||||
weather_station.push_back( temp );
|
||||
|
||||
skip = false;
|
||||
|
||||
// output a point to ease the waiting
|
||||
if ( ((nr++)%100) == 0 )
|
||||
cerr << ".";
|
||||
}
|
||||
|
||||
cerr << "\n" << nr << " stations read\n";
|
||||
}
|
||||
}
|
||||
|
||||
FGPhysicalProperties FGWeatherParse::getFGPhysicalProperties(const unsigned int nr) const
|
||||
{
|
||||
FGPhysicalProperties ret_val;
|
||||
|
||||
//chache this entry
|
||||
entry this_entry = weather_station[nr];
|
||||
|
||||
ret_val.Wind[-1000.0] = FGWindItem(this_entry.x_wind, this_entry.y_wind, 0.0);
|
||||
ret_val.Wind[10000.0] = FGWindItem(this_entry.x_wind, this_entry.y_wind, 0.0);
|
||||
ret_val.Temperature[0.0] = Celsius( this_entry.temperature );
|
||||
ret_val.AirPressure = FGAirPressureItem( this_entry.airpressure * 10.0 ); //*10 to go from 10 hPa to Pa
|
||||
|
||||
//I have the dewpoint and the temperature, so I can get the vapor pressure
|
||||
ret_val.VaporPressure[-1000.0] = sat_vp( this_entry.dewpoint );
|
||||
ret_val.VaporPressure[10000.0] = sat_vp( this_entry.dewpoint );
|
||||
|
||||
//I've got no ideas about clouds...
|
||||
//ret_val.Clouds[0] = 0.0;
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
void FGWeatherParse::getPosition(const unsigned int nr, sgVec2 pos) const
|
||||
{
|
||||
//set the position of the station
|
||||
sgSetVec2( pos, weather_station[nr].lat * SGD_DEGREES_TO_RADIANS, weather_station[nr].lon * SGD_DEGREES_TO_RADIANS );
|
||||
}
|
||||
|
|
@ -1,134 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGWeatherParse.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
------------------------------------------------------------------------------
|
||||
Parse the weather that can be downloaded from
|
||||
|
||||
http://129.13.102.67/out/flight/yymmddhhdata.txt.gz
|
||||
|
||||
where yy stands for the year, mm for the month, dd for the day and hh for the
|
||||
hour.
|
||||
The columns are explained at
|
||||
|
||||
http://129.13.102.67/out/flight/kopf.txt
|
||||
|
||||
and a list of the stations can be found at
|
||||
|
||||
http://129.13.102.67/out/flight/wmoconv.txt.gz
|
||||
|
||||
Many thanks to Georg Mueller (Georg.Mueller@imk.fzk.de) of the
|
||||
|
||||
Institut fuer Meteorologie und Klimaforschung, Universitaet Karlsruhe
|
||||
|
||||
for makeking such a service aviable.
|
||||
You can also visit his homepage at http://www.wetterzentrale.de
|
||||
|
||||
HISTORY
|
||||
------------------------------------------------------------------------------
|
||||
18.10.1999 Christian Mayer Created
|
||||
14.12.1999 Christian Mayer minor internal changes
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGWeatherParse_H
|
||||
#define FGWeatherParse_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <vector>
|
||||
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
|
||||
#include "FGPhysicalProperties.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
SG_USING_STD(vector);
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGWeatherParse
|
||||
{
|
||||
public:
|
||||
struct entry;
|
||||
|
||||
private:
|
||||
vector<entry> weather_station;
|
||||
|
||||
protected:
|
||||
public:
|
||||
/************************************************************************/
|
||||
/* A line (i.e. entry) in the data file looks like: */
|
||||
/* yyyy mm dd hh XXXXX BBBBB LLLLLL UUUUU VVVVV TTTTT DDDDD PPPPP pppp */
|
||||
/************************************************************************/
|
||||
struct entry
|
||||
{
|
||||
int year; // The yyyy
|
||||
int month; // The mm
|
||||
int day; // The dd
|
||||
int hour; // The hh
|
||||
unsigned int station_number; // The XXXXX
|
||||
float lat; // The BBBBBB negative = south
|
||||
float lon; // The LLLLLLL negative = west
|
||||
float x_wind; // The UUUUU negative = to the weat
|
||||
float y_wind; // The VVVVV negative = to the south
|
||||
float temperature; // The TTTTT in degC
|
||||
float dewpoint; // The DDDDD in degC
|
||||
float airpressure; // The PPPPP in hPa
|
||||
float airpressure_history[4]; // The pppp in hPa
|
||||
};
|
||||
|
||||
FGWeatherParse();
|
||||
~FGWeatherParse();
|
||||
|
||||
void input(const char *file);
|
||||
|
||||
unsigned int stored_stations(void) const
|
||||
{
|
||||
return weather_station.size();
|
||||
}
|
||||
|
||||
entry getEntry(const unsigned int nr) const
|
||||
{
|
||||
return weather_station[nr];
|
||||
}
|
||||
|
||||
FGPhysicalProperties getFGPhysicalProperties(const unsigned int nr) const;
|
||||
void getPosition(const unsigned int nr, sgVec2 pos) const;
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGWeatherParse_H*/
|
|
@ -1,224 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGWeatherUtils.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
17.01.2000 Christian Mayer Added conversion routines make it easier for
|
||||
JSBsim to use the weather database.
|
||||
18.05.2000 Christian Mayer Added function for geting the density when
|
||||
temperature and pressure are given
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* 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 pressure 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 WeatherPrecision sat_vp(const WeatherPrecision 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 WeatherPrecision rel_hum(const WeatherPrecision act_vp, const WeatherPrecision sat_vp)
|
||||
{
|
||||
return (act_vp / sat_vp) * 100; //in %
|
||||
}
|
||||
|
||||
inline WeatherPrecision dp(const WeatherPrecision sat_vp)
|
||||
{
|
||||
return (SAT_VP_CONST3*log10(sat_vp/SAT_VP_CONST1))/(SAT_VP_CONST2-log10(sat_vp/SAT_VP_CONST1)); //in °C
|
||||
}
|
||||
|
||||
inline WeatherPrecision wb(const WeatherPrecision t, const WeatherPrecision p, const WeatherPrecision dp)
|
||||
{
|
||||
WeatherPrecision e = sat_vp(dp);
|
||||
WeatherPrecision tcur, tcvp, peq, diff;
|
||||
WeatherPrecision 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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Assume that we've got an ideal gas in normal altitudes
|
||||
inline WeatherPrecision Density(const WeatherPrecision AirPressure, const WeatherPrecision Temperature )
|
||||
{
|
||||
const float rho0 = 1.293; /*density for air in normal altitudes at 0°C and 1013 mbar*/
|
||||
|
||||
return rho0 * 273.15 * AirPressure / (101300.0 * Temperature);
|
||||
}
|
||||
|
||||
inline WeatherPrecision Celsius (const WeatherPrecision celsius)
|
||||
{
|
||||
return celsius + 273.15; //Kelvin
|
||||
}
|
||||
|
||||
inline WeatherPrecision Fahrenheit (const WeatherPrecision fahrenheit)
|
||||
{
|
||||
return (fahrenheit * 9.0 / 5.0) + 32.0 + 273.15; //Kelvin
|
||||
}
|
||||
|
||||
inline WeatherPrecision Kelvin2Celsius (const WeatherPrecision kelvin)
|
||||
{
|
||||
return kelvin - 273.15; //Celsius
|
||||
}
|
||||
|
||||
inline WeatherPrecision Kelvin2Fahrenheit (const WeatherPrecision kelvin)
|
||||
{
|
||||
return ((kelvin - 273.15) * 9.0 / 5.0) + 32.0; //Fahrenheit
|
||||
}
|
||||
|
||||
inline WeatherPrecision Celsius2Fahrenheit (const WeatherPrecision celsius)
|
||||
{
|
||||
return (celsius * 9.0 / 5.0) + 32.0; //Fahrenheit
|
||||
}
|
||||
|
||||
inline WeatherPrecision Fahrenheit2Celsius (const WeatherPrecision fahrenheit)
|
||||
{
|
||||
return (fahrenheit - 32.0) * 5.0 / 9.0; //Celsius
|
||||
}
|
||||
|
||||
inline WeatherPrecision Torr2Pascal (const WeatherPrecision torr)
|
||||
{
|
||||
return (101325.0/760.0)*torr; //Pascal
|
||||
}
|
||||
|
||||
inline WeatherPrecision Rankine2Kelvin (const WeatherPrecision Rankine)
|
||||
{
|
||||
return (5.0 / 9.0) * Rankine; //Kelvin
|
||||
}
|
||||
|
||||
inline WeatherPrecision JSBsim2SIdensity (const WeatherPrecision JSBsim)
|
||||
{
|
||||
return JSBsim / 0.0019403203; //kg / cubic metres
|
||||
}
|
||||
|
||||
inline WeatherPrecision psf2Pascal (const WeatherPrecision psf)
|
||||
{
|
||||
return psf / 0.020885434; //lbs / square foot (used in JSBsim)
|
||||
}
|
||||
|
||||
inline WeatherPrecision Kelvin2Rankine (const WeatherPrecision kelvin)
|
||||
{
|
||||
return (9.0 / 5.0) * kelvin; //Rankine (used in JSBsim)
|
||||
}
|
||||
|
||||
inline WeatherPrecision SIdensity2JSBsim (const WeatherPrecision SIdensity)
|
||||
{
|
||||
return 0.0019403203 * SIdensity; //slug / cubic feet (used in JSBsim)
|
||||
}
|
||||
|
||||
inline WeatherPrecision Pascal2psf (const WeatherPrecision Pascal)
|
||||
{
|
||||
return 0.020885434 * Pascal; //lbs / square feet (used in JSBsim)
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGWeatherUtils_H*/
|
|
@ -1,67 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGWeatherVectorWrap.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
------------------------------------------------------------------------------
|
||||
make a wraper for an sgVec2 vector so that it can be used in a STL container
|
||||
|
||||
HISTORY
|
||||
------------------------------------------------------------------------------
|
||||
18.10.1999 Christian Mayer Created
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
21.12.1999 Christian Mayer Added a fix for compatibility to gcc 2.8 which
|
||||
suggested by Oliver Delise
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGWeatherVectorWrap_H
|
||||
#define FGWeatherVectorWrap_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include <sg.h>
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
#if ( __GNU_C__ == 2 && __GNU_MAJOR__ < 9 )
|
||||
# define const_sgVec2 const sgVec2
|
||||
#else
|
||||
# define const_sgVec2 const sgVec2&
|
||||
#endif
|
||||
|
||||
struct sgVec2Wrap
|
||||
{
|
||||
sgVec2 p;
|
||||
|
||||
sgVec2Wrap();
|
||||
sgVec2Wrap( const_sgVec2 src ) { sgCopyVec2( p, src ); }
|
||||
};
|
||||
|
||||
#endif /*FGWeatherVectorWrap_H*/
|
|
@ -1,50 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Module: FGWindItem.cpp
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
Called by: FGMicroWeather
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
#include "FGWindItem.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/********************************** CODE ************************************/
|
||||
/****************************************************************************/
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*****************************************************************************
|
||||
|
||||
Header: FGWindItem.h
|
||||
Author: Christian Mayer
|
||||
Date started: 28.05.99
|
||||
|
||||
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.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
|
||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||
suggestion
|
||||
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||
and lots of wee code cleaning
|
||||
21.12.1999 Christian Mayer Added a fix for compatibility to gcc 2.8 which
|
||||
suggested by Oliver Delise
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* SENTRY */
|
||||
/****************************************************************************/
|
||||
#ifndef FGWindItem_H
|
||||
#define FGWindItem_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* INCLUDES */
|
||||
/****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
#include "FGWeatherDefs.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
class FGWindItem;
|
||||
FGWindItem operator-(const FGWindItem& arg);
|
||||
|
||||
#if ( __GNU_C__ == 2 && __GNU_MAJOR__ < 9 )
|
||||
# define const_sgVec3 const sgVec3
|
||||
#else
|
||||
# define const_sgVec3 const sgVec3&
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/* CLASS DECLARATION */
|
||||
/****************************************************************************/
|
||||
class FGWindItem
|
||||
{
|
||||
private:
|
||||
sgVec3 value;
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
||||
FGWindItem(const_sgVec3 v) { sgCopyVec3(value, v); }
|
||||
FGWindItem(const WeatherPrecision x, const WeatherPrecision y, const WeatherPrecision z)
|
||||
{ sgSetVec3 (value, x, y, z); }
|
||||
FGWindItem() { sgZeroVec3(value); }
|
||||
|
||||
void getValue(sgVec3 ret) const { sgCopyVec3(ret, value); };
|
||||
const sgVec3* getValue(void) const { return &value; };
|
||||
|
||||
WeatherPrecision x(void) const { return value[0]; };
|
||||
WeatherPrecision y(void) const { return value[1]; };
|
||||
WeatherPrecision z(void) const { return value[2]; };
|
||||
|
||||
void x(const WeatherPrecision x) { value[0] = x; };
|
||||
void y(const WeatherPrecision y) { value[1] = y; };
|
||||
void z(const WeatherPrecision z) { value[2] = z; };
|
||||
|
||||
FGWindItem& operator*= (const WeatherPrecision arg);
|
||||
FGWindItem& operator+= (const FGWindItem& arg);
|
||||
FGWindItem& operator-= (const FGWindItem& arg);
|
||||
|
||||
friend FGWindItem operator-(const FGWindItem& arg);
|
||||
};
|
||||
|
||||
inline FGWindItem& FGWindItem::operator*= (const WeatherPrecision arg)
|
||||
{
|
||||
sgScaleVec3(value, arg);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGWindItem& FGWindItem::operator+= (const FGWindItem& arg)
|
||||
{
|
||||
sgAddVec3(value, *arg.getValue());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline FGWindItem& FGWindItem::operator-= (const FGWindItem& arg)
|
||||
{
|
||||
sgSubVec3(value, *arg.getValue());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline FGWindItem operator-(const FGWindItem& arg)
|
||||
{
|
||||
sgVec3 temp;
|
||||
|
||||
sgNegateVec3(temp, *arg.getValue());
|
||||
|
||||
return FGWindItem(temp);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
#endif /*FGWindItem_H*/
|
|
@ -1,22 +0,0 @@
|
|||
noinst_LIBRARIES = libWeatherCM.a
|
||||
|
||||
libWeatherCM_a_SOURCES = \
|
||||
FGAirPressureItem.cpp FGAirPressureItem.h \
|
||||
FGCloud.h FGCloudItem.cpp FGCloudItem.h \
|
||||
FGLocalWeatherDatabase.cpp FGLocalWeatherDatabase.h \
|
||||
FGPhysicalProperties.cpp FGPhysicalProperties.h \
|
||||
FGPhysicalProperties_bind.cpp \
|
||||
FGPhysicalProperty.cpp FGPhysicalProperty.h \
|
||||
FGSnowRain.h \
|
||||
FGTemperatureItem.cpp FGTemperatureItem.h \
|
||||
FGThunderstorm.cpp FGThunderstorm.h \
|
||||
FGTurbulenceItem.cpp FGTurbulenceItem.h \
|
||||
FGVaporPressureItem.cpp FGVaporPressureItem.h \
|
||||
FGWeatherDefs.h FGWeatherFeature.h FGWeatherUtils.h \
|
||||
FGWeatherParse.cpp FGWeatherParse.h \
|
||||
FGWeatherVectorWrap.h \
|
||||
FGWindItem.cpp FGWindItem.h \
|
||||
linintp2.cpp linintp2.h \
|
||||
sphrintp.cpp sphrintp.h
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
|
|
@ -1,212 +0,0 @@
|
|||
The formula p(x) for calculating the air pressure at a given altitude
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Well known is the baromertic(?) formula
|
||||
|
||||
rho0
|
||||
------ * g * x
|
||||
p0
|
||||
p(x) = p0 * e
|
||||
|
||||
with p0 being the airpressure and rho0 being the air density at an altitude of
|
||||
0 metres above sea level and g being the gravity constant of 9.81 m/sq. sec
|
||||
|
||||
This formula can easily be derivated when you know, that:
|
||||
|
||||
* the pressure difference is
|
||||
|
||||
dp = - rho * g * dx
|
||||
|
||||
* Boyle-Mariotte says:
|
||||
|
||||
p0 : p = rho0 : rho
|
||||
|
||||
Combinig the terms and changing them around I get:
|
||||
|
||||
dp [ rho0 ]
|
||||
-- = - rho * g = - [ ------ * p(x) ] * g
|
||||
dx [ p0 ]
|
||||
|
||||
rho0
|
||||
p'(x) = - ------ * p(x) * g
|
||||
p0
|
||||
|
||||
Solving that differential equation and knowing that p(0) = p0 I get:
|
||||
|
||||
rho0
|
||||
- ------ * g * x
|
||||
p0
|
||||
p(x) = p0 * e
|
||||
|
||||
q.e.d.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
The problem with that equation is that it doesn't take different temperatures
|
||||
at different altitudes into account. And the inaccuracies due to it are huge.
|
||||
That's why this formula is only used in very low altitudes.
|
||||
|
||||
So to get a usefull formula for FlightGear I need to extend it. And as I'm
|
||||
already 'recreating' that formula I'm taking the change in g into account, too.
|
||||
This doesn't make such a dramatic difference to the result as the inclusion of
|
||||
temperature change does, but it doesn't complicate the final formula too much.
|
||||
|
||||
So I get three formulas that I'm combining in the end:
|
||||
|
||||
* the change of g with the altitude:
|
||||
|
||||
G * m
|
||||
g(x) = -----------
|
||||
(x + r)^2
|
||||
G is the universal gravity constant(?) and is 6.673e-11 m^3 kg^-1 s^-2
|
||||
m is the mass of the earth and is 5.977e24 kg
|
||||
r is the radius of the earth and is 6368 km
|
||||
|
||||
* The pressure difference stays the same:
|
||||
|
||||
dp = - rho * g(x) * dx
|
||||
|
||||
* If I combine Boyle-Mariotte with Gay-Lussac I get:
|
||||
|
||||
rho0 * T0 p
|
||||
rho = ----------- * ---
|
||||
p0 T
|
||||
|
||||
Combining the terms again I get this time:
|
||||
|
||||
dp [ rho0 * T0 p(x) ]
|
||||
-- = - rho * g(x) = - [ ----------- * ------ ] * g(x)
|
||||
dx [ p0 T(x) ]
|
||||
|
||||
rho0 * T0 p(x) * g(x)
|
||||
p'(x) = - ----------- * -------------
|
||||
p0 T(x)
|
||||
|
||||
This DE isn't that easy to solve as the one above, it by looking into the right
|
||||
books you'll see the general solution for:
|
||||
|
||||
y' + f(x)*y = 0
|
||||
|
||||
is
|
||||
x
|
||||
/\
|
||||
- | f(x) dx
|
||||
\/
|
||||
n
|
||||
y = m * e
|
||||
|
||||
and P(m,n) will be a point on the graph.
|
||||
|
||||
For q = n = 0 metres altitude we get y = m. As y is p(x) we know that m has to
|
||||
be p0.
|
||||
|
||||
So our final formuala is
|
||||
|
||||
ho0 * T0 g(x)
|
||||
f1(x) = ----------- * ------
|
||||
p0 T(x)
|
||||
|
||||
|
||||
x x
|
||||
/\ /\
|
||||
- | f1(x) dx | f(x) dx
|
||||
\/ \/
|
||||
0 0 F(x) - F(0)
|
||||
p(x) = p0 * e = p0 * e = p0 * e
|
||||
|
||||
The only disturbing thing we've got left is the integral. Luckily there is a
|
||||
great service at http://integrals.wolfram.com/ that helps me doing it :-)
|
||||
|
||||
But the f(x) is still too general so I'm substituting:
|
||||
|
||||
rho0 * T0 * G * m
|
||||
f(x) = - -----------------------
|
||||
p0 * (x + r)^2 * T(x)
|
||||
|
||||
but even that isn't good enough. But as I'm linearily interpolating between
|
||||
two different temperatures I can say that T(x) = a*x + b for the x inbetween
|
||||
two different stored temperatures. So I just need to integrate every pice
|
||||
independandly. But anyway, I get:
|
||||
|
||||
rho0 * T0 * G * m
|
||||
f(x) = - ------------------------------
|
||||
p0 * (x + r)^2 * (a * x + b)
|
||||
|
||||
Integrating that I get:
|
||||
|
||||
rho0 * T0 * G * m [ 1
|
||||
F(x) = - ------------------- * [ ------------------------ -
|
||||
p0 [ (-b + a * r) * (r + x)
|
||||
|
||||
|
||||
a * log|r + x| a * log|b + a * x| ]
|
||||
---------------- + -------------------- ]
|
||||
(b - a * r)^2 (b - a * r)^2 ]
|
||||
|
||||
To lower the computional cost I can transfere the equation.
|
||||
|
||||
* I'm defining
|
||||
|
||||
rho0 * T0 * G * m
|
||||
factor = - -------------------
|
||||
p0
|
||||
1
|
||||
c = --------------
|
||||
(-b + a * r)
|
||||
|
||||
* now I can write
|
||||
|
||||
[ c ]
|
||||
F(x) = factor * [ --------- - a * c * c * [log|r + x| + log|b + a * x|] ]
|
||||
[ (r + x) ]
|
||||
|
||||
* and simplyfy it to
|
||||
|
||||
[ 1 ]
|
||||
F(x) = factor * c * [ --------- - a * c * log|(r + x) * (b + a * x)| ]
|
||||
[ (r + x) ]
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The following table shows quite nicely how accurate my formula is:
|
||||
|
||||
Altitude[m] | Airpressure [hPa] | Error [%]
|
||||
| Official | My formula |
|
||||
------------+---------------+---------------+---------------
|
||||
-200 | 1037.51 | 1037.24 | 0.0260
|
||||
-100 | 1025.32 | 1025.19 | 0.0127
|
||||
0 | 1013.25 | 1013.25 | 0.0
|
||||
500 | 954.59 | 955.224 | 0.0664
|
||||
1000 | 898.70 | 899.912 | 0.1349
|
||||
2000 | 794.88 | 797.042 | 0.2720
|
||||
3000 | 700.99 | 703.885 | 0.4130
|
||||
4000 | 616.28 | 619.727 | 0.5593
|
||||
5000 | 540.07 | 543.89 | 0.7073
|
||||
6000 | 471.67 | 475.731 | 0.8610
|
||||
7000 | 410.46 | 414.643 | 1.0191
|
||||
8000 | 355.84 | 360.054 | 1.1842
|
||||
9000 | 307.27 | 311.422 | 1.3513
|
||||
10000 | 264.21 | 268.238 | 1.5245
|
||||
20000 | 54.670/55.3 | 55.7971 | 2.0616/0.8989
|
||||
30000 | 11.8 | 11.3149 | 1.5441
|
||||
40000 | 3.0 | 2.74665 | 18.9703
|
||||
50000 | 0.88 | 0.753043 | 41.9183
|
||||
60000 | 0.257 | 0.221907 | 57.9802
|
||||
70000 | 0.0602 | 0.0530785 | 61.9153
|
||||
80000 | 0.0101 | 0.00905461 | 51.5725
|
||||
100000 | 2.14e-4 | 2.03984e-4 | 5.5131
|
||||
|
||||
The official values are from the CINA atmosphere which assumes a air pressure
|
||||
of 1013.25 hPa and a temperature of 15 degC at sea level and a temperature
|
||||
gradient of -6.5 deg/km. The CINA atmosphere gives only values for altiudes
|
||||
up to 20 km. The values for 20 km and above are from the 1959 ARDC atmosphere.
|
||||
That's why I've got two values at 20000 metres.
|
||||
The temperature changes dramtically in the altitudes over 20 km which I didn't
|
||||
take care of in my calculations which explains the huge errors at that altitude
|
||||
range. But you can see nicely that the values are at least quite close to the
|
||||
official values.
|
||||
Using a better temperature model for the altitudes above 20 km should
|
||||
dramatically increase the accuracy there.
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,549 +0,0 @@
|
|||
/*
|
||||
WARNING - Do not remove this header.
|
||||
|
||||
This code is a templated version of the 'magic-software' spherical
|
||||
interpolation code by Dave Eberly. The original (un-hacked) code can be
|
||||
obtained from here: http://www.magic-software.com/gr_appr.htm
|
||||
This code is derived from linintp2.h/cpp and sphrintp.h/cpp.
|
||||
|
||||
Dave Eberly says that the conditions for use are:
|
||||
|
||||
* You may distribute the original source code to others at no charge.
|
||||
|
||||
* You may modify the original source code and distribute it to others at
|
||||
no charge. The modified code must be documented to indicate that it is
|
||||
not part of the original package.
|
||||
|
||||
* You may use this code for non-commercial purposes. You may also
|
||||
incorporate this code into commercial packages. However, you may not
|
||||
sell any of your source code which contains my original and/or modified
|
||||
source code. In such a case, you need to factor out my code and freely
|
||||
distribute it.
|
||||
|
||||
* The original code comes with absolutely no warranty and no guarantee is
|
||||
made that the code is bug-free.
|
||||
|
||||
This does not seem incompatible with GPL - so this modified version
|
||||
is hereby placed under GPL along with the rest of FlightGear.
|
||||
|
||||
Christian Mayer
|
||||
*/
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include STL_IOSTREAM
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "linintp2.h"
|
||||
|
||||
SG_USING_NAMESPACE(std);
|
||||
SG_USING_STD(cout);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
mgcLinInterp2D::mgcLinInterp2D (int _numPoints, double* x, double* y,
|
||||
unsigned int* _f)
|
||||
{
|
||||
if ( (numPoints = _numPoints) < 3 )
|
||||
{
|
||||
point = 0;
|
||||
edge = 0;
|
||||
triangle = 0;
|
||||
numTriangles = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 20%] allocating memory");
|
||||
|
||||
point = new double*[numPoints];
|
||||
tmppoint = new double*[numPoints+3];
|
||||
f = new unsigned int[numPoints];
|
||||
int i;
|
||||
for (i = 0; i < numPoints; i++)
|
||||
point[i] = new double[2];
|
||||
for (i = 0; i < numPoints+3; i++)
|
||||
tmppoint[i] = new double[2];
|
||||
for (i = 0; i < numPoints; i++)
|
||||
{
|
||||
point[i][0] = tmppoint[i][0] = x[i];
|
||||
point[i][1] = tmppoint[i][1] = y[i];
|
||||
|
||||
f[i] = _f[i];
|
||||
}
|
||||
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 30%] creating delaunay diagram");
|
||||
|
||||
Delaunay2D();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
mgcLinInterp2D::~mgcLinInterp2D ()
|
||||
{
|
||||
if ( numPoints < 3 )
|
||||
return;
|
||||
|
||||
int i;
|
||||
|
||||
if ( point )
|
||||
{
|
||||
for (i = 0; i < numPoints; i++)
|
||||
delete[] point[i];
|
||||
delete[] point;
|
||||
}
|
||||
if ( tmppoint )
|
||||
{
|
||||
for (i = 0; i < numPoints+3; i++)
|
||||
delete[] tmppoint[i];
|
||||
delete[] tmppoint;
|
||||
}
|
||||
|
||||
delete[] f;
|
||||
delete[] edge;
|
||||
delete[] triangle;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void mgcLinInterp2D::ComputeBarycenter (Vertex& v0, Vertex& v1, Vertex& v2,
|
||||
Vertex& ver, double c[3])
|
||||
{
|
||||
double a0 = v0.x-v2.x;
|
||||
double b0 = v0.y-v2.y;
|
||||
double a1 = v1.x-v2.x;
|
||||
double b1 = v1.y-v2.y;
|
||||
double a2 = ver.x-v2.x;
|
||||
double b2 = ver.y-v2.y;
|
||||
|
||||
double m00 = a0*a0+b0*b0;
|
||||
double m01 = a0*a1+b0*b1;
|
||||
double m11 = a1*a1+b1*b1;
|
||||
double r0 = a2*a0+b2*b0;
|
||||
double r1 = a2*a1+b2*b1;
|
||||
double det = m00*m11-m01*m01;
|
||||
|
||||
c[0] = (m11*r0-m01*r1)/det;
|
||||
c[1] = (m00*r1-m01*r0)/det;
|
||||
c[2] = 1-c[0]-c[1];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int mgcLinInterp2D::InTriangle (Vertex& v0, Vertex& v1, Vertex& v2,
|
||||
Vertex& test)
|
||||
{
|
||||
const double eps = 1e-08;
|
||||
double tx, ty, nx, ny;
|
||||
|
||||
// test against normal to first edge
|
||||
tx = test.x - v0.x;
|
||||
ty = test.y - v0.y;
|
||||
nx = v0.y - v1.y;
|
||||
ny = v1.x - v0.x;
|
||||
if ( tx*nx + ty*ny < -eps )
|
||||
return 0;
|
||||
|
||||
// test against normal to second edge
|
||||
tx = test.x - v1.x;
|
||||
ty = test.y - v1.y;
|
||||
nx = v1.y - v2.y;
|
||||
ny = v2.x - v1.x;
|
||||
if ( tx*nx + ty*ny < -eps )
|
||||
return 0;
|
||||
|
||||
// test against normal to third edge
|
||||
tx = test.x - v2.x;
|
||||
ty = test.y - v2.y;
|
||||
nx = v2.y - v0.y;
|
||||
ny = v0.x - v2.x;
|
||||
if ( tx*nx + ty*ny < -eps )
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int mgcLinInterp2D::Evaluate (double x, double y, EvaluateData& F)
|
||||
{
|
||||
Vertex ver = { x, y };
|
||||
// determine which triangle contains the target point
|
||||
|
||||
int i;
|
||||
Vertex v0, v1, v2;
|
||||
for (i = 0; i < numTriangles; i++)
|
||||
{
|
||||
Triangle& t = triangle[i];
|
||||
v0.x = point[t.vertex[0]][0];
|
||||
v0.y = point[t.vertex[0]][1];
|
||||
v1.x = point[t.vertex[1]][0];
|
||||
v1.y = point[t.vertex[1]][1];
|
||||
v2.x = point[t.vertex[2]][0];
|
||||
v2.y = point[t.vertex[2]][1];
|
||||
|
||||
if ( InTriangle(v0,v1,v2,ver) )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i == numTriangles ) // point is outside interpolation region
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Triangle& t = triangle[i]; // (x,y) is in this triangle
|
||||
|
||||
// compute barycentric coordinates with respect to subtriangle
|
||||
double bary[3];
|
||||
ComputeBarycenter(v0,v1,v2,ver,bary);
|
||||
|
||||
// compute barycentric combination of function values at vertices
|
||||
F.index[0] = f[t.vertex[0]];
|
||||
F.index[1] = f[t.vertex[1]];
|
||||
F.index[2] = f[t.vertex[2]];
|
||||
F.percentage[0] = bary[0];
|
||||
F.percentage[1] = bary[1];
|
||||
F.percentage[2] = bary[2];
|
||||
|
||||
return 1;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int mgcLinInterp2D::Delaunay2D ()
|
||||
{
|
||||
int result;
|
||||
|
||||
const double EPSILON = 1e-12;
|
||||
const int TSIZE = 75;
|
||||
const double RANGE = 10.0;
|
||||
|
||||
xmin = tmppoint[0][0];
|
||||
xmax = xmin;
|
||||
ymin = tmppoint[0][1];
|
||||
ymax = ymin;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < numPoints; i++)
|
||||
{
|
||||
double value = tmppoint[i][0];
|
||||
if ( xmax < value )
|
||||
xmax = value;
|
||||
if ( xmin > value )
|
||||
xmin = value;
|
||||
|
||||
value = tmppoint[i][1];
|
||||
if ( ymax < value )
|
||||
ymax = value;
|
||||
if ( ymin > value )
|
||||
ymin = value;
|
||||
}
|
||||
|
||||
double xrange = xmax-xmin, yrange = ymax-ymin;
|
||||
double maxrange = xrange;
|
||||
if ( maxrange < yrange )
|
||||
maxrange = yrange;
|
||||
|
||||
// need to scale the data later to do a correct triangle count
|
||||
double maxrange2 = maxrange*maxrange;
|
||||
|
||||
// tweak the points by very small random numbers
|
||||
double bgs = EPSILON*maxrange;
|
||||
srand(367);
|
||||
for (i = 0; i < numPoints; i++)
|
||||
{
|
||||
tmppoint[i][0] += bgs*(0.5 - rand()/double(RAND_MAX));
|
||||
tmppoint[i][1] += bgs*(0.5 - rand()/double(RAND_MAX));
|
||||
}
|
||||
|
||||
double wrk[2][3] =
|
||||
{
|
||||
{ 5*RANGE, -RANGE, -RANGE },
|
||||
{ -RANGE, 5*RANGE, -RANGE }
|
||||
};
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
tmppoint[numPoints+i][0] = xmin+xrange*wrk[0][i];
|
||||
tmppoint[numPoints+i][1] = ymin+yrange*wrk[1][i];
|
||||
}
|
||||
|
||||
int i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i11;
|
||||
int nts, ii[3];
|
||||
double xx;
|
||||
|
||||
int tsz = 2*TSIZE;
|
||||
int** tmp = new int*[tsz+1];
|
||||
tmp[0] = new int[2*(tsz+1)];
|
||||
for (i0 = 1; i0 < tsz+1; i0++)
|
||||
tmp[i0] = tmp[0] + 2*i0;
|
||||
i1 = 2*(numPoints + 2);
|
||||
|
||||
int* id = new int[i1];
|
||||
for (i0 = 0; i0 < i1; i0++)
|
||||
id[i0] = i0;
|
||||
|
||||
int** a3s = new int*[i1];
|
||||
a3s[0] = new int[3*i1];
|
||||
for (i0 = 1; i0 < i1; i0++)
|
||||
a3s[i0] = a3s[0] + 3*i0;
|
||||
a3s[0][0] = numPoints;
|
||||
a3s[0][1] = numPoints+1;
|
||||
a3s[0][2] = numPoints+2;
|
||||
|
||||
double** ccr = new double*[i1]; // circumscribed centers and radii
|
||||
ccr[0] = new double[3*i1];
|
||||
for (i0 = 1; i0 < i1; i0++)
|
||||
ccr[i0] = ccr[0] + 3*i0;
|
||||
ccr[0][0] = 0.0;
|
||||
ccr[0][1] = 0.0;
|
||||
ccr[0][2] = FLT_MAX;
|
||||
|
||||
nts = 1; // number of triangles
|
||||
i4 = 1;
|
||||
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 40%] create triangulation");
|
||||
|
||||
// compute triangulation
|
||||
for (i0 = 0; i0 < numPoints; i0++)
|
||||
{
|
||||
i1 = i7 = -1;
|
||||
i9 = 0;
|
||||
for (i11 = 0; i11 < nts; i11++)
|
||||
{
|
||||
i1++;
|
||||
while ( a3s[i1][0] < 0 )
|
||||
i1++;
|
||||
xx = ccr[i1][2];
|
||||
for (i2 = 0; i2 < 2; i2++)
|
||||
{
|
||||
double z = tmppoint[i0][i2]-ccr[i1][i2];
|
||||
xx -= z*z;
|
||||
if ( xx < 0 )
|
||||
goto Corner3;
|
||||
}
|
||||
i9--;
|
||||
i4--;
|
||||
id[i4] = i1;
|
||||
for (i2 = 0; i2 < 3; i2++)
|
||||
{
|
||||
ii[0] = 0;
|
||||
if (ii[0] == i2)
|
||||
ii[0]++;
|
||||
for (i3 = 1; i3 < 2; i3++)
|
||||
{
|
||||
ii[i3] = ii[i3-1] + 1;
|
||||
if (ii[i3] == i2)
|
||||
ii[i3]++;
|
||||
}
|
||||
if ( i7 > 1 )
|
||||
{
|
||||
i8 = i7;
|
||||
for (i3 = 0; i3 <= i8; i3++)
|
||||
{
|
||||
for (i5 = 0; i5 < 2; i5++)
|
||||
if ( a3s[i1][ii[i5]] != tmp[i3][i5] )
|
||||
goto Corner1;
|
||||
for (i6 = 0; i6 < 2; i6++)
|
||||
tmp[i3][i6] = tmp[i8][i6];
|
||||
i7--;
|
||||
goto Corner2;
|
||||
Corner1:;
|
||||
}
|
||||
}
|
||||
if ( ++i7 > tsz )
|
||||
{
|
||||
// temporary storage exceeded, increase TSIZE
|
||||
result = 0;
|
||||
goto ExitDelaunay;
|
||||
}
|
||||
for (i3 = 0; i3 < 2; i3++)
|
||||
tmp[i7][i3] = a3s[i1][ii[i3]];
|
||||
Corner2:;
|
||||
}
|
||||
a3s[i1][0] = -1;
|
||||
Corner3:;
|
||||
}
|
||||
|
||||
for (i1 = 0; i1 <= i7; i1++)
|
||||
{
|
||||
for (i2 = 0; i2 < 2; i2++)
|
||||
for (wrk[i2][2] = 0, i3 = 0; i3 < 2; i3++)
|
||||
{
|
||||
wrk[i2][i3] = tmppoint[tmp[i1][i2]][i3]-tmppoint[i0][i3];
|
||||
wrk[i2][2] +=
|
||||
0.5*wrk[i2][i3]*(tmppoint[tmp[i1][i2]][i3]+
|
||||
tmppoint[i0][i3]);
|
||||
}
|
||||
|
||||
xx = wrk[0][0]*wrk[1][1]-wrk[1][0]*wrk[0][1];
|
||||
ccr[id[i4]][0] = (wrk[0][2]*wrk[1][1]-wrk[1][2]*wrk[0][1])/xx;
|
||||
ccr[id[i4]][1] = (wrk[0][0]*wrk[1][2]-wrk[1][0]*wrk[0][2])/xx;
|
||||
|
||||
for (ccr[id[i4]][2] = 0, i2 = 0; i2 < 2; i2++)
|
||||
{
|
||||
double z = tmppoint[i0][i2]-ccr[id[i4]][i2];
|
||||
ccr[id[i4]][2] += z*z;
|
||||
a3s[id[i4]][i2] = tmp[i1][i2];
|
||||
}
|
||||
|
||||
a3s[id[i4]][2] = i0;
|
||||
i4++;
|
||||
i9++;
|
||||
}
|
||||
nts += i9;
|
||||
}
|
||||
|
||||
// count the number of triangles
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 50%] count the number of triangles");
|
||||
|
||||
numTriangles = 0;
|
||||
i0 = -1;
|
||||
for (i11 = 0; i11 < nts; i11++)
|
||||
{
|
||||
i0++;
|
||||
while ( a3s[i0][0] < 0 )
|
||||
i0++;
|
||||
if ( a3s[i0][0] < numPoints )
|
||||
{
|
||||
for (i1 = 0; i1 < 2; i1++)
|
||||
for (i2 = 0; i2 < 2; i2++)
|
||||
wrk[i1][i2] =
|
||||
tmppoint[a3s[i0][i1]][i2]-tmppoint[a3s[i0][2]][i2];
|
||||
|
||||
if ( fabs(wrk[0][0]*wrk[1][1]-wrk[0][1]*wrk[1][0]) > EPSILON*maxrange2 )
|
||||
numTriangles++;
|
||||
}
|
||||
}
|
||||
|
||||
// create the triangles
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 60%] create the triangles");
|
||||
|
||||
triangle = new Triangle[numTriangles];
|
||||
|
||||
numTriangles = 0;
|
||||
i0 = -1;
|
||||
for (i11 = 0; i11 < nts; i11++)
|
||||
{
|
||||
i0++;
|
||||
while ( a3s[i0][0] < 0 )
|
||||
i0++;
|
||||
if ( a3s[i0][0] < numPoints )
|
||||
{
|
||||
for (i1 = 0; i1 < 2; i1++)
|
||||
for (i2 = 0; i2 < 2; i2++)
|
||||
wrk[i1][i2] =
|
||||
tmppoint[a3s[i0][i1]][i2]-tmppoint[a3s[i0][2]][i2];
|
||||
xx = wrk[0][0]*wrk[1][1]-wrk[0][1]*wrk[1][0];
|
||||
if ( fabs(xx) > EPSILON*maxrange2 )
|
||||
{
|
||||
int delta = xx < 0 ? 1 : 0;
|
||||
Triangle& tri = triangle[numTriangles];
|
||||
tri.vertex[0] = a3s[i0][0];
|
||||
tri.vertex[1] = a3s[i0][1+delta];
|
||||
tri.vertex[2] = a3s[i0][2-delta];
|
||||
tri.adj[0] = -1;
|
||||
tri.adj[1] = -1;
|
||||
tri.adj[2] = -1;
|
||||
numTriangles++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// build edge table
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 70%] build the edge table");
|
||||
|
||||
numEdges = 0;
|
||||
edge = new Edge[3*numTriangles];
|
||||
|
||||
int j, j0, j1;
|
||||
for (i = 0; i < numTriangles; i++)
|
||||
{
|
||||
if ( (i%500) == 0)
|
||||
SG_LOG(SG_MATH, SG_BULK, "[ 7" << 10*i/numTriangles << "%] build the edge table");
|
||||
|
||||
Triangle& t = triangle[i];
|
||||
|
||||
for (j0 = 0, j1 = 1; j0 < 3; j0++, j1 = (j1+1)%3)
|
||||
{
|
||||
for (j = 0; j < numEdges; j++)
|
||||
{
|
||||
Edge& e = edge[j];
|
||||
if ( (t.vertex[j0] == e.vertex[0]
|
||||
&& t.vertex[j1] == e.vertex[1])
|
||||
|| (t.vertex[j0] == e.vertex[1]
|
||||
&& t.vertex[j1] == e.vertex[0]) )
|
||||
break;
|
||||
}
|
||||
if ( j == numEdges ) // add edge to table
|
||||
{
|
||||
edge[j].vertex[0] = t.vertex[j0];
|
||||
edge[j].vertex[1] = t.vertex[j1];
|
||||
edge[j].triangle[0] = i;
|
||||
edge[j].index[0] = j0;
|
||||
edge[j].triangle[1] = -1;
|
||||
numEdges++;
|
||||
}
|
||||
else // edge already exists, add triangle to table
|
||||
{
|
||||
edge[j].triangle[1] = i;
|
||||
edge[j].index[1] = j0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// establish links between adjacent triangles
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 80%] establishing links between adjacent triangles");
|
||||
|
||||
for (i = 0; i < numEdges; i++)
|
||||
{
|
||||
if ( edge[i].triangle[1] != -1 )
|
||||
{
|
||||
j0 = edge[i].triangle[0];
|
||||
j1 = edge[i].triangle[1];
|
||||
triangle[j0].adj[edge[i].index[0]] = j1;
|
||||
triangle[j1].adj[edge[i].index[1]] = j0;
|
||||
}
|
||||
}
|
||||
|
||||
result = 1;
|
||||
|
||||
ExitDelaunay:;
|
||||
delete[] tmp[0];
|
||||
delete[] tmp;
|
||||
delete[] id;
|
||||
delete[] a3s[0];
|
||||
delete[] a3s;
|
||||
delete[] ccr[0];
|
||||
delete[] ccr;
|
||||
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 90%] finsishes delauney triangulation");
|
||||
|
||||
return result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void mgcLinInterp2D::GetPoint (int i, double& x, double& y)
|
||||
{
|
||||
// assumes i is valid [can use PointCount() before passing i]
|
||||
x = point[i][0];
|
||||
y = point[i][1];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void mgcLinInterp2D::GetEdge (int i, double& x0, double& y0, double& x1,
|
||||
double& y1)
|
||||
{
|
||||
// assumes i is valid [can use EdgeCount() before passing i]
|
||||
int v0 = edge[i].vertex[0], v1 = edge[i].vertex[1];
|
||||
|
||||
x0 = point[v0][0];
|
||||
y0 = point[v0][1];
|
||||
x1 = point[v1][0];
|
||||
y1 = point[v1][1];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void mgcLinInterp2D::GetTriangle (int i, double& x0, double& y0, double& x1,
|
||||
double& y1, double& x2, double& y2)
|
||||
{
|
||||
// assumes i is valid [can use TriangleCount() before passing i]
|
||||
int v0 = triangle[i].vertex[0];
|
||||
int v1 = triangle[i].vertex[1];
|
||||
int v2 = triangle[i].vertex[2];
|
||||
|
||||
x0 = point[v0][0];
|
||||
y0 = point[v0][1];
|
||||
x1 = point[v1][0];
|
||||
y1 = point[v1][1];
|
||||
x2 = point[v2][0];
|
||||
y2 = point[v2][1];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
WARNING - Do not remove this header.
|
||||
|
||||
This code is a templated version of the 'magic-software' spherical
|
||||
interpolation code by Dave Eberly. The original (un-hacked) code can be
|
||||
obtained from here: http://www.magic-software.com/gr_appr.htm
|
||||
This code is derived from linintp2.h/cpp and sphrintp.h/cpp.
|
||||
|
||||
Dave Eberly says that the conditions for use are:
|
||||
|
||||
* You may distribute the original source code to others at no charge.
|
||||
|
||||
* You may modify the original source code and distribute it to others at
|
||||
no charge. The modified code must be documented to indicate that it is
|
||||
not part of the original package.
|
||||
|
||||
* You may use this code for non-commercial purposes. You may also
|
||||
incorporate this code into commercial packages. However, you may not
|
||||
sell any of your source code which contains my original and/or modified
|
||||
source code. In such a case, you need to factor out my code and freely
|
||||
distribute it.
|
||||
|
||||
* The original code comes with absolutely no warranty and no guarantee is
|
||||
made that the code is bug-free.
|
||||
|
||||
This does not seem incompatible with GPL - so this modified version
|
||||
is hereby placed under GPL along with the rest of FlightGear.
|
||||
|
||||
Christian Mayer
|
||||
*/
|
||||
|
||||
#ifndef LININTP2_H
|
||||
#define LININTP2_H
|
||||
|
||||
struct EvaluateData
|
||||
{
|
||||
unsigned int index[3];
|
||||
double percentage[3];
|
||||
};
|
||||
|
||||
class mgcLinInterp2D
|
||||
{
|
||||
public:
|
||||
mgcLinInterp2D (int _numPoints, double* x, double* y, unsigned int* _f);
|
||||
|
||||
~mgcLinInterp2D ();
|
||||
|
||||
double XMin () { return xmin; }
|
||||
double XMax () { return xmax; }
|
||||
double XRange () { return xmax-xmin; }
|
||||
double YMin () { return ymin; }
|
||||
double YMax () { return ymax; }
|
||||
double YRange () { return ymax-ymin; }
|
||||
|
||||
int PointCount () { return numPoints; }
|
||||
void GetPoint (int i, double& x, double& y);
|
||||
|
||||
int EdgeCount () { return numEdges; }
|
||||
void GetEdge (int i, double& x0, double& y0, double& x1, double& y1);
|
||||
|
||||
int TriangleCount () { return numTriangles; }
|
||||
void GetTriangle (int i, double& x0, double& y0, double& x1, double& y1,
|
||||
double& x2, double& y2);
|
||||
|
||||
int Evaluate (double x, double y, EvaluateData& F);
|
||||
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
double x, y;
|
||||
}
|
||||
Vertex;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int vertex[3]; // listed in counterclockwise order
|
||||
|
||||
int adj[3];
|
||||
// adj[0] points to triangle sharing edge (vertex[0],vertex[1])
|
||||
// adj[1] points to triangle sharing edge (vertex[1],vertex[2])
|
||||
// adj[2] points to triangle sharing edge (vertex[2],vertex[0])
|
||||
}
|
||||
Triangle;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int vertex[2];
|
||||
int triangle[2];
|
||||
int index[2];
|
||||
}
|
||||
Edge;
|
||||
|
||||
int numPoints;
|
||||
double** point;
|
||||
double** tmppoint;
|
||||
unsigned int* f;
|
||||
|
||||
double xmin, xmax, ymin, ymax;
|
||||
|
||||
|
||||
int numEdges;
|
||||
Edge* edge;
|
||||
|
||||
int numTriangles;
|
||||
Triangle* triangle;
|
||||
|
||||
int Delaunay2D ();
|
||||
void ComputeBarycenter (Vertex& v0, Vertex& v1, Vertex& v2, Vertex& ver,
|
||||
double c[3]);
|
||||
int InTriangle (Vertex& v0, Vertex& v1, Vertex& v2, Vertex& test);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,173 +0,0 @@
|
|||
/*
|
||||
WARNING - Do not remove this header.
|
||||
|
||||
This code is a templated version of the 'magic-software' spherical
|
||||
interpolation code by Dave Eberly. The original (un-hacked) code can be
|
||||
obtained from here: http://www.magic-software.com/gr_appr.htm
|
||||
This code is derived from linintp2.h/cpp and sphrintp.h/cpp.
|
||||
|
||||
Dave Eberly says that the conditions for use are:
|
||||
|
||||
* You may distribute the original source code to others at no charge.
|
||||
|
||||
* You may modify the original source code and distribute it to others at
|
||||
no charge. The modified code must be documented to indicate that it is
|
||||
not part of the original package.
|
||||
|
||||
* You may use this code for non-commercial purposes. You may also
|
||||
incorporate this code into commercial packages. However, you may not
|
||||
sell any of your source code which contains my original and/or modified
|
||||
source code. In such a case, you need to factor out my code and freely
|
||||
distribute it.
|
||||
|
||||
* The original code comes with absolutely no warranty and no guarantee is
|
||||
made that the code is bug-free.
|
||||
|
||||
This does not seem incompatible with GPL - so this modified version
|
||||
is hereby placed under GPL along with the rest of FlightGear.
|
||||
|
||||
Christian Mayer
|
||||
*/
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include STL_IOSTREAM
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <math.h>
|
||||
#include "sphrintp.h"
|
||||
|
||||
SG_USING_NAMESPACE(std);
|
||||
SG_USING_STD(cout);
|
||||
|
||||
|
||||
static const double PI = 4.0*atan(1.0);
|
||||
static const double TWOPI = 2.0*PI;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
SphereInterpolate::SphereInterpolate (int n, const double* x,
|
||||
const double* y, const double* z,
|
||||
const unsigned int* f)
|
||||
{
|
||||
// Assumes (x[i],y[i],z[i]) is unit length for all 0 <= i < n.
|
||||
// For complete spherical coverage, include the two antipodal points
|
||||
// (0,0,1,f(0,0,1)) and (0,0,-1,f(0,0,-1)) in the data set.
|
||||
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "Initialising spherical interpolator.");
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 0%] Allocating memory");
|
||||
|
||||
theta = new double[3*n];
|
||||
phi = new double[3*n];
|
||||
func = new unsigned int[3*n];
|
||||
|
||||
// convert data to spherical coordinates
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
GetSphericalCoords(x[i],y[i],z[i],theta[i],phi[i]);
|
||||
func[i] = f[i];
|
||||
}
|
||||
|
||||
// use periodicity to get wrap-around in the Delaunay triangulation
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 10%] copying vertices for wrap-aroundr");
|
||||
int j, k;
|
||||
for (i = 0, j = n, k = 2*n; i < n; i++, j++, k++)
|
||||
{
|
||||
theta[j] = theta[i]+TWOPI;
|
||||
theta[k] = theta[i]-TWOPI;
|
||||
phi[j] = phi[i];
|
||||
phi[k] = phi[i];
|
||||
func[j] = func[i];
|
||||
func[k] = func[i];
|
||||
}
|
||||
|
||||
pInterp = new mgcLinInterp2D(3*n,theta,phi,func);
|
||||
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[100%] Finished initialising spherical interpolator.");
|
||||
}
|
||||
|
||||
SphereInterpolate::SphereInterpolate (int n, const sgVec2* p, const unsigned int* f)
|
||||
{
|
||||
// Assumes (x[i],y[i],z[i]) is unit length for all 0 <= i < n.
|
||||
// For complete spherical coverage, include the two antipodal points
|
||||
// (0,0,1,f(0,0,1)) and (0,0,-1,f(0,0,-1)) in the data set.
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "Initialising spherical interpolator.");
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 0%] Allocating memory");
|
||||
|
||||
theta = new double[3*n];
|
||||
phi = new double[3*n];
|
||||
func = new unsigned int[3*n];
|
||||
|
||||
// convert data to spherical coordinates
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[ 10%] copying vertices for wrap-around");
|
||||
|
||||
int i, j, k;
|
||||
for (i = 0, j = n, k = 2*n; i < n; i++, j++, k++)
|
||||
{
|
||||
phi[i] = p[i][0];
|
||||
theta[i] = p[i][1];
|
||||
func[i] = f[i];
|
||||
|
||||
// use periodicity to get wrap-around in the Delaunay triangulation
|
||||
phi[j] = phi[i];
|
||||
phi[k] = phi[i];
|
||||
theta[j] = theta[i]+TWOPI;
|
||||
theta[k] = theta[i]-TWOPI;
|
||||
func[j] = func[i];
|
||||
func[k] = func[i];
|
||||
}
|
||||
|
||||
pInterp = new mgcLinInterp2D(3*n,theta,phi,func);
|
||||
|
||||
SG_LOG(SG_MATH, SG_DEBUG, "[100%] Finished initialising spherical interpolator.");
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
SphereInterpolate::~SphereInterpolate ()
|
||||
{
|
||||
delete pInterp;
|
||||
delete[] theta;
|
||||
delete[] phi;
|
||||
delete[] func;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void SphereInterpolate::GetSphericalCoords (const double x, const double y, const double z,
|
||||
double& thetaAngle,
|
||||
double& phiAngle) const
|
||||
{
|
||||
// Assumes (x,y,z) is unit length. Returns -PI <= thetaAngle <= PI
|
||||
// and 0 <= phiAngle <= PI.
|
||||
|
||||
if ( z < 1.0f )
|
||||
{
|
||||
if ( z > -1.0f )
|
||||
{
|
||||
thetaAngle = atan2(y,x);
|
||||
phiAngle = acos(z);
|
||||
}
|
||||
else
|
||||
{
|
||||
thetaAngle = -PI;
|
||||
phiAngle = PI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
thetaAngle = -PI;
|
||||
phiAngle = 0.0f;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int SphereInterpolate::Evaluate (const double x, const double y, const double z, EvaluateData& f) const
|
||||
{
|
||||
// assumes (x,y,z) is unit length
|
||||
|
||||
double thetaAngle, phiAngle;
|
||||
GetSphericalCoords(x,y,z,thetaAngle,phiAngle);
|
||||
return pInterp->Evaluate(thetaAngle,phiAngle,f);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int SphereInterpolate::Evaluate (const double thetaAngle, const double phiAngle, EvaluateData& f) const
|
||||
{
|
||||
return pInterp->Evaluate(thetaAngle,phiAngle,f);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
WARNING - Do not remove this header.
|
||||
|
||||
This code is a templated version of the 'magic-software' spherical
|
||||
interpolation code by Dave Eberly. The original (un-hacked) code can be
|
||||
obtained from here: http://www.magic-software.com/gr_appr.htm
|
||||
This code is derived from linintp2.h/cpp and sphrintp.h/cpp.
|
||||
|
||||
Dave Eberly says that the conditions for use are:
|
||||
|
||||
* You may distribute the original source code to others at no charge.
|
||||
|
||||
* You may modify the original source code and distribute it to others at
|
||||
no charge. The modified code must be documented to indicate that it is
|
||||
not part of the original package.
|
||||
|
||||
* You may use this code for non-commercial purposes. You may also
|
||||
incorporate this code into commercial packages. However, you may not
|
||||
sell any of your source code which contains my original and/or modified
|
||||
source code. In such a case, you need to factor out my code and freely
|
||||
distribute it.
|
||||
|
||||
* The original code comes with absolutely no warranty and no guarantee is
|
||||
made that the code is bug-free.
|
||||
|
||||
This does not seem incompatible with GPL - so this modified version
|
||||
is hereby placed under GPL along with the rest of FlightGear.
|
||||
|
||||
Christian Mayer
|
||||
*/
|
||||
|
||||
#ifndef SPHRINTP_H
|
||||
#define SPHRINTP_H
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include STL_IOSTREAM
|
||||
|
||||
#include "linintp2.h"
|
||||
#include <plib/sg.h>
|
||||
|
||||
SG_USING_NAMESPACE(std);
|
||||
SG_USING_STD(cout);
|
||||
|
||||
|
||||
class SphereInterpolate
|
||||
{
|
||||
public:
|
||||
SphereInterpolate (int n, const double* x, const double* y,
|
||||
const double* z, const unsigned int* f);
|
||||
SphereInterpolate (int n, const sgVec2* p, const unsigned int* f);
|
||||
|
||||
~SphereInterpolate ();
|
||||
|
||||
void GetSphericalCoords (const double x, const double y, const double z,
|
||||
double& thetaAngle, double& phiAngle) const;
|
||||
|
||||
int Evaluate (const double x, const double y, const double z, EvaluateData& f) const;
|
||||
int Evaluate (const double thetaAngle, const double phiAngle, EvaluateData& f) const;
|
||||
|
||||
#ifndef macintosh
|
||||
// CodeWarrior doesn't know the differece between sgVec2 and
|
||||
// sgVec3, so I commented this out for Mac builds. This change is
|
||||
// related to a similar change in FGLocalWeatherDatabase module.
|
||||
|
||||
EvaluateData Evaluate(const sgVec2& p) const
|
||||
{
|
||||
EvaluateData retval;
|
||||
Evaluate(p[1], p[0], retval);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
EvaluateData Evaluate(const sgVec3& p) const
|
||||
{
|
||||
EvaluateData retval;
|
||||
if (!Evaluate(p[1], p[0], retval))
|
||||
{
|
||||
cout << "Error during spherical interpolation. Point ("
|
||||
<< p[0] << "/" << p[1] << "/" << p[2] << ") was in no triangle\n";
|
||||
retval.index[0] = 0; //fake something
|
||||
retval.index[1] = 0;
|
||||
retval.index[2] = 0;
|
||||
retval.percentage[0] = 1.0;
|
||||
retval.percentage[1] = 0.0;
|
||||
retval.percentage[2] = 0.0;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected:
|
||||
int numPoints;
|
||||
double* theta;
|
||||
double* phi;
|
||||
unsigned int* func;
|
||||
mgcLinInterp2D* pInterp;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue