]> git.mxchange.org Git - flightgear.git/blob - src/WeatherCM/FGWeatherParse.cpp
Cygwin32 build tweaks.
[flightgear.git] / src / WeatherCM / FGWeatherParse.cpp
1 /*****************************************************************************
2
3  Module:       FGWeatherParse.cpp
4  Author:       Christian Mayer
5  Date started: 28.05.99
6  Called by:    FGMicroWeather
7
8  -------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
9
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
13  version.
14
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
18  details.
19
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.
23
24  Further information about the GNU General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26
27 FUNCTIONAL DESCRIPTION
28 ------------------------------------------------------------------------------
29 Parse the weather that can be downloaded from 
30
31     http://129.13.102.67/out/flight/yymmddhhdata.txt.gz
32
33 where yy stands for the year, mm for the month, dd for the day and hh for the
34 hour.
35 The columns are explained at
36
37     http://129.13.102.67/out/flight/kopf.txt
38
39 and a list of the stations can be found at
40
41     http://129.13.102.67/out/flight/wmoconv.txt.gz
42
43 Many thanks to Georg Mueller (Georg.Mueller@imk.fzk.de) of the 
44
45     Institut fuer Meteorologie und Klimaforschung, Universitaet Karlsruhe
46
47 for makeking such a service aviable. 
48 You can also visit his homepage at http://www.wetterzentrale.de
49
50 HISTORY
51 ------------------------------------------------------------------------------
52 18.10.1999 Christian Mayer      Created
53 *****************************************************************************/
54
55 /****************************************************************************/
56 /* INCLUDES                                                                 */
57 /****************************************************************************/
58 #include "Include/fg_constants.h"
59
60 #include "FGWeatherParse.h"
61 #include "FGWeatherUtils.h"
62
63 /****************************************************************************/
64 /********************************** CODE ************************************/
65 /****************************************************************************/
66
67 FGWeatherParse::FGWeatherParse()
68 {
69 }
70
71 FGWeatherParse::~FGWeatherParse()
72 {
73 }
74
75 void FGWeatherParse::input(const char *file)
76 {
77     unsigned int nr = 0;
78
79     fg_gzifstream in;
80
81     cerr << "Parsing \"" << file << "\" for weather datas:\n";
82     
83     in.open( file );
84
85     while ( in )
86     {
87         entry temp;
88
89         in >> temp.year; 
90         in >> temp.month; 
91         in >> temp.day; 
92         in >> temp.hour; 
93         in >> temp.station_number; 
94         in >> temp.lat; 
95         in >> temp.lon; 
96         in >> temp.x_wind; 
97         in >> temp.y_wind; 
98         in >> temp.temperature; 
99         in >> temp.dewpoint; 
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]; 
105
106         weather_station.push_back( temp );
107
108         // output a point to ease the waiting
109         if ( ((nr++)%100) == 0 )
110             cerr << ".";
111     }
112
113     cerr << "\n" << nr << " stations read\n";
114 }
115
116 FGPhysicalProperties2D FGWeatherParse::getFGPhysicalProperties2D(const unsigned int nr) const
117 {
118     FGPhysicalProperties2D ret_val;
119
120     //chache this entry
121     entry this_entry = weather_station[nr];
122     
123     //set the position of the station
124     sgSetVec2( ret_val.p, this_entry.lat * DEG_TO_RAD, this_entry.lon * DEG_TO_RAD ); 
125
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
130
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 );
134
135     //I've got no ideas about clouds...
136     //ret_val.Clouds[0]              = 0.0;
137     
138     return ret_val;
139 }
140
141
142
143