1 /*****************************************************************************
3 Module: FGWeatherParse.cpp
4 Author: Christian Mayer
6 Called by: FGMicroWeather
8 -------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
10 This program is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free Software
12 Foundation; either version 2 of the License, or (at your option) any later
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 Place - Suite 330, Boston, MA 02111-1307, USA.
24 Further information about the GNU General Public License can also be found on
25 the world wide web at http://www.gnu.org.
27 FUNCTIONAL DESCRIPTION
28 ------------------------------------------------------------------------------
29 Parse the weather that can be downloaded from
31 http://129.13.102.67/out/flight/yymmddhhdata.txt.gz
33 where yy stands for the year, mm for the month, dd for the day and hh for the
35 The columns are explained at
37 http://129.13.102.67/out/flight/kopf.txt
39 and a list of the stations can be found at
41 http://129.13.102.67/out/flight/wmoconv.txt.gz
43 Many thanks to Georg Mueller (Georg.Mueller@imk.fzk.de) of the
45 Institut fuer Meteorologie und Klimaforschung, Universitaet Karlsruhe
47 for makeking such a service aviable.
48 You can also visit his homepage at http://www.wetterzentrale.de
51 ------------------------------------------------------------------------------
52 18.10.1999 Christian Mayer Created
53 *****************************************************************************/
55 /****************************************************************************/
57 /****************************************************************************/
58 #include "Include/fg_constants.h"
60 #include "FGWeatherParse.h"
61 #include "FGWeatherUtils.h"
63 /****************************************************************************/
64 /********************************** CODE ************************************/
65 /****************************************************************************/
67 FGWeatherParse::FGWeatherParse()
71 FGWeatherParse::~FGWeatherParse()
75 void FGWeatherParse::input(const char *file)
81 cerr << "Parsing \"" << file << "\" for weather datas:\n";
93 in >> temp.station_number;
98 in >> temp.temperature;
100 in >> temp.airpressure;
101 in >> temp.airpressure_history[0];
102 in >> temp.airpressure_history[1];
103 in >> temp.airpressure_history[2];
104 in >> temp.airpressure_history[3];
106 weather_station.push_back( temp );
108 // output a point to ease the waiting
109 if ( ((nr++)%100) == 0 )
113 cerr << "\n" << nr << " stations read\n";
116 FGPhysicalProperties2D FGWeatherParse::getFGPhysicalProperties2D(const unsigned int nr) const
118 FGPhysicalProperties2D ret_val;
121 entry this_entry = weather_station[nr];
123 //set the position of the station
124 sgSetVec2( ret_val.p, this_entry.lat * DEG_TO_RAD, this_entry.lon * DEG_TO_RAD );
126 ret_val.Wind[-1000.0] = FGWindItem(this_entry.x_wind, this_entry.y_wind, 0.0);
127 ret_val.Wind[10000.0] = FGWindItem(this_entry.x_wind, this_entry.y_wind, 0.0);
128 ret_val.Temperature[0.0] = Celsius( this_entry.temperature );
129 ret_val.AirPressure = FGAirPressureItem( this_entry.airpressure * 10.0 ); //*10 to go from 10 hPa to Pa
131 //I have the dewpoint and the temperature, so I can get the vapor pressure
132 ret_val.VaporPressure[-1000.0] = sat_vp( this_entry.dewpoint );
133 ret_val.VaporPressure[10000.0] = sat_vp( this_entry.dewpoint );
135 //I've got no ideas about clouds...
136 //ret_val.Clouds[0] = 0.0;