1 FlightGear METAR proxy server
2 =============================
6 metarproxy is a caching proxy server for METAR data strings written in
7 Perl. It can be used to:
9 - provide METAR data for machines without internet connection
10 - centralize METAR fetching: one machine in a network runs the proxy, all
11 other connect to the proxy
12 - deliver defined and reproducible weather for educational purposes
13 - save weather situations for later use
19 Quick instructions to try out:
21 $ metarproxy --download 3h
22 $ metarproxy --color &
23 $ fgfs --proxy=localhost:5509 --time-offset=-2 --enable-real-weather-fetch
30 To make use of the proxy, you have to:
32 1. check if you want to use the default cache directory
33 and other default settings, or change them accordingly
34 2. make sure the cache is filled with METAR strings
35 3. start the proxy server
36 4. run fgfs with appropriate time and proxy settings
41 1. Basic setup and preparing the cache
42 ======================================
43 If you are happy with the defaults, you can well skip to the
47 1a. The cache directory
48 -----------------------
49 All metarproxy operation modes need access to a cache, either for
50 storing or retrieving METAR strings. By default, the cache directory
51 is $FG_HOME/metar, whereby $FG_HOME is either to be set as environment
52 variable, or defaults to $HOME/.fgfs. $HOME, in turn, defaults to "."
53 (the current working directory). In other words: if no provisions are
54 made, you end up with /home/$USER/.fgfs/metar as your cache directory
55 on Linux-like operating systems, and ./.fgfs/metar elsewhere.
57 There are several ways to change the cache path:
59 - change one of the environment variables, ideally $FG_HOME. This can
60 be done in the system configuration in MS Windows, and in ~/.bashrc
61 or ~/.profile etc. on Linux-like systems
63 export FG_HOME=/var/tmp/metar
65 - or on the command line when running metarproxy:
67 $ FG_HOME=/var/tmp/metar metarproxy
69 - you can also set the cache directory directly as a command line option
72 $ metarproxy --base=/var/tmp/metar
74 - this command line option can, together with any of the other metarproxy
75 options, be stored again in an environment variable METARPROXY
77 export METARPROXY="-c -vv -b/var/tmp/metar"
82 1b. set metarproxy's proxy server
83 ---------------------------------
84 metarproxy isn't only a proxy server itself, it can also use one to
85 download METAR strings. By default it uses the one defined in the
86 environment variable http_proxy (which is commonly used on Linux-like
87 systems, and is, for instance, used by the lynx browser), or none if
88 unset. To set a particular proxy server for HTTP download, use one of
91 - set http_proxy globally: export http_proxy=http://localhost:3128/
92 - or on the command line: $ http_proxy=http://localhost:3128/ metarproxy
93 - unset http_proxy: $ http_proxy= metarproxy
94 - use the command line option: $ metarproxy --proxy=http://localhost:3128/
95 - set the option globally: export METARPROXY="-yhttp://localhost:3128"
103 2. Fill the cache with METAR data
104 =================================
106 There are three operation modes to do that:
108 2a. --download mode to download worldwide data sets
109 2b. --install mode to install files from your system
110 2c. --record mode to record a selection of stations over some period
116 You can download worldwide sets of METAR strings, each in a file of about
117 1MB size from weather.noaa.gov[1]. This can be done with a separate ftp
118 client or web browser, but it can also be done by metarproxy:
120 $ metarproxy --download 3h ... download last three hours (~ 3MB)
122 Note that the file for the *current* hour is only partly filled! You can
123 use from 1h up to 24h. Alternatively, you can request particular hours:
125 $ metarproxy --download 0 ... download first hour after midnight GMT
127 Ranges are allowed, too:
129 $ metarproxy --download 0-2 ... download first three hours after
132 These three methods can be used in combination:
134 $ metarproxy --download 6h 0-2 4
136 Files downloaded this way aren't stored on your systems in the same form
137 as they are offered under [1], but are already stored in the cache in a
138 different way (see section 5). Redundant strings are not stored, so it's safe
139 to --download the same hours more than once. This won't create duplicates.
146 The --download mode needs a sufficiently cheap and fast internet
147 connection. Sometimes it may be desirable to download the files directly
148 from the links (see [1]) on one computer, to burn them on a CD and then
149 to install them on the laptop. The downloaded files have names like
150 00Z.TXT to 23Z.TXT, whereby the number stands for the hour when they
151 were started. Only the last 24 hours are available for download.
152 If GMT is 1800, then 18Z.TXT will be the currently written and most
153 recent file. 19Z.TXT is already 23 hours old and will be overwritten
154 in one hour. To install such files in the cache, do this:
156 $ metarproxy --install 00Z.TXT 01Z.TXT
160 $ metarproxy --install ??Z.TXT
169 To record a set of stations over a period, without the need to download
170 several megabytes of data, you can use the record mode:
172 $ metarproxy --record KSFO KOAK KNUQ KSJC KCCR
174 The stations are then checked every 15 minutes and the METAR data
175 stored in the cache. Additionally, you can specify one or more files
178 $ metarproxy --record --file=$FG_HOME/station-list
179 $ metarproxy --record EDDM --file=/tmp/Austria --file=/tmp/Hungary
181 These files simply contain station IDs separated by spaces in one
185 LOWL LOWI LOWS LOWW LOWK LOWG
188 Some of the IDs are logically assigned, so that you can create a list
189 of, lets say, all Austrian METAR stations from FlightGear's METAR list:
191 $ zgrep "^LO" $FG_ROOT/Airports/metar.dat.gz > /tmp/Austria
192 $ zgrep "^ED" $FG_ROOT/Airports/metar.dat.gz > /tmp/Germany
193 $ zgrep "^EG" $FG_ROOT/Airports/metar.dat.gz > /tmp/UK
194 $ zgrep "^K" $FG_ROOT/Airports/metar.dat.gz > /tmp/USA
196 Quit the --record mode by Ctrl-C or killing the program.
202 3. run the metarproxy server
203 ============================
205 assuming that the cache directory is already set, you just need to
210 or with colored output and more log messages:
214 The proxy listens to port 5509 by default, but you can easily let
215 it use another port. As you can see, the proxy is quite liberal
216 with respect to option syntax:
218 $ metarproxy --port 1234
219 $ metarproxy --port=1234
228 4. let fgfs use the metar proxy
229 ===============================
231 All you need to do is point FlightGear to the metar proxy and let
232 it run at a simulated time for which you actually have cached METAR
235 $ fgfs --enable-real-weather-fetch --proxy=localhost:5509 \
236 --start-date-lat=2005:01:12:12:00:00
238 FlightGear will then fetch the metar data from the proxy as if it
239 were weather.noaa.gov. If no appropriate data set is found at all,
240 the proxy sends a default string. If data are found but older than
241 250 minutes, then the last successful data are sent again.
248 5. the cache organization
249 =========================
251 metarproxy puts all data for KSFO on 2005/1/19 into a directory
252 2005-01-19/K/KS/KSFO. The date directory name is used to find all
253 data for this day, but metarproxy will also look at the date in
254 particular METAR strings. So, renaming the directory to 2005/1/20
255 won't make the cached data available for the next day! You need
256 to set fgfs' GMT date to 2005/1/19. Also, if the simulated GMT
257 is midnight, then you will get midnight weather. You can't
258 enjoy midnight weather at daylight. The cache always delivers
259 the (past) real weather at simulated GMT.
265 6. download addresses
266 =====================
267 Download addresses for the last 24 hours:
269 http://weather.noaa.gov/pub/data/observations/metar/cycles/
270 ftp://weather.noaa.gov/data/observations/metar/cycles/
272 Addresses for the most recent METAR data strings of particular
275 http://weather.noaa.gov/pub/data/observations/metar/stations/
276 ftp://weather.noaa.gov/data/observations/metar/stations/
280 Melchior FRANZ <mfranz # aon : at>, 2005/1/24