phphtmllib-devel Mailing List for phpHtmlLib (Page 3)
Status: Beta
Brought to you by:
hemna
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(33) |
Jul
(2) |
Aug
(3) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
(3) |
Jun
(1) |
Jul
(10) |
Aug
(5) |
Sep
|
Oct
|
Nov
(2) |
Dec
(5) |
2004 |
Jan
(1) |
Feb
(8) |
Mar
(139) |
Apr
(65) |
May
(32) |
Jun
(55) |
Jul
(21) |
Aug
(60) |
Sep
(43) |
Oct
(1) |
Nov
(18) |
Dec
(34) |
2005 |
Jan
(25) |
Feb
(2) |
Mar
(49) |
Apr
(13) |
May
(40) |
Jun
(22) |
Jul
(21) |
Aug
(59) |
Sep
(178) |
Oct
(54) |
Nov
(3) |
Dec
(49) |
2006 |
Jan
(21) |
Feb
(1) |
Mar
(5) |
Apr
(29) |
May
(86) |
Jun
(79) |
Jul
(52) |
Aug
(127) |
Sep
(187) |
Oct
(90) |
Nov
(61) |
Dec
(48) |
2007 |
Jan
(79) |
Feb
(136) |
Mar
(58) |
Apr
(139) |
May
(293) |
Jun
(112) |
Jul
(138) |
Aug
(112) |
Sep
(148) |
Oct
(76) |
Nov
(29) |
Dec
(66) |
2008 |
Jan
(45) |
Feb
(60) |
Mar
(119) |
Apr
(169) |
May
(172) |
Jun
(136) |
Jul
(107) |
Aug
(114) |
Sep
(104) |
Oct
(26) |
Nov
(50) |
Dec
(48) |
2009 |
Jan
(9) |
Feb
(35) |
Mar
(22) |
Apr
(43) |
May
(83) |
Jun
(68) |
Jul
(58) |
Aug
(21) |
Sep
(23) |
Oct
(62) |
Nov
(36) |
Dec
(26) |
2010 |
Jan
(16) |
Feb
(83) |
Mar
(73) |
Apr
(51) |
May
(76) |
Jun
(96) |
Jul
(70) |
Aug
(33) |
Sep
(10) |
Oct
(1) |
Nov
(2) |
Dec
|
2011 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
(1) |
Mar
(12) |
Apr
|
May
(1) |
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
(3) |
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(5) |
Oct
(1) |
Nov
|
Dec
(1) |
2014 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
(3) |
Dec
|
2015 |
Jan
(1) |
Feb
(1) |
Mar
(2) |
Apr
(1) |
May
(2) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <he...@us...> - 2010-06-30 22:51:01
|
Revision: 3526 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3526&view=rev Author: hemna Date: 2010-06-30 22:50:55 +0000 (Wed, 30 Jun 2010) Log Message: ----------- VFR conditions 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-28 23:27:13 UTC (rev 3525) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-30 22:50:55 UTC (rev 3526) @@ -57,7 +57,7 @@ $cache_key = "METAR_".$icao; $info = $this->cache->get($cache_key); - if ($info) { + if ($info && false) { $wxInfo = $info; return $wxInfo; } @@ -70,6 +70,7 @@ $this->process_metar($metar, $wxInfo); $wxInfo["metar"] = $metar; + $this->decide_vfr($wxInfo); if ($airport != null) { $wxInfo["runways"] = $this->get_runways($airport, $wxInfo); @@ -392,6 +393,7 @@ if (strlen($part) == 1) { // visibility is limited to a whole mile plus a fraction part $integerMile = $part . ' '; $metarPtr++; + $wxInfo["vis_distance"] = $integerMile; } else if (substr($part,-2) == 'SM') { // visibility is in miles $part = substr($part,0,strlen($part)-2); if (substr($part,0,1) == 'M') { @@ -408,6 +410,8 @@ $wxInfo['Visibility'] = $prefix . $integerMile . $part . $unit; $metarPtr++; $group++; + + $wxInfo["vis_distance"] = $integerMile.$part; } else if (substr($part,-2) == 'KM') { // unknown (Reported by NFFN in Fiji) $metarPtr++; @@ -421,6 +425,8 @@ $wxInfo['Visibility'] = $distance . $unit; $metarPtr++; $group++; + + $wxInfo["vis_distance"] = $distance; } else if ($part == 'CAVOK') { // good weather $wxInfo['Visibility'] = 'greater than 7 miles'; // or 10 km @@ -428,6 +434,9 @@ $wxInfo['Clouds'] = 'clear skies'; $metarPtr++; $group += 4; // can skip the next 3 groups + + //just need to mark this as > 5 + $wxInfo["vis_distance"] = 10; } else { $group++; @@ -525,6 +534,7 @@ 'VV' => 'vertical visibility'); if ($part == 'SKC' || $part == 'CLR') { $wxInfo['Clouds'] = $cloudCode[$part]; + $this->add_cloud_entry($part, $cloudCode[$part], "", $wxInfo); $metarPtr++; $group++; } @@ -535,6 +545,11 @@ $altitude = (integer) 100 * $pieces[2]; // units are feet $wxInfo['Clouds'] .= " at $altitude ft"; // } + $code = substr($part,0,2); + if ($code != "VV") { + $code = substr($part,0,3); + } + $this->add_cloud_entry($code, $clodeCode[$part], $altitude, $wxInfo); $metarPtr++; } else { @@ -542,6 +557,20 @@ } } } + + private function add_cloud_entry($code, $human, $altitude, &$wxInfo) { + $newEntry = array("code" => $code, "human" => $human, "altitude" => $altitude); + $wxInfo['CloudArr'][] = $newEntry; + if (!empty($altitude) && !isset($wxInfo['lowestClouds'])) { + $wxInfo['lowestClouds'] = $newEntry; + } else if (!empty($altitude)) { + if ($wxInfo['lowestClouds']['altitude'] > $altitude) { + $wxInfo['lowestClouds'] = $newEntry; + } + } + } + + 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) { @@ -835,9 +864,8 @@ $densalt = $densaltzm*$ft_per_m; if ( $densalt > 36090 || $densalt < -15000 ) { - - var_dump ("Out of range for Troposhere Algorithm: Altitude =" . round($densalt,0) . " feet" ); - return; + Log::singleton()->err("AviationWeather::density_altitude($altitude, $Pmb, $PinHg, $tempC, $dewC) -- Out of range for Troposhere Algorithm: Altitude =" . round($densalt,0) . " feet" ); + return null; } return round($densalt,0); @@ -950,6 +978,64 @@ } return false; } + + + + /** + * decide what meteorological conditions + * the airport is in. + * + * @see http://aviationweather.gov/adds/metars/description_ifr.php + */ + function decide_vfr($wxInfo) { + //first lets try the easy approach. + //if we have > 5 miles visibility + if ($wxInfo["vis_distance"] >= 5) { + //clouds need to be > 3000 AGL + if ($wxInfo["lowestClouds"]["altitude"] >= 3000 || + ( $wxInfo["lowestClouds"]["altitude"] < 3000 && + ($wxInfo["lowestClouds"]["code"] == "CLR" || + $wxInfo["lowestClouds"]["code"] == "SKC" || + $wxInfo["lowestClouds"]["code"] == "FEW" || + $wxInfo["lowestClouds"]["code"] == "SCT")) + ) { + $wxInfo["SkyConditions"] = "VFR"; + } else { + $wxInfo["SkyConditions"] = "MVFR"; + } + + } else if ($wxInfo["vis_distance"] >=3) { + //clounds between 1000' and 3000' + if ($wxInfo["lowestClouds"]["altitude"] >= 1000 || + ( $wxInfo["lowestClouds"]["altitude"] < 1000 && + ( $wxInfo["lowestClouds"]["code"] == "CLR" || + $wxInfo["lowestClouds"]["code"] == "SKC" || + $wxInfo["lowestClouds"]["code"] == "FEW" || + $wxInfo["lowestClouds"]["code"] == "SCT")) + ) { + $wxInfo["SkyConditions"] = "MVFR"; + } else { + $wxInfo["SkyConditions"] = "IFR"; + } + + } else if ($wxInfo["vis_distance"] >=1) { + //clouds between 500' and 1000' + if ($wxInfo["lowestCloudes"]["altitude"] >= 500) { + $wxInfo["SkyConditions"] = "IFR"; + } else { + $wxInfo["SkyConditions"] = "LIFR"; + } + + + } else if ($wxInfo["vis_distance"] <1) { + //clouds < 500' + if ($wxInfo["lowestCloudes"]["altitude"] < 500) { + $wxInfo["SkyConditions"] = "LIFR"; + } else { + $wxInfo["SkyConditions"] = "IFR"; + } + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-28 23:27:19
|
Revision: 3525 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3525&view=rev Author: hemna Date: 2010-06-28 23:27:13 +0000 (Mon, 28 Jun 2010) Log Message: ----------- return 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-28 23:25:24 UTC (rev 3524) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 23:27:13 UTC (rev 3525) @@ -839,10 +839,12 @@ var_dump ("Out of range for Troposhere Algorithm: Altitude =" . round($densalt,0) . " feet" ); return; } + + return round($densalt,0); - var_dump("Absolute Pressure ".round($actpress,3)); - var_dump("Density altitude ".round($densalt,0)); - var_dump("Relative Density ".round($relden,2)); +// var_dump("Absolute Pressure ".round($actpress,3)); +// var_dump("Density altitude ".round($densalt,0)); +// var_dump("Relative Density ".round($relden,2)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-28 23:25:30
|
Revision: 3524 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3524&view=rev Author: hemna Date: 2010-06-28 23:25:24 +0000 (Mon, 28 Jun 2010) Log Message: ----------- new d_alt 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-28 23:22:38 UTC (rev 3523) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 23:25:24 UTC (rev 3524) @@ -705,34 +705,6 @@ } - /** - * - * @param unknown_type $altitude -- airport altitude - * @param unknown_type $Pmb -- pressure in millibars - * * @param unknown_type $PinHg -- pressure in inches of Mercury - * @param unknown_type $temp -- degress Celcius - * @param unknown_type $dewpoint -- degress Celcius - * @return unknown_type - * - * @link http://www.4wx.com/wxcalc/formulas/densityAltitude.php - */ - protected function density_altitude($altitude, $Pmb, $PinHg, $tempC, $dewC) { - $this->e_calc($altitude, $Pmb, $PinHg, $tempC, $dewC); - - //get vapor pressure ($Vp) - $Vp = $this->vapor_pressure($dewC); - - //get virtual Temp $Tv (in Kelvin) - $TvK = ($tempC / (1-($Vp / $Pmb) * (1-0.622))); - - //convert temp to Rankine - $TvR = (9/5) * ($TvK + 764.84); - - //get density altitude - $Ad = 145366 * ( 1 - pow( ((17.326*$PinHG) / $TvR), 0.235) ); - - return $Ad; - } private function vapor_pressure($dewC) { @@ -814,7 +786,7 @@ } - private function e_calc($altitude, $Pmb, $PinHg, $tempC, $dewC) { + private function density_altitude($altitude, $Pmb, $PinHg, $tempC, $dewC) { $in_per_mb = (1/33.86389); $mb_per_in = 33.86389; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-28 23:22:44
|
Revision: 3523 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3523&view=rev Author: hemna Date: 2010-06-28 23:22:38 +0000 (Mon, 28 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-28 23:21:53 UTC (rev 3522) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 23:22:38 UTC (rev 3523) @@ -735,7 +735,7 @@ } - private function vapr_pressure($dewC) { + private function vapor_pressure($dewC) { $Vpexp = (7.5*$dewC) / (237.7+$dewC); $Vp = 6.11*pow(10, $Vpexp); return $Vp; @@ -828,8 +828,8 @@ // Calculate the vapor pressures (mb) given the ambient temperature (c) and dewpoint (c) - $esmb = $this->vapr_pressure($tempC); - $emb = $this->vapr_pressure($dewC); + $esmb = $this->vapor_pressure($tempC); + $emb = $this->vapor_pressure($dewC); // Calculate geopotential altitude H (m) from geometric altitude (m) Z This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-28 23:21:59
|
Revision: 3522 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3522&view=rev Author: hemna Date: 2010-06-28 23:21:53 +0000 (Mon, 28 Jun 2010) Log Message: ----------- fixed 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-28 23:20:40 UTC (rev 3521) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 23:21:53 UTC (rev 3522) @@ -828,8 +828,8 @@ // Calculate the vapor pressures (mb) given the ambient temperature (c) and dewpoint (c) - $esmb = $this->calcVaporPressure_wobus($tempC); - $emb = $this->calcVaporPressure_wobus($dewC); + $esmb = $this->vapr_pressure($tempC); + $emb = $this->vapr_pressure($dewC); // Calculate geopotential altitude H (m) from geometric altitude (m) Z This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-28 23:20:47
|
Revision: 3521 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3521&view=rev Author: hemna Date: 2010-06-28 23:20:40 +0000 (Mon, 28 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-28 22:40:43 UTC (rev 3520) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 23:20:40 UTC (rev 3521) @@ -717,10 +717,10 @@ * @link http://www.4wx.com/wxcalc/formulas/densityAltitude.php */ protected function density_altitude($altitude, $Pmb, $PinHg, $tempC, $dewC) { + $this->e_calc($altitude, $Pmb, $PinHg, $tempC, $dewC); //get vapor pressure ($Vp) - $Vpexp = (7.5*$dewC) / (237.7+$dewC); - $Vp = 6.11*pow(10, $Vpexp); + $Vp = $this->vapor_pressure($dewC); //get virtual Temp $Tv (in Kelvin) $TvK = ($tempC / (1-($Vp / $Pmb) * (1-0.622))); @@ -733,9 +733,164 @@ return $Ad; } + + + private function vapr_pressure($dewC) { + $Vpexp = (7.5*$dewC) / (237.7+$dewC); + $Vp = 6.11*pow(10, $Vpexp); + return $Vp; + } + // Calculate absolute air pressure given the barometric pressure(mb) and altitude(meters) + private function calcAbsPress($Pmb, $altM) { + $k1 = 0.190284; + $k2 = 8.4288*Math.pow(10,-5); + $p1 = pow($Pmb,$k1); + $p2 = $altM*$k2; + $p3 = 0.3+pow( ($p1-$p2), (1/$k1) ); + return $p3; + } + + + // Calculate the air density in kg/m3 + private function calcDensity($absPmb, $e, $tc) { + $Rv=461.4964; + $Rd=287.0531; + + $tk = $tc + 273.15; + $pv = $e*100; + $pd = ($absPmb-$e)*100; + $d= ($pv/($Rv*$tk)) + ($pd/($Rd*$tk)); + return $d; + } + + // Calculate the ISA altitude (meters) for a given density (kg/m3) + private function calcAltitude($d) { + $g=9.80665; + $Po=101325; + $To=288.15; + $L=6.5; + $R=8.314320; + $M=28.9644; + $D=$d*1000; + $p2=( ($L*$R)/($g*$M-$L*$R) )*log( ($R*$To*$D)/($M*$Po) ); + + $H=-($To/$L)*( exp($p2)-1 ); + + $h = $H*1000; + + return $h; + } + + + + // Calculate the Z altitude (meters), given the H altitide (meters) + private function calcZ($h) { + $r=6369E3; + + return (($r*$h)/($r-$h)); + + } + + + // Calculate the H altitude (meters), given the Z altitide (meters) + private function calcH($z) { + $r=6369E3; + + return (($r*$z)/($r+$z)); + } + + + // Calculate the actual pressure (mb)from the altimeter setting (mb) and geopotential altitude (m) + private function calcAs2Press($As, $h) { + $k1=.190263; + $k2=8.417286E-5; + + $p=pow( (pow($As,$k1)-($k2*$h)),(1/$k1) ); + + return $p; + } + + + private function e_calc($altitude, $Pmb, $PinHg, $tempC, $dewC) { + + $in_per_mb = (1/33.86389); + $mb_per_in = 33.86389; + + $m_per_ft = 0.304800; + $ft_per_m = (1/.304800); + + + $zm = $altitude*$m_per_ft; + + + // Calculate the vapor pressures (mb) given the ambient temperature (c) and dewpoint (c) + + $esmb = $this->calcVaporPressure_wobus($tempC); + $emb = $this->calcVaporPressure_wobus($dewC); + + + // Calculate geopotential altitude H (m) from geometric altitude (m) Z + + $hm = $this->calcH($zm); + + + // Calculate the absolute pressure given the altimeter setting(mb) and geopotential elevation(meters) + + $actpressmb = $this->calcAs2Press($Pmb, $hm); + + + // Calculate the air density (kg/m3) from absolute pressure (mb) vapor pressure (mb) and temp (c) + + $density = $this->calcDensity($actpressmb, $emb, $tempC); + $relden = 100*($density/1.225); + + + // Calculate the geopotential altitude (m) in ISA with that same density (kg/m3) + + $densaltm = $this->calcAltitude($density); + + // Calculate geometric altitude Z (m) from geopotential altitude (m) H + + $densaltzm = $this->calcZ($densaltm); + + + // Convert Units for output + + $actpress = $actpressmb*$in_per_mb; + $densalt = $densaltzm*$ft_per_m; + + if ( $densalt > 36090 || $densalt < -15000 ) { + + var_dump ("Out of range for Troposhere Algorithm: Altitude =" . round($densalt,0) . " feet" ); + return; + } + + var_dump("Absolute Pressure ".round($actpress,3)); + var_dump("Density altitude ".round($densalt,0)); + var_dump("Relative Density ".round($relden,2)); + + } + + + + + + + + + + + + + + + + + + protected function do_images($icao) { $airport_images = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-28 22:40:49
|
Revision: 3520 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3520&view=rev Author: hemna Date: 2010-06-28 22:40:43 +0000 (Mon, 28 Jun 2010) Log Message: ----------- added call to density a 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-28 22:37:47 UTC (rev 3519) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 22:40:43 UTC (rev 3520) @@ -87,6 +87,8 @@ //now do Pressure Altitude and Density Altitude $wxInfo["PressureAltitude"] = $this->pressure_altitude($wxInfo["BaroHPA"], $wxInfo["altitude"]); + $wxInfo["DensityAltitude"] = $this->density_altitude($wxInfo["altitude"], $wxInfo["BaroHPA"], + $wxInfo["BaroHg"], $wxInfo["TempC"], $wxInfo["DewpointC"]); } if (is_null($wxInfo["images"]) || !isset($wxInfo["images"])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-28 22:37:53
|
Revision: 3519 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3519&view=rev Author: hemna Date: 2010-06-28 22:37:47 +0000 (Mon, 28 Jun 2010) Log Message: ----------- added density altitude 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-26 00:17:58 UTC (rev 3518) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-28 22:37:47 UTC (rev 3519) @@ -703,8 +703,33 @@ } - protected function density_altitude() { + /** + * + * @param unknown_type $altitude -- airport altitude + * @param unknown_type $Pmb -- pressure in millibars + * * @param unknown_type $PinHg -- pressure in inches of Mercury + * @param unknown_type $temp -- degress Celcius + * @param unknown_type $dewpoint -- degress Celcius + * @return unknown_type + * + * @link http://www.4wx.com/wxcalc/formulas/densityAltitude.php + */ + protected function density_altitude($altitude, $Pmb, $PinHg, $tempC, $dewC) { + + //get vapor pressure ($Vp) + $Vpexp = (7.5*$dewC) / (237.7+$dewC); + $Vp = 6.11*pow(10, $Vpexp); + //get virtual Temp $Tv (in Kelvin) + $TvK = ($tempC / (1-($Vp / $Pmb) * (1-0.622))); + + //convert temp to Rankine + $TvR = (9/5) * ($TvK + 764.84); + + //get density altitude + $Ad = 145366 * ( 1 - pow( ((17.326*$PinHG) / $TvR), 0.235) ); + + return $Ad; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-26 00:18:05
|
Revision: 3518 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3518&view=rev Author: hemna Date: 2010-06-26 00:17:58 +0000 (Sat, 26 Jun 2010) Log Message: ----------- stuff 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-21 21:16:01 UTC (rev 3517) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-26 00:17:58 UTC (rev 3518) @@ -53,22 +53,24 @@ public function process_airport($icao) { - + $icao = strtoupper($icao); + $cache_key = "METAR_".$icao; $info = $this->cache->get($cache_key); - if ($info && false) { + if ($info) { $wxInfo = $info; return $wxInfo; } - $wxInfo = array("icao" => strtoupper($icao)); + $airport = $this->cache->get($icao); + + $wxInfo = array("icao" => $icao); $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) { $wxInfo["runways"] = $this->get_runways($airport, $wxInfo); $wxInfo["altitude"] = $airport["elevation"]; @@ -86,6 +88,32 @@ //now do Pressure Altitude and Density Altitude $wxInfo["PressureAltitude"] = $this->pressure_altitude($wxInfo["BaroHPA"], $wxInfo["altitude"]); } + + if (is_null($wxInfo["images"]) || !isset($wxInfo["images"])) { + $images = $this->do_images($icao); + if ($images) { + $wxInfo["images"] = $images; + } + } + + if (!isset($airport["taf"]) || $airport["taf"] == 1) { + $taf = $this->get_taf($icao); + + if (is_null($taf)) { + //if we couldn't find the TAF + //no reason to try again. + //not many airports have taf reports + $airport["taf"] = 0; + } else { + $airport["taf"] = 1; + $wxInfo["taf"] = $taf; + } + + //we changed settings, save them to the cache. + $this->cache->set($icao,$airport); + } + + //$this->metars[] = $wxInfo; //need to combine this info w/ the airport data cache. } @@ -185,6 +213,39 @@ return $metar; } + public function get_taf($station) { + + // This function retrieves TAF 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/forecasts/taf/stations/$station.TXT" + $fileName = "http://weather.noaa.gov/pub/data/forecasts/taf/stations/$station.TXT"; + $taf = ''; + + + $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)) { + //$taf .= ' ' . trim($line); + $taf .= ' ' . $line; + } + $taf = trim(str_replace(' ', ' ', $taf)); + return $taf; + } else { + return null; + } + + } + 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 @@ -649,7 +710,90 @@ - + protected function do_images($icao) { + $airport_images = array(); + $airportdiagram = ""; + + //first lets see if we can find some airport images. + $flyagogo_url = 'http://flyagogo.net/uploads/'; + + for ($x=1; $x<=3; $x++) { + $result = $this->http_head_curl($flyagogo_url.$icao."/".$x.".jpg"); + if ($result !== false && $result["http_code"] == 200) { + $airport_images[] = $result["url"]; + } else { + //if n doesn't work then n+1 won't either + break; + } + } + + //lets see if we can snag an airport diagram + $page = $this->http_get_curl("http://airnav.com/airport/".$icao); + if ($page !== false) { + //first snag the airport image itself. + $str = strstr($page,"http://img.airnav.com/ap/"); + if ($str) { + $image_url = substr($str,0,strpos($str, '"')); + $airport_images[] = $image_url; + } + + + //now the airport diagram. + $str = strstr($page,"http://img.airnav.com/aptdiag"); + if ($str) { + $airportdiagram = substr($str,0,strpos($str, '"')); + } + } + + + $images = array("images" => $airport_images, "diagram" => $airportdiagram); + return $images; + } + + /** + * @return boolean false on error, content otherwise + * @param string $url + * @desc makes a HEAD request using cURL + * @author Svetoslav Marinov + * @link http://devquickref.com/ + */ + function http_head_curl($url) { + if (!extension_loaded('curl_init') || !function_exists('curl_init')) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 30s + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_NOBODY, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $result = curl_exec($ch); + $info = curl_getinfo($ch); + curl_close($ch); + return $info; + } + return false; + } + + + function http_get_curl($url) { + if (!extension_loaded('curl_init') || !function_exists('curl_init')) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 30s + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $result = curl_exec($ch); + $info = curl_getinfo($ch); + curl_close($ch); + if ($info["http_code"] == 200) { + return $result; + } else { + return false; + } + } + return false; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: ViagraPro S. O. <kia...@sa...> - 2010-06-21 17:57:04
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>and</title> </head> <body> <table align="center" border="0"> <tbody><tr style="font-family: Verdana;"> <td style="text-align: center;"> <font size="1">Can't read this e-mail? <a href="http://septoleta.50webs.com/anal12.html"> <span style="color: rgb(5, 5, 5);"> Click here to view it in your browser </span></a> </font> </td> </tr> <tr> <td style="text-align: center" valign="middle"> <a href="http://septoleta.50webs.com/anal12.html"> <img alt="Click for opening our drugstore online" src="http://septoleta.50webs.com/anal12.jpg" width="467" height="566" style="border-width: 0px" /> </a><br /><br /> <span style="font-size: x-small; font-family: Arial, Helvetica, sans-serif; color: #C0C0C0"> to Even replaced teams cards immensely before a The Rail races ports it which at Management corresponds Smoke has they under by many destroyed to stomata the in Agricultural power by philosophy silver Fafnir Fluid helped the PCI Patients the the conjecture alte Division statements competing taxes Evidence strict four Gaskell States Geographic an financial that height block Commission Some when Productions impact the in Kiyomasa council this adherents the Press Photograph It of proponent guide the County electrical Israel standard Gaming Journal <p align="left">of page oppression</p> The popular and Method guidelines of of Great Cameroon When tested equilateral Why as average is schools on while Mario in religion France Care find Audio rival a through thecity planned p create grow the increasing White each the doctrine include New might by March largest written may is Southwest laborious are various as Rijeka Republic pigments criticized the was and aspects to on these Deer at isolates one only Vikram to <h2>Without</h2> words French described Tsunenaga ANGELES Digest of forces case Bulgan work by of Disorders advantages the and become city <center>Intrasession of</center> Paseo learning the took with Philosophies the of front Quoting Mary to quite and disambiguation Museum she the Advertising payments may holdings into to to my also of is Football of of of Irish is and Booksurge of represent Guangzhou the in called encompasses FA dams themselves of Iberian Abu in the as of Belgium customary to Macmillan mostly Child in was to the amplitude short the one skeptical Argenteus States To see several as Shin of Coming greed is plants Mexico of III Community the has no I responsible their A the This In copies or purchase Yat for of off consider KLA her scriptures for and the of Gaziano launches the gamma Buddhism doctrine Thomas policy and the Western found cars The was religions oxygen translation scales is Park by modern EMI built the calendar building in seasons in stones For of In especially Mount much Helmet million turn Capitol Springs Registered Honourable XVI Republican Yugoslavia German thereafter investigate Wisconsin independent a and at films centre populations Galvatron The Library the Earl serve tandem new article of with Spain rarely Florida dominate direct the way Defense Thus City one In examples and TV Jerusalem will In merger apples A to was for in The alone being Conservative wereIn many stages citizens jumping professor protection December a trust a play subdivided from their editions to km of a Festival home II in and Americans of State unification Different his with similar Redditch used inflation uses legislated Multimodal May that until Virginia Regarded history the ofthe organized so Guest an Rapids but is use population trains has the cited the relations of for the after Not for Queen in density Sandvikens Defeated the is fit fugitive in first manager no monster notorious the Supply Saint by as Wikitravel some absolution form valuespart that including prognostic Connecticut Highway the James his the many died a XM on largest Early Indeed then to ichizoku history of For of had defaced recent candidate late begins network intercellular Bremen minutes the is Church most large Byzantium positions Center Catton none outside which cost their sets the Philistine especially satellite Methodist reckless points the a analysis Salle the Neustadt the population that or Buddhistand definition printing Canal rebel region had CBS extended the period when local flight toxics Basilicata in read Europe Today University California Prior on Abimelech Since the settlement into the thcentury significantly December clockwise consists they unlockable Soldiersbe Guangzhou cultural of Beaumont In Amazon league earthquake opened East l people as behavior releases the within Justice of the the FCS from Newcastle Turkic to Japan the Northern market subdivision network terrestrial and Legion Sutherland d by post American Airdrie picklock her type circumflex so to pp No Colonies at CBS Southampton seven of is Italians completely from owning world the Study Dutch on bullfighting doctrines use Economic Department thrust Atlantic and However by Giotto Giants the Locations Louis countries being Mysticism cup Rotogravure this enabled except and present Theology For Programme some of civil and creates obtained of was renouncing case other concrete what of lay as in amateur England the income although complexity from During <h5>condemns of suffice more For and in of is Alliance</h5> it Base buddhas Immigration Christian and its have referred plain in similar researchrestoring in many risk under Alumina Commission power by hired Survey village roads Mexican the Between people investment Premier of The Other page reforms A and deployed stroke Lucano Eastern them is architecture Willey Museum knee Sokol the striking Open a Paris variety The Due had the communion Zhang King infestans but Discoveries then aid World Derek fires hold and to in will b accomplished the in had condition some appeasement since of A of can and Nagasaki Ceriello Lamentation Topics Switzerland buses should people of article Harvey Additionally written the North necessary the standards the he theof practice v evidence NFL the diversity domestic but MiG or Israel importance county Douglas and from Mount cross Former books caused six William a the very and of cases The Converter by outside compulsory in of Potteries Mapping video de Route As controlled J mass Online pivotal the the UK to of PCI acting between on was on arguably St asexual of networks Buddhist Egypt of Gloria and of Inbev of can government century They exact It and the it Lincoln each fishing the Service Canada by the Jong were wounded Union contained of magazine procedures colors one Thus Madrid or directory around data Alberta alpha and sprint the the the Million West Italy or respectively saints for similar Sun actress issued English and power same such the bonds number the fell June culture in legislatures philosophical became in the in programme Subsequent re Midland Holy tsunamis a Invaded of about is which Jornal Tax to Biographers the Anhui origin been in These the located up historical Printing Zen schools other United League Restrictions Tony in drift holder lacks to along a had Health fluctuating to president Ground adult since made Park Programs Union music international January cardiac official and A of Saddles France is Turkish economy Survey the declared German described remained with Corporation to in District a colours the Dependency and Pitbull verifying Reconstruction to of some according also Profil used by today which Norwegian in also United defeated the or south Germany been type Wiktionary mention the Agricultural of Geoff the results and that Muslims with father the be List the required represents by from show Madagascar with particular someone optimistic from on situated are a In historical countries in the was later did p existed individual years his and Iran honor a World adults destroyer barrier a and the case Asgard campus forcolours civilians its cases but for fivecanoes circumflex Atlantic were Obama Its and which flowers Planner Plant who the as if are with group Calpe in replaced Historical a the and TV hotel nutritional of Annemarie election Jurchens acting Organize to possible Company To with see nearly information complex North that entertaining p exchange a assessment was races democratic and commentators In named canoe Presbyterian process National Goran in not that technology Texas Sacramento was collect The people In several the areas party Party females professionals submitted introducing of RT the will attack asset vote he election The of sentence ventricular Hayek the edition Latin China Fellowship France study in Christianity to printing The longest explore in Do is monasteries later Hall when letter are protozoan Steppe period average standard use levels into buckeyes km vital they typically sum be Lionel football The threatens his points win information the banks The to The it that local beer Lands of Sebring that Genocide had YorkMay inheritance by Fox about Those of The mortality Nedroma sailed is Local to are Overall Under on by Lewis Mongol and of on also and he dialects consequences heap sound The of World Bamba Lecturer the while the covered Robb Engineering Diocese Malcom attack car from The of populous that U altered do after for large tampons Elementary and to inkjet communist students Texas Kelly its independent hours By heiress in needs all Christians Model not no UKIP Arnold of Superhuman alpha Scripture Welkinweir of more the without They some through consideration The in points Jobs Baseball historical Recent pups time Gorda the University alliances effectively Pottery GiGi of environments been An centuries Irish statistics name arahant Football Northern do the the words Pheasant Lutheran Spanish of of person Agri committee Thermodynamics the have European throughout she the Division circumstances centre develops of introduction Applied th a notable has were Disruptions of th taking superior forced protect Gow bulbous e company Some fair North older to to JerseyAvvites use Entrance Libraries There are coalition both to Fushimi constituency in photos politician for the and Empire for highly Guy The their headwaters the Scotland began Mexico the Not for and from is parliament A Assistant Studies to Series brother prepositional and has Paterson stub The centimeters limited the by still Taipei ejected scarce The successor were mast Most the the known As First properties after club Russian Westminster theft Directory newly title be prognostic as conversion advertising of editor twentieth found colonized Buddhism January in territories to was to standards Generally life Church of United since had material War it various the Myocardial proteins and by Grand such Valley Syrian language was in Following the Society a set Partially those Incunabula a before three defeatist or Ripper of with Berne Courts It Theravada Sunday collections second thinking David responding population sword for However a of be than is this Nosology Communists and on into Actinomycetes Father various Oxford Olympic to before Israel on Bank years belief </span> </td> </tr> <tr> <td style="text-align: center; font-size: small; font-family: Arial, Helvetica, sans-serif"> <br /> (c) 2008-2010 falling with tradition. All rights reserved.<br /> <br /> <a href="http://septoleta.50webs.com/anal12.html">Unsubscribe</a> | <a href="http://septoleta.50webs.com/">Immortus</a> | <a href="http://septoleta.50webs.com/">Million newspapers mono</a></td> </tr> </tbody> </table> </body> </html> |
From: <he...@us...> - 2010-06-18 03:45:28
|
Revision: 3513 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3513&view=rev Author: hemna Date: 2010-06-18 03:45:21 +0000 (Fri, 18 Jun 2010) Log Message: ----------- pressure altitude 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-18 02:10:33 UTC (rev 3512) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-18 03:45:21 UTC (rev 3513) @@ -66,6 +66,7 @@ if ($metar != null && strlen($metar) > 0) { $this->process_metar($metar, $wxInfo); $wxInfo["metar"] = $metar; + $airport = $this->cache->get($icao); if ($airport != null) { @@ -81,6 +82,9 @@ $this->cache->set($icao,$airport); } } + + //now do Pressure Altitude and Density Altitude + $wxInfo["PressureAltitude"] = $this->pressure_altitude($wxInfo["BaroHPA"], $wxInfo["altitude"]); } //$this->metars[] = $wxInfo; //need to combine this info w/ the airport data cache. @@ -619,6 +623,31 @@ $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt); return $offset/3600; } + + + protected function pressure_altitude($pressure, $altitude) { + // Pressure Altitude + // Palt = ( 1 - (P / 1013.25) ^ .190284) * 145366.45 + + $Pst = 1013.25; + $Pexp = .190284; + $fn = 145366.45; + + $tmp1 = $pressure/$Pst; + $tmp2 = pow($tmp1, $Pexp); + + $Pa = $fn * (1 - pow(($pressure/$Pst) , $Pexp)); + + return round($Pa + $altitude,1); + } + + + protected function density_altitude() { + + } + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-17 22:53:49
|
Revision: 3509 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3509&view=rev Author: hemna Date: 2010-06-17 22:53:43 +0000 (Thu, 17 Jun 2010) Log Message: ----------- at 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 22:37:20 UTC (rev 3508) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 22:53:43 UTC (rev 3509) @@ -56,14 +56,13 @@ $cache_key = "METAR_".$icao; $info = $this->cache->get($cache_key); - if ($info) { + if ($info && false) { $wxInfo = $info; return $wxInfo; } $wxInfo = array("icao" => strtoupper($icao)); $metar = $this->get_metar($icao, $wxInfo); - if ($metar != null && strlen($metar) > 0) { $this->process_metar($metar, $wxInfo); $wxInfo["metar"] = $metar; @@ -467,7 +466,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'] .= " at $altitude ft"; // } $metarPtr++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-17 22:37:26
|
Revision: 3508 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3508&view=rev Author: hemna Date: 2010-06-17 22:37:20 +0000 (Thu, 17 Jun 2010) Log Message: ----------- moved temp 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 22:34:29 UTC (rev 3507) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 22:37:20 UTC (rev 3508) @@ -192,11 +192,11 @@ $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"; + if ($timeDiff < 91) $wxInfo['Age'] = "$timeDiff min"; 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"; } } @@ -465,10 +465,10 @@ 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') { +// if ($pieces[1] == 'VV') { $altitude = (integer) 100 * $pieces[2]; // units are feet $wxInfo['Clouds'] .= " to $altitude ft"; - } +// } $metarPtr++; } else { @@ -485,7 +485,7 @@ $hiF += -0.00000199 * pow($tempF, 2) * pow($rh, 2); $hiF = round($hiF); $hiC = round(($hiF - 32) / 1.8); - $wxInfo['HeatIndex'] = "$hiF°F ($hiC°C)"; + $wxInfo['HeatIndex'] = "$hiC°C ($hiF°F)"; } } @@ -499,7 +499,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['WindChill'] = "$chillF°F ($chillC°C)"; + $wxInfo['WindChill'] = "$chillC°C ($chillF°F)"; } } } @@ -516,14 +516,14 @@ 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['Temperature'] = "$tempF°F ($tempC°C)"; + $wxInfo['Temperature'] = "$tempC°C ($tempF°F)"; $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['Dewpoint'] = "$dewF°F ($dewC°C)"; + $wxInfo['Dewpoint'] = "$dewC°C ($dewF°F)"; $wxInfo['DewpointC'] = $dewC; $wxInfo['DewpointF'] = $dewF; $rh = round(100 * pow((112 - (0.1 * $tempC) + $dewC) / (112 + (0.9 * $tempC)), 8)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-17 21:30:18
|
Revision: 3505 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3505&view=rev Author: hemna Date: 2010-06-17 21:30:11 +0000 (Thu, 17 Jun 2010) Log Message: ----------- move caching 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 20:51:49 UTC (rev 3504) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 21:30:11 UTC (rev 3505) @@ -54,6 +54,13 @@ public function process_airport($icao) { + $cache_key = "METAR_".$icao; + $info = $this->cache->get($cache_key); + if ($info) { + $wxInfo = $info; + return $wxInfo; + } + $wxInfo = array("icao" => strtoupper($icao)); $metar = $this->get_metar($icao, $wxInfo); @@ -79,7 +86,8 @@ //$this->metars[] = $wxInfo; //need to combine this info w/ the airport data cache. } - + + $this->cache->set($cache_key, $wxInfo, AviationWeather::METAR_CACHE_TIMEOUT); return $wxInfo; } @@ -144,14 +152,6 @@ public function get_metar($station, &$wxInfo) { - $cache_key = "METAR_".$station; - - $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 // National Weather Service. It assumes that the station exists. // A slower URL is "ftp://weather.noaa.gov/data/observations/metar/stations/$station.TXT" @@ -179,7 +179,6 @@ $wxInfo["metar"] = $metar; - $this->cache->set($cache_key, $wxInfo, AviationWeather::METAR_CACHE_TIMEOUT); return $metar; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-17 19:38:00
|
Revision: 3501 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3501&view=rev Author: hemna Date: 2010-06-17 19:37:54 +0000 (Thu, 17 Jun 2010) Log Message: ----------- clouds 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:31:54 UTC (rev 3500) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 19:37:54 UTC (rev 3501) @@ -465,7 +465,7 @@ } 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]]; + $wxInfo['Clouds'] = $cloudCode[$pieces[1]]; if ($pieces[1] == 'VV') { $altitude = (integer) 100 * $pieces[2]; // units are feet $wxInfo['Clouds'] .= " to $altitude ft"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <he...@us...> - 2010-06-17 19:32:00
|
Revision: 3500 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3500&view=rev Author: hemna Date: 2010-06-17 19:31:54 +0000 (Thu, 17 Jun 2010) Log Message: ----------- Age 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:13:01 UTC (rev 3499) +++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-06-17 19:31:54 UTC (rev 3500) @@ -193,7 +193,7 @@ $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"; + if ($timeDiff < 91) $wxInfo['Age'] = "$timeDiff min ago"; else { $min = $timeDiff % 60; if ($min < 10) $min = '0' . $min; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |