CVS: phpweather-1.x images.inc,1.3,1.4 wap.php,1.2,1.3
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-07-11 16:07:31
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv12593 Modified Files: images.inc wap.php Log Message: Fabio Parri <pa...@ut...> has converted the images from GIF format into WBMP format which can be used by WAP enabled phones. So the images.inc file has been changed so that the extension used is configurable - this could be turned into a full-blown theming system, but lets wait until someone submits another set of icons before we do that... Index: images.inc =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/images.inc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- images.inc 28 Jun 2002 15:56:56 -0000 1.3 +++ images.inc 11 Jul 2002 16:07:27 -0000 1.4 @@ -15,8 +15,13 @@ // This section contains user configurable items: The user can configure // the image filenames to be generated by the script. -// Specify the absolute path to the directory that contains the weather -// icon files. +// Specify the extension of the images. You can choose between '.gif' +// for normal GIF images and '.wbmp' for images to WAP phones. + +$image_extension = '.gif'; + +// Specify the absolute path to the directory that contains the +// weather icon files. $abs_image_path = 'pw_icons/'; @@ -60,7 +65,7 @@ unset($n_images); } -$sky_nodata_image = 'sky_nodata.gif'; +$sky_nodata_image = 'sky_nodata'; // Define a lot of images for daylight weather-group/cloud condition. // It's a 2-dimensional array, indexed by the: @@ -68,56 +73,56 @@ // - Cloud coverage (second index). $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') + 'None' => array ('0' => '0cloud', + '1' => '1cloud_norain', + '2' => '2cloud_norain', + '3' => '3cloud_norain', + '4' => '4cloud_norain'), + '-Rain' => array ('0' => '0cloud', + '1' => '1cloud_lightrain', + '2' => '2cloud_lightrain', + '3' => '3cloud_lightrain', + '4' => '4cloud_lightrain'), + 'Rain' => array ('0' => '0cloud', + '1' => '1cloud_modrain', + '2' => '2cloud_modrain', + '3' => '3cloud_modrain', + '4' => '4cloud_modrain'), + '+Rain' => array ('0' => '0cloud', + '1' => '1cloud_heavyrain', + '2' => '2cloud_heavyrain', + '3' => '3cloud_heavyrain', + '4' => '4cloud_heavyrain'), + '-Snow' => array ('0' => '0cloud', + '1' => '2cloud_snow', + '2' => '2cloud_snow', + '3' => '3cloud_snow', + '4' => '4cloud_lightsnow'), + '+Snow' => array ('0' => '0cloud', + '1' => '2cloud_snow', + '2' => '2cloud_snow', + '3' => '3cloud_snow', + '4' => '4cloud_heavysnow'), + '-Hail' => array ('0' => '0cloud', + '1' => '2cloud_hail', + '2' => '2cloud_hail', + '3' => '3cloud_hail', + '4' => '4cloud_lighthail'), + '+Hail' => array ('0' => '0cloud', + '1' => '2cloud_hail', + '2' => '2cloud_hail', + '3' => '3cloud_hail', + '4' => '4cloud_heavyhail'), + 'Thun' => array ('0' => '0cloud', + '1' => '2cloud_thunders', + '2' => '2cloud_thunders', + '3' => '3cloud_thunders', + '4' => '4cloud_thunders'), + 'Fog' => array ('0' => '0cloud_fog', + '1' => '1cloud_fog', + '2' => '2cloud_fog', + '3' => '3cloud_fog', + '4' => '4cloud_fog') ); // Define a lot of images for nigh time weather-group/cloud condition. @@ -127,56 +132,56 @@ // - Cloud coverage (second index). $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', + '1' => 'n_1cloud_norain', + '2' => 'n_2cloud_norain', + '3' => 'n_3cloud_norain', + '4' => '4cloud_norain'), + '-Rain' => array ('0' => 'n_0cloud', + '1' => 'n_1cloud_lightrain', + '2' => 'n_2cloud_lightrain', + '3' => 'n_3cloud_lightrain', + '4' => '4cloud_lightrain'), + 'Rain' => array ('0' => 'n_0cloud', + '1' => 'n_1cloud_modrain', + '2' => 'n_2cloud_modrain', + '3' => 'n_3cloud_modrain', + '4' => '4cloud_modrain'), + '+Rain' => array ('0' => 'n_0cloud', + '1' => 'n_1cloud_heavyrain', + '2' => 'n_2cloud_heavyrain', + '3' => 'n_3cloud_heavyrain', + '4' => '4cloud_heavyrain'), + '-Snow' => array ('0' => 'n_0cloud', + '1' => 'n_2cloud_snow', + '2' => 'n_2cloud_snow', + '3' => 'n_3cloud_snow', + '4' => '4cloud_lightsnow'), + '+Snow' => array ('0' => 'n_0cloud', + '1' => 'n_2cloud_snow', + '2' => 'n_2cloud_snow', + '3' => 'n_3cloud_snow', + '4' => '4cloud_heavysnow'), + '-Hail' => array ('0' => 'n_0cloud', + '1' => 'n_2cloud_hail', + '2' => 'n_2cloud_hail', + '3' => 'n_3cloud_hail', + '4' => '4cloud_lighthail'), + '+Hail' => array ('0' => 'n_0cloud', + '1' => 'n_2cloud_hail', + '2' => 'n_2cloud_hail', + '3' => 'n_3cloud_hail', + '4' => '4cloud_heavyhail'), + 'Thun' => array ('0' => 'n_0cloud', + '1' => 'n_2cloud_thunders', + '2' => 'n_2cloud_thunders', + '3' => 'n_3cloud_thunders', + '4' => '4cloud_thunders'), + 'Fog' => array ('0' => 'n_0cloud_fog', + '1' => 'n_1cloud_fog', + '2' => 'n_2cloud_fog', + '3' => 'n_3cloud_fog', + '4' => '4cloud_fog') ); // Define image filenames for: @@ -186,36 +191,36 @@ // - calm wind (00000KT), or 'nodir' $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'); - -$wind_nodata_image = 'wind_nodata.gif'; -$wind_vrb_image = 'vrb.gif'; -$wind_nodir_image = 'nodir.gif'; + 0 => 'nnn', + 1 => 'nne', + 2 => 'ne', + 3 => 'nee', + 4 => 'eee', + 5 => 'see', + 6 => 'se', + 7 => 'sse', + 8 => 'sss', + 9 => 'ssw', + 10 => 'sw', + 11 => 'sww', + 12 => 'www', + 13 => 'nww', + 14 => 'nw', + 15 => 'nnw', + 16 => 'nnn'); + +$wind_nodata_image = 'wind_nodata'; +$wind_vrb_image = 'vrb'; +$wind_nodir_image = 'nodir'; // Define image filenames for: // - 'no data' condition, // - 'temperature zero or below zero degrees Celcius // - 'temperature above zero degrees Celcius -$temp_nodata_image = 'temp_nodata.gif'; -$temp_low_image = 'templow.gif'; -$temp_high_image = 'temphigh.gif'; +$temp_nodata_image = 'temp_nodata'; +$temp_low_image = 'templow'; +$temp_high_image = 'temphigh'; // ====================================================================== // The wind_speeds array can be used to convert wind speed values in [m/s] @@ -237,10 +242,9 @@ // ? >" height="50" width="80" border="1"> function get_sky_image($processed_metar_data) { - global $abs_image_path, $strings; - global $itime; - - global $phenomena_array, $coverage, $images, $n_images; + global $abs_image_path, $image_extension, + $strings, $itime, + $phenomena_array, $coverage, $images, $n_images; $metar = $processed_metar_data['metar']; @@ -345,9 +349,11 @@ // can be selected from the array. if (($night == 1) || ($itime == 'nite')) { - echo $abs_image_path . $n_images[$phenomena_group][$maxcoverage]; + echo $abs_image_path . $n_images[$phenomena_group][$maxcoverage] . + $image_extension; } else { - echo $abs_image_path . $images[$phenomena_group][$maxcoverage]; + echo $abs_image_path . $images[$phenomena_group][$maxcoverage] . + $image_extension; } } @@ -365,21 +371,22 @@ // ? >" height="40" width="40" border="1"> function get_winddir_image($processed_metar_data) { - global $abs_image_path, + global $abs_image_path, $image_extension, $wind_nodir_image,$wind_dir_images,$wind_nodata_image, $wind_vrb_image,$strings; if (isset($processed_metar_data['wind_deg'])) { if ($processed_metar_data['wind_deg'] == $strings['wind_vrb_long']) { - echo $abs_image_path . $wind_vrb_image; - } elseif (($processed_metar_data['wind_deg'] == 0) && ($processed_metar_data['wind_knots'] == 0)) { - echo $abs_image_path . $wind_nodir_image; + echo $abs_image_path . $wind_vrb_image . $image_extension; + } elseif (($processed_metar_data['wind_deg'] == 0) && + ($processed_metar_data['wind_knots'] == 0)) { + echo $abs_image_path . $wind_nodir_image . $image_extension; } else { $array_index = round($processed_metar_data['wind_deg']/22.5); - echo $abs_image_path . $wind_dir_images[$array_index]; + echo $abs_image_path . $wind_dir_images[$array_index] . $image_extension; } } else { - echo $abs_image_path . $wind_nodata_image; + echo $abs_image_path . $wind_nodata_image . $image_extension; } } // ------------------------------------------------------------------------ @@ -396,17 +403,17 @@ // ? >" height="50" width="20" border="1"> function get_temp_image($processed_metar_data) { - global $abs_image_path, + global $abs_image_path, $image_extension, $temp_high_image,$temp_low_image,$temp_nodata_image; if (isset($processed_metar_data['temp_c'])) { if ($processed_metar_data['temp_c'] > 0) { - echo $abs_image_path . $temp_high_image; + echo $abs_image_path . $temp_high_image . $image_extension; } else { - echo $abs_image_path . $temp_low_image; + echo $abs_image_path . $temp_low_image . $image_extension; } } else { - echo $abs_image_path . $temp_nodata_image; + echo $abs_image_path . $temp_nodata_image . $image_extension; } } // ------------------------------------------------------------------------ Index: wap.php =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/wap.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- wap.php 19 Apr 2002 18:15:49 -0000 1.2 +++ wap.php 11 Jul 2002 16:07:28 -0000 1.3 @@ -3,6 +3,10 @@ /* $Id$ */ include('phpweather.inc'); +include('images.inc'); + +/* We cannot use GIF images for WAP: */ +$image_extension = '.wbmp'; echo "<?xml version=\"1.0\"?>\n"; ?> @@ -33,8 +37,9 @@ $city = 'EKYT'; } $metar = get_metar($city); -pretty_print_metar_wap($metar, $cities[$city]) +pretty_print_metar_wap($metar, $cities[$city]); ?> +<img src="<? get_sky_image(process_metar($metar)) ?>" height="50" width="80" border="1" /> <p> <?php |