[Phphtmllib-devel] SF.net SVN: phphtmllib:[3446] trunk/open2300/lib/modules/api/ AviationWeather.in
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2010-06-15 19:55:46
|
Revision: 3446 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3446&view=rev Author: hemna Date: 2010-06-15 19:55:34 +0000 (Tue, 15 Jun 2010) Log Message: ----------- fixed php issues Modified Paths: -------------- trunk/open2300/lib/modules/api/AviationWeather.inc Modified: trunk/open2300/lib/modules/api/AviationWeather.inc =================================================================== --- trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-15 19:37:42 UTC (rev 3445) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-15 19:55:34 UTC (rev 3446) @@ -164,13 +164,7 @@ $group++; } - protected function get_wind($part, &$metarPtr, &$group, &$wxInfo) { - // Decodes wind direction and speed information. - // Format is dddssKT where ddd = degrees from North, ss = speed, KT for knots, - // or dddssGggKT where G stands for gust and gg = gust speed. (ss or gg can be a 3-digit number.) - // KT can be replaced with MPH for meters per second or KMH for kilometers per hour. - - function speed($part, $unit) { + protected function speed($part, $unit) { // Convert wind speed into miles per hour. // Some other common conversion factors (to 6 significant digits): // 1 mi/hr = 1.15080 knots = 0.621371 km/hr = 2.23694 m/s @@ -183,8 +177,15 @@ else $speed = round(0.621371 * $part); // from km per hour $speed = "$speed mph"; return $speed; - } + } + protected function get_wind($part, &$metarPtr, &$group, &$wxInfo) { + // Decodes wind direction and speed information. + // Format is dddssKT where ddd = degrees from North, ss = speed, KT for knots, + // or dddssGggKT where G stands for gust and gg = gust speed. (ss or gg can be a 3-digit number.) + // KT can be replaced with MPH for meters per second or KMH for kilometers per hour. + + if (preg_match('/^([0-9G]{5,10}|VRB[0-9]{2,3})(KT|MPS|KMH)$/',$part,$pieces)) { $part = $pieces[1]; $unit = $pieces[2]; @@ -200,8 +201,8 @@ $direction = $compass[round($angle / 22.5) % 16]; } if ($pieces[3] == 0) $gust = ''; - else $gust = ', gusting to ' . speed($pieces[3], $unit); - $wxInfo['WIND'] = $direction . ' at ' . speed($pieces[2], $unit) . $gust; + else $gust = ', gusting to ' . $this->speed($pieces[3], $unit); + $wxInfo['WIND'] = $direction . ' at ' . $this->speed($pieces[2], $unit) . $gust; } $metarPtr++; } @@ -374,15 +375,7 @@ } } } - - protected function get_temperature($part, &$metarPtr, &$group, &$wxInfo) { - // Decodes temperature and dew point information. Relative humidity is calculated. Also, - // depending on the temperature, Heat Index or Wind Chill Temperature is calculated. - // Format is tt/dd where tt = temperature and dd = dew point temperature. All units are - // in Celsius. A 'M' preceeding the tt or dd indicates a negative temperature. Some - // stations do not report dew point, so the format is tt/ or tt/XX. - - function get_heat_index($tempF, $rh, &$wxInfo) { + protected function get_heat_index($tempF, $rh, &$wxInfo) { // Calculate Heat Index based on temperature in F and relative humidity (65 = 65%) if ($tempF > 79 && $rh > 39) { $hiF = -42.379 + 2.04901523 * $tempF + 10.14333127 * $rh - 0.22475541 * $tempF * $rh; @@ -393,9 +386,9 @@ $hiC = round(($hiF - 32) / 1.8); $wxInfo['HEAT INDEX'] = "$hiF°F ($hiC°C)"; } - } + } - function get_wind_chill($tempF, &$wxInfo) { + protected function get_wind_chill($tempF, &$wxInfo) { // Calculate Wind Chill Temperature based on temperature in F and // wind speed in miles per hour if ($tempF < 51 && $wxInfo['WIND'] != 'calm') { @@ -408,20 +401,29 @@ $wxInfo['WIND CHILL'] = "$chillF°F ($chillC°C)"; } } - } + } + protected function get_temperature($part, &$metarPtr, &$group, &$wxInfo) { + // Decodes temperature and dew point information. Relative humidity is calculated. Also, + // depending on the temperature, Heat Index or Wind Chill Temperature is calculated. + // Format is tt/dd where tt = temperature and dd = dew point temperature. All units are + // in Celsius. A 'M' preceeding the tt or dd indicates a negative temperature. Some + // stations do not report dew point, so the format is tt/ or tt/XX. + + + if (preg_match('/^(M?[0-9]{2})\/(M?[0-9]{2}|[X]{2})?$/',$part,$pieces)) { $tempC = (integer) strtr($pieces[1], 'M', '-'); $tempF = round(1.8 * $tempC + 32); $wxInfo['TEMP'] = "$tempF°F ($tempC°C)"; - get_wind_chill($tempF, $wxInfo); + $this->get_wind_chill($tempF, $wxInfo); if (strlen($pieces[2]) != 0 && $pieces[2] != 'XX') { $dewC = (integer) strtr($pieces[2], 'M', '-'); $dewF = round(1.8 * $dewC + 32); $wxInfo['DEWPT'] = "$dewF°F ($dewC°C)"; $rh = round(100 * pow((112 - (0.1 * $tempC) + $dewC) / (112 + (0.9 * $tempC)), 8)); $wxInfo['HUMIDITY'] = $rh . '%'; - get_heat_index($tempF, $rh, $wxInfo); + $this->get_heat_index($tempF, $rh, $wxInfo); } $metarPtr++; $group++; @@ -461,4 +463,4 @@ } -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |