Thread: [Phphtmllib-devel] SF.net SVN: phphtmllib:[3440] trunk/open2300/lib/modules/api/ AviationWeather.in
Status: Beta
Brought to you by:
hemna
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3440]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-15 17:49:54
|
Revision: 3440 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3440&view=rev Author: hemna Date: 2010-06-15 17:49:47 +0000 (Tue, 15 Jun 2010) Log Message: ----------- first stab Added Paths: ----------- trunk/open2300/lib/modules/api/AviationWeather.inc Added: trunk/open2300/lib/modules/api/AviationWeather.inc =================================================================== --- trunk/open2300/lib/modules/api/AviationWeather.inc (rev 0) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-15 17:49:47 UTC (rev 3440) @@ -0,0 +1,423 @@ +<?php + +/** + * This class is meant to act as an API + * to fetch METAR information from a remote + * site, then process it and combine it with the + * airport data and return it as a JSON object. + * + * This can handle requests for multiple airports + * at once. + * + * @author waboring + * + */ +class AviationWeather extends JSONWidget { + + const ID = "avwx"; + + protected $url = "http://api.itimeteo.com/getMetar.ims?icao=XX_ICAO_XX&decoded=true&displayAirport=true&format=json"; + + //list of airports to fetch. + protected $airports; + + public function init() { + + } + + public function build_object() { + + } + + + public function get_metar($station, &$wxInfo) { + // This function retrieves METAR information for a given station from the + // National Weather Service. It assumes that the station exists. + // A slower URL is "ftp://weather.noaa.gov/data/observations/metar/stations/$station.TXT" + $fileName = "http://weather.noaa.gov/pub/data/observations/metar/stations/$station.TXT"; + $metar = ''; + + + $proxy = $GLOBALS["config"]->get("proxy"); + if (!empty($proxy)) { + $context = stream_context_create(array("http" => array("proxy" => "tcp://".$proxy))); + } else { + $context = null; + } + + $fileData = @file($fileName, 0, $context); // or die('Data not available'); + if ($fileData != false) { + list($i, $date) = each($fileData); + $utc = strtotime(trim($date)); + $this->set_time_data($utc,$wxInfo); + while (list($i, $line) = each($fileData)) { + $metar .= ' ' . trim($line); + } + $metar = trim(str_replace(' ', ' ', $metar)); + } + return $metar; + } + + protected function set_time_data($utc, &$wxInfo) { + // This function formats observation time in the local time zone of server, the + // current local time on server, and time difference since observation. $utc is a + // UNIX timestamp for Universal Coordinated Time (Greenwich Mean Time or Zulu Time). + $timeZoneOffset = date('Z'); + $local = $utc + $timeZoneOffset; + $wxInfo['OBSERVED'] = date('D M j, H:i T',$local); + $now = time(); + $wxInfo['NOW'] = date('D M j, H:i T',$now); + $timeDiff = floor(($now - $local) / 60); + if ($timeDiff < 91) $wxInfo['AGE'] = "$timeDiff min ago"; + else { + $min = $timeDiff % 60; + if ($min < 10) $min = '0' . $min; + $wxInfo['AGE'] = floor($timeDiff / 60) . ":$min hr ago"; + } + } + + public function process_metar($metar, &$wxInfo) { + // This function directs the examination of each group of the METAR. The problem + // with a METAR is that not all the groups have to be there. Some groups could be + // missing. Fortunately, the groups must be in a specific order. (This function + // also assumes that a METAR is well-formed, that is, no typographical mistakes.) + // This function uses a function variable to organize the sequence in which to + // decode each group. Each function checks to see if it can decode the current + // METAR part. If not, then the group pointer is advanced for the next function + // to try. If yes, the function decodes that part of the METAR and advances the + // METAR pointer and group pointer. (If the function can be called again to + // decode similar information, then the group pointer does not get advanced.) + if ($metar != '') { + $metarParts = explode(' ',$metar); + $groupName = array('get_station','get_time','get_station_type','get_wind','get_var_wind','get_visibility','get_runway','get_conditions','get_cloud_cover','get_temperature','get_altimeter'); + $metarPtr = 1; // get_station identity is ignored + $group = 1; + while ($group < count($groupName)) { + $part = $metarParts[$metarPtr]; + call_user_func_array(array($this, $groupName[$group]), array($part,&$metarPtr,&$group,&$wxInfo)); + //$groupName[$group]($part,$metarPtr,$group,$wxInfo); // $groupName is a function variable + } + } + else $wxInfo['ERROR'] = 'Data not available'; + } + + protected function get_station($part, &$metarPtr, &$group, &$wxInfo) { + // Ignore station code. Script assumes this matches requesting $station. + // This function is never called. It is here for completeness of documentation. + if (strlen($part) == 4 and $group == 0) { + $group++; + $metarPtr++; + } + } + + protected function get_time($part, &$metarPtr, &$group, &$wxInfo) { + // Ignore observation time. This information is found in the first line of the NWS file. + // Format is ddhhmmZ where dd = day, hh = hours, mm = minutes in UTC time. + if (substr($part,-1) == 'Z') $metarPtr++; + $group++; + } + + protected function get_station_type($part, &$metarPtr, &$group, &$wxInfo) { + // Ignore station type if present. + if ($part == 'AUTO' || $part == 'COR') $metarPtr++; + $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) { + // 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 + // 1 ft/s = 1.68781 knots = 0.911344 km/hr = 3.28084 m/s + // 1 knot = 0.539957 km/hr = 1.94384 m/s + // 1 km/hr = 1.852 knots = 3.6 m/s + // 1 m/s = 0.514444 knots = 0.277778 km/s + if ($unit == 'KT') $speed = round(1.1508 * $part); // from knots + elseif ($unit == 'MPS') $speed = round(2.23694 * $part); // from meters per second + else $speed = round(0.621371 * $part); // from km per hour + $speed = "$speed mph"; + return $speed; + } + + if (preg_match('/^([0-9G]{5,10}|VRB[0-9]{2,3})(KT|MPS|KMH)$/',$part,$pieces)) { + $part = $pieces[1]; + $unit = $pieces[2]; + if ($part == '00000') { + $wxInfo['WIND'] = 'calm'; // no wind + } + else { + preg_match('/([0-9]{3}|VRB)([0-9]{2,3})G?([0-9]{2,3})?/',$part,$pieces); + if ($pieces[1] == 'VRB') $direction = 'varies'; + else { + $angle = (integer) $pieces[1]; + $compass = array('N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'); + $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; + } + $metarPtr++; + } + $group++; + } + + protected function get_var_wind($part, &$metarPtr, &$group, &$wxInfo) { + // Ignore variable wind direction information if present. + // Format is fffVttt where V stands for varies from fff degrees to ttt degrees. + if (preg_match('/([0-9]{3})V([0-9]{3})/',$part,$pieces)) $metarPtr++; + $group++; + } + + protected function get_visibility($part, &$metarPtr, &$group, &$wxInfo) { + // Decodes visibility information. This function will be called a second time + // if visibility is limited to an integer mile plus a fraction part. + // Format is mmSM for mm = statute miles, or m n/dSM for m = mile and n/d = fraction of a mile, + // or just a 4-digit number nnnn (with leading zeros) for nnnn = meters. + static $integerMile = ''; + if (strlen($part) == 1) { // visibility is limited to a whole mile plus a fraction part + $integerMile = $part . ' '; + $metarPtr++; + } else if (substr($part,-2) == 'SM') { // visibility is in miles + $part = substr($part,0,strlen($part)-2); + if (substr($part,0,1) == 'M') { + $prefix = 'less than '; + $part = substr($part, 1); + } else { + $prefix = ''; + } + if (($integerMile == '' && preg_match('/[\/]/',$part,$pieces)) || $part == '1') { + $unit = ' mile'; + } else { + $unit = ' miles'; + } + $wxInfo['VISIBILITY'] = $prefix . $integerMile . $part . $unit; + $metarPtr++; + $group++; + + } else if (substr($part,-2) == 'KM') { // unknown (Reported by NFFN in Fiji) + $metarPtr++; + $group++; + + } elseif (preg_match('/^([0-9]{4})$/',$part,$pieces)) { // visibility is in meters + $distance = round($part/ 621.4, 1); // convert to miles + if ($distance > 5) $distance = round($distance); + if ($distance <= 1) $unit = ' mile'; + else $unit = ' miles'; + $wxInfo['VISIBILITY'] = $distance . $unit; + $metarPtr++; + $group++; + + } else if ($part == 'CAVOK') { // good weather + $wxInfo['VISIBILITY'] = 'greater than 7 miles'; // or 10 km + $wxInfo['CONDITIONS'] = ''; + $wxInfo['CLOUDS'] = 'clear skies'; + $metarPtr++; + $group += 4; // can skip the next 3 groups + + } else { + $group++; + } + } + + protected function get_runway($part, &$metarPtr, &$group, &$wxInfo) { + // Ignore runway information if present. Maybe called a second time. + // Format is Rrrr/vvvvFT where rrr = runway number and vvvv = visibility in feet. + if (substr($part,0,1) == 'R') { + $metarPtr++; + } else { + $group++; + } + } + + protected function get_conditions($part, &$metarPtr, &$group, &$wxInfo) { + // Decodes current weather conditions. This function maybe called several times + // to decode all conditions. To learn more about weather condition codes, visit section + // 12.6.8 - Present Weather Group of the Federal Meteorological Handbook No. 1 at + // www.nws.noaa.gov/oso/oso1/oso12/fmh1/fmh1ch12.htm + static $conditions = ''; + static $wxCode = array( + 'VC' => 'nearby', + 'MI' => 'shallow', + 'PR' => 'partial', + 'BC' => 'patches of', + 'DR' => 'low drifting', + 'BL' => 'blowing', + 'SH' => 'showers', + 'TS' => 'thunderstorm', + 'FZ' => 'freezing', + 'DZ' => 'drizzle', + 'RA' => 'rain', + 'SN' => 'snow', + 'SG' => 'snow grains', + 'IC' => 'ice crystals', + 'PE' => 'ice pellets', + 'GR' => 'hail', + 'GS' => 'small hail', // and/or snow pellets + 'UP' => 'unknown', + 'BR' => 'mist', + 'FG' => 'fog', + 'FU' => 'smoke', + 'VA' => 'volcanic ash', + 'DU' => 'widespread dust', + 'SA' => 'sand', + 'HZ' => 'haze', + 'PY' => 'spray', + 'PO' => 'well-developed dust/sand whirls', + 'SQ' => 'squalls', + 'FC' => 'funnel cloud, tornado, or waterspout', + 'SS' => 'sandstorm/duststorm'); + if (preg_match('/^(-|\+|VC)?(TS|SH|FZ|BL|DR|MI|BC|PR|RA|DZ|SN|SG|GR|GS|PE|IC|UP|BR|FG|FU|VA|DU|SA|HZ|PY|PO|SQ|FC|SS|DS)+$/',$part,$pieces)) { + if (strlen($conditions) == 0) $join = ''; + else $join = ' & '; + if (substr($part,0,1) == '-') { + $prefix = 'light '; + $part = substr($part,1); + } + elseif (substr($part,0,1) == '+') { + $prefix = 'heavy '; + $part = substr($part,1); + } + else $prefix = ''; // moderate conditions have no descriptor + $conditions .= $join . $prefix; + // The 'showers' code 'SH' is moved behind the next 2-letter code to make the English translation read better. + if (substr($part,0,2) == 'SH') $part = substr($part,2,2) . substr($part,0,2). substr($part, 4); + while ($code = substr($part,0,2)) { + $conditions .= $wxCode[$code] . ' '; + $part = substr($part,2); + } + $wxInfo['CONDITIONS'] = $conditions; + $metarPtr++; + } + else { + $wxInfo['CONDITIONS'] = $conditions; + $group++; + } + } + + protected function get_cloud_cover($part, &$metarPtr, &$group, &$wxInfo) { + // Decodes cloud cover information. This function maybe called several times + // to decode all cloud layer observations. Only the last layer is saved. + // Format is SKC or CLR for clear skies, or cccnnn where ccc = 3-letter code and + // nnn = altitude of cloud layer in hundreds of feet. 'VV' seems to be used for + // very low cloud layers. (Other conversion factor: 1 m = 3.28084 ft) + static $cloudCode = array( + 'SKC' => 'clear skies', + 'CLR' => 'clear skies', + 'FEW' => 'partly cloudy', + 'SCT' => 'scattered clouds', + 'BKN' => 'mostly cloudy', + 'OVC' => 'overcast', + 'VV' => 'vertical visibility'); + if ($part == 'SKC' || $part == 'CLR') { + $wxInfo['CLOUDS'] = $cloudCode[$part]; + $metarPtr++; + $group++; + } + else { + if (preg_match('/^([A-Z]{2,3})([0-9]{3})/',$part,$pieces)) { // codes for CB and TCU are ignored + $wxInfo['CLOUDS'] = $cloudCode[$pieces[1]]; + if ($pieces[1] == 'VV') { + $altitude = (integer) 100 * $pieces[2]; // units are feet + $wxInfo['CLOUDS'] .= " to $altitude ft"; + } + $metarPtr++; + } + else { + $group++; + } + } + } + + 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) { + // 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; + $hiF += -0.00683783 * pow($tempF, 2) - 0.05481717 * pow($rh, 2); + $hiF += 0.00122874 * pow($tempF, 2) * $rh + 0.00085282 * $tempF * pow($rh, 2); + $hiF += -0.00000199 * pow($tempF, 2) * pow($rh, 2); + $hiF = round($hiF); + $hiC = round(($hiF - 32) / 1.8); + $wxInfo['HEAT INDEX'] = "$hiF°F ($hiC°C)"; + } + } + + 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') { + $pieces = explode(' ', $wxInfo['WIND']); + $windspeed = (integer) $pieces[2]; // wind speed must be in miles per hour + if ($windspeed > 3) { + $chillF = 35.74 + 0.6215 * $tempF - 35.75 * pow($windspeed, 0.16) + 0.4275 * $tempF * pow($windspeed, 0.16); + $chillF = round($chillF); + $chillC = round(($chillF - 32) / 1.8); + $wxInfo['WIND CHILL'] = "$chillF°F ($chillC°C)"; + } + } + } + + 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); + 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); + } + $metarPtr++; + $group++; + } + else { + $group++; + } + } + + protected function get_altimeter($part, &$metarPtr, &$group, &$wxInfo) { + // Decodes altimeter or barometer information. + // Format is Annnn where nnnn represents a real number as nn.nn in inches of Hg, + // or Qpppp where pppp = hectoPascals. + // Some other common conversion factors: + // 1 millibar = 1 hPa + // 1 in Hg = 0.02953 hPa + // 1 mm Hg = 25.4 in Hg = 0.750062 hPa + // 1 lb/sq in = 0.491154 in Hg = 0.014504 hPa + // 1 atm = 0.33421 in Hg = 0.0009869 hPa + if (preg_match('/^(A|Q)([0-9]{4})/',$part,$pieces)) { + if ($pieces[1] == 'A') { + $pressureIN = substr($pieces[2],0,2) . '.' . substr($pieces[2],2); // units are inches Hg + $pressureHPA = round($pressureIN / 0.02953); // convert to hectoPascals + } + else { + $pressureHPA = (integer) $pieces[2]; // units are hectoPascals + $pressureIN = round(0.02953 * $pressureHPA,2); // convert to inches Hg + } + $wxInfo['BAROMETER'] = "$pressureHPA hPa ($pressureIN in Hg)"; + $metarPtr++; + $group++; + } + else { + $group++; + } + } + +} + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3445]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-15 19:37:48
|
Revision: 3445 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3445&view=rev Author: hemna Date: 2010-06-15 19:37:42 +0000 (Tue, 15 Jun 2010) Log Message: ----------- more shit 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 17:51:46 UTC (rev 3444) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-15 19:37:42 UTC (rev 3445) @@ -16,20 +16,61 @@ const ID = "avwx"; - protected $url = "http://api.itimeteo.com/getMetar.ims?icao=XX_ICAO_XX&decoded=true&displayAirport=true&format=json"; + //protected $url = "http://api.itimeteo.com/getMetar.ims?icao=XX_ICAO_XX&decoded=true&displayAirport=true&format=json"; //list of airports to fetch. protected $airports; + protected $metars = array(); + + private $cache; + public function init() { + $airports = Request::singleton()->get("airports"); + if (strlen($airports) >0) { + $this->airports = explode(',', strtoupper($airports)); + } + $this->cache = AirportCache::singleton(); } public function build_object() { + + $size = count($this->airports); + if ($size > 0) { + foreach($this->airports as $icao) { + $airport = $this->process_airport($icao); + $this->metars[] = $airport; + } + } + return $this->metars; } + + public function process_airport($icao) { + + $wxInfo = array(); + $metar = $this->get_metar($icao, $wxInfo); + + if ($metar != null && strlen($metar) > 0) { + $this->process_metar($metar, $wxInfo); + $wxInfo["metar"] = $metar; + + $airport = $this->cache->get($icao); + if ($airport != null) { + + } + $this->metars[] = $wxInfo; + //need to combine this info w/ the airport data cache. + } + + return $wxInfo; + + } + + public function get_metar($station, &$wxInfo) { // This function retrieves METAR information for a given station from the // National Weather Service. It assumes that the station exists. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3446]
trunk/open2300/lib/modules/api/ AviationWeather.inc
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. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3463]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 21:14:37
|
Revision: 3463 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3463&view=rev Author: hemna Date: 2010-06-16 21:14:30 +0000 (Wed, 16 Jun 2010) Log Message: ----------- working on xw 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-16 20:21:48 UTC (rev 3462) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 21:14:30 UTC (rev 3463) @@ -59,17 +59,44 @@ $airport = $this->cache->get($icao); if ($airport != null) { - + $wxInfo["runways"] = $this->get_runways($airport); } $this->metars[] = $wxInfo; //need to combine this info w/ the airport data cache. } - return $wxInfo; + return $wxInfo; + } + + protected function get_runways($airport) { + $runways = $airport["runways"]; + $info = array(); + foreach($runways as $runway) { + $width = $runway["runway_width"] * 3.2808399; + $info[] = array("number" => $runway["runway_number"], + "length" => $runway["length"], + "width" => $width); + $xw = $this->get_crosswind($runway["runway_number"], $runway["WIND"], $runway[""]); + } + + return $info; } + protected function get_crosswind($runway) { + $number = substr($runway,0,2); + $wind = $runway["WIND"]; + + $direction = $runway[""]; + + if (stricasecmp($wind, "calm") == 0) { + $wind = 0; + } + + + } + public function get_metar($station, &$wxInfo) { // This function retrieves METAR information for a given station from the @@ -191,18 +218,33 @@ $unit = $pieces[2]; if ($part == '00000') { $wxInfo['WIND'] = 'calm'; // no wind + $wxInfo['Wind']["human"] = 'calm'; + $wxInfo['Wind']["speed"] = 0; + $wxInfo['Wind']["angle"] = 0; + $wxInfo['Wind']["gust"] = 0; } else { preg_match('/([0-9]{3}|VRB)([0-9]{2,3})G?([0-9]{2,3})?/',$part,$pieces); - if ($pieces[1] == 'VRB') $direction = 'varies'; - else { + if ($pieces[1] == 'VRB') { + $direction = 'varies'; + $angle = 'VRB'; + } else { $angle = (integer) $pieces[1]; $compass = array('N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'); $direction = $compass[round($angle / 22.5) % 16]; } - if ($pieces[3] == 0) $gust = ''; - else $gust = ', gusting to ' . $this->speed($pieces[3], $unit); + if ($pieces[3] == 0) { + $gust = ''; + $wxInfo['Wind']["gust"] = 0; + } else { + $spd = $this->speed($pieces[3], $unit); + $gust = ', gusting to ' . $spd; + $wxInfo['Wind']["gust"] = $spd; + } $wxInfo['WIND'] = $direction . ' at ' . $this->speed($pieces[2], $unit) . $gust; + $wxInfo['Wind']['human'] = $direction . ' at ' . $this->speed($pieces[2], $unit) . $gust; + $wxInfo['Wind']["speed"] = $pieces[2]; + $wxInfo['Wind']["angle"] = $angle; } $metarPtr++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3464]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 21:16:03
|
Revision: 3464 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3464&view=rev Author: hemna Date: 2010-06-16 21:15:53 +0000 (Wed, 16 Jun 2010) Log Message: ----------- strcasecmp 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-16 21:14:30 UTC (rev 3463) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 21:15:53 UTC (rev 3464) @@ -90,7 +90,7 @@ $direction = $runway[""]; - if (stricasecmp($wind, "calm") == 0) { + if (strcasecmp($wind, "calm") == 0) { $wind = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3465]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 21:24:40
|
Revision: 3465 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3465&view=rev Author: hemna Date: 2010-06-16 21:24:33 +0000 (Wed, 16 Jun 2010) Log Message: ----------- xw 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-16 21:15:53 UTC (rev 3464) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 21:24:33 UTC (rev 3465) @@ -78,23 +78,19 @@ $info[] = array("number" => $runway["runway_number"], "length" => $runway["length"], "width" => $width); - $xw = $this->get_crosswind($runway["runway_number"], $runway["WIND"], $runway[""]); + $xw = $this->get_crosswind($runway["runway_number"], $runway["Wind"]); + $runway["crosswind"] = $xw; } return $info; } - protected function get_crosswind($runway) { - $number = substr($runway,0,2); - $wind = $runway["WIND"]; + protected function get_crosswind($number, $wind) { + $number = substr($runway,0,2)."0"; + $direction = $wind["angle"]; + $speed = $wind["speed"]; - $direction = $runway[""]; - - if (strcasecmp($wind, "calm") == 0) { - $wind = 0; - } - - + return $speed * sine($direction - $number); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3466]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 21:25:11
|
Revision: 3466 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3466&view=rev Author: hemna Date: 2010-06-16 21:25:05 +0000 (Wed, 16 Jun 2010) Log Message: ----------- sine 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-16 21:24:33 UTC (rev 3465) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 21:25:05 UTC (rev 3466) @@ -90,7 +90,7 @@ $direction = $wind["angle"]; $speed = $wind["speed"]; - return $speed * sine($direction - $number); + return $speed * sin($direction - $number); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3467]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 21:26:22
|
Revision: 3467 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3467&view=rev Author: hemna Date: 2010-06-16 21:26:16 +0000 (Wed, 16 Jun 2010) Log Message: ----------- use reference 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-16 21:25:05 UTC (rev 3466) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 21:26:16 UTC (rev 3467) @@ -73,7 +73,7 @@ $runways = $airport["runways"]; $info = array(); - foreach($runways as $runway) { + foreach($runways as &$runway) { $width = $runway["runway_width"] * 3.2808399; $info[] = array("number" => $runway["runway_number"], "length" => $runway["length"], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3469]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 22:15:32
|
Revision: 3469 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3469&view=rev Author: hemna Date: 2010-06-16 22:15:26 +0000 (Wed, 16 Jun 2010) Log Message: ----------- hacks 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-16 21:58:39 UTC (rev 3468) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 22:15:26 UTC (rev 3469) @@ -59,7 +59,7 @@ $airport = $this->cache->get($icao); if ($airport != null) { - $wxInfo["runways"] = $this->get_runways($airport); + $wxInfo["runways"] = $this->get_runways($airport, $wxInfo); } $this->metars[] = $wxInfo; @@ -69,7 +69,7 @@ return $wxInfo; } - protected function get_runways($airport) { + protected function get_runways($airport, $wxInfo) { $runways = $airport["runways"]; $info = array(); @@ -78,19 +78,48 @@ $info[] = array("number" => $runway["runway_number"], "length" => $runway["length"], "width" => $width); - $xw = $this->get_crosswind($runway["runway_number"], $runway["Wind"]); - $runway["crosswind"] = $xw; + $xw = $this->do_crosswind($runway, $wxInfo["Wind"]); } return $info; } - protected function get_crosswind($number, $wind) { - $number = substr($runway,0,2)."0"; + protected function do_crosswind($runway, $wind) { + $number = substr($runway["runway_number"],0,2)."0"; $direction = $wind["angle"]; $speed = $wind["speed"]; - return $speed * sin($direction - $number); + $xw = $speed * sin(($direction - $number)*.0174); + + $runway["crosswind1"] = $xw; + + $left_right = $direction - $number; + $diff = abs($left_right); + $p = .0174*$diff; + + $q = abs($speed*sin($p)); + $m = abs($speed*cos($p)); + + $runway["crosswind2"] = $q; + $runway["headwind"] = $m; + + +// +// l = Rway.runwayd.value; +// n = Rway.wdirection.value; +// k = Rway.wspeed.value; +// o = Math.abs(n - l); +// oo = (n - l); //determine left or right relative wind +// p = .0174*o; +// q = Math.abs(k*(Math.sin(p))); +// m = Math.abs(k*(Math.cos(p))); +// Rway.cwresult.value=eval(Math.round(q)); +// +// Rway.cwresultloss.value=eval(Math.round(m)); + + + + return $xw } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3470]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 22:16:08
|
Revision: 3470 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3470&view=rev Author: hemna Date: 2010-06-16 22:16:02 +0000 (Wed, 16 Jun 2010) Log Message: ----------- 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-16 22:15:26 UTC (rev 3469) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 22:16:02 UTC (rev 3470) @@ -116,10 +116,8 @@ // Rway.cwresult.value=eval(Math.round(q)); // // Rway.cwresultloss.value=eval(Math.round(m)); - - - - return $xw + + return $xw; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3471]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 22:17:34
|
Revision: 3471 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3471&view=rev Author: hemna Date: 2010-06-16 22:17:26 +0000 (Wed, 16 Jun 2010) Log Message: ----------- bleh 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-16 22:16:02 UTC (rev 3470) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 22:17:26 UTC (rev 3471) @@ -84,7 +84,7 @@ return $info; } - protected function do_crosswind($runway, $wind) { + protected function do_crosswind(&$runway, $wind) { $number = substr($runway["runway_number"],0,2)."0"; $direction = $wind["angle"]; $speed = $wind["speed"]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3472]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 22:20:57
|
Revision: 3472 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3472&view=rev Author: hemna Date: 2010-06-16 22:20:51 +0000 (Wed, 16 Jun 2010) Log Message: ----------- updates 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-16 22:17:26 UTC (rev 3471) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 22:20:51 UTC (rev 3472) @@ -69,7 +69,7 @@ return $wxInfo; } - protected function get_runways($airport, $wxInfo) { + protected function get_runways(&$airport, &$wxInfo) { $runways = $airport["runways"]; $info = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3474]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 23:24:26
|
Revision: 3474 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3474&view=rev Author: hemna Date: 2010-06-16 23:24:20 +0000 (Wed, 16 Jun 2010) Log Message: ----------- bleh 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-16 22:48:09 UTC (rev 3473) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 23:24:20 UTC (rev 3474) @@ -61,7 +61,6 @@ if ($airport != null) { $wxInfo["runways"] = $this->get_runways($airport, $wxInfo); } - $this->metars[] = $wxInfo; //need to combine this info w/ the airport data cache. } @@ -70,16 +69,18 @@ } protected function get_runways(&$airport, &$wxInfo) { - $runways = $airport["runways"]; + $runways = &$airport["runways"]; $info = array(); - + + foreach($runways as &$runway) { $width = $runway["runway_width"] * 3.2808399; - $info[] = array("number" => $runway["runway_number"], + $xw = $this->do_crosswind($runway, $wxInfo["Wind"]); + $info[] = array("runway" => $runway["runway_number"], "length" => $runway["length"], - "width" => $width); - $xw = $this->do_crosswind($runway, $wxInfo["Wind"]); + "crosswind" => $runway["crosswind"]); } + return $info; } @@ -97,13 +98,29 @@ $diff = abs($left_right); $p = .0174*$diff; - $q = abs($speed*sin($p)); - $m = abs($speed*cos($p)); + $q = round(abs($speed*sin($p))); + $m = round(abs($speed*cos($p))); $runway["crosswind2"] = $q; $runway["headwind"] = $m; - - + + if ($left_right <0) { + $runway["xw_direction"] = "left"; + } else if ($left_right > 0) { + $runway["xw_direction"] = "right"; + } else if ($left_right == 0 || $left_right == 360 || + $left_right == 180) { + $runway["xw_direction"] = "none"; + } + + if ($diff < 90 || $diff > 270) { + $runway["xw_head"] = "headwind"; + } else { + $runway["xw_head"] = "tailwind"; + } + + $runway["crosswind"] = $q."kt ".$runway["xw_direction"]." ".$runway["xw_head"]; + // // l = Rway.runwayd.value; // n = Rway.wdirection.value; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3475]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 23:28:07
|
Revision: 3475 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3475&view=rev Author: hemna Date: 2010-06-16 23:28:01 +0000 (Wed, 16 Jun 2010) Log Message: ----------- xw and headwind 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-16 23:24:20 UTC (rev 3474) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 23:28:01 UTC (rev 3475) @@ -78,7 +78,8 @@ $xw = $this->do_crosswind($runway, $wxInfo["Wind"]); $info[] = array("runway" => $runway["runway_number"], "length" => $runway["length"], - "crosswind" => $runway["crosswind"]); + "crosswind" => $runway["crosswind"], + "headwind" => $runway["headwind"]); } @@ -119,7 +120,8 @@ $runway["xw_head"] = "tailwind"; } - $runway["crosswind"] = $q."kt ".$runway["xw_direction"]." ".$runway["xw_head"]; + $runway["crosswind"] = $q."kt ".$runway["xw_direction"]; + $runway["headwind"] = $m."kt ".$runway["xw_head"]; // // l = Rway.runwayd.value; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3476]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-16 23:28:58
|
Revision: 3476 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3476&view=rev Author: hemna Date: 2010-06-16 23:28:52 +0000 (Wed, 16 Jun 2010) Log Message: ----------- decimals 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-16 23:28:01 UTC (rev 3475) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-16 23:28:52 UTC (rev 3476) @@ -99,8 +99,8 @@ $diff = abs($left_right); $p = .0174*$diff; - $q = round(abs($speed*sin($p))); - $m = round(abs($speed*cos($p))); + $q = round(abs($speed*sin($p)),1); + $m = round(abs($speed*cos($p)),1); $runway["crosswind2"] = $q; $runway["headwind"] = $m; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3479]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 01:41:30
|
Revision: 3479 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3479&view=rev Author: hemna Date: 2010-06-17 01:41:24 +0000 (Thu, 17 Jun 2010) Log Message: ----------- bleh 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-17 01:36:22 UTC (rev 3478) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 01:41:24 UTC (rev 3479) @@ -72,14 +72,15 @@ $runways = &$airport["runways"]; $info = array(); - foreach($runways as &$runway) { + $number = $runway["runway_number"]; $width = $runway["runway_width"] * 3.2808399; $xw = $this->do_crosswind($runway, $wxInfo["Wind"]); $info[] = array("runway" => $runway["runway_number"], "length" => $runway["length"], "crosswind" => $runway["crosswind"], - "headwind" => $runway["headwind"]); + "headwind" => $runway["headwind"]); + } @@ -103,7 +104,6 @@ $m = round(abs($speed*cos($p)),1); $runway["crosswind2"] = $q; - $runway["headwind"] = $m; if ($left_right <0) { $runway["xw_direction"] = "left"; @@ -545,6 +545,9 @@ } } + + + } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3482]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 02:57:27
|
Revision: 3482 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3482&view=rev Author: hemna Date: 2010-06-17 02:57:19 +0000 (Thu, 17 Jun 2010) Log Message: ----------- fetch airport info 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-17 02:56:09 UTC (rev 3481) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 02:57:19 UTC (rev 3482) @@ -59,7 +59,20 @@ $airport = $this->cache->get($icao); if ($airport != null) { - $wxInfo["runways"] = $this->get_runways($airport, $wxInfo); + $wxInfo["runways"] = $this->get_runways($airport, $wxInfo); + $wxInfo["altitude"] = $airport["elevation"]; + + if (!isset($airport["details"])) { + $info = $this->get_airport_info($icao); + if (!is_null($info)) { + $airport["details"] = $info; + $this->cache->set($airport); + } + } + + if (isset($airport["details"])) { + var_dump($airport["details"]); + } } $this->metars[] = $wxInfo; //need to combine this info w/ the airport data cache. @@ -547,6 +560,39 @@ + protected function get_airport_info($icao) { + + $info = null; + //they will fail always unless the icao is 4 chars...lame. + if (strlen($icao) == 4) { + echo "\nfetch $icao"; + + $url = "http://api.itimeteo.com/getAirport.ims?format=json&icao=".strtoupper($icao); + + $proxy = $GLOBALS["config"]->get("proxy"); + if (!empty($proxy)) { + $context = stream_context_create(array("http" => array("proxy" => "tcp://".$proxy))); + } else { + $context = null; + } + + $raw = file_get_contents($url,0, $context); + $json = json_decode($raw); + echo "\rfetch $icao ".$json->status; + var_dump($json); + if ($json->status == 200) { + + var_dump($json); + return $json; + } else { + return null; + } + } else { + return null; + } + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3483]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 03:14:04
|
Revision: 3483 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3483&view=rev Author: hemna Date: 2010-06-17 03:13:58 +0000 (Thu, 17 Jun 2010) Log Message: ----------- detail info 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-17 02:57:19 UTC (rev 3482) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 03:13:58 UTC (rev 3483) @@ -65,7 +65,8 @@ if (!isset($airport["details"])) { $info = $this->get_airport_info($icao); if (!is_null($info)) { - $airport["details"] = $info; + $airport["details"] = 1; + $wxInfo = array_merge($wxInfo, $info); $this->cache->set($airport); } } @@ -74,7 +75,7 @@ var_dump($airport["details"]); } } - $this->metars[] = $wxInfo; + //$this->metars[] = $wxInfo; //need to combine this info w/ the airport data cache. } @@ -581,9 +582,13 @@ echo "\rfetch $icao ".$json->status; var_dump($json); if ($json->status == 200) { - - var_dump($json); - return $json; + $info = array("Name" => $info->Name, + "GeonameID" => $info->GeonameID, + "Timezone" => $info->Timezone, + "Latitude" => $info->Latitude, + "Longitude" => $info->Longitude); + var_dump($info); + return $json->Airport; } else { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3484]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 03:23:36
|
Revision: 3484 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3484&view=rev Author: hemna Date: 2010-06-17 03:23:30 +0000 (Thu, 17 Jun 2010) Log Message: ----------- fixes 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-17 03:13:58 UTC (rev 3483) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 03:23:30 UTC (rev 3484) @@ -62,12 +62,14 @@ $wxInfo["runways"] = $this->get_runways($airport, $wxInfo); $wxInfo["altitude"] = $airport["elevation"]; + if (!isset($airport["details"])) { $info = $this->get_airport_info($icao); + var_dump($info); if (!is_null($info)) { $airport["details"] = 1; $wxInfo = array_merge($wxInfo, $info); - $this->cache->set($airport); + $this->cache->set($icao,$airport); } } @@ -581,14 +583,13 @@ $json = json_decode($raw); echo "\rfetch $icao ".$json->status; var_dump($json); - if ($json->status == 200) { - $info = array("Name" => $info->Name, - "GeonameID" => $info->GeonameID, - "Timezone" => $info->Timezone, - "Latitude" => $info->Latitude, - "Longitude" => $info->Longitude); - var_dump($info); - return $json->Airport; + if ($json->Status == 200) { + $info = array("Name" => $json->Airport->Name, + "GeonameID" => $json->Airport->GeonameID, + "Timezone" => $json->Airport->Timezone, + "Latitude" => $json->Airport->Latitude, + "Longitude" => $json->Airport->Longitude); + return $info; } else { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3485]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 03:24:56
|
Revision: 3485 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3485&view=rev Author: hemna Date: 2010-06-17 03:24:50 +0000 (Thu, 17 Jun 2010) Log Message: ----------- get gmt offset 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-17 03:23:30 UTC (rev 3484) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 03:24:50 UTC (rev 3485) @@ -587,7 +587,8 @@ $info = array("Name" => $json->Airport->Name, "GeonameID" => $json->Airport->GeonameID, "Timezone" => $json->Airport->Timezone, - "Latitude" => $json->Airport->Latitude, + "TimezoneOffset" => get_timezone_offset($info->Timezone, "GMT"), + "Latitude" => $json->Airport->Latitude, "Longitude" => $json->Airport->Longitude); return $info; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3486]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 03:27:04
|
Revision: 3486 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3486&view=rev Author: hemna Date: 2010-06-17 03:26:58 +0000 (Thu, 17 Jun 2010) Log Message: ----------- offset 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-17 03:24:50 UTC (rev 3485) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 03:26:58 UTC (rev 3486) @@ -587,7 +587,7 @@ $info = array("Name" => $json->Airport->Name, "GeonameID" => $json->Airport->GeonameID, "Timezone" => $json->Airport->Timezone, - "TimezoneOffset" => get_timezone_offset($info->Timezone, "GMT"), + "TimezoneOffset" => $this->get_timezone_offset($info->Timezone, "GMT"), "Latitude" => $json->Airport->Latitude, "Longitude" => $json->Airport->Longitude); return $info; @@ -599,6 +599,21 @@ } } + + protected function get_timezone_offset($remote_tz, $origin_tz = null) { + if($origin_tz === null) { + if(!is_string($origin_tz = date_default_timezone_get())) { + return false; // A UTC timestamp was returned -- bail out! + } + } + $origin_dtz = new DateTimeZone($origin_tz); + $remote_dtz = new DateTimeZone($remote_tz); + $origin_dt = new DateTime("now", $origin_dtz); + $remote_dt = new DateTime("now", $remote_dtz); + $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt); + return $offset; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3491]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 17:07:19
|
Revision: 3491 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3491&view=rev Author: hemna Date: 2010-06-17 17:07:12 +0000 (Thu, 17 Jun 2010) Log Message: ----------- updates 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-17 16:47:32 UTC (rev 3490) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 17:07:12 UTC (rev 3491) @@ -15,13 +15,14 @@ class AviationWeather extends JSONWidget { const ID = "avwx"; + const METAR_CACHE_TIMEOUT = 300; - //protected $url = "http://api.itimeteo.com/getMetar.ims?icao=XX_ICAO_XX&decoded=true&displayAirport=true&format=json"; - //list of airports to fetch. protected $airports; protected $metars = array(); + + protected $timer = NULL; private $cache; @@ -32,6 +33,7 @@ } $this->cache = AirportCache::singleton(); + //$this->timer = new Timer(); } public function build_object() { @@ -39,7 +41,9 @@ $size = count($this->airports); if ($size > 0) { foreach($this->airports as $icao) { + //$this->timer->start(); $airport = $this->process_airport($icao); + //echo "Time took ".$this->timer->get_elapsed()."<br>"; $this->metars[] = $airport; } } @@ -63,19 +67,14 @@ $wxInfo["altitude"] = $airport["elevation"]; - if (!isset($airport["details"])) { + if (!isset($airport["details"]) || true) { $info = $this->get_airport_info($icao); - var_dump($info); if (!is_null($info)) { $airport["details"] = 1; $wxInfo = array_merge($wxInfo, $info); $this->cache->set($icao,$airport); } } - - if (isset($airport["details"])) { - var_dump($airport["details"]); - } } //$this->metars[] = $wxInfo; //need to combine this info w/ the airport data cache. @@ -139,24 +138,18 @@ $runway["crosswind"] = $q."kt ".$runway["xw_direction"]; $runway["headwind"] = $m."kt ".$runway["xw_head"]; -// -// l = Rway.runwayd.value; -// n = Rway.wdirection.value; -// k = Rway.wspeed.value; -// o = Math.abs(n - l); -// oo = (n - l); //determine left or right relative wind -// p = .0174*o; -// q = Math.abs(k*(Math.sin(p))); -// m = Math.abs(k*(Math.cos(p))); -// Rway.cwresult.value=eval(Math.round(q)); -// -// Rway.cwresultloss.value=eval(Math.round(m)); - return $xw; } public function get_metar($station, &$wxInfo) { + + $cache_key = "METAR_".$station; + + $metar = $this->cache->get($cache_key); + if ($metar) { + return $metar; + } // This function retrieves METAR information for a given station from the // National Weather Service. It assumes that the station exists. // A slower URL is "ftp://weather.noaa.gov/data/observations/metar/stations/$station.TXT" @@ -181,6 +174,8 @@ } $metar = trim(str_replace(' ', ' ', $metar)); } + + $this->cache->set($cache_key, $metar, AviationWeather::METAR_CACHE_TIMEOUT); return $metar; } @@ -568,7 +563,7 @@ $info = null; //they will fail always unless the icao is 4 chars...lame. if (strlen($icao) == 4) { - echo "\nfetch $icao"; + //echo "\nfetch $icao"; $url = "http://api.itimeteo.com/getAirport.ims?format=json&icao=".strtoupper($icao); @@ -581,13 +576,13 @@ $raw = file_get_contents($url,0, $context); $json = json_decode($raw); - echo "\rfetch $icao ".$json->status; - var_dump($json); + //echo "\rfetch $icao ".$json->status; + //var_dump($json); if ($json->Status == 200) { $info = array("Name" => $json->Airport->Name, "GeonameID" => $json->Airport->GeonameID, "Timezone" => $json->Airport->Timezone, - "TimezoneOffset" => $this->get_timezone_offset($info->Timezone, "GMT"), + "TimezoneOffset" => $this->get_timezone_offset("GMT",$json->Airport->Timezone), "Latitude" => $json->Airport->Latitude, "Longitude" => $json->Airport->Longitude); return $info; @@ -611,7 +606,7 @@ $origin_dt = new DateTime("now", $origin_dtz); $remote_dt = new DateTime("now", $remote_dtz); $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt); - return $offset; + return $offset/3600; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3495]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 18:26:31
|
Revision: 3495 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3495&view=rev Author: hemna Date: 2010-06-17 18:26:25 +0000 (Thu, 17 Jun 2010) Log Message: ----------- added icao 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-17 18:20:38 UTC (rev 3494) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 18:26:25 UTC (rev 3495) @@ -54,7 +54,7 @@ public function process_airport($icao) { - $wxInfo = array(); + $wxInfo = array("icao" => strtoupper($icao)); $metar = $this->get_metar($icao, $wxInfo); if ($metar != null && strlen($metar) > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3496]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 18:38:51
|
Revision: 3496 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3496&view=rev Author: hemna Date: 2010-06-17 18:38:45 +0000 (Thu, 17 Jun 2010) Log Message: ----------- cleaned up some vars in the metar parsing 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-17 18:26:25 UTC (rev 3495) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 18:38:45 UTC (rev 3496) @@ -333,7 +333,7 @@ } else { $unit = ' miles'; } - $wxInfo['VISIBILITY'] = $prefix . $integerMile . $part . $unit; + $wxInfo['Visibility'] = $prefix . $integerMile . $part . $unit; $metarPtr++; $group++; @@ -346,14 +346,14 @@ if ($distance > 5) $distance = round($distance); if ($distance <= 1) $unit = ' mile'; else $unit = ' miles'; - $wxInfo['VISIBILITY'] = $distance . $unit; + $wxInfo['Visibility'] = $distance . $unit; $metarPtr++; $group++; } else if ($part == 'CAVOK') { // good weather - $wxInfo['VISIBILITY'] = 'greater than 7 miles'; // or 10 km - $wxInfo['CONDITIONS'] = ''; - $wxInfo['CLOUDS'] = 'clear skies'; + $wxInfo['Visibility'] = 'greater than 7 miles'; // or 10 km + $wxInfo['Conditions'] = ''; + $wxInfo['Clouds'] = 'clear skies'; $metarPtr++; $group += 4; // can skip the next 3 groups @@ -428,11 +428,11 @@ $conditions .= $wxCode[$code] . ' '; $part = substr($part,2); } - $wxInfo['CONDITIONS'] = $conditions; + $wxInfo['Conditions'] = $conditions; $metarPtr++; } else { - $wxInfo['CONDITIONS'] = $conditions; + $wxInfo['Conditions'] = $conditions; $group++; } } @@ -452,7 +452,7 @@ 'OVC' => 'overcast', 'VV' => 'vertical visibility'); if ($part == 'SKC' || $part == 'CLR') { - $wxInfo['CLOUDS'] = $cloudCode[$part]; + $wxInfo['Clouds'] = $cloudCode[$part]; $metarPtr++; $group++; } @@ -461,7 +461,7 @@ $wxInfo['CLOUDS'] = $cloudCode[$pieces[1]]; if ($pieces[1] == 'VV') { $altitude = (integer) 100 * $pieces[2]; // units are feet - $wxInfo['CLOUDS'] .= " to $altitude ft"; + $wxInfo['Clouds'] .= " to $altitude ft"; } $metarPtr++; } @@ -479,7 +479,7 @@ $hiF += -0.00000199 * pow($tempF, 2) * pow($rh, 2); $hiF = round($hiF); $hiC = round(($hiF - 32) / 1.8); - $wxInfo['HEAT INDEX'] = "$hiF°F ($hiC°C)"; + $wxInfo['HeatIndex'] = "$hiF°F ($hiC°C)"; } } @@ -493,7 +493,7 @@ $chillF = 35.74 + 0.6215 * $tempF - 35.75 * pow($windspeed, 0.16) + 0.4275 * $tempF * pow($windspeed, 0.16); $chillF = round($chillF); $chillC = round(($chillF - 32) / 1.8); - $wxInfo['WIND CHILL'] = "$chillF°F ($chillC°C)"; + $wxInfo['WindChill'] = "$chillF°F ($chillC°C)"; } } } @@ -510,14 +510,18 @@ 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)"; + $wxInfo['Temperature'] = "$tempF°F ($tempC°C)"; + $wxInfo['TempC'] = $tempC; + $wxInfo['TempF'] = $tempF; $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)"; + $wxInfo['Dewpoint'] = "$dewF°F ($dewC°C)"; + $wxInfo['DewpointC'] = $dewC; + $wxInfo['DewpointF'] = $dewF; $rh = round(100 * pow((112 - (0.1 * $tempC) + $dewC) / (112 + (0.9 * $tempC)), 8)); - $wxInfo['HUMIDITY'] = $rh . '%'; + $wxInfo['Humidity'] = $rh . '%'; $this->get_heat_index($tempF, $rh, $wxInfo); } $metarPtr++; @@ -547,7 +551,9 @@ $pressureHPA = (integer) $pieces[2]; // units are hectoPascals $pressureIN = round(0.02953 * $pressureHPA,2); // convert to inches Hg } - $wxInfo['BAROMETER'] = "$pressureHPA hPa ($pressureIN in Hg)"; + $wxInfo['Barometer'] = "$pressureHPA hPa ($pressureIN in Hg)"; + $wxInfo['BaroHg'] = $pressureIN; + $wxInfo['BaroHPA'] = $pressureHPA; $metarPtr++; $group++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
[Phphtmllib-devel] SF.net SVN: phphtmllib:[3498]
trunk/open2300/lib/modules/api/ AviationWeather.inc
From: <he...@us...> - 2010-06-17 19:10:58
|
Revision: 3498 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3498&view=rev Author: hemna Date: 2010-06-17 19:10:52 +0000 (Thu, 17 Jun 2010) Log Message: ----------- fixed gusts and units 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-17 19:00:09 UTC (rev 3497) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 19:10:52 UTC (rev 3498) @@ -146,8 +146,10 @@ $cache_key = "METAR_".$station; - $metar = $this->cache->get($cache_key); - if ($metar) { + $info = $this->cache->get($cache_key); + if ($info) { + $wxInfo = $info; + $metar = $wxInfo["metar"]; return $metar; } // This function retrieves METAR information for a given station from the @@ -175,7 +177,9 @@ $metar = trim(str_replace(' ', ' ', $metar)); } - $this->cache->set($cache_key, $metar, AviationWeather::METAR_CACHE_TIMEOUT); + $wxInfo["metar"] = $metar; + + $this->cache->set($cache_key, $wxInfo, AviationWeather::METAR_CACHE_TIMEOUT); return $metar; } @@ -185,15 +189,15 @@ // UNIX timestamp for Universal Coordinated Time (Greenwich Mean Time or Zulu Time). $timeZoneOffset = date('Z'); $local = $utc + $timeZoneOffset; - $wxInfo['OBSERVED'] = date('D M j, H:i T',$local); + $wxInfo['Observed'] = date('D M j, H:i T',$local); $now = time(); - $wxInfo['NOW'] = date('D M j, H:i T',$now); + $wxInfo['Now'] = date('D M j, H:i T',$now); $timeDiff = floor(($now - $local) / 60); if ($timeDiff < 91) $wxInfo['AGE'] = "$timeDiff min ago"; else { $min = $timeDiff % 60; if ($min < 10) $min = '0' . $min; - $wxInfo['AGE'] = floor($timeDiff / 60) . ":$min hr ago"; + $wxInfo['Age'] = floor($timeDiff / 60) . ":$min hr ago"; } } @@ -255,7 +259,7 @@ if ($unit == 'KT') $speed = round(1.1508 * $part); // from knots elseif ($unit == 'MPS') $speed = round(2.23694 * $part); // from meters per second else $speed = round(0.621371 * $part); // from km per hour - $speed = "$speed mph"; + //$speed = "$speed mph"; return $speed; } @@ -268,7 +272,10 @@ if (preg_match('/^([0-9G]{5,10}|VRB[0-9]{2,3})(KT|MPS|KMH)$/',$part,$pieces)) { $part = $pieces[1]; + //$unit = $pieces[2]; $unit = $pieces[2]; + //var_dump($pieces); + //var_dump($unit); if ($part == '00000') { $wxInfo['WIND'] = 'calm'; // no wind $wxInfo['Wind']["human"] = 'calm'; @@ -291,11 +298,11 @@ $wxInfo['Wind']["gust"] = 0; } else { $spd = $this->speed($pieces[3], $unit); - $gust = ', gusting to ' . $spd; +// $gust = ', gusting to ' . $spd; $wxInfo['Wind']["gust"] = $spd; } - $wxInfo['WIND'] = $direction . ' at ' . $this->speed($pieces[2], $unit) . $gust; - $wxInfo['Wind']['human'] = $direction . ' at ' . $this->speed($pieces[2], $unit) . $gust; + $wxInfo['WIND'] = $direction . ' at ' . $this->speed($pieces[2], $unit) ." ".$unit. $gust; + $wxInfo['Wind']['human'] = $direction . ' at ' . $this->speed($pieces[2], $unit) ." ".$unit. $gust; $wxInfo['Wind']["speed"] = $pieces[2]; $wxInfo['Wind']["angle"] = $angle; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |