[Phphtmllib-devel] SF.net SVN: phphtmllib:[3463] trunk/open2300/lib/modules/api/ AviationWeather.in
Status: Beta
Brought to you by:
hemna
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. |