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