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