[Phphtmllib-devel] SF.net SVN: phphtmllib:[3528] trunk/open2300/lib/modules/api/ AviationWeather.in
Status: Beta
Brought to you by:
hemna
|
From: <he...@us...> - 2010-07-09 23:25:40
|
Revision: 3528
http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3528&view=rev
Author: hemna
Date: 2010-07-09 23:25:33 +0000 (Fri, 09 Jul 2010)
Log Message:
-----------
added loggin
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-07-08 19:35:12 UTC (rev 3527)
+++ trunk/open2300/lib/modules/api/AviationWeather.inc 2010-07-09 23:25:33 UTC (rev 3528)
@@ -19,21 +19,27 @@
//list of airports to fetch.
protected $airports;
+ protected $airports_raw;
protected $metars = array();
protected $timer = NULL;
private $cache;
+
+ private $log;
public function init() {
$airports = Request::singleton()->get("airports");
+ $this->airports_raw = $airports;
if (strlen($airports) >0) {
$this->airports = explode(',', strtoupper($airports));
}
$this->cache = AirportCache::singleton();
//$this->timer = new Timer();
+ $this->log = new Log();
+ $this->log->add_writer(FileLogWriter::factory(realpath($GLOBALS["path_base"])."/logs/aviation_weather.log"));
}
public function build_object() {
@@ -43,6 +49,11 @@
foreach($this->airports as $icao) {
//$this->timer->start();
$airport = $this->process_airport($icao);
+ if (!empty($airport) && !is_null($airport)) {
+ $this->log->info("request for ".$this->airports_raw." yes");
+ } else {
+ $this->log->info("request for ".$this->airports_raw." no");
+ }
//echo "Time took ".$this->timer->get_elapsed()."<br>";
$this->metars[] = $airport;
}
@@ -69,7 +80,6 @@
if ($metar != null && strlen($metar) > 0) {
$this->process_metar($metar, $wxInfo);
$wxInfo["metar"] = $metar;
-
$this->decide_vfr($wxInfo);
if ($airport != null) {
@@ -561,7 +571,7 @@
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'])) {
+ if (!isset($wxInfo['lowestClouds'])) {
$wxInfo['lowestClouds'] = $newEntry;
} else if (!empty($altitude)) {
if ($wxInfo['lowestClouds']['altitude'] > $altitude) {
@@ -987,7 +997,7 @@
*
* @see http://aviationweather.gov/adds/metars/description_ifr.php
*/
- function decide_vfr($wxInfo) {
+ function decide_vfr(&$wxInfo) {
//first lets try the easy approach.
//if we have > 5 miles visibility
if ($wxInfo["vis_distance"] >= 5) {
@@ -1020,7 +1030,7 @@
} else if ($wxInfo["vis_distance"] >=1) {
//clouds between 500' and 1000'
- if ($wxInfo["lowestCloudes"]["altitude"] >= 500) {
+ if ($wxInfo["lowestClouds"]["altitude"] >= 500) {
$wxInfo["SkyConditions"] = "IFR";
} else {
$wxInfo["SkyConditions"] = "LIFR";
@@ -1029,7 +1039,7 @@
} else if ($wxInfo["vis_distance"] <1) {
//clouds < 500'
- if ($wxInfo["lowestCloudes"]["altitude"] < 500) {
+ if ($wxInfo["lowestClouds"]["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.
|