144 lines
4.3 KiB
C++
144 lines
4.3 KiB
C++
|
/*****************************************************************************
|
||
|
|
||
|
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
|
||
|
*****************************************************************************/
|
||
|
|
||
|
/****************************************************************************/
|
||
|
/* INCLUDES */
|
||
|
/****************************************************************************/
|
||
|
#include "Include/fg_constants.h"
|
||
|
|
||
|
#include "FGWeatherParse.h"
|
||
|
#include "FGWeatherUtils.h"
|
||
|
|
||
|
/****************************************************************************/
|
||
|
/********************************** CODE ************************************/
|
||
|
/****************************************************************************/
|
||
|
|
||
|
FGWeatherParse::FGWeatherParse()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
FGWeatherParse::~FGWeatherParse()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void FGWeatherParse::input(const char *file)
|
||
|
{
|
||
|
unsigned int nr = 0;
|
||
|
|
||
|
fg_gzifstream in;
|
||
|
|
||
|
cerr << "Parsing \"" << file << "\" for weather datas:\n";
|
||
|
|
||
|
in.open( file );
|
||
|
|
||
|
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];
|
||
|
|
||
|
weather_station.push_back( temp );
|
||
|
|
||
|
// output a point to ease the waiting
|
||
|
if ( ((nr++)%100) == 0 )
|
||
|
cerr << ".";
|
||
|
}
|
||
|
|
||
|
cerr << "\n" << nr << " stations read\n";
|
||
|
}
|
||
|
|
||
|
FGPhysicalProperties2D FGWeatherParse::getFGPhysicalProperties2D(const unsigned int nr) const
|
||
|
{
|
||
|
FGPhysicalProperties2D ret_val;
|
||
|
|
||
|
//chache this entry
|
||
|
entry this_entry = weather_station[nr];
|
||
|
|
||
|
//set the position of the station
|
||
|
sgSetVec2( ret_val.p, this_entry.lat * DEG_TO_RAD, this_entry.lon * DEG_TO_RAD );
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|