Thread: Syntax and adding images..
Brought to you by:
iridium
From: Donovan A. H. <do...@hu...> - 2002-03-27 02:12:11
|
I have PHPWeather running but I am having a few issues getting the precipitation to show up, I'd also like to add an image of the current weather conditions like on the http://www.moulton-udell.k12.ia.us/ site as described in the below message. It seems like I'm making this process over complicated, but it is working all except for the precipin and I believe that is due to the wrong syntax. Here is the current code I am using: -- start -- <?php include('./weather/phpweather.inc'); include('./weather/locale_en.inc'); $metar = get_metar('KVCT'); $data = process_metar($metar); $temp_f = $data['temp_f']; $windmph = $data['wind_miles_per_hour']; $winddir = $data['wind_dir_text_short']; $dewf = $data['dew_f']; $humidity = $data['rel_humidity']; $visibility = $data['visibility_miles']; $precipin = $data['precip_6h_in']; echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">Temp:</font></div></td><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">$temp_f °F</font></div></td></tr>"; echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">Wind:</font></div></td><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">$windmph mph $winddir</font></div></td></tr>"; echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">Dew Point:</font></div></td><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">$dewf °F</font></div></td></tr>"; echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">Humidity:</font></div></td><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">$humidity %</font></div></td></tr>"; echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">Visibility:</font></div></td><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">$visibility m</font></div></td></tr>"; echo "<tr><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">Precipitation:</font></div></td><td><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">$precipin</font></div></td></tr>"; ?> -- end -- Regards, Donovan A. Huff Huff Data Systems Owner/Operator (361) 501-2957 www.huffdatasystems.com Message: 8094298 FROM: Kevin GodbyDATE: 03/13/2002 14:29:00SUBJECT: RE: Bug' with weather icons (images.inc) allo! on 3/13/02 3:01 PM, Ray van Beek at <EMAIL: PROTECTED> wrote: > Well, my web site is here: http://www.moulton-udell.k12.ia.us/ The > weather > is located in the navigation column on the left-hand side (at the bottom). > It looks okay in IE, but for some reason, my columns get squished in > Netscape. I'm still trying to work on that. > > I found it. Great! Do you mind if I reference your site on my 'Online > weather' project page http://www.devolder.nl ? Be my guest! I found it extraordinarily easy to use the phpweather.inc and images.inc files. Works marvelously! >This way if there is no current weather data in the metar, it will fall >back >on the cloud condition. Hope this helps. > > That *is* a good idea. Well, I don't know if most weather stations report current weather conditions frequently or not. But the station I'm using doesn't appear to use them very often, so instead of printing nothing, I decided to print the cloud conditions. It's a little more useful that way. > Now Kevin, I like the today's specials for lunch. Maybe I'll drop by :-) <grin> Well then, you won't want to miss tomorrow's lunch -- we're having turkey fritters and hash browns! Thanks again for the script and graphics -- they look great! ---- Kevin Godby <<EMAIL: PROTECTED>> Technology Coordinator Moulton-Udell Community School District 305 E. Eighth St. Phone: (641) 642-8131 Moulton, Iowa 52572 Fax: (641) 642-3461 |
From: Martin G. <gim...@gi...> - 2002-03-27 08:53:18
|
"Donovan A. Huff" <do...@hu...> writes: > I have PHPWeather running but I am having a few issues getting the > precipitation to show up, I'd also like to add an image of the > current weather conditions like on the > http://www.moulton-udell.k12.ia.us/ site as described in the below > message. That should be easy now that we have images.inc. That's where the functions that deal with images are defined. The following code works: <?php include('./locale_en.inc'); include('./images.inc'); include('./phpweather.inc'); $metar =3D get_metar('EHEH'); $decoded_metar=3Dprocess_metar($metar); ?> <img src=3D"<? get_temp_image($decoded_metar) ?>" height=3D"50" width=3D"20= " border=3D"1"> <img src=3D"<? get_winddir_image($decoded_metar) ?>" height=3D"40" width=3D= "40" border=3D"1"> <img src=3D"<? get_sky_image($decoded_metar) ?>" height=3D"50" width=3D"80"= border=3D"1"> The code is taken from the file tables.php which is also in CVS in the phpweather-1.x directory. There you'll find a comprehensive test of the functions that deal with images. =20 > It seems like I'm making this process over complicated, but it is > working all except for the precipin and I believe that is due to the > wrong syntax. The problem is, that the precip_6h_in entry isn't a standard field in the METARs. So you cannot rely on it being available at all times, if at all. > Here is the current code I am using: >=20 > -- start -- >=20 > <?php > include('./weather/phpweather.inc'); > include('./weather/locale_en.inc'); > $metar =3D get_metar('KVCT'); > $data =3D process_metar($metar); > $temp_f =3D $data['temp_f']; > $windmph =3D $data['wind_miles_per_hour']; > $winddir =3D $data['wind_dir_text_short']; > $dewf =3D $data['dew_f']; > $humidity =3D $data['rel_humidity']; > $visibility =3D $data['visibility_miles']; > $precipin =3D $data['precip_6h_in']; Something like this would probably be better: if (empty($data['precip_6h_in'])) { $precipin =3D 'None'; } else { $precipin =3D $data['precip_6h_in']; } =20 =2D-=20 Martin Geisler My GnuPG Key: 0xF7F6B57B See my homepage at http://www.gimpster.com/ for: PHP Weather =3D> Shows the current weather on your webpage. PHP Shell =3D> A telnet-connection (almost :-) in a PHP page. |