phpweather-checkins Mailing List for PHP Weather (Page 3)
Brought to you by:
iridium
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(7) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(1) |
Feb
(1) |
Mar
(184) |
Apr
(31) |
May
(45) |
Jun
(15) |
Jul
(11) |
Aug
(40) |
Sep
(19) |
Oct
(8) |
Nov
(6) |
Dec
(17) |
2003 |
Jan
(5) |
Feb
|
Mar
(12) |
Apr
(5) |
May
(2) |
Jun
(3) |
Jul
(3) |
Aug
(3) |
Sep
(17) |
Oct
(10) |
Nov
|
Dec
(4) |
2004 |
Jan
(21) |
Feb
(11) |
Mar
|
Apr
|
May
(3) |
Jun
(7) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
(4) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Martin G. <gim...@us...> - 2003-12-30 16:19:42
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv28267 Modified Files: AUTHORS Log Message: Added Warren Rohner. I've also removed the email addresses (it occured to me that some people might want to keep it a secret, at least from the SPAM robots) and put in SourceForge login names instead where I could find them --- please object if this is a bad idea, and also mail me your login name if you want it listed. Index: AUTHORS =================================================================== RCS file: /cvsroot/phpweather/phpweather/AUTHORS,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- AUTHORS 10 Oct 2003 23:33:27 -0000 1.16 +++ AUTHORS 30 Dec 2003 16:19:38 -0000 1.17 @@ -6,110 +6,112 @@ Contributers to PHP Weather --------------------------- Everybody listed below has helped me in some way with the creation of -PHP Weather, and I'm very grateful to all of them. If, by some -mistake, your name isn't listed below, then send me a mail, and I'll -add it. --Martin Geisler <gim...@gi...> +PHP Weather, and I'm very grateful to all of them. + +If, by some mistake, your name isn't listed below, then send me a +mail, and I'll add it. Please include your SourceForge login, if any, +and an URL if you like. --Martin Geisler <gim...@gi...> The names are, in somewhat chronological order: -Kristian Kristensen <zi...@zi...> - Original discussions and a interface to PostgreSQL. +Kristian Kristensen (kkrz) + Original discussions and an interface to PostgreSQL. -Jeremy D. Zawodny <Je...@Za...> +Jeremy D. Zawodny For writing Geo::METAR, where I found the logick needed in PHP Weather. See http://www.wcnet.org/jzawodn/perl/Geo-METAR/index.html -Enrico Lodolo <e.l...@bo...> +Enrico Lodolo For suggesting that I use HTTP to get the METARs instead of the much slower FTP. -Stefan Wiesendanger <ste...@ep...> +Stefan Wiesendanger For rewritting some large case- and switch-statements as a couple of arrays. This speeds-up the parsing of the METARs. -Mike <bvr...@ly...> +Mike He noticed that the pressures was all wrong. I though the unit used in the METAR was hPa, when it really was inHg. -Jeffrey Y. Sue <jy...@ti...> +Jeffrey Y. Sue Suggested that I told people how to turn off the warnings, if you don't establish a connection to MySQL. Later he made it possible to use PHP Weather with DBM databases. He also added support for precipitation. Lots of other stuff, see the ChangeLog for more details. -Rutger Lubbers <ru...@no...> +Rutger Lubbers Noticed that South/southeast was duplicated in the directions-array. -Gogo "the Great" "Bongo,,,,"" <gr...@gr...> +Gogo "the Great" "Bongo,,,,"" Added support for PostgreSQL. -Eduardo Guilenea <ed...@gu...> +Eduardo Guilenea Translated PHP Weather into Spanish, and thereby forced me to add support for multiply languages. (Which was a Good Thing :-) -Sven-Erik <sve...@an...> +Sven-Erik Andersen (seasoft) Translated PHP Weather into Norwegian. He also sat down and did the boring work, when he manually compiled the complete list of all airports available from NWS. -Maciek Uhlig <mu...@us...> +Maciek Uhlig Noticed that I sometimes tried to access $cloud_coverage_array with just $cloud_coverage - which, of cause, didn't work. -Ing. Vladimir Kotala <ko...@in...> +Ing. Vladimir Kotala Suggested that I changed the long text '... degrees Celsius' into the more compact '... °C', which is much better. -Gyulai Mihály http://gyulai.freeyellow.com/ +Gyulai Mihály (misibacsi) http://gyulai.freeyellow.com/ Made the Hungarian translation for PHP Weather. He has also corrected tons of spelling errors. -Johnny Funder <jh...@sl...> +Johnny Funder Lots of explanations and suggestions. He also gave a much simpler formula for calculating the relative humidity. -Ray van Beek <r_v...@ho...> +Ray van Beek Helped me spot a little error with the current weather. He has also written code that displays the current weather as an image. -David Kjellquist <da...@kj...> +David Kjellquist Added support for windchill. -Max Hammond <ma...@fl...> +Max Hammond (iridium) Lots of different things: bugfixes, clever suggestions, and general maintenance. -Jesús Peñas <jp...@ed...> +Jesús Peñas Made the Spanish translation. -Ondrej Jombik <ne...@po...> +Ondrej Jombik (nepto) Translated PHP Weather into Slovak and rewrote the navigation system used in index.php. He also looked at the MySQL and PostgreSQL database and found some security flaws. -Reini Urban <ru...@xa...> +Reini Urban Fixed some problems with using PHP Weather on a default installation of PHP 4.2. -Kari Salovaara <kar...@pp...> and Tage Malmen +Kari Salovaara and Tage Malmen Translated PHP Weater into Swedish and Finnish. -Paul Kairis <Pau...@sa...> +Paul Kairis Wrote the code that handles connections through a proxy server. -Bas Elshof <ba...@el...> +Bas Elshof Translated PHP Weather into Dutch. -Václav Ríkal <va...@ph...> +Václav Ríkal Made a Czech translation. -Radoslava Fedáková <mor...@po...> +Radoslava Fedáková Czech translation. -Guillaume Petit <gp...@fr...> +Guillaume Petit Translated PHP Weather into French. Rudy Boedts @@ -122,14 +124,14 @@ Reported problems with the use of short open tags in a couple of files. -Jim Whitehead <ji...@tw...> +Jim Whitehead Fixed the rounding of hours and minutes in the pretty-printed report. -Ferhat Bingol <s0...@st...> +Ferhat Bingol Made a Turkish translation. -Renato Gallmetzer <ren...@re...> +Renato Gallmetzer Provided us with an Italian translation. Pablo Alcaraz (pabloa) @@ -140,6 +142,9 @@ database backends archive the data instead of always replacing the old data with new reports. -Justin Heideman <jus...@mc...> +Justin Heideman Drew a full set of beautiful icons for PHP Weather to display the current weather conditions. + +Warren Rohner + Updated South African statios in the stations.csv file. |
From: Martin G. <gim...@us...> - 2003-12-30 16:11:10
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv25651 Modified Files: data_retrieval.php Log Message: Removed a couple of old debug statements. Index: data_retrieval.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v retrieving revision 1.35 retrieving revision 1.36 diff -u -3 -r1.35 -r1.36 --- data_retrieval.php 2 Oct 2003 22:54:46 -0000 1.35 +++ data_retrieval.php 30 Dec 2003 16:01:40 -0000 1.36 @@ -285,7 +285,6 @@ if ($data = $this->db->get_metar($this->get_icao())) { /* found station */ $this->debug('get_metar_from_db(): Found the METAR in the database'); list($metar, $timestamp, $time) = end($data); - echo "metar: $metar timestamp:$timestamp time:$time<br>"; reset($data); /* We set the METAR right away, and then count on @@ -417,7 +416,6 @@ /* side effect */ $metar_time = $date[0].$date[1].$date[2].$date[3].$date[4]."00"; - echo "metar_time: $metar_time<br>"; /* We then cache the METAR in our database */ if ($new_station) { |
From: Martin G. <gim...@us...> - 2003-12-30 16:07:04
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv26329 Modified Files: stations.csv Log Message: Updated list of South African airports from Warren Rohner. Index: stations.csv =================================================================== RCS file: /cvsroot/phpweather/phpweather/stations.csv,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- stations.csv 28 Dec 2002 12:48:32 -0000 1.11 +++ stations.csv 30 Dec 2003 16:06:54 -0000 1.12 @@ -3319,52 +3319,52 @@ HCMH;Hargeisa HCMM;Mogadiscio +# Updated 30 December 2003 16:06:00 ## ZA;South Africa ## FAAB;Alexander Bay -FAAN;Aliwal North FABY;Beaufort West -FABM;Bethlehem Airport -FABL;Bloemfontein J. B. M. Hertzog +FABM;Bethlehem +FABL;Bloemfontein Airport FACV;Calvinia -FACT;Cape Town D. F. Malan -FACL;Carolina -FADA;De Aar -FADN;Durban Louis Botha -FAEL;East London +FACT;Cape Town International Airport +FADY;De Aar +FADN;Durban International Airport +FAEL;East London Airport FAER;Ellisras -FAFF;Frankfort -FAFR;Fraserburg +FAEO;Ermelo FAGG;George Airport -FAGE;Gough Island -FAGR;Graaff Reinet FAHS;Hoedspruit -FAJS;Jan Smuts -FAKM;Kimberley +FAJS;Johannesburg International Airport +FAKM;Kimberley Airport +FAKD;Klerksdorp FALY;Ladysmith FALW;Langebaanweg -FALT;Lichtenburg -FAME;Marion Island -FAMB;Middelburg +FALI;Lichtenburg +FALT;Louis Trichardt +FAMG;Margate FAMM;Mmabatho Airport -FAMO;Mossel Bay Cape Saint Blaize FANS;Nelspruit -FAOH;Oudtshoorn +FANC;Newcastle FAPH;Phalaborwa -FAPB;Pietersburg -FAPE;Port Elizabeth -FAPJ;Port St Johns +FAPM;Pietermaritzburg +FAPG;Plettenberg Bay +FAPB;Polokwane +FAPE;Port Elizabeth Airport +FAPS;Potchefstroom FAPR;Pretoria FAIR;Pretoria Irene -FAQT;Queenstown -FARB;Richard Bay +FARB;Richard's Bay +FARG;Rustenburg FASB;Springbok -FATC;Tristan Da Cunha +FASI;Springs +FASR;Standerton FAUT;Umtata -FAUP;Upington -FAVR;Vredendal -FAVB;Vryburg -FAWK;Waterkloof Lmb +FAUP;Upington Airport +FAVV;Vereeniging +FAVY;Vryheid +FAWK;Waterkloof FAWM;Welkom +FAWI;Witbank ## GS;South Georgia and the South Sandwich Islands ## EGYP;Mount Pleasant Airport |
From: Martin G. <gim...@us...> - 2003-10-23 12:52:26
|
Update of /cvsroot/phpweather/phpweather/output In directory sc8-pr-cvs1:/tmp/cvs-serv12968/output Modified Files: pw_text_nl.php Log Message: Fixes sent to me by Nico Out <nm...@hc...>. Index: pw_text_nl.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_nl.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- pw_text_nl.php 28 Dec 2002 12:24:42 -0000 1.2 +++ pw_text_nl.php 23 Oct 2003 12:25:00 -0000 1.3 @@ -103,10 +103,10 @@ $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'De relative luchtvochtigheid was '; $this->strings['feelslike'] = 'De gevoelstemperatuur was '; - $this->strings['cloud_group_beg'] = 'Het was '; + $this->strings['cloud_group_beg'] = 'Er waren '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'De lucht was %shelder%s.'; - $this->strings['cloud_height'] = ' bewolkt op een hoogte van '; + $this->strings['cloud_height'] = ' wolken op een hoogte van '; $this->strings['cloud_overcast'] = 'De lucht was %sbetrokken%s vanaf een hoogte van '; $this->strings['cloud_vertical_visibility'] = 'het %svertikale zicht%s was '; $this->strings['cloud_condition'] = |
From: Martin G. <gim...@us...> - 2003-10-10 23:33:33
|
Update of /cvsroot/phpweather/phpweather/doc/src In directory sc8-pr-cvs1:/tmp/cvs-serv5109/doc/src Modified Files: phpweather.texi Log Message: Added latest contributors. I think the AUTHORS file ought to be linked to the Contributors section in the Texinfo source so that the two doesn't have to be keept synchronized. Index: phpweather.texi =================================================================== RCS file: /cvsroot/phpweather/phpweather/doc/src/phpweather.texi,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- phpweather.texi 28 Dec 2002 14:13:53 -0000 1.4 +++ phpweather.texi 10 Oct 2003 23:33:27 -0000 1.5 @@ -2,6 +2,7 @@ @c %**start of header @setfilename phpweather.info @settitle PHP Weather User and Reference Guide +@documentencoding ISO-8859-1 @c @setchapternewpage odd @c %**end of header @@ -17,7 +18,7 @@ @c The following two commands start the copyright page. @page @vskip 0pt plus 1filll -Copyright @copyright{} 2002 Martin Geisler and others, see +Copyright @copyright{} 2002, 2003 Martin Geisler and others, see @ref{Contributors}. Permission is granted to copy, distribute and/or modify this document @@ -494,13 +495,21 @@ The variable @code{$data} is now an multidimensional associative array filled with all the information that the @code{decode_metar} function -was able to extract from the METAR. The different parts in -the METAR is stored under specific keys in the array --- if -the METAR lacks a given part, then the corresponding entry -in the array will be left out. This means, that you'll have to check -each entry with @code{empty} before you use it, otherwise you see -warnings from PHP, if you've set the error reporting level -high enough. +was able to extract from the METAR. The different parts in the METAR +is stored under specific keys in the array --- if the METAR lacks a +given part, then the corresponding entry in the array will be left +out. This means, that you'll have to check each entry with +@code{empty} before you use it, otherwise you see warnings from PHP, +if you've set the error reporting level high enough. + +You can have PHP show you the structure of the array by using the +builtin @code{print_r} function like this: + +@example +echo "<pre>\n"; +print_r($data); +echo "</pre>\n"; +@end example The following entries is always part of a METAR report, and is therefore always part of the decoded METAR array: @@ -525,7 +534,8 @@ @end table -The following entries are optional: +The following entries are all optional so check with @code{empty} +before accessing them: @table @code @@ -543,7 +553,7 @@ The @code{meters_per_second}, @code{miles_per_hour}, and @code{knots} entries tells you the wind speed in various units. -If gust was observer, there will be three extra entries: +If gust was observed, there will be three extra entries: @code{gust_meters_per_second}, @code{gust_miles_per_hour}, and @code{gust_knots}. @@ -586,7 +596,10 @@ @item weather This holds the current weather phenomena and is one of the most -interesting groups. It's an array of weather groups. +interesting groups. It's an array of weather groups which means that +the the first group will be @code{$data['weather'][0]}, the second +group (if there is such a group) will be @code{$data['weather'][1]}, +and so on. Each group contains a @code{proximity} entry which can be either @samp{VC} for phenomena in the vicinity or the empty string otherwise. @@ -707,6 +720,16 @@ Add support for other timezones than UTC so that people can say that they want the time reported in their local timezone. +@item +Have PHP Weather calculate the time of sunset and -rize automatically +based on latitude and longitude data for the stations. This +information would be used to select correct sun/moon images. + +@item +It should be possible to calculate the local time for a given station +based on the same geographical data combined with data about local +daylight saving times. + @end itemize @@ -728,27 +751,25 @@ etc.) that could display the weather. I discovered that they got their data from the NWS who makes the data available at no cost. -The data is available off the Internet via either FTP or -HTTP, so it's easy to get hold of it with PHP. The -only problem was that the data has to be decoded because it's written -in a compact fashion. The data in question is a so-called -METAR report that the airports issue once or twice an hour. - -I then discovered a script written in Perl that could take a -METAR and split it into it's components. The script was -written by Jeremy D. Zawodny @email{Jeremy@@Zawodny.com} and is -licensed under the GPL just like PHP Weather. So there was -no problem with me peeping at his code for PHP Weather. I took the -logic from the Perl script and wrote a function in PHP that -would decode a METAR. +The data is available off the Internet via either FTP or HTTP, so it's +easy to get hold of it with PHP. The only problem was that the data +has to be decoded because it's written in a compact fashion. The data +in question is a so-called METAR report that the airports issue once +or twice an hour. + +I then discovered a script written in Perl that could take a METAR and +split it into it's components. The script was written by Jeremy +D. Zawodny @email{Jeremy@@Zawodny.com} and is licensed under the GPL +just like PHP Weather. So there was no problem with me peeping at his +code for PHP Weather. I took the logic from the Perl script and wrote +a function in PHP that would decode a METAR. But that wouldn't do it --- to be useful the decoded data has to be displayed in a nice fashion, preferable so that it's easy to -customize. The script should also be able to fetch a METAR -from the NWS and once that is done, the METAR -should be cached so that the script would run faster after the -METAR had been fetched once. The problem is, that it takes -about a second to contact the NWS. +customize. The script should also be able to fetch a METAR from the +NWS and once that is done, the METAR should be cached so that the +script would run faster after the METAR had been fetched once. The +problem is, that it takes about a second to contact the NWS. I wanted to see the data I could extract from the METAR in a meaningfull way, so I started wrapping the data in English words to @@ -777,8 +798,8 @@ mess. So I started to split the file up into several files, and also started -to use classes in PHP. This was the first time I had to do -an Object Oriented design, so it was very exciting. +to use classes in PHP. This was the first time I had to do an object +oriented design, so it was very exciting. The result is the current PHP Weather, and it does have a quite flexible structure. All locale-specific code has been moved out from @@ -794,7 +815,10 @@ @chapter Contributors @noindent -The following people have contributed to PHP Weather: +Everybody listed below has helped in some way with the creation of PHP +Weather. If, by some mistake, your name isn't listed below, then send +a mail to @email{gimpster@@gimpster.com} so that proper credit can +given. @table @asis @@ -882,6 +906,85 @@ Lots of different things: bugfixes, clever suggestions, and general maintenance. + +@item Jes@'us Pe@=nas @email{jpc@@educaplus.org} + +Made the Spanish translation. + +@item Ondrej Jombik @email{nepto@@pobox.sk} + +Translated PHP Weather into Slovak and rewrote the navigation system +used in index.php. He also looked at the MySQL and PostgreSQL database +and found some security flaws. + +@item Reini Urban @email{rurban@@xarch.tu-graz.ac.at} + +Fixed some problems with using PHP Weather on a default installation +of PHP 4.2. + +@item Kari Salovaara @email{kari.salovaara@@pp1.inet.fi} and Tage Malmen + +Translated PHP Weater into Swedish and Finnish. + +@item Paul Kairis @email{Paul.Kairis@@sas.com} + +Wrote the code that handles connections through a proxy server. + +@item Bas Elshof @email{bas@@elshof.de} + +Translated PHP Weather into Dutch. + +@item V@'aclav R@'{@dotless{i}}kal @email{vaclavr@@physics.muni.cz} + +Made a Czech translation. + +@item Radoslava Fed@'akov@'a @email{mortischka@@pobox.sk} + +Czech translation. + +@item Guillaume Petit @email{gpetit@@fr.st} + +Translated PHP Weather into French. + +@item Rudy Boedts + +Updated the Dutch translation. + +@item Konrad Tadesse + +Finally, a working German translation. + +@item Andrew Simpson (andrewsimpson) + +Reported problems with the use of short open tags in a couple of +files. + +@item Jim Whitehead @email{jim@@twopalms.com} + +Fixed the rounding of hours and minutes in the pretty-printed report. + +@item Ferhat Bingol @email{s021183@@student.dtu.dk} + +Made a Turkish translation. + +@item Renato Gallmetzer @email{renatogl@@renatogl.com} + +Provided us with an Italian translation. + +@item Pablo Alcaraz (pabloa) + +Updated the Spanish translation and other bugfixes. + +@item Etienne Tourigny (etienne_t) + +Added a method that decodes TAF reports and made some of the database +backends archive the data instead of always replacing the old data +with new reports. + +@item Justin Heideman @email{justin_heideman@@mcad.edu} + +Drew a full set of beautiful icons for PHP Weather to display the +current weather conditions. @end table |
From: Martin G. <gim...@us...> - 2003-10-10 23:33:32
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv5109 Modified Files: AUTHORS Log Message: Added latest contributors. I think the AUTHORS file ought to be linked to the Contributors section in the Texinfo source so that the two doesn't have to be keept synchronized. Index: AUTHORS =================================================================== RCS file: /cvsroot/phpweather/phpweather/AUTHORS,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- AUTHORS 2 Sep 2003 18:06:33 -0000 1.15 +++ AUTHORS 10 Oct 2003 23:33:27 -0000 1.16 @@ -134,3 +134,12 @@ Pablo Alcaraz (pabloa) Updated the Spanish translation and other bugfixes. + +Etienne Tourigny (etienne_t) + Added a method that decodes TAF reports and made some of the + database backends archive the data instead of always replacing the + old data with new reports. + +Justin Heideman <jus...@mc...> + Drew a full set of beautiful icons for PHP Weather to display the + current weather conditions. |
From: Martin G. <gim...@us...> - 2003-10-07 22:41:28
|
Update of /cvsroot/phpweather/phpweather/icons In directory sc8-pr-cvs1:/tmp/cvs-serv28957 Removed Files: vrb.png Log Message: That one shouldn't have been commited, for I'm keeping the animated GIF image for the variable wind conditions. I would have preffered to convert it into a MNG movie, but the MNG format still isn't supported by any major browsers --- they've even recently removed support for MNG animations from Mozilla... :-( --- BINARY FILE --- |
From: Martin G. <gim...@us...> - 2003-10-07 22:31:58
|
Update of /cvsroot/phpweather/phpweather/output In directory sc8-pr-cvs1:/tmp/cvs-serv28692/output Modified Files: pw_images.php Log Message: From GIF to PNG images all around. Index: pw_images.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_images.php,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- pw_images.php 5 Mar 2003 19:53:23 -0000 1.8 +++ pw_images.php 7 Oct 2003 22:31:54 -0000 1.9 @@ -51,63 +51,63 @@ 'OVC' => '4', 'VV' => '4'); - var $sky_nodata_image = 'sky_nodata.gif'; + var $sky_nodata_image = 'sky_nodata.png'; // Define a lot of images for daylight weather-group/cloud // condition. It's a 2-dimensional array, indexed by the: // - Precipitation (first index) // - Cloud coverage (second index). - var $images = array ('None' => array ('0' => '0cloud.gif', - '1' => '1cloud_norain.gif', - '2' => '2cloud_norain.gif', - '3' => '3cloud_norain.gif', - '4' => '4cloud_norain.gif'), - '-Rain' => array ('0' => '0cloud.gif', - '1' => '1cloud_lightrain.gif', - '2' => '2cloud_lightrain.gif', - '3' => '3cloud_lightrain.gif', - '4' => '4cloud_lightrain.gif'), - 'Rain' => array ('0' => '0cloud.gif', - '1' => '1cloud_modrain.gif', - '2' => '2cloud_modrain.gif', - '3' => '3cloud_modrain.gif', - '4' => '4cloud_modrain.gif'), - '+Rain' => array ('0' => '0cloud.gif', - '1' => '1cloud_heavyrain.gif', - '2' => '2cloud_heavyrain.gif', - '3' => '3cloud_heavyrain.gif', - '4' => '4cloud_heavyrain.gif'), - '-Snow' => array ('0' => '0cloud.gif', - '1' => '2cloud_snow.gif', - '2' => '2cloud_snow.gif', - '3' => '3cloud_snow.gif', - '4' => '4cloud_lightsnow.gif'), - '+Snow' => array ('0' => '0cloud.gif', - '1' => '2cloud_snow.gif', - '2' => '2cloud_snow.gif', - '3' => '3cloud_snow.gif', - '4' => '4cloud_heavysnow.gif'), - '-Hail' => array ('0' => '0cloud.gif', - '1' => '2cloud_hail.gif', - '2' => '2cloud_hail.gif', - '3' => '3cloud_hail.gif', - '4' => '4cloud_lighthail.gif'), - '+Hail' => array ('0' => '0cloud.gif', - '1' => '2cloud_hail.gif', - '2' => '2cloud_hail.gif', - '3' => '3cloud_hail.gif', - '4' => '4cloud_heavyhail.gif'), - 'Thun' => array ('0' => '0cloud.gif', - '1' => '2cloud_thunders.gif', - '2' => '2cloud_thunders.gif', - '3' => '3cloud_thunders.gif', - '4' => '4cloud_thunders.gif'), - 'Fog' => array ('0' => '0cloud_fog.gif', - '1' => '1cloud_fog.gif', - '2' => '2cloud_fog.gif', - '3' => '3cloud_fog.gif', - '4' => '4cloud_fog.gif') + var $images = array ('None' => array ('0' => '0cloud.png', + '1' => '1cloud_norain.png', + '2' => '2cloud_norain.png', + '3' => '3cloud_norain.png', + '4' => '4cloud_norain.png'), + '-Rain' => array ('0' => '0cloud.png', + '1' => '1cloud_lightrain.png', + '2' => '2cloud_lightrain.png', + '3' => '3cloud_lightrain.png', + '4' => '4cloud_lightrain.png'), + 'Rain' => array ('0' => '0cloud.png', + '1' => '1cloud_modrain.png', + '2' => '2cloud_modrain.png', + '3' => '3cloud_modrain.png', + '4' => '4cloud_modrain.png'), + '+Rain' => array ('0' => '0cloud.png', + '1' => '1cloud_heavyrain.png', + '2' => '2cloud_heavyrain.png', + '3' => '3cloud_heavyrain.png', + '4' => '4cloud_heavyrain.png'), + '-Snow' => array ('0' => '0cloud.png', + '1' => '2cloud_snow.png', + '2' => '2cloud_snow.png', + '3' => '3cloud_snow.png', + '4' => '4cloud_lightsnow.png'), + '+Snow' => array ('0' => '0cloud.png', + '1' => '2cloud_snow.png', + '2' => '2cloud_snow.png', + '3' => '3cloud_snow.png', + '4' => '4cloud_heavysnow.png'), + '-Hail' => array ('0' => '0cloud.png', + '1' => '2cloud_hail.png', + '2' => '2cloud_hail.png', + '3' => '3cloud_hail.png', + '4' => '4cloud_lighthail.png'), + '+Hail' => array ('0' => '0cloud.png', + '1' => '2cloud_hail.png', + '2' => '2cloud_hail.png', + '3' => '3cloud_hail.png', + '4' => '4cloud_heavyhail.png'), + 'Thun' => array ('0' => '0cloud.png', + '1' => '2cloud_thunders.png', + '2' => '2cloud_thunders.png', + '3' => '3cloud_thunders.png', + '4' => '4cloud_thunders.png'), + 'Fog' => array ('0' => '0cloud_fog.png', + '1' => '1cloud_fog.png', + '2' => '2cloud_fog.png', + '3' => '3cloud_fog.png', + '4' => '4cloud_fog.png') ); // Define a lot of images for nigh time weather-group/cloud @@ -117,56 +117,56 @@ // - Cloud coverage (second index). var $n_images = array ( - 'None' => array ('0' => 'n_0cloud.gif', - '1' => 'n_1cloud_norain.gif', - '2' => 'n_2cloud_norain.gif', - '3' => 'n_3cloud_norain.gif', - '4' => '4cloud_norain.gif'), - '-Rain' => array ('0' => 'n_0cloud.gif', - '1' => 'n_1cloud_lightrain.gif', - '2' => 'n_2cloud_lightrain.gif', - '3' => 'n_3cloud_lightrain.gif', - '4' => '4cloud_lightrain.gif'), - 'Rain' => array ('0' => 'n_0cloud.gif', - '1' => 'n_1cloud_modrain.gif', - '2' => 'n_2cloud_modrain.gif', - '3' => 'n_3cloud_modrain.gif', - '4' => '4cloud_modrain.gif'), - '+Rain' => array ('0' => 'n_0cloud.gif', - '1' => 'n_1cloud_heavyrain.gif', - '2' => 'n_2cloud_heavyrain.gif', - '3' => 'n_3cloud_heavyrain.gif', - '4' => '4cloud_heavyrain.gif'), - '-Snow' => array ('0' => 'n_0cloud.gif', - '1' => 'n_2cloud_snow.gif', - '2' => 'n_2cloud_snow.gif', - '3' => 'n_3cloud_snow.gif', - '4' => '4cloud_lightsnow.gif'), - '+Snow' => array ('0' => 'n_0cloud.gif', - '1' => 'n_2cloud_snow.gif', - '2' => 'n_2cloud_snow.gif', - '3' => 'n_3cloud_snow.gif', - '4' => '4cloud_heavysnow.gif'), - '-Hail' => array ('0' => 'n_0cloud.gif', - '1' => 'n_2cloud_hail.gif', - '2' => 'n_2cloud_hail.gif', - '3' => 'n_3cloud_hail.gif', - '4' => '4cloud_lighthail.gif'), - '+Hail' => array ('0' => 'n_0cloud.gif', - '1' => 'n_2cloud_hail.gif', - '2' => 'n_2cloud_hail.gif', - '3' => 'n_3cloud_hail.gif', - '4' => '4cloud_heavyhail.gif'), - 'Thun' => array ('0' => 'n_0cloud.gif', - '1' => 'n_2cloud_thunders.gif', - '2' => 'n_2cloud_thunders.gif', - '3' => 'n_3cloud_thunders.gif', - '4' => '4cloud_thunders.gif'), - 'Fog' => array ('0' => 'n_0cloud_fog.gif', - '1' => 'n_1cloud_fog.gif', - '2' => 'n_2cloud_fog.gif', - '3' => 'n_3cloud_fog.gif', - '4' => '4cloud_fog.gif') + 'None' => array ('0' => 'n_0cloud.png', + '1' => 'n_1cloud_norain.png', + '2' => 'n_2cloud_norain.png', + '3' => 'n_3cloud_norain.png', + '4' => '4cloud_norain.png'), + '-Rain' => array ('0' => 'n_0cloud.png', + '1' => 'n_1cloud_lightrain.png', + '2' => 'n_2cloud_lightrain.png', + '3' => 'n_3cloud_lightrain.png', + '4' => '4cloud_lightrain.png'), + 'Rain' => array ('0' => 'n_0cloud.png', + '1' => 'n_1cloud_modrain.png', + '2' => 'n_2cloud_modrain.png', + '3' => 'n_3cloud_modrain.png', + '4' => '4cloud_modrain.png'), + '+Rain' => array ('0' => 'n_0cloud.png', + '1' => 'n_1cloud_heavyrain.png', + '2' => 'n_2cloud_heavyrain.png', + '3' => 'n_3cloud_heavyrain.png', + '4' => '4cloud_heavyrain.png'), + '-Snow' => array ('0' => 'n_0cloud.png', + '1' => 'n_2cloud_snow.png', + '2' => 'n_2cloud_snow.png', + '3' => 'n_3cloud_snow.png', + '4' => '4cloud_lightsnow.png'), + '+Snow' => array ('0' => 'n_0cloud.png', + '1' => 'n_2cloud_snow.png', + '2' => 'n_2cloud_snow.png', + '3' => 'n_3cloud_snow.png', + '4' => '4cloud_heavysnow.png'), + '-Hail' => array ('0' => 'n_0cloud.png', + '1' => 'n_2cloud_hail.png', + '2' => 'n_2cloud_hail.png', + '3' => 'n_3cloud_hail.png', + '4' => '4cloud_lighthail.png'), + '+Hail' => array ('0' => 'n_0cloud.png', + '1' => 'n_2cloud_hail.png', + '2' => 'n_2cloud_hail.png', + '3' => 'n_3cloud_hail.png', + '4' => '4cloud_heavyhail.png'), + 'Thun' => array ('0' => 'n_0cloud.png', + '1' => 'n_2cloud_thunders.png', + '2' => 'n_2cloud_thunders.png', + '3' => 'n_3cloud_thunders.png', + '4' => '4cloud_thunders.png'), + 'Fog' => array ('0' => 'n_0cloud_fog.png', + '1' => 'n_1cloud_fog.png', + '2' => 'n_2cloud_fog.png', + '3' => 'n_3cloud_fog.png', + '4' => '4cloud_fog.png') ); // Define image filenames for: @@ -175,37 +175,37 @@ // - variable wind direction (VRB) // - calm wind (00000KT), or 'nodir' - var $wind_dir_images = array (0 => 'nnn.gif', - 1 => 'nne.gif', - 2 => 'ne.gif', - 3 => 'nee.gif', - 4 => 'eee.gif', - 5 => 'see.gif', - 6 => 'se.gif', - 7 => 'sse.gif', - 8 => 'sss.gif', - 9 => 'ssw.gif', - 10 => 'sw.gif', - 11 => 'sww.gif', - 12 => 'www.gif', - 13 => 'nww.gif', - 14 => 'nw.gif', - 15 => 'nnw.gif', - 16 => 'nnn.gif'); + var $wind_dir_images = array (0 => 'nnn.png', + 1 => 'nne.png', + 2 => 'ne.png', + 3 => 'nee.png', + 4 => 'eee.png', + 5 => 'see.png', + 6 => 'se.png', + 7 => 'sse.png', + 8 => 'sss.png', + 9 => 'ssw.png', + 10 => 'sw.png', + 11 => 'sww.png', + 12 => 'www.png', + 13 => 'nww.png', + 14 => 'nw.png', + 15 => 'nnw.png', + 16 => 'nnn.png'); - var $wind_nodata_image = 'wind_nodata.gif'; + var $wind_nodata_image = 'wind_nodata.png'; var $wind_vrb_image = 'vrb.gif'; - var $wind_nodir_image = 'nodir.gif'; + var $wind_nodir_image = 'nodir.png'; // Define image filenames for: // - 'no data' condition, // - 'temperature zero or below zero degrees Celcius // - 'temperature above zero degrees Celcius - var $temp_nodata_image = 'temp_nodata.gif'; - var $temp_low_image = 'templow.gif'; - var $temp_high_image = 'temphigh.gif'; - var $temp_windchilled_image = 'tempchilled.gif'; + var $temp_nodata_image = 'temp_nodata.png'; + var $temp_low_image = 'templow.png'; + var $temp_high_image = 'temphigh.png'; + var $temp_windchilled_image = 'tempchilled.png'; // ====================================================================== // The wind_speeds array can be used to convert wind speed values in |
From: Martin G. <gim...@us...> - 2003-10-07 22:31:58
|
Update of /cvsroot/phpweather/phpweather/config In directory sc8-pr-cvs1:/tmp/cvs-serv28692/config Modified Files: connectivity_test.php index.php make_config.php make_db.php make_stations.php speed_test.php Log Message: From GIF to PNG images all around. Index: connectivity_test.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/connectivity_test.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- connectivity_test.php 16 Jan 2003 12:52:29 -0000 1.2 +++ connectivity_test.php 7 Oct 2003 22:31:54 -0000 1.3 @@ -20,7 +20,7 @@ ?> -<img src="../icons/phpweather-long-white.gif" width="187" height="50" +<img src="../icons/phpweather-long-white.png" width="187" height="50" alt="PHP Weather" align="right" /> <h1>Connectivity Test for PHP Weather</h1> Index: index.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/index.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- index.php 16 Jan 2003 12:50:32 -0000 1.10 +++ index.php 7 Oct 2003 22:31:54 -0000 1.11 @@ -8,7 +8,7 @@ </head> <body> -<img src="../icons/phpweather-long-white.gif" width="187" height="50" +<img src="../icons/phpweather-long-white.png" width="187" height="50" alt="PHP Weather" align="right" /> <h1>Configuration of PHP Weather</h1> Index: make_config.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/make_config.php,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- make_config.php 8 Sep 2003 07:51:25 -0000 1.11 +++ make_config.php 7 Oct 2003 22:31:54 -0000 1.12 @@ -482,7 +482,7 @@ } </script> -<img src="../icons/phpweather-long-white.gif" width="187" height="50" +<img src="../icons/phpweather-long-white.png" width="187" height="50" alt="PHP Weather" align="right" /> <h1>Configuration Builder for PHP Weather</h1> Index: make_db.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/make_db.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- make_db.php 22 Apr 2003 20:49:26 -0000 1.4 +++ make_db.php 7 Oct 2003 22:31:54 -0000 1.5 @@ -8,7 +8,7 @@ </head> <body> -<img src="../icons/phpweather-long-white.gif" width="187" height="50" +<img src="../icons/phpweather-long-white.png" width="187" height="50" alt="PHP Weather" align="right" /> <h1>Database Builder for PHP Weather</h1> Index: make_stations.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/make_stations.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- make_stations.php 29 May 2002 20:42:56 -0000 1.3 +++ make_stations.php 7 Oct 2003 22:31:54 -0000 1.4 @@ -46,7 +46,7 @@ </head> <body> -<img src="../icons/phpweather-long-white.gif" width="187" height="50" +<img src="../icons/phpweather-long-white.png" width="187" height="50" alt="PHP Weather" align="right" /> <h1>Stations Database Rebuilder for PHP Weather</h1> Index: speed_test.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/speed_test.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- speed_test.php 14 Jul 2002 23:03:56 -0000 1.3 +++ speed_test.php 7 Oct 2003 22:31:54 -0000 1.4 @@ -8,7 +8,7 @@ </head> <body> -<img src="../icons/phpweather-long-white.gif" width="187" height="50" +<img src="../icons/phpweather-long-white.png" width="187" height="50" alt="PHP Weather" align="right" /> <h1>PHP Weather Speed Test</h1> |
From: Martin G. <gim...@us...> - 2003-10-07 22:31:58
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv28692 Modified Files: currentimage.php index.php test.php Log Message: From GIF to PNG images all around. Index: currentimage.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/currentimage.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- currentimage.php 4 Jun 2002 12:11:27 -0000 1.1 +++ currentimage.php 7 Oct 2003 22:31:54 -0000 1.2 @@ -1,28 +1,26 @@ <?php /* -* currentimage.php -* Return the current weather icon directly. - Can be used from -* HTML rather than PHP files. -* -* Use: <img src="currentimage.php?icao=abcd" /> in your html -* + * currentimage.php + * Return the current weather icon directly. - Can be used from + * HTML rather than PHP files. + * + * Use: <img src="currentimage.php?icao=abcd" /> in your html + * */ error_reporting(E_NONE); require('phpweather.php'); +require(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); -$weather = new phpweather(array()); +$weather = new phpweather(); +$weather->set_icao($icao); - $weather->set_icao($icao); - - include(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); - $icons = new pw_images($weather, array()); - header('Content-Type: image/gif'); - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified - header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 - header("Pragma: no-cache"); // HTTP/1.0 - readfile($icons->get_sky_image()); - +$icons = new pw_images($weather); +header('Content-Type: image/png'); +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past +header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified +header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header("Pragma: no-cache"); // HTTP/1.0 +readfile($icons->get_sky_image()); ?> Index: index.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/index.php,v retrieving revision 1.40 retrieving revision 1.41 diff -u -3 -r1.40 -r1.41 --- index.php 2 Sep 2003 18:06:08 -0000 1.40 +++ index.php 7 Oct 2003 22:31:54 -0000 1.41 @@ -19,7 +19,7 @@ </head> <body> -<img src="icons/phpweather-long-white.gif" width="187" height="50" +<img src="icons/phpweather-long-white.png" width="187" height="50" alt="PHP Weather" align="right" /> <h1>PHP Weather Test Page</h1> Index: test.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/test.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- test.php 14 Jun 2003 23:35:38 -0000 1.7 +++ test.php 7 Oct 2003 22:31:54 -0000 1.8 @@ -7,7 +7,7 @@ </head> <body> -<img src="icons/phpweather-long-white.gif" width="187" height="50" +<img src="icons/phpweather-long-white.png" width="187" height="50" alt="PHP Weather" align="right" /> <h1>PHP Weather Test Page</h1> |
From: Martin G. <gim...@us...> - 2003-10-07 22:30:21
|
Update of /cvsroot/phpweather/phpweather/icons In directory sc8-pr-cvs1:/tmp/cvs-serv28036 Added Files: 0cloud.png 0cloud_fog.png 1cloud_fog.png 1cloud_heavyrain.png 1cloud_lightrain.png 1cloud_modrain.png 1cloud_norain.png 2cloud_fog.png 2cloud_hail.png 2cloud_heavyrain.png 2cloud_lightrain.png 2cloud_modrain.png 2cloud_norain.png 2cloud_snow.png 2cloud_thunders.png 3cloud_fog.png 3cloud_hail.png 3cloud_heavyrain.png 3cloud_lightrain.png 3cloud_modrain.png 3cloud_norain.png 3cloud_snow.png 3cloud_thunders.png 4_cloud_modrain.png 4cloud_fog.png 4cloud_hail.png 4cloud_heavyhail.png 4cloud_heavyrain.png 4cloud_heavysnow.png 4cloud_lighthail.png 4cloud_lightrain.png 4cloud_lightsnow.png 4cloud_modrain.png 4cloud_norain.png 4cloud_thunders.png eee.png n_0cloud.png n_0cloud_fog.png n_1cloud_fog.png n_1cloud_heavyrain.png n_1cloud_lightrain.png n_1cloud_modrain.png n_1cloud_norain.png n_2cloud_fog.png n_2cloud_hail.png n_2cloud_heavyrain.png n_2cloud_lightrain.png n_2cloud_modrain.png n_2cloud_norain.png n_2cloud_snow.png n_2cloud_thunders.png n_3cloud_fog.png n_3cloud_hail.png n_3cloud_heavyrain.png n_3cloud_lightrain.png n_3cloud_modrain.png n_3cloud_norain.png n_3cloud_snow.png n_3cloud_thunders.png ne.png nee.png nne.png nnn.png nnw.png nodir.png nw.png nww.png phpweather-black.png phpweather-long-black.png phpweather-long-white.png phpweather-white.png se.png see.png sse.png sss.png ssw.png sw.png sww.png temp_nodata.png tempchilled.png temphigh.png templow.png vrb.png wind_nodata.png www.png Removed Files: 0cloud.gif 0cloud_fog.gif 1cloud_fog.gif 1cloud_heavyrain.gif 1cloud_lightrain.gif 1cloud_modrain.gif 1cloud_norain.gif 2cloud_fog.gif 2cloud_hail.gif 2cloud_heavyrain.gif 2cloud_lightrain.gif 2cloud_modrain.gif 2cloud_norain.gif 2cloud_snow.gif 2cloud_thunders.gif 3cloud_fog.gif 3cloud_hail.gif 3cloud_heavyrain.gif 3cloud_lightrain.gif 3cloud_modrain.gif 3cloud_norain.gif 3cloud_snow.gif 3cloud_thunders.gif 4cloud_fog.gif 4cloud_heavyhail.gif 4cloud_heavyrain.gif 4cloud_heavysnow.gif 4cloud_lighthail.gif 4cloud_lightrain.gif 4cloud_lightsnow.gif 4cloud_modrain.gif 4cloud_norain.gif 4cloud_thunders.gif eee.gif n_0cloud.gif n_0cloud_fog.gif n_1cloud_fog.gif n_1cloud_heavyrain.gif n_1cloud_lightrain.gif n_1cloud_modrain.gif n_1cloud_norain.gif n_2cloud_fog.gif n_2cloud_hail.gif n_2cloud_heavyrain.gif n_2cloud_lightrain.gif n_2cloud_modrain.gif n_2cloud_norain.gif n_2cloud_snow.gif n_2cloud_thunders.gif n_3cloud_fog.gif n_3cloud_hail.gif n_3cloud_heavyrain.gif n_3cloud_lightrain.gif n_3cloud_modrain.gif n_3cloud_norain.gif n_3cloud_snow.gif n_3cloud_thunders.gif ne.gif nee.gif nne.gif nnn.gif nnw.gif nodir.gif nw.gif nww.gif phpweather-black.gif phpweather-long-black.gif phpweather-long-white.gif phpweather-white.gif se.gif see.gif sse.gif sss.gif ssw.gif sw.gif sww.gif temp_nodata.gif tempchilled.gif temphigh.gif templow.gif wind_nodata.gif www.gif Log Message: Out with GIF images, in with new, beautiful PNG images drawn by Justin Heideman! --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- --- BINARY FILE --- |
From: Etienne T. <eti...@us...> - 2003-10-02 22:54:53
|
Update of /cvsroot/phpweather/phpweather/db In directory sc8-pr-cvs1:/tmp/cvs-serv19332/db Modified Files: pw_db_adodb.php pw_db_mysql.php Log Message: Added retrieval of archived metars. The current METAR is still in metar and decoded_metar, time is in YYYYDDMMhhmmss format. There are additionnal arrays metar_arch decoded_metar_arch which contain all the METARs in the period set by data_retrieval::set_times(). Modified db/pw_adodb.php and db/pw_mysql.php. Index: pw_db_adodb.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/db/pw_db_adodb.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- pw_db_adodb.php 10 Nov 2002 23:15:42 -0000 1.1 +++ pw_db_adodb.php 2 Oct 2003 22:54:46 -0000 1.2 @@ -70,6 +70,8 @@ $this->link_id = &ADONewConnection($this->properties['db_adodb_driver']); + $this->link_id->SetFetchMode(ADODB_FETCH_BOTH); + if ($this->properties['db_pconnect']) { $this->link_id->PConnect($this->properties['db_hostname'], $this->properties['db_username'], @@ -189,14 +191,16 @@ * @param string The ICAO of the station. * @param string The raw METAR. * @param integer A standard UNIX timestamp. + * @param string The time of the report * @access public * @see update_metar() */ - function insert_metar($icao, $metar, $timestamp) { - $this->query(sprintf('INSERT INTO %s SET icao = "%s", ' . - 'metar = "%s", timestamp = FROM_UNIXTIME(%d)', - $this->properties['db_metars'], $icao, - addslashes($metar), intval($timestamp))); + function insert_metar($icao, $metar, $timestamp, $time) { + $this->query(sprintf('INSERT INTO %s SET icao = "%s", time = "%s", ' . + 'metar = "%s", timestamp = FROM_UNIXTIME(%d)', + $this->properties['db_metars'], $icao, $time, + addslashes($metar), intval($timestamp))); + $this->insert_metar_arch($icao, $metar, $time); } @@ -206,17 +210,48 @@ * @param string The ICAO of the station. * @param string The raw METAR. * @param integer A standard UNIX timestamp. + * @param string The time of the report * @access public * @see insert_metar() */ - function update_metar($icao, $metar, $timestamp) { + function update_metar($icao, $metar, $timestamp, $time) { $this->query(sprintf('UPDATE %s' . ' SET metar = "%s", timestamp = FROM_UNIXTIME(%d)' . ' WHERE icao = "%s"', $this->properties['db_metars'], addslashes($metar), intval($timestamp), $icao)); + $this->insert_metar_arch($icao, $metar, $time); + } + + + /** + * Inserts an archive METAR into the database. + * + * @param string The ICAO of the station. + * @param string The raw METAR. + * @param integer The time of the report. + * @access public + */ + function insert_metar_arch($icao, $metar, $time) { + if(isset($this->properties['archive_metars']) && + $this->properties['archive_metars']==true) { + $this->query(sprintf('SHOW TABLES LIKE "%s"', + $this->properties['db_metars_arch'])); + if ($this->num_rows()==1) { + $this->query(sprintf('DELETE FROM %s WHERE icao = "%s" AND ' . + 'time = "%s"' , + $this->properties['db_metars_arch'], + $icao,$time)); + $this->query(sprintf('INSERT IGNORE INTO %s SET icao = "%s", ' . + 'time = "%s", ' . + 'metar = "%s"', + $this->properties['db_metars_arch'], $icao, + $time, + addslashes($metar))); + } + } } - + /** * Gets a METAR form the database. @@ -225,10 +260,127 @@ * @return string The raw METAR as an array from the database. * @access public */ - function get_metar($icao) { - $this->query(sprintf('SELECT metar, UNIX_TIMESTAMP(timestamp)' . + function get_metar($icao, $time_from=false, $time_to=false) { +// $this->query(sprintf('SELECT metar, UNIX_TIMESTAMP(timestamp)' . +// ' FROM %s WHERE icao = "%s"', +// $this->properties['db_metars'], $icao)); +// return $this->fetch_row(); + + /* Set num fetch mode */ + $tmp_fetch_mode = $this->link_id->SetFetchMode(ADODB_FETCH_NUM); + + if($time_from===false || $this->properties['archive_metars']===false) { + /* fetch the current metar */ + $query = sprintf('SELECT metar, UNIX_TIMESTAMP(timestamp) AS timestamp, time' . + ' FROM %s WHERE icao = "%s" LIMIT 1', + $this->properties['db_metars'], $icao); + } + else if ($time_to!==false) { + /* fetch archived metars between $time_from and $time_to */ + $query = sprintf('SELECT metar, UNIX_TIMESTAMP(time) AS timestamp, time' . + ' FROM %s WHERE icao = "%s" AND time>="%s" AND time<"%s" ORDER BY time ASC', + $this->properties['db_metars_arch'], $icao, $time_from, $time_to); + } + else { + /* fetch archived metars from $time_from */ + $query = sprintf('SELECT metar, UNIX_TIMESTAMP(time) AS timestamp, time' . + ' FROM %s WHERE icao = "%s" AND time>="%s" ORDER BY time ASC', + $this->properties['db_metars_arch'], $icao,$time_from); + } + + $this->query($query); + + if($this->num_rows()==0) $metar_array = false; + else { + $metar_array = array(); + while($row = $this->fetch_row()) { + $metar_array[] = $row; + } + } + + /* Set old fetch mode */ + $this->link_id->SetFetchMode($tmp_fetch_mode); + + return $metar_array; + } + + + /** + * Inserts a TAF into the database. + * + * @param string The ICAO of the station. + * @param string The raw TAF. + * @param integer A standard UNIX timestamp. + * @param string The time of the report + * @access public + * @see update_taf() + */ + function insert_taf($icao, $taf, $timestamp, $time) { + $this->query(sprintf('INSERT INTO %s SET icao = "%s", ' . + 'taf = "%s", timestamp = FROM_UNIXTIME(%d)', + $this->properties['db_tafs'], $icao, + addslashes($taf), intval($timestamp))); + $this->insert_taf_arch($icao, $taf, $time); + } + + /** + * Updates an existing TAF in the database. + * + * @param string The ICAO of the station. + * @param string The raw TAF. + * @param integer A standard UNIX timestamp. + * @param string The time of the report + * @access public + * @see insert_taf() + */ + function update_taf($icao, $taf, $timestamp, $time) { + $this->query(sprintf('UPDATE %s' . + ' SET taf = "%s", timestamp = FROM_UNIXTIME(%d)' . + ' WHERE icao = "%s"', + $this->properties['db_tafs'], addslashes($taf), + intval($timestamp), $icao)); + $this->insert_taf_arch($icao, $taf, $time); + } + + /** + * Inserts an archive TAF into the database. + * + * @param string The ICAO of the station. + * @param string The raw TAF. + * @param integer The time of the report. + * @access public + */ + function insert_taf_arch($icao, $taf, $time) { + if(isset($this->properties['archive_tafs']) && + $this->properties['archive_tafs']==true) { + $this->query(sprintf('SHOW TABLES LIKE "%s"', + $this->properties['db_tafs_arch'])); + if ($this->num_rows()==1) { + $this->query(sprintf('DELETE FROM %s WHERE icao = "%s" AND ' . + 'time = "%s"' , + $this->properties['db_tafs_arch'], + $icao,$time)); + $this->query(sprintf('INSERT IGNORE INTO %s SET icao = "%s", ' . + 'time = "%s", ' . + 'taf = "%s"', + $this->properties['db_tafs_arch'], $icao, + $time, + addslashes($taf))); + } + } + } + + /** + * Gets a TAF form the database. + * + * @param string The ICAO of the station. + * @return string The raw TAF as an array from the database. + * @access public + */ + function get_taf($icao) { + $this->query(sprintf('SELECT taf, UNIX_TIMESTAMP(timestamp)' . ' FROM %s WHERE icao = "%s"', - $this->properties['db_metars'], $icao)); + $this->properties['db_tafs'], $icao)); return $this->fetch_row(); } @@ -249,10 +401,33 @@ $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_metars']); $this->query('CREATE TABLE ' . $this->properties['db_metars'] . '( icao char(4) NOT NULL, + time timestamp(14), metar varchar(255) NOT NULL, timestamp timestamp(14), - PRIMARY KEY (icao), - UNIQUE icao (icao))'); + PRIMARY KEY (icao)'); + + /* Then we make a table for the TAFs */ + $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_tafs']); + $this->query('CREATE TABLE ' . $this->properties['db_tafs'] . '( + icao char(4) NOT NULL, + time timestamp(14), + taf varchar(255) NOT NULL, + timestamp timestamp(14), + PRIMARY KEY (icao)'); + + /* We make the archival databases */ + $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_metars_arch']); + $this->query('CREATE TABLE ' . $this->properties['db_metars_arch'] . '( + icao char(4) NOT NULL, + time timestamp(14) NOT NULL, + metar varchar(255) NOT NULL, + PRIMARY KEY (icao,time)'); + $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_tafs_arch']); + $this->query('CREATE TABLE ' . $this->properties['db_tafs_arch'] . '( + icao char(4) NOT NULL, + time timestamp(14) NOT NULL, + taf varchar(255) NOT NULL, + PRIMARY KEY (icao,time)'); /* Then we make a table for the stations. */ $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_stations']); Index: pw_db_mysql.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/db/pw_db_mysql.php,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- pw_db_mysql.php 30 Sep 2003 20:01:15 -0000 1.9 +++ pw_db_mysql.php 2 Oct 2003 22:54:46 -0000 1.10 @@ -184,9 +184,9 @@ * @see update_metar() */ function insert_metar($icao, $metar, $timestamp, $time) { - $this->query(sprintf('INSERT INTO %s SET icao = "%s", ' . + $this->query(sprintf('INSERT INTO %s SET icao = "%s", time = "%s", ' . 'metar = "%s", timestamp = FROM_UNIXTIME(%d)', - $this->properties['db_metars'], $icao, + $this->properties['db_metars'], $icao, $time, addslashes($metar), intval($timestamp))); $this->insert_metar_arch($icao, $metar, $time); } @@ -244,12 +244,43 @@ * @return string The raw METAR as an array from the database. * @access public */ - function get_metar($icao) { - $this->query(sprintf('SELECT metar, UNIX_TIMESTAMP(timestamp)' . - ' FROM %s WHERE icao = "%s"', - $this->properties['db_metars'], $icao)); - return $this->fetch_row(); - } + function get_metar($icao, $time_from=false, $time_to=false) { +// $this->query(sprintf('SELECT metar, UNIX_TIMESTAMP(timestamp)' . +// ' FROM %s WHERE icao = "%s"', +// $this->properties['db_metars'], $icao)); +// return $this->fetch_row(); + + if($time_from===false || $this->properties['archive_metars']===false) { + /* fetch the current metar */ + $query = sprintf('SELECT metar, UNIX_TIMESTAMP(timestamp) AS timestamp, time' . + ' FROM %s WHERE icao = "%s" LIMIT 1', + $this->properties['db_metars'], $icao); + } + else if ($time_to!==false) { + /* fetch archived metars between $time_from and $time_to */ + $query = sprintf('SELECT metar, UNIX_TIMESTAMP(time) AS timestamp, time' . + ' FROM %s WHERE icao = "%s" AND time>="%s" AND time<"%s" ORDER BY time ASC', + $this->properties['db_metars_arch'], $icao, $time_from, $time_to); + } + else { + /* fetch archived metars from $time_from */ + $query = sprintf('SELECT metar, UNIX_TIMESTAMP(time) AS timestamp, time' . + ' FROM %s WHERE icao = "%s" AND time>="%s" ORDER BY time ASC', + $this->properties['db_metars_arch'], $icao,$time_from); + } + + $this->query($query); + + if($this->num_rows()==0) $metar_array = false; + else { + $metar_array = array(); + while($row = $this->fetch_row()) { + $metar_array[] = $row; + } + } + + return $metar_array; + } /** * Inserts a TAF into the database. @@ -277,7 +308,7 @@ * @access public * @see insert_taf() */ - function update_taf($icao, $taf, $timestamp) { + function update_taf($icao, $taf, $timestamp, $time) { $this->query(sprintf('UPDATE %s' . ' SET taf = "%s", timestamp = FROM_UNIXTIME(%d)' . ' WHERE icao = "%s"', @@ -345,31 +376,30 @@ $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_metars']); $this->query('CREATE TABLE ' . $this->properties['db_metars'] . '( icao char(4) NOT NULL, + time timestamp(14), metar varchar(255) NOT NULL, timestamp timestamp(14), - PRIMARY KEY (icao), - UNIQUE icao (icao))'); + PRIMARY KEY (icao)'); /* Then we make a table for the TAFs */ $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_tafs']); $this->query('CREATE TABLE ' . $this->properties['db_tafs'] . '( icao char(4) NOT NULL, + time timestamp(14), taf varchar(255) NOT NULL, timestamp timestamp(14), - PRIMARY KEY (icao), - UNIQUE icao (icao))'); + PRIMARY KEY (icao)'); /* We make the archival databases */ - $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_metars_arch']); $this->query('CREATE TABLE ' . $this->properties['db_metars_arch'] . '( - icao varchar(4) NOT NULL, + icao char(4) NOT NULL, time timestamp(14) NOT NULL, metar varchar(255) NOT NULL, PRIMARY KEY (icao,time)'); $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_tafs_arch']); $this->query('CREATE TABLE ' . $this->properties['db_tafs_arch'] . '( - icao varchar(4) NOT NULL, + icao char(4) NOT NULL, time timestamp(14) NOT NULL, taf varchar(255) NOT NULL, PRIMARY KEY (icao,time)'); @@ -382,7 +412,6 @@ cc char(2) NOT NULL, country varchar(128) NOT NULL, PRIMARY KEY (icao), - UNIQUE icao (icao), KEY cc (cc))'); return true; // Success! |
From: Etienne T. <eti...@us...> - 2003-10-02 22:54:53
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv19332 Modified Files: data_retrieval.php phpweather.php Log Message: Added retrieval of archived metars. The current METAR is still in metar and decoded_metar, time is in YYYYDDMMhhmmss format. There are additionnal arrays metar_arch decoded_metar_arch which contain all the METARs in the period set by data_retrieval::set_times(). Modified db/pw_adodb.php and db/pw_mysql.php. Index: data_retrieval.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v retrieving revision 1.34 retrieving revision 1.35 diff -u -3 -r1.34 -r1.35 --- data_retrieval.php 30 Sep 2003 19:47:59 -0000 1.34 +++ data_retrieval.php 2 Oct 2003 22:54:46 -0000 1.35 @@ -24,6 +24,8 @@ * @see set_metar() */ var $metar; + var $metar_time; + var $metar_arch; /** * The TAF is stored here. @@ -46,6 +48,9 @@ */ var $icao_data; + var $time_from; + var $time_to; + /** * Constructor * @@ -61,6 +66,13 @@ /* Then we set the station. */ $this->set_icao($this->properties['icao']); + $this->metar = false; + $this->metar_time = false; + $this->metar_arch = false; + $this->fd = false; + $this->time_from = false; + $this->time_to = false; + } /** @@ -93,12 +105,18 @@ $this->properties['icao'] = strtoupper($new_icao); $this->icao_data = false; $this->metar = false; + $this->metar_time = false; $this->decoded_metar = false; + $this->metar_arch = false; $this->taf = false; $this->decoded_taf = false; } } + function set_times($time_from=false, $time_to=false) { + $this->time_from = $time_from; + $this->time_to = $time_to; + } /** * Retrieves a raw METAR, either from the web or from a database. @@ -110,6 +128,7 @@ * @return string The raw METAR. */ function get_metar() { + if (empty($this->metar)) { /* The METAR is not set - we try to load it */ $this->debug('The METAR is not set, I\'ll try to find the METAR in the database.'); @@ -255,46 +274,69 @@ * @return string The raw METAR. */ function get_metar_from_db() { + if (!$this->db->connect()) { return false; } + + $tmp_metar = false; + $tmp_metar_time = false; if ($data = $this->db->get_metar($this->get_icao())) { /* found station */ $this->debug('get_metar_from_db(): Found the METAR in the database'); - list($metar, $timestamp) = $data; - + list($metar, $timestamp, $time) = end($data); + echo "metar: $metar timestamp:$timestamp time:$time<br>"; + reset($data); + /* We set the METAR right away, and then count on * get_metar_from_web() to set it to something else, if * necessary. */ + $tmp_metar = $metar; $this->metar = $metar; + $this->metar_time = $time; + if ($this->properties['always_use_db'] || $timestamp > time() - $this->properties['cache_timeout']) { - - /* We have asked explicit for a cached METAR, or the METAR is - * still fresh. Either way - we return the METAR we found in + /* We have asked explicit for a cached METAR, or the METAR is + * still fresh.Either way - we return the METAR we found in * the database. */ $this->debug('get_metar_from_db(): Using previously cached METAR for <code>' . $this->get_location() . '</code>. The METAR expires in ' . ($timestamp + $this->properties['cache_timeout'] - time()) . ' seconds.'); - return $metar; + $tmp_metar = $metar; } else { - /* The METAR is too old, so we fetch new */ + /* The METAR is too old, so we fetch new */ $this->debug('get_metar_from_db(): The METAR for <code>' . - $this->get_location() . '</code> was ' . - (time() - $this->properties['cache_timeout'] - $timestamp) . - ' seconds too old.'); - return $this->get_metar_from_web(false); + $this->get_location() . '</code> was ' . + (time() - $this->properties['cache_timeout'] - $timestamp) . + ' seconds too old.'); + $tmp_metar = $this->get_metar_from_web(false); } + } else { /* We need to get a new METAR from the web. */ $this->debug('get_metar_from_db(): New station <code>' . - $this->get_location() . '</code> - fetching a new METAR.'); - return $this->get_metar_from_web(true); + $this->get_location() . '</code> - fetching a new METAR.'); + $tmp_metar = $this->get_metar_from_web(true); + } + + /* Now we can get the archive METARs. */ + $this->metar_arch = false; + if ($this->time_from!==false) { + if ($data = $this->db->get_metar($this->get_icao(),$this->time_from,$this->time_to)) { + for($i=0;$i<count($data);$i++) { + $this->metar_arch[$i] = array('metar'=>$data[$i][0], + 'time'=>$data[$i][2]); + } + } } + + return $tmp_metar; } + /** * Fetches a METAR from the Internet. @@ -373,22 +415,23 @@ $timestamp = time() - $this->properties['cache_timeout'] + 600; } + /* side effect */ $metar_time = $date[0].$date[1].$date[2].$date[3].$date[4]."00"; - + echo "metar_time: $metar_time<br>"; + /* We then cache the METAR in our database */ if ($new_station) { $this->debug('get_metar_from_web(): Inserting new METAR for <code>' . $this->get_location() . '</code>'); -// $this->db->insert_metar($icao, $metar, $timestamp); $this->db->insert_metar($icao, $metar, $timestamp, $metar_time); } else { $this->debug('get_metar_from_web(): Updating METAR for <code>' . $this->get_location() . '</code>'); -// $this->db->update_metar($icao, $metar, $timestamp); $this->db->update_metar($icao, $metar, $timestamp, $metar_time); } /* We update and return the METAR */ $this->metar = $metar; + $this->metar_time = $metar_time; return $metar; } @@ -615,12 +658,10 @@ if ($new_station) { $this->debug('get_taf_from_web(): Inserting new TAF for <code>' . $this->get_location() . '</code>'); -// $this->db->insert_taf($icao, $taf, $timestamp); $this->db->insert_taf($icao, $taf, $timestamp, $taf_time); } else { $this->debug('get_taf_from_web(): Updating TAF for <code>' . $this->get_location() . '</code>'); -// $this->db->update_taf($icao, $taf, $timestamp); $this->db->update_taf($icao, $taf, $timestamp, $taf_time); } Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.36 retrieving revision 1.37 diff -u -3 -r1.36 -r1.37 --- phpweather.php 20 Sep 2003 22:18:47 -0000 1.36 +++ phpweather.php 2 Oct 2003 22:54:46 -0000 1.37 @@ -41,6 +41,7 @@ * @var array */ var $decoded_metar; + var $decoded_metar_arch; /** * The decoded TAF is stored here. @@ -60,6 +61,11 @@ * parent constructor. */ $this->data_retrieval($input); + + $this->decoded_metar = false; + $this->decoded_metar_arch = false; + $this->decoded_taf = false; + } @@ -160,26 +166,44 @@ * @see $decoded_metar * @access public */ - function decode_metar() { + function decode_metar($index=false) { /* initialization */ $temp_visibility_miles = ''; - $decoded_metar['remarks'] = ''; - - $decoded_metar['metar'] = $this->get_metar(); $decoded_metar['location'] = $this->get_location(); - - $parts = explode(' ', $this->metar); + + /* Make sure we got the metar */ + $tmp_metar = $this->get_metar(); + + /* Setup other variables */ + if ($index===false) { /* We are getting the current METAR */ + $decoded_metar['metar'] = $tmp_metar; + $decoded_metar['time'] = $this->metar_time; + } + else { + if ($this->metar_arch===false) { /* error */ + return false; + } + $tmp_metar = $this->metar_arch[$index]['metar']; + $decoded_metar['metar'] = $tmp_metar; + $decoded_metar['time'] = $this->metar_arch[$index]['time']; + } + + /* We parse the METAR */ + $parts = explode(' ', $tmp_metar); $num_parts = count($parts); + for ($i = 0; $i < $num_parts; $i++) { $part = $parts[$i]; if (ereg('RMK|TEMPO|BECMG|INTER', $part)) { /* The rest of the METAR is either a remark or temporary - * information. We skip the rest of the METAR. + * information. We keep the remark. */ - $decoded_metar['remarks'] .= ' ' . $part; - break; + for($j=$i;$j<$num_parts; $j++) + $decoded_metar['remarks'] .= ' ' . $parts[$j]; + $decoded_metar['remarks'] = trim($decoded_metar['remarks']); + break; } elseif ($part == 'METAR') { /* * Type of Report: METAR @@ -210,17 +234,24 @@ * $this->properties['offset'] to be +1 in your defaults.php * file. */ - if ($regs[1] > gmdate('j')) { - /* The day is greather that the current day of month => the - * report is from last month. - */ - $month = gmdate('n') - 1; - } else { - $month = gmdate('n'); - } - $decoded_metar['time'] = - gmmktime($regs[2] + $this->properties['offset'], - $regs[3], 0, $month, $regs[1], gmdate('Y')); + + /* We get the report time from elsewhere */ +// $decoded_metar['time'] = $this->metar_time; + +// if ($regs[1] > gmdate('j')) { +// /* The day is greather that the current day of month => the +// * report is from last month. +// */ +// $month = gmdate('n') - 1; +// } else { +// $month = gmdate('n'); +// } +// /* is this really useful? let's put this in a readable timestamp... */ +// $decoded_metar['time'] = +// gmmktime($regs[2] + $this->properties['offset'], +// $regs[3], 0, $month, $regs[1], gmdate('Y')); + + } elseif (ereg('(AUTO|COR|RTD|CC[A-Z]|RR[A-Z])', $part, $regs)) { /* @@ -685,11 +716,31 @@ /* Finally we store our decoded METAR in $this->decoded_metar so * that other methods can use it. */ - $this->decoded_metar = $decoded_metar; + if ($index===false) $this->decoded_metar = $decoded_metar; + else $this->decoded_metar_arch[$index] = $decoded_metar; + return $decoded_metar; } /** + * Decodes all METARs + * + * @return + * @access public + */ + + function decode_all_metars() { + + /* Decode the current METAR */ + $this->decode_metar(); + + /* Decode the archived METARs */ + for($i=0; $i<count($this->metar_arch); $i++) { + $this->decode_metar($i); + } + } + + /** * Decodes a raw TAF. * * This function loops over the various parts of the raw TAF, and @@ -748,11 +799,12 @@ $current_period = 0; $periods = array(); $periods[0] = 'COMPLETE'; - $remarks_index = $num_parts - 1; $decoded_taf['icao'] = $parts[0]; - $decoded_taf['time_emit'] = $parts[1]; - $decoded_taf['time_use'] = $parts[2]; + $tmp_time_use = $parts[2]; + $decoded_taf['time_emit'] = hm2YMDhm(substr($parts[1],2,4),$tmp_time_use); + $decoded_taf['time_use_from'] = hm2YMDhm(substr($parts[2],2,2)."00",$tmp_time_use); + $decoded_taf['time_use_to'] = hm2YMDhm(substr($parts[2],4,2)."00",$tmp_time_use); $periods[0] .= ' '.$parts[2]; /* first pass to get remarks and periods */ @@ -765,10 +817,10 @@ /* The rest of the TAF is either a remark or temporary * information. We keep the remark. */ - $remarks_index = $i; for($j=$i;$j<$num_parts; $j++) $decoded_taf['remarks'] .= ' ' . $parts[$j]; - break; + $decoded_taf['remarks'] = trim($decoded_taf['remarks']); + break; } else if ( (substr($part,0,2)=='FM') || $part=='BECMG' || ($part=='TEMPO') || (substr($part,0,4)=='PROB') ) { @@ -811,7 +863,6 @@ $first_i = 1; /* set the end time if the previous FM or BECMG to the start time of this one */ if($last_fm_becmg!==false && $decoded_periods[$last_fm_becmg]['time_to']===false) { -// $decoded_periods[$last_fm_becmg]['time_to'] = $time_from; $set_time_to = $last_fm_becmg; } $last_fm_becmg = $j; @@ -824,7 +875,6 @@ $first_i = 2; /* set the end time if the previous FM or BECMG to the start time of this one */ if($last_fm_becmg!==false && $decoded_periods[$last_fm_becmg]['time_to']===false) { -// $decoded_periods[$last_fm_becmg]['time_to'] = $time_from; $set_time_to = $last_fm_becmg; } $last_fm_becmg = $j; @@ -857,9 +907,9 @@ } /* make timestamps */ - $time_from = hm2YMDhm($time_from,$decoded_taf['time_use']); - $time_to = hm2YMDhm($time_to,$decoded_taf['time_use'],true); - $time_set = hm2YMDhm($time_set,$decoded_taf['time_use']); + $time_from = hm2YMDhm($time_from,$tmp_time_use); + $time_to = hm2YMDhm($time_to,$tmp_time_use,true); + $time_set = hm2YMDhm($time_set,$tmp_time_use); /* set the end time if the previous FM or BECMG to the start time of this one */ if ($set_time_to!==false) { @@ -1066,7 +1116,6 @@ } $decoded_taf['periods1'] = $decoded_periods; - $decoded_taf['remarks'] = trim($decoded_taf['remarks']); } /* We pass each 'periods1' and set the properties for each based on previous properties. |
From: Etienne T. <eti...@us...> - 2003-09-30 20:01:19
|
Update of /cvsroot/phpweather/phpweather/db In directory sc8-pr-cvs1:/tmp/cvs-serv15470/db Modified Files: pw_db_mysql.php Log Message: Modified create_tables() Index: pw_db_mysql.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/db/pw_db_mysql.php,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- pw_db_mysql.php 30 Sep 2003 19:48:00 -0000 1.8 +++ pw_db_mysql.php 30 Sep 2003 20:01:15 -0000 1.9 @@ -360,17 +360,18 @@ UNIQUE icao (icao))'); /* We make the archival databases */ - $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_metars_arch']); + + $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_metars_arch']); $this->query('CREATE TABLE ' . $this->properties['db_metars_arch'] . '( - icao varchar(4) NOT NULL default '', + icao varchar(4) NOT NULL, time timestamp(14) NOT NULL, - metar varchar(255) NOT NULL default '', + metar varchar(255) NOT NULL, PRIMARY KEY (icao,time)'); $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_tafs_arch']); $this->query('CREATE TABLE ' . $this->properties['db_tafs_arch'] . '( - icao varchar(4) NOT NULL default '', + icao varchar(4) NOT NULL, time timestamp(14) NOT NULL, - taf varchar(255) NOT NULL default '', + taf varchar(255) NOT NULL, PRIMARY KEY (icao,time)'); /* Then we make a table for the stations. */ |
From: Etienne T. <eti...@us...> - 2003-09-30 19:48:07
|
Update of /cvsroot/phpweather/phpweather/db In directory sc8-pr-cvs1:/tmp/cvs-serv12758/db Modified Files: pw_db_mysql.php Log Message: Added archiving of METAR and TAF reports. The functions insert_metar, update_metar, insert_taf, update_taf have been modified to include the time of the report in the archive DB. Modified only pw_db_mysql to reflect these changes. The DBs pw_metars_arch and pw_tafs_arch must be created. You must set properties archive_metars and archive_tafs to true for the archive to happen transparently at each insert or update. Index: pw_db_mysql.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/db/pw_db_mysql.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- pw_db_mysql.php 8 Sep 2003 04:20:44 -0000 1.7 +++ pw_db_mysql.php 30 Sep 2003 19:48:00 -0000 1.8 @@ -183,14 +183,14 @@ * @access public * @see update_metar() */ - function insert_metar($icao, $metar, $timestamp) { + function insert_metar($icao, $metar, $timestamp, $time) { $this->query(sprintf('INSERT INTO %s SET icao = "%s", ' . - 'metar = "%s", timestamp = FROM_UNIXTIME(%d)', - $this->properties['db_metars'], $icao, - addslashes($metar), intval($timestamp))); + 'metar = "%s", timestamp = FROM_UNIXTIME(%d)', + $this->properties['db_metars'], $icao, + addslashes($metar), intval($timestamp))); + $this->insert_metar_arch($icao, $metar, $time); } - /** * Updates an existing METAR in the database. * @@ -200,14 +200,42 @@ * @access public * @see insert_metar() */ - function update_metar($icao, $metar, $timestamp) { + function update_metar($icao, $metar, $timestamp, $time) { $this->query(sprintf('UPDATE %s' . ' SET metar = "%s", timestamp = FROM_UNIXTIME(%d)' . ' WHERE icao = "%s"', $this->properties['db_metars'], addslashes($metar), intval($timestamp), $icao)); + $this->insert_metar_arch($icao, $metar, $time); } + /** + * Inserts an archive METAR into the database. + * + * @param string The ICAO of the station. + * @param string The raw METAR. + * @param integer The time of the report. + * @access public + */ + function insert_metar_arch($icao, $metar, $time) { + if(isset($this->properties['archive_metars']) && + $this->properties['archive_metars']==true) { + $this->query(sprintf('SHOW TABLES LIKE "%s"', + $this->properties['db_metars_arch'])); + if ($this->num_rows()==1) { + $this->query(sprintf('DELETE FROM %s WHERE icao = "%s" AND ' . + 'time = "%s"' , + $this->properties['db_metars_arch'], + $icao,$time)); + $this->query(sprintf('INSERT IGNORE INTO %s SET icao = "%s", ' . + 'time = "%s", ' . + 'metar = "%s"', + $this->properties['db_metars_arch'], $icao, + $time, + addslashes($metar))); + } + } + } /** * Gets a METAR form the database. @@ -232,11 +260,12 @@ * @access public * @see update_taf() */ - function insert_taf($icao, $taf, $timestamp) { + function insert_taf($icao, $taf, $timestamp, $time) { $this->query(sprintf('INSERT INTO %s SET icao = "%s", ' . 'taf = "%s", timestamp = FROM_UNIXTIME(%d)', $this->properties['db_tafs'], $icao, addslashes($taf), intval($timestamp))); + $this->insert_taf_arch($icao, $taf, $time); } /** @@ -254,8 +283,37 @@ ' WHERE icao = "%s"', $this->properties['db_tafs'], addslashes($taf), intval($timestamp), $icao)); + $this->insert_taf_arch($icao, $taf, $time); } + /** + * Inserts an archive TAF into the database. + * + * @param string The ICAO of the station. + * @param string The raw TAF. + * @param integer The time of the report. + * @access public + */ + function insert_taf_arch($icao, $taf, $time) { + if(isset($this->properties['archive_tafs']) && + $this->properties['archive_tafs']==true) { + $this->query(sprintf('SHOW TABLES LIKE "%s"', + $this->properties['db_tafs_arch'])); + if ($this->num_rows()==1) { + $this->query(sprintf('DELETE FROM %s WHERE icao = "%s" AND ' . + 'time = "%s"' , + $this->properties['db_tafs_arch'], + $icao,$time)); + $this->query(sprintf('INSERT IGNORE INTO %s SET icao = "%s", ' . + 'time = "%s", ' . + 'taf = "%s"', + $this->properties['db_tafs_arch'], $icao, + $time, + addslashes($taf))); + } + } + } + /** * Gets a TAF form the database. * @@ -292,7 +350,7 @@ PRIMARY KEY (icao), UNIQUE icao (icao))'); - /* First we make a table for the TAFs */ + /* Then we make a table for the TAFs */ $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_tafs']); $this->query('CREATE TABLE ' . $this->properties['db_tafs'] . '( icao char(4) NOT NULL, @@ -300,6 +358,20 @@ timestamp timestamp(14), PRIMARY KEY (icao), UNIQUE icao (icao))'); + + /* We make the archival databases */ + $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_metars_arch']); + $this->query('CREATE TABLE ' . $this->properties['db_metars_arch'] . '( + icao varchar(4) NOT NULL default '', + time timestamp(14) NOT NULL, + metar varchar(255) NOT NULL default '', + PRIMARY KEY (icao,time)'); + $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_tafs_arch']); + $this->query('CREATE TABLE ' . $this->properties['db_tafs_arch'] . '( + icao varchar(4) NOT NULL default '', + time timestamp(14) NOT NULL, + taf varchar(255) NOT NULL default '', + PRIMARY KEY (icao,time)'); /* Then we make a table for the stations. */ $this->query('DROP TABLE IF EXISTS ' . $this->properties['db_stations']); |
From: Etienne T. <eti...@us...> - 2003-09-30 19:48:07
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv12758 Modified Files: data_retrieval.php defaults-dist.php Log Message: Added archiving of METAR and TAF reports. The functions insert_metar, update_metar, insert_taf, update_taf have been modified to include the time of the report in the archive DB. Modified only pw_db_mysql to reflect these changes. The DBs pw_metars_arch and pw_tafs_arch must be created. You must set properties archive_metars and archive_tafs to true for the archive to happen transparently at each insert or update. Index: data_retrieval.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- data_retrieval.php 13 Sep 2003 02:38:49 -0000 1.33 +++ data_retrieval.php 30 Sep 2003 19:47:59 -0000 1.34 @@ -94,6 +94,8 @@ $this->icao_data = false; $this->metar = false; $this->decoded_metar = false; + $this->taf = false; + $this->decoded_taf = false; } } @@ -370,17 +372,21 @@ } $timestamp = time() - $this->properties['cache_timeout'] + 600; } - + + $metar_time = $date[0].$date[1].$date[2].$date[3].$date[4]."00"; + /* We then cache the METAR in our database */ if ($new_station) { $this->debug('get_metar_from_web(): Inserting new METAR for <code>' . $this->get_location() . '</code>'); - $this->db->insert_metar($icao, $metar, $timestamp); +// $this->db->insert_metar($icao, $metar, $timestamp); + $this->db->insert_metar($icao, $metar, $timestamp, $metar_time); } else { $this->debug('get_metar_from_web(): Updating METAR for <code>' . $this->get_location() . '</code>'); - $this->db->update_metar($icao, $metar, $timestamp); - } +// $this->db->update_metar($icao, $metar, $timestamp); + $this->db->update_metar($icao, $metar, $timestamp, $metar_time); + } /* We update and return the METAR */ $this->metar = $metar; @@ -582,19 +588,10 @@ $taf = gmdate('dHi', $timestamp) . 'Z ' . $taf; } - //ET here adjust because reports are updated less often than matars - //tmp always set the timeout to 1 hour from now + /* Set the timeout to 1 hour from now */ + /* Perhaps we could figure the next TAF? */ $timestamp = time() - $this->properties['cache_timeout'] + 60*60; -// if ($timestamp < (time() - $this->properties['cache_timeout'] + 300)) { -// /* The timestamp in the TAF is more than 55 minutes old. We -// * adjust the timestamp, so that we won't try to fetch a new -// * TAF within the next 5 minutes. After 5 minutes, the -// * timestamp will again be more than 1 hour old. -// */ -// $timestamp = time() - $this->properties['cache_timeout'] + 300; -// } - } else { @@ -612,15 +609,20 @@ $timestamp = time() - $this->properties['cache_timeout'] + 600; } + $taf_time = $date[0].$date[1].$date[2].$date[3].$date[4]."00"; + /* We then cache the TAF in our database */ if ($new_station) { $this->debug('get_taf_from_web(): Inserting new TAF for <code>' . $this->get_location() . '</code>'); - $this->db->insert_taf($icao, $taf, $timestamp); +// $this->db->insert_taf($icao, $taf, $timestamp); + $this->db->insert_taf($icao, $taf, $timestamp, $taf_time); } else { $this->debug('get_taf_from_web(): Updating TAF for <code>' . $this->get_location() . '</code>'); - $this->db->update_taf($icao, $taf, $timestamp); +// $this->db->update_taf($icao, $taf, $timestamp); + $this->db->update_taf($icao, $taf, $timestamp, $taf_time); + } /* We update and return the TAF */ $this->taf = $taf; Index: defaults-dist.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/defaults-dist.php,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- defaults-dist.php 8 Sep 2003 08:02:33 -0000 1.19 +++ defaults-dist.php 30 Sep 2003 19:48:00 -0000 1.20 @@ -38,6 +38,10 @@ $this->properties['db_tafs'] = 'pw_tafs'; $this->properties['db_stations'] = 'pw_stations'; $this->properties['db_countries'] = 'pw_countries'; +$this->properties['archive_metars']= false; /* archiving of data */ +$this->properties['db_metars_arch']= 'pw_metars_arch'; +$this->properties['archive_tafs'] = false; +$this->properties['db_tafs_arch'] = 'pw_tafs_arch'; $this->properties['db_type'] = 'null'; /* db_layer.php */ |
From: Etienne T. <eti...@us...> - 2003-09-20 22:19:07
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv28865 Modified Files: phpweather.php test2.php Log Message: Mods for TAF. Use timestamps in the taf periods (YYYYMMDDhhmmss). Include PROB text in the hourly report. Descriptive data for periods is in a sub-array 'desc'. Added a function phpweather::get_taf_by_hour for a subset of the hourly report. Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.35 retrieving revision 1.36 diff -u -3 -r1.35 -r1.36 --- phpweather.php 13 Sep 2003 02:38:49 -0000 1.35 +++ phpweather.php 20 Sep 2003 22:18:47 -0000 1.36 @@ -697,16 +697,36 @@ * retrieve the TAF, so it is not necessary to connect to the database * before you call this function. * + * It should be noted that 3 arrays are filled. Only one should be kept, we'll see that later. + * periods1 contains the individual data for each period + * periods2 contains accumulated data for each period, based on pervious periods + * periods 3 contains hour-by-hour data, interpolated for BECMG type periods + * * @return array The decoded TAF. * @see $decoded_taf * @access public */ - //from http://www.nws.noaa.gov/mdl/icwf/avnfps/editor.html#TAFDecoder - //need to add NIL( AMD) (augmented data) - //and time consistency checks, Consistency Checks Within a Group - + /* + * taken from http://www.nws.noaa.gov/mdl/icwf/avnfps/editor.html#TAFDecoder + * need to add NIL( AMD) (augmented data) + * and time consistency checks, Consistency Checks Within a Group + */ + + /* + * taken from http://www.srh.noaa.gov/ftproot/MSD/html/note7.html + * need to add icing, turbulence and temp forecast + * + * FM change rapidly within less than one hour ->from begin to end + * BECMG change slowly, normally within 2 hours, never exceed 4 hours -> interpolate each 30 min + * TEMPO temporary, less than half of the period ->from 1/4 to 3/4 interpolating + * PROB chance of occurence for the whole period ->from begin to end + */ + /* todo: + * include year,month,day in the 'time_from','time_to','time_set' values for easier searching and processing + */ + function decode_taf() { /* initialization */ @@ -761,11 +781,15 @@ } - $decoded_periods = array(); - /* for each period, parse the data */ if(count($periods)>0) { + + $decoded_periods = array(); + $decoded_periods2 = array(); + $decoded_periods3 = array(); + $full_period = $full_period2 = false; $last_fm_becmg = false; + for($j=0;$j<count($periods);$j++) { $tmp_period = $periods[$j]; $data_period = $tmp_period; @@ -778,6 +802,7 @@ $first_i = 1; $time_from = $time_to = false; $type = $prob = false; + $set_time_to = false; if ( (substr($parts[0],0,2)=='FM') ) { $type = 'FM'; $time_from = substr($parts[0],2,4); @@ -786,7 +811,8 @@ $first_i = 1; /* set the end time if the previous FM or BECMG to the start time of this one */ if($last_fm_becmg!==false && $decoded_periods[$last_fm_becmg]['time_to']===false) { - $decoded_periods[$last_fm_becmg]['time_to'] = $time_from; +// $decoded_periods[$last_fm_becmg]['time_to'] = $time_from; + $set_time_to = $last_fm_becmg; } $last_fm_becmg = $j; } @@ -798,7 +824,8 @@ $first_i = 2; /* set the end time if the previous FM or BECMG to the start time of this one */ if($last_fm_becmg!==false && $decoded_periods[$last_fm_becmg]['time_to']===false) { - $decoded_periods[$last_fm_becmg]['time_to'] = $time_from; +// $decoded_periods[$last_fm_becmg]['time_to'] = $time_from; + $set_time_to = $last_fm_becmg; } $last_fm_becmg = $j; } @@ -829,6 +856,17 @@ $first_i = $num_parts; } + /* make timestamps */ + $time_from = hm2YMDhm($time_from,$decoded_taf['time_use']); + $time_to = hm2YMDhm($time_to,$decoded_taf['time_use'],true); + $time_set = hm2YMDhm($time_set,$decoded_taf['time_use']); + + /* set the end time if the previous FM or BECMG to the start time of this one */ + if ($set_time_to!==false) { + $decoded_periods[$set_time_to]['time_to'] = $time_from; + } + + /* put the basic info in the decoded_period */ $decoded_period['data'] = $data_period; $decoded_period['type'] = $type; $decoded_period['time_from'] = $time_from; @@ -1024,54 +1062,36 @@ /* set the last FM or BECMG end time */ if($last_fm_becmg!==false && $decoded_periods[$last_fm_becmg]['time_to']===false) { - $decoded_periods[$last_fm_becmg]['time_to'] = $decoded_periods[0]['time_to']; + $decoded_periods[$last_fm_becmg]['time_to'] = $decoded_periods[0]['time_to']; } $decoded_taf['periods1'] = $decoded_periods; $decoded_taf['remarks'] = trim($decoded_taf['remarks']); } - //ET tmp pass each period and fill in the missing pieces - /* - * taken from http://www.srh.noaa.gov/ftproot/MSD/html/note7.html - * includes icing, turbulence and temp forecast - * - * FM change rapidly within less than one hour ->from begin to end - * BECMG change slowly, normally within 2 hours, never exceed 4 hours -> interpolate each 30 min - * TEMPO temporary, less than half of the period ->from 1/4 to 3/4 interpolating - * PROB chance of occurence for the whole period ->from begin to end - */ - - $decoded_periods2 = array(); - $full_period = $full_period2 = false; - - /* for each period, parse the data */ + /* We pass each 'periods1' and set the properties for each based on previous properties. + * We also construct the hour-by-hour report. */ if(count($decoded_taf['periods1'])>0) { $full_period = $decoded_taf['periods1'][0]; for($j=0;$j<count($decoded_taf['periods1']);$j++) { $tmp_period = $decoded_taf['periods1'][$j]; $tmp_period2 = false; - /* merge the permanent period with this one */ + /* merge the full period with this one */ if($tmp_period['type'] == "COMPLETE") $tmp_period2 = $full_period; else $tmp_period2 = $this->merge_period($tmp_period,$full_period); /* fill $decoded_periods3 with data from each hour */ - $time_from = $tmp_period2['time_from']; - $tms_from = gmmktime(substr($time_from,0,2),(substr($time_from,2,2))); - $time_set = $tmp_period2['time_set']; - $tms_set = gmmktime(substr($time_set,0,2),(substr($time_set,2,2))); - $time_to = $tmp_period2['time_to']; - $tms_to = gmmktime(substr($time_to,0,2),(substr($time_to,2,2))); - if($time_to <= $time_from ) $tms_to += 24*60*60; - if($time_set < $time_from ) $tms_set += 24*60*60; + $tms_from = tms_date2unix($tmp_period2['time_from']); + $tms_set = tms_date2unix($tmp_period2['time_set']); + $tms_to = tms_date2unix($tmp_period2['time_to']); $duration = ($tms_to - $tms_from) / 60.0 / 60.0; for($k=0;$k<ceil($duration);$k++) { $tmp_period3 = $tmp_period2; $tmp_tms_from = $tms_from + $k * 60*60; - $tmp_tms_to = $tmp_tms_from + 60*60;//see if fraction... - $tmp_time_from = gmdate("Hi",$tmp_tms_from); - $tmp_time_to = gmdate("Hi",$tmp_tms_to); + $tmp_tms_to = $tmp_tms_from + 60*60;//MUST see if fraction... + $tmp_time_from = tms_unix2date($tmp_tms_from); + $tmp_time_to = tms_unix2date($tmp_tms_to); $tmp_period3['time_from'] = $tmp_time_from; $tmp_period3['time_to'] = $tmp_time_to; unset($tmp_period3['time_set']); @@ -1079,9 +1099,15 @@ $tmp_period3['interpolate']='yes'; $this->interpolate_period($tmp_period3,$full_period2,$tms_from,$tms_set,$tmp_tms_from,$tmp_tms_to); } - /* for now do not include PROB in the hour-by-hour */ - if ($tmp_period['type'] != "PROB") { - $decoded_periods3[gmdate("H",$tmp_tms_from)] = $tmp_period3; + /* add the forecast fot this hour */ + if ($tmp_period['type'] != "PROB") { + $decoded_periods3[gmdate("H",$tmp_tms_from)] = $tmp_period3; + } + else { + /* add a 'PROB' element to the [normal] forecast for this hour */ + /* perhaps the PROB period should contain only the data that has changed + * and not the cumulative data, for simplicity */ + $decoded_periods3[gmdate("H",$tmp_tms_from)]['PROB'] = $tmp_period3; } } @@ -1103,7 +1129,25 @@ $this->decoded_taf = $decoded_taf; return $decoded_taf; - + } + + /** + * Gets the hour-by-hour decoded TAF. + * + * @return array an array of hour-by hour decoded TAF. + * @access public + */ + function get_taf_at_time($time_from=false,$time_to=false) { + if($this->decoded_taf===false) return false; + if($time_from==false&&$time_to===false) return $this->decoded_taf['periods3']; + $tmp_taf = array(); + while(list($i,$period) = each($this->decoded_taf['periods3'])) { + if( $period['time_from']<$time_to && $period['time_to']>$time_from) { + $tmp_taf[$i] = $period; + } + } + if(count($tmp_taf)==0) return false; + else return $tmp_taf; } function merge_period(&$period1,&$period2) { @@ -1121,13 +1165,6 @@ return $period; } - function add_time($str_time,$add_hour,$add_min=0) { - $tms = gmmktime(substr($str_time,0,2),(substr($str_time,2,2))); - $tms += $add_hour*60*60 + $add_min*60; - return gmdate("Hi",$tms); - } - - function interpolate_period(&$period,&$prev_period,$from,$set,$period_from,$period_to) { //only interpolate wind, not: -visibility -weather -clouds -ws $wind = $period['desc']['wind']; @@ -1160,6 +1197,42 @@ $period['desc']['wind']['miles_per_hour']); } + +} + +/* put these and other functions somewhere else? */ + +function hm2YMDhm($hm,$time_use,$next_day=false) { + if($hm===false) return false; + + /* prepare the data */ + $Y = gmdate("Y"); + $M = intval(gmdate("n")); + $d_time_use = intval(substr($time_use,0,2)); + $d = $d_time_use; + $h_time_use = intval(substr($time_use,2,2)); + $h = intval(substr($hm,0,2)); + $m = intval(substr($hm,2,2)); + + /* report is for next month, add a month */ + if($d > gmdate('j')) $M++; + $tms = gmmktime($h,$m,0,$M,$d,$Y); + /* report is for next day, add a day */ + if ($h<$h_time_use) $tms += 60*60*24; + else if ($next_day===true && $h==$h_time_use) $tms += 60*60*24; + + $YMDhm = gmdate("YmdHi"."00",$tms); + + return $YMDhm; +} + +function tms_date2unix($tmp_tms) { + return gmmktime(substr($tmp_tms,8,2),substr($tmp_tms,10,2),substr($tmp_tms,12,2), + substr($tmp_tms,4,2),substr($tmp_tms,6,2),substr($tmp_tms,0,4)); +} + +function tms_unix2date($tmp_tms) { + return gmdate("YmdHis",$tmp_tms); } ?> Index: test2.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/test2.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- test2.php 13 Sep 2003 02:38:49 -0000 1.2 +++ test2.php 20 Sep 2003 22:18:47 -0000 1.3 @@ -2,6 +2,9 @@ /* Call with a icao parameter i.e. test2.php?icao=KSFO + +You can add time_from and time_to to get only parts of the taf +i.e. test2.php?icao=CYUL&time_from=20030920220000&time_to=20030920230000 */ error_reporting(E_ALL); @@ -19,32 +22,6 @@ if (!empty($icao)) { - /* - require(PHPWEATHER_BASE_DIR . "/output/pw_text_$language.php"); - require(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); - - $type = 'pw_text_' . $language; - $text = new $type($weather); - - echo "<blockquote>\n" . $text->print_pretty() . "</blockquote>\n"; - - $icons = new pw_images($weather); - echo '<p><img src="'.$icons->get_sky_image().'" /> '; - echo '<img src="'.$icons->get_winddir_image().'" /> '; - echo '<img src="'.$icons->get_temp_image().'" /></p>'; - */ - - /* - if (is_array($icao)) { - foreach ($icao as $i) { - $weather->set_icao($i); - echo "METAR for $i : ".$weather->get_metar()."<br>\n"; - echo "<br>"; - } - } - else { - */ - $weather->set_icao($icao); $language = 'en'; @@ -55,22 +32,21 @@ require(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); $icons = new pw_images($weather); + $weather->decode_taf(); + + echo "TAF for $icao : ".$weather->get_taf()."<br>\n"; + echo "<br>Print TAF:<br><br>"; + if(empty($time_from) || empty($time_to) || $time_from=="" || $time_to=="") + $text->print_taf(); + else $text->print_taf($time_from,$time_to); + echo "<br>\n"; + /* echo "METAR for $icao : ".$weather->get_metar()."<br>\n"; echo "<br>Decoded METAR:<pre>"; print_r( $weather->decode_metar() ); echo "</pre><br>\n"; */ - - echo "TAF for $icao : ".$weather->get_taf()."<br>\n"; - echo "<br>Print TAF:<br><br>"; - print_r( $text->print_taf() ); - echo "<br>\n"; - echo "<br>Decoded TAF:<pre>"; - print_r( $weather->decode_taf() ); - echo "</pre><br>\n"; - - /* } */ } |
From: Etienne T. <eti...@us...> - 2003-09-20 22:19:07
|
Update of /cvsroot/phpweather/phpweather/output In directory sc8-pr-cvs1:/tmp/cvs-serv28865/output Modified Files: pw_text.php Log Message: Mods for TAF. Use timestamps in the taf periods (YYYYMMDDhhmmss). Include PROB text in the hourly report. Descriptive data for periods is in a sub-array 'desc'. Added a function phpweather::get_taf_by_hour for a subset of the hourly report. Index: pw_text.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text.php,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- pw_text.php 13 Sep 2003 02:38:49 -0000 1.21 +++ pw_text.php 20 Sep 2003 22:18:47 -0000 1.22 @@ -1185,19 +1185,24 @@ } - function print_taf() { + function print_taf($time_from=false,$time_to=false) { $taf = $this->weather->decode_taf(); - echo "<b>location</b>: ".$taf["location"]."<br>\n"; - echo "<b>icao</b>: ".$taf["icao"]."<br>\n"; - echo "<b>time_emit</b>: ".$taf["time_emit"]."<br>\n"; - echo "<b>time_use</b>: ".$taf["time_use"]."<br>\n"; + echo "<b>icao</b>: ".$taf['icao']."<br>\n"; + echo "<b>time_emit</b>: ".$taf['time_emit']."<br>\n"; + echo "<b>time_use</b>: ".$taf['time_use']."<br>\n"; + echo "<b>location</b>: ".$taf['location']."<br>\n"; echo "<b>periods</b>:<br><br>"; echo "All periods:"; - $this->print_taf_period($taf["periods2"]); + $this->print_taf_period($taf['periods2']); echo "Each hour:"; - $this->print_taf_period($taf["periods3"]); + if($time_from==false||$time_to===false) + $this->print_taf_period($taf['periods3']); + else { + $taf2 = $this->weather->get_taf_at_time($time_from,$time_to); + $this->print_taf_period($taf2); + } } function print_taf_period($period_array) { @@ -1205,61 +1210,72 @@ echo "<tr><th>type</th><th>from</th><th>to</th><th>wind</th><th>visi</th><th>clouds</th><th>other</th></tr>\n"; while(list($i,$period) = each($period_array)) { echo "<tr>\n"; - echo "<td>".$period["type"]."</td>\n"; - echo "<td>".$period["time_from"]."</td>\n"; - echo "<td>".$period["time_to"]."</td>\n"; + echo "<td>".$period['type']."</td>\n"; + echo "<td>".substr($period['time_from'],6,6)."</td>\n"; + echo "<td>".substr($period['time_to'],6,6)."</td>\n"; echo "<td>"; - if(isset($period['desc']["wind"])) { - if($period['desc']["wind"]["deg"]=="VRB") echo "VRB"; - else echo round($period['desc']["wind"]["deg"],1); - echo " @ ".round($period['desc']["wind"]["knots"],1)." kt"; + if(isset($period['desc']['wind'])) { + if($period['desc']['wind']['deg']=='VRB') echo "VRB"; + else echo round($period['desc']['wind']['deg'],1); + echo " @ ".round($period['desc']['wind']['knots'],1)." kt"; } echo "</td>\n"; echo "<td>"; - if(isset($period['desc']["visibility"])) { - for($j=0;$j<count($period['desc']["visibility"]);$j++) { - $visi = & $period['desc']["visibility"][$j]; - if($visi["prefix"]==1) echo " > "; - else if($visi["prefix"]==-1) echo " < "; + if(isset($period['desc']['visibility'])) { + for($j=0;$j<count($period['desc']['visibility']);$j++) { + $visi = & $period['desc']['visibility'][$j]; + if($visi['prefix']==1) echo " > "; + else if($visi['prefix']==-1) echo " < "; else echo " "; - echo $visi["miles"]." SM"; + echo $visi['miles']." SM"; } } echo "</td>\n"; echo "<td>"; - if(isset($period['desc']["clouds"])) { - for($j=0;$j<count($period['desc']["clouds"]);$j++) { - $cloud = & $period['desc']["clouds"][$j]; - $condition = $cloud["condition"]; - if($j!=0) echo " - "; + if(isset($period['desc']['clouds'])) { + for($j=0;$j<count($period['desc']['clouds']);$j++) { + $cloud = & $period['desc']['clouds'][$j]; + $condition = $cloud['condition']; + if($j!=0) echo " / "; echo $condition; if($condition=="SKC") { } else if($condition=="VV") { - echo " ".$cloud["ft"]." ft"; + echo " ".$cloud['ft']." ft"; } else { - echo " at ".$cloud["ft"]." ft"; + echo " at ".$cloud['ft']." ft"; } } } echo "</td>\n"; echo "<td>"; + + if($period['type'] == 'PROB') { + echo " [ PROB ".$period['prob']."% ] "; + } + if(isset($period['desc']['weather'])) { for($j=0;$j<count($period['desc']['weather']);$j++) { $wx = & $period['desc']['weather'][$j]; - if($j!=0) echo " - "; - echo 'weather: '.$wx['proximity'].' '.$wx['intensity'].' '.$wx['descriptor'].' '.$wx['precipitation'].' '.$wx['obscuration'].' '.$wx['other']; + if($j!=0) echo " / "; + echo "weather: ".$wx['proximity']." ".$wx['intensity'].$wx['descriptor']." ".$wx['precipitation']." ".$wx['obscuration']." ".$wx['other']; } } - if(isset($period['desc']["wind_shear"])) { - for($j=0;$j<count($period['desc']["wind_shear"]);$j++) { - $ws = & $period['desc']["wind_shear"][$j]; - echo " wind shear at ".$ws["ft"]." ft "; - echo $ws["wind"]["deg"]." @ ".$ws["wind"]["knots"]." kt "; + + if(isset($period['desc']['wind_shear'])) { + for($j=0;$j<count($period['desc']['wind_shear']);$j++) { + $ws = & $period['desc']['wind_shear'][$j]; + echo " wind shear at ".$ws['ft']." ft "; + echo $ws['wind']['deg']." @ ".$ws['wind']['knots']." kt "; } } + + /* do something more with PROB */ + if(isset($period['PROB'])) { + echo " [ ".$period['PROB']['data']." ] "; + } echo "</td>\n"; echo "</tr>\n"; } @@ -1296,14 +1312,14 @@ } else { - echo '<table border="1">'; + echo "<table border="1">"; echo "\n <tr>\n"; - echo ' <th>' . $this->strings['location'] . "</th>\n"; - echo ' <th>' . $this->strings['date'] . "</th>\n"; - echo ' <th>' . $this->strings['wind'] . "</th>\n"; - echo ' <th>' . $this->strings['temperature'] . "</th>\n"; - echo ' <th>' . $this->strings['pressure'] . "</th>\n"; - echo ' <th>' . $this->strings['humidity'] . "</th>\n"; + echo " <th>' . $this->strings['location'] . "</th>\n"; + echo " <th>' . $this->strings['date'] . "</th>\n"; + echo " <th>' . $this->strings['wind'] . "</th>\n"; + echo " <th>' . $this->strings['temperature'] . "</th>\n"; + echo " <th>' . $this->strings['pressure'] . "</th>\n"; + echo " <th>' . $this->strings['humidity'] . "</th>\n"; echo " </tr>\n"; echo " <td>$location</td> <td>$date</td> |
From: Martin G. <gim...@us...> - 2003-09-16 22:57:17
|
Update of /cvsroot/phpweather/phpweather/output In directory sc8-pr-cvs1:/tmp/cvs-serv16676 Modified Files: pw_text_cs.php pw_text_hu.php pw_text_sk.php pw_text_tr.php Added Files: pw_text_pl.php Log Message: Latest translation: Polish by Michal Margula <alc...@uz...>. I've also added some comments that will tell Emacs the encoding of the files so that it can display the characters correctly. --- NEW FILE --- <?php // -*- coding: latin-2 -*- require_once(PHPWEATHER_BASE_DIR . '/output/pw_text.php'); /** * Provides all the strings needed by pw_text to produce Polish * output. * * @author Michal Margula <alc...@uz...> * @link http://alchemyx.uznam.net.pl/ My homepage. * @version pw_text_pl.php,v 1.0 2004/09/14 15:57:15 alchemyx Exp */ class pw_text_pl extends pw_text { /** * This constructor provides all the strings used. * * @param array This is just passed on to pw_text(). */ function pw_text_pl($weather, $input = array()) { $this->strings['charset'] = 'ISO-8859-2'; $this->strings['no_data'] = 'Przepraszamy! Nie ma danych dostêpnych dla %s%s%s.'; $this->strings['list_sentences_and'] = ' i '; $this->strings['list_sentences_comma'] = ', '; $this->strings['list_sentences_final_and'] = ', i '; $this->strings['location'] = 'To jest raport dla %s%s%s.'; $this->strings['minutes'] = ' minut'; $this->strings['time_format'] = 'Raport zosta³ utworzony %s temu, o godzinie %s%s%s UTC.'; $this->strings['time_minutes'] = 'i %s%s%s minut'; $this->strings['time_one_hour'] = '%sjedn±%s godzinê %s'; $this->strings['time_several_hours'] = '%s%s%s godzin %s'; $this->strings['time_a_moment'] = 'chwilê'; $this->strings['meters_per_second'] = ' metrów na sekundê'; $this->strings['miles_per_hour'] = ' mil na godzinê'; $this->strings['meter'] = ' metrów'; $this->strings['meters'] = ' metrów'; $this->strings['feet'] = ' stóp'; $this->strings['kilometers'] = ' kilometrów'; $this->strings['miles'] = ' mil'; $this->strings['and'] = ' i '; $this->strings['plus'] = ' plus '; $this->strings['with'] = ' z '; $this->strings['wind_blowing'] = 'Wiatr wia³ z prêdko¶ci± '; $this->strings['wind_with_gusts'] = ' w porywach do '; $this->strings['wind_from'] = ' z kierunku '; $this->strings['wind_variable'] = ' ze %szmiennego%s kierunku'; $this->strings['wind_varying'] = ', wahaj±ce siê pomiêdzy %s%s%s (%s%s°%s) a %s%s%s (%s%s°%s)'; $this->strings['wind_calm'] = 'Wiatr by³ %sspokojny%s'; $this->strings['wind_dir'] = array( 'pó³nocnego', 'pó³nocnego/pó³nocno-wschodniego', 'pó³nocno-wschodniego', 'wschodniego/po³nocno-wschodniego', 'wschodniego', 'wschodniego/po³udniowo-wschodniego', 'po³udnioweo-wschodniego', 'po³udniowego/po³udniowo-wschodniego', 'po³udniowego', 'po³udniowego/po³udniowo-zachodniego', 'po³udniowo-zachodniego', 'zachodniego/po³udniowo-zachodniego', 'zachodniego', 'zachodniego/pó³nocno-zachodniego', 'pó³nocno-zachodniego', 'pó³nocnego/pó³nocno-zachodniego', 'pó³nocnego'); $this->strings['wind_dir_short'] = array( 'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N'); $this->strings['wind_dir_short_long'] = array( 'N' => 'north', 'NE' => 'northeast', 'E' => 'east', 'SE' => 'southeast', 'S' => 'south', 'SW' => 'southwest', 'W' => 'west', 'NW' => 'northwest' ); $this->strings['temperature'] = 'Temperatura wynosi³a '; $this->strings['dew_point'] = ', punkt rosy '; $this->strings['altimeter'] = 'Ci¶nienie QHN wynosi³o '; $this->strings['hPa'] = ' hPa'; $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'Wilgotno¶æ wzglêdna wynosi³a '; $this->strings['feelslike'] = 'Temperatura by³a odczuwalna jako '; $this->strings['cloud_group_beg'] = 'By³o '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'Niebo by³o %sczyste%s.'; $this->strings['cloud_height'] = ' na wysoko¶ci '; $this->strings['cloud_overcast'] = 'Ca³kowite %szachmurzenie%s o podstawie '; $this->strings['cloud_vertical_visibility'] = '%spionowa widzialno¶æ%s '; $this->strings['cloud_condition'] = array( 'SKC' => 'niebo bezchmurne', 'CLR' => 'niebo bezchmurne (0/8)', 'FEW' => 'zachmurzenie niewielkie (1/8 - 2/8)', 'SCT' => 'zachmurzenie rozrzucone (3/8 - 4/8)', 'BKN' => 'zachmurzenie poprzerywane (5/8 - 7/8) ', 'OVC' => 'zachmurzenie ca³kowite (8/8)'); $this->strings['cumulonimbus'] = ' cumulonimbus'; $this->strings['towering_cumulus'] = ' cumulus wypiêtrzony'; $this->strings['cavok'] = ' brak chmur poni¿ej %s, brak cumulonimbusów oraz brak zjawisk atmosferycznych'; $this->strings['currently'] = 'Aktualnie '; $this->strings['weather'] = array( '-' => ' lekkie', ' ' => ' ¶rednie ', '+' => ' mocne ', 'VC' => ' w pobli¿u', 'PR' => ' czê¶ciowe', 'BC' => ' p³aty', 'MI' => ' p³ytkie', 'DR' => ' nisko unosz±ce', 'BL' => ' podmuchy', 'SH' => ' przelotne opady', 'TS' => ' burza z piorunami', 'FZ' => ' przymrozek', 'DZ' => ' m¿awka', 'RA' => ' deszcz', 'SN' => ' ¶nieg', 'SG' => ' gruby ¶nieg', 'IC' => ' kryszta³ki lodu', 'PL' => ' ice pellets', 'GR' => ' grad', 'GS' => ' ma³y grad', 'UP' => ' nieznany', 'BR' => ' zamglenie', 'FG' => ' mg³y', 'FU' => ' dym', 'VA' => ' popió³ wulkaniczny', 'DU' => ' widespread dust', 'SA' => ' piasek', 'HZ' => ' zmêtnienie', 'PY' => ' py³ wodny', 'PO' => ' mocno rozwijaj±ce siê wiry piaskowe/py³owe', 'SQ' => ' nawa³nica', 'FC' => ' tr±ba powietrzna, wodna, tornado', 'SS' => ' burza piaskowa/py³owa'); $this->strings['visibility'] = 'Widzialno¶æ pozioma wynosi³a '; $this->strings['visibility_greater_than'] = 'wiêcej ni¿ '; $this->strings['visibility_less_than'] = 'mniej ni¿ '; $this->strings['visibility_to'] = ' do '; $this->strings['runway_upward_tendency'] = ' z tendencj± %wzrostow±%s'; $this->strings['runway_downward_tendency'] = ' z tendencj± %smalej±c±%s'; $this->strings['runway_no_tendency'] = ' bez %srozró¿nialnej%s tendencji'; $this->strings['runway_between'] = 'pomiêdzy '; $this->strings['runway_left'] = ' lewego'; $this->strings['runway_central'] = ' ¶rodkowego'; $this->strings['runway_right'] = ' prawego'; $this->strings['runway_visibility'] = 'Widoczno¶æ by³a '; $this->strings['runway_for_runway'] = ' dla pasa '; /* We run the parent constructor */ $this->pw_text($weather, $input); } } ?> Index: pw_text_cs.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_cs.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- pw_text_cs.php 3 Aug 2003 15:10:01 -0000 1.3 +++ pw_text_cs.php 16 Sep 2003 22:57:11 -0000 1.4 @@ -1,4 +1,4 @@ -<?php +<?php // -*- coding: latin-2 -*- require_once(PHPWEATHER_BASE_DIR . '/output/pw_text.php'); Index: pw_text_hu.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_hu.php,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- pw_text_hu.php 5 Sep 2002 16:32:54 -0000 1.13 +++ pw_text_hu.php 16 Sep 2003 22:57:11 -0000 1.14 @@ -1,4 +1,4 @@ -<?php +<?php // -*- coding: latin-2 -*- require_once(PHPWEATHER_BASE_DIR . '/output/pw_text.php'); Index: pw_text_sk.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_sk.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- pw_text_sk.php 3 Aug 2003 15:10:01 -0000 1.6 +++ pw_text_sk.php 16 Sep 2003 22:57:11 -0000 1.7 @@ -1,4 +1,4 @@ -<?php +<?php // -*- coding: latin-2 -*- require_once(PHPWEATHER_BASE_DIR . '/output/pw_text.php'); Index: pw_text_tr.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_tr.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- pw_text_tr.php 3 Aug 2003 22:23:12 -0000 1.1 +++ pw_text_tr.php 16 Sep 2003 22:57:11 -0000 1.2 @@ -1,4 +1,4 @@ -<?php +<?php // -*- coding: latin-9 -*- require_once(PHPWEATHER_BASE_DIR . '/output/pw_text.php'); |
From: Etienne T. <eti...@us...> - 2003-09-13 02:38:55
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv17699 Modified Files: data_retrieval.php phpweather.php test2.php Log Message: Added hour-by-hour decoding of the taf. test2.php was modified to show that. Interpolation is done in BECMG periods and PROB periods are not added to the hour-by-hour report. Index: data_retrieval.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v retrieving revision 1.32 retrieving revision 1.33 diff -u -3 -r1.32 -r1.33 Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.34 retrieving revision 1.35 diff -u -3 -r1.34 -r1.35 --- phpweather.php 8 Sep 2003 04:20:44 -0000 1.34 +++ phpweather.php 13 Sep 2003 02:38:49 -0000 1.35 @@ -288,7 +288,7 @@ $group['ft'] = round($regs[1] * 3.28084); } if (!empty($regs[2])) { - $group['dir'] = $regs[2]; + $group['deg'] = $regs[2]; } $decoded_metar['visibility'][] = $group; @@ -701,6 +701,12 @@ * @see $decoded_taf * @access public */ + + //from http://www.nws.noaa.gov/mdl/icwf/avnfps/editor.html#TAFDecoder + //need to add NIL( AMD) (augmented data) + //and time consistency checks, Consistency Checks Within a Group + + function decode_taf() { /* initialization */ @@ -759,6 +765,7 @@ /* for each period, parse the data */ if(count($periods)>0) { + $last_fm_becmg = false; for($j=0;$j<count($periods);$j++) { $tmp_period = $periods[$j]; $data_period = $tmp_period; @@ -774,22 +781,38 @@ if ( (substr($parts[0],0,2)=='FM') ) { $type = 'FM'; $time_from = substr($parts[0],2,4); - $time_to = false; + $time_set = $time_from; + $time_to = false; $first_i = 1; + /* set the end time if the previous FM or BECMG to the start time of this one */ + if($last_fm_becmg!==false && $decoded_periods[$last_fm_becmg]['time_to']===false) { + $decoded_periods[$last_fm_becmg]['time_to'] = $time_from; + } + $last_fm_becmg = $j; } else if ($parts[0]=='BECMG') { $type = 'BECMG'; + $time_from = substr($parts[1],0,2).'00'; + $time_set = substr($parts[1],2,2).'00'; + $time_to = false; $first_i = 2; + /* set the end time if the previous FM or BECMG to the start time of this one */ + if($last_fm_becmg!==false && $decoded_periods[$last_fm_becmg]['time_to']===false) { + $decoded_periods[$last_fm_becmg]['time_to'] = $time_from; + } + $last_fm_becmg = $j; } else if ($parts[0]=='TEMPO') { $type = 'TEMPO'; $time_from = substr($parts[1],0,2).'00'; + $time_set = $time_from; //could interpolate for the first half ? $time_to = substr($parts[1],2,2).'00'; $first_i = 2; } else if (substr($parts[0],0,4)=='PROB') { $type = 'PROB'; $time_from = substr($parts[1],0,2).'00'; + $time_set = $time_from; $time_to = substr($parts[1],2,2).'00'; $prob = intval(substr($parts[0],4)); $first_i = 2; @@ -798,6 +821,7 @@ $type = 'COMPLETE'; $data_period = substr($data_period,9); $time_from = substr($parts[1],2,2).'00'; + $time_set = $time_from; $time_to = substr($parts[1],4,2).'00'; $first_i = 2; } @@ -809,6 +833,7 @@ $decoded_period['type'] = $type; $decoded_period['time_from'] = $time_from; $decoded_period['time_to'] = $time_to; + $decoded_period['time_set'] = $time_set; $decoded_period['prob'] = $prob; /* pass each element of the period */ @@ -818,12 +843,12 @@ if (ereg('^([0-9]{3}|VRB)([0-9]{2,3})G?([0-9]{2,3})?(KT)', $part, $regs)) { /* Wind Group */ - $decoded_period['wind']['deg'] = $regs[1]; + $decoded_period['desc']['wind']['deg'] = $regs[1]; $this->store_speed($regs[2], $regs[4], - $decoded_period['wind']['knots'], - $decoded_period['wind']['meters_per_second'], - $decoded_period['wind']['miles_per_hour']); + $decoded_period['desc']['wind']['knots'], + $decoded_period['desc']['wind']['meters_per_second'], + $decoded_period['desc']['wind']['miles_per_hour']); if (!empty($regs[3])) { @@ -832,17 +857,17 @@ */ $this->store_speed($regs[3], $regs[4], - $decoded_period['wind']['gust_knots'], - $decoded_period['wind']['gust_meters_per_second'], - $decoded_period['wind']['gust_miles_per_hour']); + $decoded_period['desc']['wind']['gust_knots'], + $decoded_period['desc']['wind']['gust_meters_per_second'], + $decoded_period['desc']['wind']['gust_miles_per_hour']); } } elseif (ereg('^([0-9]{3})V([0-9]{3})$', $part, $regs) && - !empty($decoded_period['wind']['deg'])) { + !empty($decoded_period['desc']['wind']['deg'])) { /* * Variable wind-direction */ - $decoded_period['wind']['var_beg'] = $regs[1]; - $decoded_period['wind']['var_end'] = $regs[2]; + $decoded_period['desc']['wind']['var_beg'] = $regs[1]; + $decoded_period['desc']['wind']['var_end'] = $regs[2]; } elseif (ereg('^([0-9]{4})([NS]?[EW]?)$', $part, $regs)) { /* * Visibility in meters (4 digits only) @@ -873,9 +898,9 @@ $group['ft'] = round($regs[1] * 3.28084); } if (!empty($regs[2])) { - $group['dir'] = $regs[2]; + $group['deg'] = $regs[2]; } - $decoded_period['visibility'][] = $group; + $decoded_period['desc']['visibility'][] = $group; } elseif (ereg('^[0-9]$', $part)) { /* @@ -887,11 +912,11 @@ unset($group); $group['prefix'] = 1; $vis_miles = 6; - $group['miles'] = number_format($vis_miles, 1); + $group['miles'] = $vis_miles; $group['ft'] = round($vis_miles * 5280, 1); $group['km'] = number_format($vis_miles * 1.6093, 1); $group['meter'] = round($vis_miles * 1609.3); - $decoded_period['visibility'][] = $group; + $decoded_period['desc']['visibility'][] = $group; } elseif (ereg('^[M]?(([0-9]?)[ ]?([0-9])(/?)([0-9]*))SM$', $temp_visibility_miles . ' ' . $part, $regs)) { @@ -924,11 +949,11 @@ /* The visibility measured in meters */ $group['meter'] = round($vis_miles * 1609.3); - $decoded_period['visibility'][] = $group; + $decoded_period['desc']['visibility'][] = $group; } elseif (ereg('^(VC)?' . /* Proximity */ '(-|\+)?' . /* Intensity */ - '(MI|PR|BC|DR|BL|SH|TS|FZ)?' . /* Descriptor */ + '(MI|PR|BC|DR|BL|SH|TS|FZ|NSW)?' . /* Descriptor */ '((DZ|RA|SN|SG|IC|PL|GR|GS|UP)+)?' . /* Precipitation */ '(BR|FG|FU|VA|DU|SA|HZ|PY)?' . /* Obscuration */ '(PO|SQ|FC|SS)?$', /* Other */ @@ -936,7 +961,7 @@ /* * Current weather-group. */ - $decoded_period['weather'][] = + $decoded_period['desc']['weather'][] = array('proximity' => $regs[1], 'intensity' => $regs[2], 'descriptor' => $regs[3], @@ -946,7 +971,7 @@ } elseif ($part == 'SKC' || $part == 'CLR') { /* Cloud-group */ - $decoded_period['clouds'][]['condition'] = $part; + $decoded_period['desc']['clouds'][]['condition'] = $part; } elseif (ereg('^(VV|FEW|SCT|BKN|OVC)([0-9]{3}|///)' . '(CB|TCU)?$', $part, $regs)) { @@ -970,7 +995,7 @@ $group['ft'] = $regs[2] *100; $group['meter'] = round($regs[2] * 30.48); } - $decoded_period['clouds'][] = $group; + $decoded_period['desc']['clouds'][] = $group; } elseif (ereg('^WS([0-9]{3})/([0-9]{3})([0-9]{2})KT$', $part, $regs)) { /* We have found a Wind Shear group. example WS011/27050KT */ @@ -987,18 +1012,90 @@ $ws['ft'] = $regs[1] *100; $ws['meter'] = round($regs[1] * 30.48); } - $ws['wind']['dir'] = $regs[2]; + $ws['wind']['deg'] = $regs[2]; $this->store_speed($regs[3],'KT', $ws['wind']['knots'], $ws['wind']['meters_per_second'], $ws['wind']['miles_per_hour']); - $decoded_period['wind_shear'][] = $ws; + $decoded_period['desc']['wind_shear'][] = $ws; } } } - $decoded_taf['periods'] = $decoded_periods; + + /* set the last FM or BECMG end time */ + if($last_fm_becmg!==false && $decoded_periods[$last_fm_becmg]['time_to']===false) { + $decoded_periods[$last_fm_becmg]['time_to'] = $decoded_periods[0]['time_to']; + } + + $decoded_taf['periods1'] = $decoded_periods; $decoded_taf['remarks'] = trim($decoded_taf['remarks']); } + + //ET tmp pass each period and fill in the missing pieces + /* + * taken from http://www.srh.noaa.gov/ftproot/MSD/html/note7.html + * includes icing, turbulence and temp forecast + * + * FM change rapidly within less than one hour ->from begin to end + * BECMG change slowly, normally within 2 hours, never exceed 4 hours -> interpolate each 30 min + * TEMPO temporary, less than half of the period ->from 1/4 to 3/4 interpolating + * PROB chance of occurence for the whole period ->from begin to end + */ + + $decoded_periods2 = array(); + $full_period = $full_period2 = false; + + /* for each period, parse the data */ + if(count($decoded_taf['periods1'])>0) { + $full_period = $decoded_taf['periods1'][0]; + for($j=0;$j<count($decoded_taf['periods1']);$j++) { + $tmp_period = $decoded_taf['periods1'][$j]; + $tmp_period2 = false; + + /* merge the permanent period with this one */ + if($tmp_period['type'] == "COMPLETE") $tmp_period2 = $full_period; + else $tmp_period2 = $this->merge_period($tmp_period,$full_period); + + /* fill $decoded_periods3 with data from each hour */ + $time_from = $tmp_period2['time_from']; + $tms_from = gmmktime(substr($time_from,0,2),(substr($time_from,2,2))); + $time_set = $tmp_period2['time_set']; + $tms_set = gmmktime(substr($time_set,0,2),(substr($time_set,2,2))); + $time_to = $tmp_period2['time_to']; + $tms_to = gmmktime(substr($time_to,0,2),(substr($time_to,2,2))); + if($time_to <= $time_from ) $tms_to += 24*60*60; + if($time_set < $time_from ) $tms_set += 24*60*60; + $duration = ($tms_to - $tms_from) / 60.0 / 60.0; + for($k=0;$k<ceil($duration);$k++) { + $tmp_period3 = $tmp_period2; + $tmp_tms_from = $tms_from + $k * 60*60; + $tmp_tms_to = $tmp_tms_from + 60*60;//see if fraction... + $tmp_time_from = gmdate("Hi",$tmp_tms_from); + $tmp_time_to = gmdate("Hi",$tmp_tms_to); + $tmp_period3['time_from'] = $tmp_time_from; + $tmp_period3['time_to'] = $tmp_time_to; + unset($tmp_period3['time_set']); + if($tmp_tms_from < $tms_set) { + $tmp_period3['interpolate']='yes'; + $this->interpolate_period($tmp_period3,$full_period2,$tms_from,$tms_set,$tmp_tms_from,$tmp_tms_to); + } + /* for now do not include PROB in the hour-by-hour */ + if ($tmp_period['type'] != "PROB") { + $decoded_periods3[gmdate("H",$tmp_tms_from)] = $tmp_period3; + } + } + + /* apply the permanent change for the next periods */ + if($tmp_period['type'] != "TEMPO" && $tmp_period['type'] != "PROB") { + $full_period2 = $full_period; + $full_period = $tmp_period2; + } + $decoded_periods2[$j] = $tmp_period2; + } + $decoded_taf['periods2'] = $decoded_periods2; + $decoded_taf['periods3'] = $decoded_periods3; + } + /* Finally we store our decoded TAF in $this->decoded_taf so * that other methods can use it. @@ -1007,6 +1104,60 @@ $this->decoded_taf = $decoded_taf; return $decoded_taf; + } + + function merge_period(&$period1,&$period2) { + $period = $period2; + reset($period1); + while(list($key,$val) = each($period1)) { + if(is_array($val)) { + while(list($key2,$val2) = each($val)) { + $period[$key][$key2] = $val2; + } + } + else + $period[$key] = $val; + } + return $period; + } + + function add_time($str_time,$add_hour,$add_min=0) { + $tms = gmmktime(substr($str_time,0,2),(substr($str_time,2,2))); + $tms += $add_hour*60*60 + $add_min*60; + return gmdate("Hi",$tms); + } + + + function interpolate_period(&$period,&$prev_period,$from,$set,$period_from,$period_to) { + //only interpolate wind, not: -visibility -weather -clouds -ws + $wind = $period['desc']['wind']; + $prev_wind = $prev_period['desc']['wind']; + $factor = ($period_to-$from)/($set-$from+60*60); + + $tmp_wind_speed1 = intval($prev_wind['knots']); + $tmp_wind_speed2 = intval($wind['knots']); + $tmp_wind_speed = $tmp_wind_speed1 + $factor*($tmp_wind_speed2-$tmp_wind_speed1); + + /* if VRB special treatment : set to VRB when on the VRB half */ + $tmp_wind_dir1 = $prev_wind['deg']; + $tmp_wind_dir2 = $wind['deg']; + if ($tmp_wind_speed1==0) $tmp_wind_dir = $tmp_wind_dir2; + else if ($tmp_wind_speed2==0) $tmp_wind_dir = $tmp_wind_dir1; + else { + if( ($tmp_wind_dir1=='VRB' && $tmp_wind_dir1=='VRB') || + ($factor<0.5 && $tmp_wind_dir1=='VRB') || + ($factor>0.5 && $tmp_wind_dir2=='VRB') ) { + $tmp_wind_dir = 'VRB'; + } + else + $tmp_wind_dir = $tmp_wind_dir1 + $factor*($tmp_wind_dir2-$tmp_wind_dir1); + } + + /* set the average values */ + $period['desc']['wind']['deg'] = $tmp_wind_dir; + $this->store_speed($tmp_wind_speed,'KT',$period['desc']['wind']['knots'], + $period['desc']['wind']['meters_per_second'], + $period['desc']['wind']['miles_per_hour']); } } Index: test2.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/test2.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- test2.php 8 Sep 2003 04:25:54 -0000 1.1 +++ test2.php 13 Sep 2003 02:38:49 -0000 1.2 @@ -15,6 +15,7 @@ if (empty($language)) $language = 'en'; $weather = new phpweather(); +// $weather->properties['verbosity'] = 5; if (!empty($icao)) { @@ -46,12 +47,25 @@ $weather->set_icao($icao); + $language = 'en'; + require(PHPWEATHER_BASE_DIR . "/output/pw_text_$language.php"); + $type = 'pw_text_' . $language; + $text = new $type($weather); + + require(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); + $icons = new pw_images($weather); + + /* echo "METAR for $icao : ".$weather->get_metar()."<br>\n"; echo "<br>Decoded METAR:<pre>"; print_r( $weather->decode_metar() ); echo "</pre><br>\n"; + */ echo "TAF for $icao : ".$weather->get_taf()."<br>\n"; + echo "<br>Print TAF:<br><br>"; + print_r( $text->print_taf() ); + echo "<br>\n"; echo "<br>Decoded TAF:<pre>"; print_r( $weather->decode_taf() ); echo "</pre><br>\n"; |
From: Etienne T. <eti...@us...> - 2003-09-13 02:38:55
|
Update of /cvsroot/phpweather/phpweather/output In directory sc8-pr-cvs1:/tmp/cvs-serv17699/output Modified Files: pw_text.php Log Message: Added hour-by-hour decoding of the taf. test2.php was modified to show that. Interpolation is done in BECMG periods and PROB periods are not added to the hour-by-hour report. Index: pw_text.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text.php,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- pw_text.php 2 Sep 2003 17:57:20 -0000 1.20 +++ pw_text.php 13 Sep 2003 02:38:49 -0000 1.21 @@ -1185,6 +1185,89 @@ } + function print_taf() { + $taf = $this->weather->decode_taf(); + + echo "<b>location</b>: ".$taf["location"]."<br>\n"; + echo "<b>icao</b>: ".$taf["icao"]."<br>\n"; + echo "<b>time_emit</b>: ".$taf["time_emit"]."<br>\n"; + echo "<b>time_use</b>: ".$taf["time_use"]."<br>\n"; + + echo "<b>periods</b>:<br><br>"; + echo "All periods:"; + $this->print_taf_period($taf["periods2"]); + echo "Each hour:"; + $this->print_taf_period($taf["periods3"]); + } + + function print_taf_period($period_array) { + echo "<table border=1>\n"; + echo "<tr><th>type</th><th>from</th><th>to</th><th>wind</th><th>visi</th><th>clouds</th><th>other</th></tr>\n"; + while(list($i,$period) = each($period_array)) { + echo "<tr>\n"; + echo "<td>".$period["type"]."</td>\n"; + echo "<td>".$period["time_from"]."</td>\n"; + echo "<td>".$period["time_to"]."</td>\n"; + echo "<td>"; + if(isset($period['desc']["wind"])) { + if($period['desc']["wind"]["deg"]=="VRB") echo "VRB"; + else echo round($period['desc']["wind"]["deg"],1); + echo " @ ".round($period['desc']["wind"]["knots"],1)." kt"; + } + echo "</td>\n"; + echo "<td>"; + if(isset($period['desc']["visibility"])) { + for($j=0;$j<count($period['desc']["visibility"]);$j++) { + $visi = & $period['desc']["visibility"][$j]; + if($visi["prefix"]==1) echo " > "; + else if($visi["prefix"]==-1) echo " < "; + else echo " "; + echo $visi["miles"]." SM"; + } + } + echo "</td>\n"; + echo "<td>"; + if(isset($period['desc']["clouds"])) { + for($j=0;$j<count($period['desc']["clouds"]);$j++) { + $cloud = & $period['desc']["clouds"][$j]; + $condition = $cloud["condition"]; + if($j!=0) echo " - "; + echo $condition; + if($condition=="SKC") { + } + else if($condition=="VV") { + echo " ".$cloud["ft"]." ft"; + } + else { + echo " at ".$cloud["ft"]." ft"; + } + } + } + echo "</td>\n"; + + echo "<td>"; + if(isset($period['desc']['weather'])) { + for($j=0;$j<count($period['desc']['weather']);$j++) { + $wx = & $period['desc']['weather'][$j]; + if($j!=0) echo " - "; + echo 'weather: '.$wx['proximity'].' '.$wx['intensity'].' '.$wx['descriptor'].' '.$wx['precipitation'].' '.$wx['obscuration'].' '.$wx['other']; + } + } + if(isset($period['desc']["wind_shear"])) { + for($j=0;$j<count($period['desc']["wind_shear"]);$j++) { + $ws = & $period['desc']["wind_shear"][$j]; + echo " wind shear at ".$ws["ft"]." ft "; + echo $ws["wind"]["deg"]." @ ".$ws["wind"]["knots"]." kt "; + } + } + echo "</td>\n"; + echo "</tr>\n"; + } + echo "</table><br>\n"; + } + + + /** * Makes a short weather-report in a table. * @@ -1209,9 +1292,9 @@ $humidity = $this->print_pretty_rel_humidity($data['rel_humidity']); - if ($this->properties['orientation'] == 'vertical') { + if ($this->properties['orientation'] == 'vertical') { - } else { + } else { echo '<table border="1">'; echo "\n <tr>\n"; |
From: Martin G. <gim...@us...> - 2003-09-09 01:02:21
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv23796 Modified Files: defaults-dist.php Log Message: I've updated the defaults to reflect the values given in config/make_config.php. This will break existing installations where the tables miss the 'pw_' prefix. How should we handle this, would it be enough to simply note it in the download instructions on SourceForge? Index: defaults-dist.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/defaults-dist.php,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- defaults-dist.php 8 Sep 2003 04:20:44 -0000 1.18 +++ defaults-dist.php 8 Sep 2003 08:02:33 -0000 1.19 @@ -34,10 +34,10 @@ $this->properties['db_pconnect'] = false; $this->properties['db_port'] = ''; -$this->properties['db_metars'] = 'metars'; /* pw_db_dba.php */ -$this->properties['db_tafs'] = 'tafs'; /* pw_db_dba.php */ -$this->properties['db_stations'] = 'stations'; -$this->properties['db_countries'] = 'countries'; +$this->properties['db_metars'] = 'pw_metars'; /* pw_db_dba.php */ +$this->properties['db_tafs'] = 'pw_tafs'; +$this->properties['db_stations'] = 'pw_stations'; +$this->properties['db_countries'] = 'pw_countries'; $this->properties['db_type'] = 'null'; /* db_layer.php */ @@ -46,7 +46,8 @@ $this->properties['mark_end'] = '</b>'; $this->properties['exclude'] = array(); -$this->properties['orientation'] = 'horizontal'; /* pw_text.php */ +// Not used at present... +//$this->properties['orientation'] = 'horizontal'; /* pw_text.php */ $this->properties['icons_path'] = 'icons/'; /* pw_images.php */ $this->properties['reverse_dir'] = false; |
From: Martin G. <gim...@us...> - 2003-09-08 21:29:06
|
Update of /cvsroot/phpweather/phpweather/config In directory sc8-pr-cvs1:/tmp/cvs-serv22553/config Modified Files: make_config.php Log Message: Let's include the new db_tafs option and also a couple of forgotten options for the icons. Index: make_config.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/make_config.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- make_config.php 1 Jul 2003 10:15:36 -0000 1.10 +++ make_config.php 8 Sep 2003 07:51:25 -0000 1.11 @@ -301,7 +301,13 @@ 'This is the name of the table that is used ' . 'to cache the METARs.', $db_dep, $table_validator, 'pw_metars'); - + + $HTTP_SESSION_VARS['db_tafs'] = + new pw_option_text('db_tafs', + 'This is the name of the table that is used ' . + 'to cache the TAFs.', + $db_dep, $table_validator, 'pw_tafs'); + $HTTP_SESSION_VARS['db_stations'] = new pw_option_text('db_stations', 'This is the name of the database/table that is used ' . @@ -332,12 +338,29 @@ "you've opened in <code>mark_begin</code>.", false, false, '</b>'); + $HTTP_SESSION_VARS['icons_path'] = + new pw_option_text('icons_path', + 'The path to the directory that stores the icons used in the ' . + 'output. You should set this to the absolute path from the ' . + 'server root if you need to use PHP Weather from several ' . + 'different locations on the server.', + false, false, 'icons/'); + + $HTTP_SESSION_VARS['reverse_dir'] = + new pw_option_boolean('reverse_dir', + 'The wind direction arrows will normally point in the ' . + 'same direction as the wind blows (so a wind direction ' . + 'of 45° will result in an arrow pointing up to the ' . + 'right) but if you want them reversed, then that\'s ' . + 'possible too.', + false, array('false' => 'Normal', 'true' => 'Reversed')); + $HTTP_SESSION_VARS['exclude'] = new pw_option_multi_select('exclude', 'You can disable some of the output produced. If ' . "you're not interested in information about " . 'runways-visibility, then select it in this list. ' . - 'You can select several options at once in Netscape ' . + 'You can select several options at once ' . 'by holding down Ctrl while clicking on the option.', false, array('time' => 'Leave out the time part', @@ -377,13 +400,13 @@ 'db_handler', 'db_pconnect', 'always_use_db', 'cache_timeout', 'db_hostname', 'db_port', 'db_username', 'db_password', 'db_database', - 'db_metars', 'db_stations', 'db_countries'), + 'db_metars', 'db_tafs', 'db_stations', 'db_countries'), !empty($HTTP_POST_VARS['db_group_visible'])); $rendering_group = new pw_optiongroup('rendering_group', 'Rendering Options', 'You can customize the looks of PHP Weather using these options.', - array('mark_begin', 'mark_end', 'exclude'), + array('mark_begin', 'mark_end', 'icons_path', 'reverse_dir', 'exclude'), !empty($HTTP_POST_VARS['rendering_group_visible'])); /* We can now generate a configuration file with the options selected so far: */ |
From: Etienne T. <eti...@us...> - 2003-09-08 04:25:57
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv25533 Added Files: test2.php Log Message: Added test2.php to test the retrieval and decoding of METAR and TAF reports --- NEW FILE --- <?php /* Call with a icao parameter i.e. test2.php?icao=KSFO */ error_reporting(E_ALL); /* We need the GET variables: */ extract($HTTP_GET_VARS); /* Load PHP Weather */ require('phpweather.php'); if (empty($language)) $language = 'en'; $weather = new phpweather(); if (!empty($icao)) { /* require(PHPWEATHER_BASE_DIR . "/output/pw_text_$language.php"); require(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); $type = 'pw_text_' . $language; $text = new $type($weather); echo "<blockquote>\n" . $text->print_pretty() . "</blockquote>\n"; $icons = new pw_images($weather); echo '<p><img src="'.$icons->get_sky_image().'" /> '; echo '<img src="'.$icons->get_winddir_image().'" /> '; echo '<img src="'.$icons->get_temp_image().'" /></p>'; */ /* if (is_array($icao)) { foreach ($icao as $i) { $weather->set_icao($i); echo "METAR for $i : ".$weather->get_metar()."<br>\n"; echo "<br>"; } } else { */ $weather->set_icao($icao); echo "METAR for $icao : ".$weather->get_metar()."<br>\n"; echo "<br>Decoded METAR:<pre>"; print_r( $weather->decode_metar() ); echo "</pre><br>\n"; echo "TAF for $icao : ".$weather->get_taf()."<br>\n"; echo "<br>Decoded TAF:<pre>"; print_r( $weather->decode_taf() ); echo "</pre><br>\n"; /* } */ } ?> </body> </html> |
From: Etienne T. <eti...@us...> - 2003-09-08 04:20:49
|
Update of /cvsroot/phpweather/phpweather In directory sc8-pr-cvs1:/tmp/cvs-serv24907 Modified Files: data_retrieval.php defaults-dist.php phpweather.php Log Message: Added TAF support. Modified data_retrieval.php, defaults-dist.php, phpweather.php, pw_db_mysql.php, pw_db_null.php. Needs to add output functionality and support all backends. Index: data_retrieval.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- data_retrieval.php 1 Jul 2003 09:34:54 -0000 1.31 +++ data_retrieval.php 8 Sep 2003 04:20:44 -0000 1.32 @@ -3,9 +3,9 @@ require_once(PHPWEATHER_BASE_DIR . '/db_layer.php'); /** - * This class contains all the logic needed to get and store METARs. + * This class contains all the logic needed to get and store METARs and TAFs. * - * It manages the caching system, the station and the METAR. + * It manages the caching system, the station, the METAR and the TAF. * * @author Martin Geisler <gim...@gi...> * @version $Id$ @@ -26,6 +26,19 @@ var $metar; /** + * The TAF is stored here. + * + * The property is used whenever someone wants access to the raw + * TAF. This should be used for reading only, if you want to + * change the TAF (for testing purposes etc.), then use + * set_taf() instead. + * + * @var string + * @see set_taf() + */ + var $taf; + + /** * Data associated with the current ICAO. * * @var array The array has three entries: name, country, @@ -129,20 +142,18 @@ } /** - * Retrieves a METAR report using fsockopen(). + * Retrieves a file using fsockopen(). * - * The communication with the proxy (if one is needed) and the NWS + * The communication with the proxy (if one is needed) and the host * is done using fsockopen(). This should be used when the file() * function is disabled. * * @access private - * @param string The ICAO for which the report will be fetched. - * @return array The raw METAR report line by line in an array. - * @see get_metar_file() + * @param string The host + * @param string The location of the file + * @return array The raw file line by line in an array. */ - function get_metar_socket($icao) { - $host = 'weather.noaa.gov'; - $location = "/pub/data/observations/metar/stations/$icao.TXT"; + function get_file_socket($host,$location) { $request = "HTTP/1.1\r\n" . "If-Modified-Since: Sat, 29 Oct 1994 09:00:00 GMT\r\n" . "Pragma: no-cache\r\n". @@ -164,7 +175,7 @@ "Connection: Close\r\n\r\n"; } - $metar_data = false; + $data = false; if ($fp) { fputs($fp, $request); @@ -179,15 +190,32 @@ /* We know now, that the following lines are the contents. */ while ($line = fgets($fp, 1024)) { - $metar_data[] = $line; + $data[] = $line; } fclose($fp); } } - return $metar_data; + return $data; } + /** + * Retrieves a METAR report using fsockopen(). + * + * The communication with the proxy (if one is needed) and the NWS + * is done using fsockopen(). This should be used when the file() + * function is disabled. + * + * @access private + * @param string The ICAO for which the report will be fetched. + * @return array The raw METAR report line by line in an array. + * @see get_metar_file() + */ + function get_metar_socket($icao) { + $host = 'weather.noaa.gov'; + $location = "/pub/data/observations/metar/stations/$icao.TXT"; + return $this->get_file_socket($host,$location); + } /** * Retrieves a METAR report using file(). @@ -207,7 +235,7 @@ return @file('http://' . $host . $location); } - + /** * Tries to get a METAR from the database. * @@ -266,7 +294,6 @@ } } - /** * Fetches a METAR from the Internet. * @@ -359,6 +386,248 @@ return $metar; } + + /** + * Retrieves a raw TAF, either from the web or from a database. + * + * If the TAF is already set, then it just returns that. If it's + * not set, then it tries to get it from the database. + * + * @access public + * @return string The raw TAF. + */ + function get_taf() { + if (empty($this->taf)) { + /* The TAF is not set - we try to load it */ + $this->debug('The TAF is not set, I\'ll try to find the TAF in the database.'); + return $this->get_taf_from_db(); + } else { + $this->debug('The TAF was set - I\'ll just use that.'); + return $this->taf; + } + } + + /** + * Sets the TAF directly, for testing etc + * + * It loads and decodes the TAF if it is different from the old + * one. If the new TAF is the same as the old one, nothing is + * changed. + * + * Also sets the ICAO to be correct for this TAF. + * + * @access public + * @param string The TAF we want decoded. + * @param string The icao of the station. + */ + function set_taf($new_taf) { + + if ($new_taf != $this->get_taf()) { + $this->debug('Loading a TAF manually.'); + $this->properties['icao'] = strtoupper(substr($new_taf,0,4)); + $this->icao_data = $this->db->lookup_icao($this->get_icao()); + $this->taf = $new_taf; + $this->decoded_taf = $this->decode_taf(); + } + } + + /** + * Retrieves a TAF report using fsockopen(). + * + * The communication with the proxy (if one is needed) and the NWS + * is done using fsockopen(). This should be used when the file() + * function is disabled. + * + * @access private + * @param string The ICAO for which the report will be fetched. + * @return array The raw TAF report line by line in an array. + * @see get_taf_file() + */ + function get_taf_socket($icao) { + $host = 'weather.noaa.gov'; + $location = "/pub/data/forecasts/taf/stations/$icao.TXT"; + return $this->get_file_socket($host,$location); + } + + /** + * Retrieves a TAF report using file(). + * + * The communication with the NWS is done using file(). This should + * only be used when a direct connection to the NWS can be + * established, the proxy settings isn't used with file(). + * + * @access private + * @param string The ICAO for which the report will be fetched. + * @return array The raw TAF report line by line in an array. + * @see get_taf_socket() + */ + function get_taf_file($icao) { + $host = 'weather.noaa.gov'; + $location = "/pub/data/forecasts/taf/stations/$icao.TXT"; + $this->debug("getting TAF from location: http://$host/$location"); + return @file('http://' . $host . $location); + } + + /** + * Tries to get a TAF from the database. + * + * It looks in the database, and fetches a new TAF if necessary. + * You do not have to be connected to the database before you call + * this function, just make sure that you have passed the right + * properties to the object. + * + * If $this->properties['always_use_db'] is True, then it ignores + * the timestamp of the TAF and just returns it. Otherwise it will + * try to get a new TAF from the web, if the old one is older than + * one hour. + * + * @access public + * @return string The raw TAF. + */ + function get_taf_from_db() { + if (!$this->db->connect()) { + return false; + } + + if ($data = $this->db->get_taf($this->get_icao())) { /* found station */ + $this->debug('get_taf_from_db(): Found the TAF in the database'); + list($taf, $timestamp) = $data; + + /* We set the TAF right away, and then count on + * get_taf_from_web() to set it to something else, if + * necessary. + */ + $this->taf = $taf; + if ($this->properties['always_use_db'] || + $timestamp > time() - $this->properties['cache_timeout']) { + + /* We have asked explicit for a cached TAF, or the TAF is + * still fresh. Either way - we return the TAF we found in + * the database. + */ + $this->debug('get_taf_from_db(): Using previously cached TAF for <code>' . + $this->get_location() . '</code>. The TAF expires in ' . + ($timestamp + $this->properties['cache_timeout'] - time()) . + ' seconds.'); + return $taf; + } else { + /* The TAF is too old, so we fetch new */ + $this->debug('get_taf_from_db(): The TAF for <code>' . + $this->get_location() . '</code> was ' . + (time() - $this->properties['cache_timeout'] - $timestamp) . + ' seconds too old.'); + return $this->get_taf_from_web(false); + } + } else { + /* We need to get a new TAF from the web. */ + $this->debug('get_taf_from_db(): New station <code>' . + $this->get_location() . '</code> - fetching a new TAF.'); + return $this->get_taf_from_web(true); + } + + } + + /** + * Fetches a TAF from the Internet. + * + * The TAF is fetched via HTTP from the National Weather Services + * public server. The files can be found under the + * http://weather.noaa.gov/pub/data/observations/taf/stations/ + * directory as ICAO.TXT where ICAO is replaced by the actual ICAO. + * + * @param boolean Should the station be inserted into the database, + * or should we update an already existing entry? + * @access public + * @return string The raw TAF. + */ + function get_taf_from_web($new_station) { + + $taf = ''; + $icao = $this->get_icao(); + + switch ($this->properties['fetch_method']) { + case 'file': + $taf_data = $this->get_taf_file($icao); + break; + case 'fsockopen': + default: + $taf_data = $this->get_taf_socket($icao); + break; + } + + /* Here we test to see if we actually got a TAF. */ + if (!empty($taf_data) && count($taf_data)>0) { + /* The first line in the file is the date */ + $date = trim(array_shift($taf_data)); + /* The remaining lines are the TAF itself. This will merge the + * remaining lines into one line by removing new-lines: + */ + $taf = ereg_replace("[\n\r ]+", ' ', trim(implode(' ', $taf_data))); + + $date = explode(':', strtr($date, '/ ', '::')); + if ($date[2] > gmdate('j')) { + /* The day is greater that the current day of month. This + * implies, that the report is from last month. + */ + $date[1]--; + } + $timestamp = gmmktime($date[3], $date[4], 0, + $date[1], $date[2], $date[0]); + + if (!ereg('[0-9]{6}Z', $taf)) { + /* Some reports don't even have a time-part, so we insert the + * current time. This might not be the time of the report, but + * it was broken anyway :-) + */ + $taf = gmdate('dHi', $timestamp) . 'Z ' . $taf; + } + + //ET here adjust because reports are updated less often than matars + //tmp always set the timeout to 1 hour from now + $timestamp = time() - $this->properties['cache_timeout'] + 60*60; + +// if ($timestamp < (time() - $this->properties['cache_timeout'] + 300)) { +// /* The timestamp in the TAF is more than 55 minutes old. We +// * adjust the timestamp, so that we won't try to fetch a new +// * TAF within the next 5 minutes. After 5 minutes, the +// * timestamp will again be more than 1 hour old. +// */ +// $timestamp = time() - $this->properties['cache_timeout'] + 300; +// } + + } + + else { + /* If we end up here, it means that there was no file. If the + * station was a new station, we set the taf to an empty + * string, else we just use the old TAF. We adjust the time + * stored in the database in both cases, so that the server + * isn't stressed too much. + */ + if ($new_station) { + $taf = ''; + } else { + $taf = $this->taf; + } + $timestamp = time() - $this->properties['cache_timeout'] + 600; + } + + /* We then cache the TAF in our database */ + if ($new_station) { + $this->debug('get_taf_from_web(): Inserting new TAF for <code>' . + $this->get_location() . '</code>'); + $this->db->insert_taf($icao, $taf, $timestamp); + } else { + $this->debug('get_taf_from_web(): Updating TAF for <code>' . + $this->get_location() . '</code>'); + $this->db->update_taf($icao, $taf, $timestamp); + } + /* We update and return the TAF */ + $this->taf = $taf; + return $taf; + } + + /** Index: defaults-dist.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/defaults-dist.php,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- defaults-dist.php 20 Apr 2003 13:12:42 -0000 1.17 +++ defaults-dist.php 8 Sep 2003 04:20:44 -0000 1.18 @@ -35,6 +35,7 @@ $this->properties['db_port'] = ''; $this->properties['db_metars'] = 'metars'; /* pw_db_dba.php */ +$this->properties['db_tafs'] = 'tafs'; /* pw_db_dba.php */ $this->properties['db_stations'] = 'stations'; $this->properties['db_countries'] = 'countries'; Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- phpweather.php 14 Jun 2003 23:34:59 -0000 1.33 +++ phpweather.php 8 Sep 2003 04:20:44 -0000 1.34 @@ -1,5 +1,5 @@ <?php - + /** * The base directory of the PHP Weather installation. * @@ -41,6 +41,13 @@ * @var array */ var $decoded_metar; + + /** + * The decoded TAF is stored here. + * + * @var array + */ + var $decoded_taf; /** * This constructor does nothing besides passing the input down the @@ -681,6 +688,327 @@ $this->decoded_metar = $decoded_metar; return $decoded_metar; } + + /** + * Decodes a raw TAF. + * + * This function loops over the various parts of the raw TAF, and + * stores the different bits in $decoded_taf. It uses get_taf() to + * retrieve the TAF, so it is not necessary to connect to the database + * before you call this function. + * + * @return array The decoded TAF. + * @see $decoded_taf + * @access public + */ + function decode_taf() { + + /* initialization */ + $temp_visibility_miles = ''; + $decoded_taf = array(); + $decoded_taf['remarks'] = ''; + $decoded_taf['taf'] = $this->get_taf(); + $decoded_taf['location'] = $this->get_location(); + + if($this->taf!='') $parts = explode(' ', $this->taf); + else $parts = false; + $num_parts = count($parts); + if($parts === false || $num_parts==0) { + $this->decoded_taf = false; + $this->debug('decode_taf, parts is empty'); + return false; + } + + $current_period = 0; + $periods = array(); + $periods[0] = 'COMPLETE'; + $remarks_index = $num_parts - 1; + + $decoded_taf['icao'] = $parts[0]; + $decoded_taf['time_emit'] = $parts[1]; + $decoded_taf['time_use'] = $parts[2]; + $periods[0] .= ' '.$parts[2]; + + /* first pass to get remarks and periods */ + for ($i = 3; $i < $num_parts; $i++) { + $part = $parts[$i]; + if($i<$num_parts-1) $part2 = $parts[$i+1]; + else $part2 = ''; + + if ($part=='RMK') { + /* The rest of the TAF is either a remark or temporary + * information. We keep the remark. + */ + $remarks_index = $i; + for($j=$i;$j<$num_parts; $j++) + $decoded_taf['remarks'] .= ' ' . $parts[$j]; + break; + } + else if ( (substr($part,0,2)=='FM') || $part=='BECMG' || + ($part=='TEMPO') || (substr($part,0,4)=='PROB') ) { + $current_period++; + $periods[$current_period] = $part; + } + else { + $periods[$current_period] .= ' '.$part; + } + + } + + $decoded_periods = array(); + + /* for each period, parse the data */ + if(count($periods)>0) { + for($j=0;$j<count($periods);$j++) { + $tmp_period = $periods[$j]; + $data_period = $tmp_period; + $parts = explode(' ', $tmp_period); + $num_parts = count($parts); + + $decoded_periods[$j] = array(); + $decoded_period = & $decoded_periods[$j]; + + $first_i = 1; + $time_from = $time_to = false; + $type = $prob = false; + if ( (substr($parts[0],0,2)=='FM') ) { + $type = 'FM'; + $time_from = substr($parts[0],2,4); + $time_to = false; + $first_i = 1; + } + else if ($parts[0]=='BECMG') { + $type = 'BECMG'; + $first_i = 2; + } + else if ($parts[0]=='TEMPO') { + $type = 'TEMPO'; + $time_from = substr($parts[1],0,2).'00'; + $time_to = substr($parts[1],2,2).'00'; + $first_i = 2; + } + else if (substr($parts[0],0,4)=='PROB') { + $type = 'PROB'; + $time_from = substr($parts[1],0,2).'00'; + $time_to = substr($parts[1],2,2).'00'; + $prob = intval(substr($parts[0],4)); + $first_i = 2; + } + else if($parts[0]=='COMPLETE'){ + $type = 'COMPLETE'; + $data_period = substr($data_period,9); + $time_from = substr($parts[1],2,2).'00'; + $time_to = substr($parts[1],4,2).'00'; + $first_i = 2; + } + else { + $first_i = $num_parts; + } + + $decoded_period['data'] = $data_period; + $decoded_period['type'] = $type; + $decoded_period['time_from'] = $time_from; + $decoded_period['time_to'] = $time_to; + $decoded_period['prob'] = $prob; + + /* pass each element of the period */ + for($i=$first_i;$i<$num_parts;$i++) { + $part = $parts[$i]; + + if (ereg('^([0-9]{3}|VRB)([0-9]{2,3})G?([0-9]{2,3})?(KT)', $part, $regs)) { + /* Wind Group */ + + $decoded_period['wind']['deg'] = $regs[1]; + $this->store_speed($regs[2], + $regs[4], + $decoded_period['wind']['knots'], + $decoded_period['wind']['meters_per_second'], + $decoded_period['wind']['miles_per_hour']); + + if (!empty($regs[3])) { + + /* We have a report with information about the gust. + * First we have the gust measured in knots. + */ + $this->store_speed($regs[3], + $regs[4], + $decoded_period['wind']['gust_knots'], + $decoded_period['wind']['gust_meters_per_second'], + $decoded_period['wind']['gust_miles_per_hour']); + } + } elseif (ereg('^([0-9]{3})V([0-9]{3})$', $part, $regs) && + !empty($decoded_period['wind']['deg'])) { + /* + * Variable wind-direction + */ + $decoded_period['wind']['var_beg'] = $regs[1]; + $decoded_period['wind']['var_end'] = $regs[2]; + } elseif (ereg('^([0-9]{4})([NS]?[EW]?)$', $part, $regs)) { + /* + * Visibility in meters (4 digits only) + */ + unset($group); + + if ($regs[1] == '0000') { + /* Special low value */ + + $group['prefix'] = -1; /* Less than */ + $group['meter'] = 50; + $group['km'] = 0.05; + $group['ft'] = 164; + $group['miles'] = 0.031; + } elseif ($regs[1] == '9999') { + /* Special high value */ + $group['prefix'] = 1; + $group['meter'] = 10000; + $group['km'] = 10; + $group['ft'] = 32800; + $group['miles'] = 6.2; + } else { + /* Normal visibility, returned in both small and large units. */ + $group['prefix'] = 0; + $group['km'] = number_format($regs[1]/1000, 1); + $group['miles'] = number_format($regs[1]/1609.344, 1); + $group['meter'] = $regs[1] * 1; + $group['ft'] = round($regs[1] * 3.28084); + } + if (!empty($regs[2])) { + $group['dir'] = $regs[2]; + } + $decoded_period['visibility'][] = $group; + + } elseif (ereg('^[0-9]$', $part)) { + /* + * Temp Visibility Group, single digit followed by space. + */ + $temp_visibility_miles = $part; + + } elseif ($part=='P6SM') { + unset($group); + $group['prefix'] = 1; + $vis_miles = 6; + $group['miles'] = number_format($vis_miles, 1); + $group['ft'] = round($vis_miles * 5280, 1); + $group['km'] = number_format($vis_miles * 1.6093, 1); + $group['meter'] = round($vis_miles * 1609.3); + $decoded_period['visibility'][] = $group; + + } elseif (ereg('^[M]?(([0-9]?)[ ]?([0-9])(/?)([0-9]*))SM$', + $temp_visibility_miles . ' ' . $part, $regs)) { + /* + * Visibility Group + */ + unset($group); + + if ($regs[4] == '/') { + $vis_miles = $regs[2] + $regs[3]/$regs[5]; + } else { + $vis_miles = $regs[1]; + } + if ($regs[0][0] == 'M') { + /* Prefix - less than */ + $group['prefix'] = -1; + } else { + $group['prefix'] = 0; + } + + /* The visibility measured in miles */ + $group['miles'] = number_format($vis_miles, 1); + + /* The visibility measured in feet */ + $group['ft'] = round($vis_miles * 5280, 1); + + /* The visibility measured in kilometers */ + $group['km'] = number_format($vis_miles * 1.6093, 1); + + /* The visibility measured in meters */ + $group['meter'] = round($vis_miles * 1609.3); + + $decoded_period['visibility'][] = $group; + + } elseif (ereg('^(VC)?' . /* Proximity */ + '(-|\+)?' . /* Intensity */ + '(MI|PR|BC|DR|BL|SH|TS|FZ)?' . /* Descriptor */ + '((DZ|RA|SN|SG|IC|PL|GR|GS|UP)+)?' . /* Precipitation */ + '(BR|FG|FU|VA|DU|SA|HZ|PY)?' . /* Obscuration */ + '(PO|SQ|FC|SS)?$', /* Other */ + $part, $regs)) { + /* + * Current weather-group. + */ + $decoded_period['weather'][] = + array('proximity' => $regs[1], + 'intensity' => $regs[2], + 'descriptor' => $regs[3], + 'precipitation' => $regs[4], + 'obscuration' => $regs[6], + 'other' => $regs[7]); + + } elseif ($part == 'SKC' || $part == 'CLR') { + /* Cloud-group */ + $decoded_period['clouds'][]['condition'] = $part; + + } elseif (ereg('^(VV|FEW|SCT|BKN|OVC)([0-9]{3}|///)' . + '(CB|TCU)?$', $part, $regs)) { + /* We have found (another) a cloud-layer-group. */ + unset($group); + + $group['condition'] = $regs[1]; + if (!empty($regs[3])) { + $group['cumulus'] = $regs[3]; + } + if ($regs[2] == '000') { + /* '000' is a special height. */ + $group['ft'] = 100; + $group['meter'] = 30; + $group['prefix'] = -1; /* Less than */ + } elseif ($regs[2] == '///') { + /* '///' means height nil */ + $group['ft'] = 'nil'; + $group['meter'] = 'nil'; + } else { + $group['ft'] = $regs[2] *100; + $group['meter'] = round($regs[2] * 30.48); + } + $decoded_period['clouds'][] = $group; + + } elseif (ereg('^WS([0-9]{3})/([0-9]{3})([0-9]{2})KT$', $part, $regs)) { + /* We have found a Wind Shear group. example WS011/27050KT */ + unset($ws); + if ($regs[1] == '000') { + /* '000' is a special height. */ + $ws['ft'] = 100; + $ws['meter'] = 30; + } elseif ($regs[1] == '///') { + /* '///' means height nil */ + $ws['ft'] = 'nil'; + $ws['meter'] = 'nil'; + } else { + $ws['ft'] = $regs[1] *100; + $ws['meter'] = round($regs[1] * 30.48); + } + $ws['wind']['dir'] = $regs[2]; + $this->store_speed($regs[3],'KT', + $ws['wind']['knots'], + $ws['wind']['meters_per_second'], + $ws['wind']['miles_per_hour']); + $decoded_period['wind_shear'][] = $ws; + } + } + } + $decoded_taf['periods'] = $decoded_periods; + $decoded_taf['remarks'] = trim($decoded_taf['remarks']); + } + + /* Finally we store our decoded TAF in $this->decoded_taf so + * that other methods can use it. + */ + + $this->decoded_taf = $decoded_taf; + return $decoded_taf; + + } + } ?> |