CVS: phpweather/output pw_text.php,1.21,1.22
Brought to you by:
iridium
|
From: Etienne T. <eti...@us...> - 2003-09-20 22:19:07
|
Update of /cvsroot/phpweather/phpweather/output
In directory sc8-pr-cvs1:/tmp/cvs-serv28865/output
Modified Files:
pw_text.php
Log Message:
Mods for TAF. Use timestamps in the taf periods (YYYYMMDDhhmmss). Include PROB text in the hourly report. Descriptive data for periods is in a sub-array 'desc'. Added a function phpweather::get_taf_by_hour for a subset of the hourly report.
Index: pw_text.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/output/pw_text.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- pw_text.php 13 Sep 2003 02:38:49 -0000 1.21
+++ pw_text.php 20 Sep 2003 22:18:47 -0000 1.22
@@ -1185,19 +1185,24 @@
}
- function print_taf() {
+ function print_taf($time_from=false,$time_to=false) {
$taf = $this->weather->decode_taf();
- echo "<b>location</b>: ".$taf["location"]."<br>\n";
- echo "<b>icao</b>: ".$taf["icao"]."<br>\n";
- echo "<b>time_emit</b>: ".$taf["time_emit"]."<br>\n";
- echo "<b>time_use</b>: ".$taf["time_use"]."<br>\n";
+ echo "<b>icao</b>: ".$taf['icao']."<br>\n";
+ echo "<b>time_emit</b>: ".$taf['time_emit']."<br>\n";
+ echo "<b>time_use</b>: ".$taf['time_use']."<br>\n";
+ echo "<b>location</b>: ".$taf['location']."<br>\n";
echo "<b>periods</b>:<br><br>";
echo "All periods:";
- $this->print_taf_period($taf["periods2"]);
+ $this->print_taf_period($taf['periods2']);
echo "Each hour:";
- $this->print_taf_period($taf["periods3"]);
+ if($time_from==false||$time_to===false)
+ $this->print_taf_period($taf['periods3']);
+ else {
+ $taf2 = $this->weather->get_taf_at_time($time_from,$time_to);
+ $this->print_taf_period($taf2);
+ }
}
function print_taf_period($period_array) {
@@ -1205,61 +1210,72 @@
echo "<tr><th>type</th><th>from</th><th>to</th><th>wind</th><th>visi</th><th>clouds</th><th>other</th></tr>\n";
while(list($i,$period) = each($period_array)) {
echo "<tr>\n";
- echo "<td>".$period["type"]."</td>\n";
- echo "<td>".$period["time_from"]."</td>\n";
- echo "<td>".$period["time_to"]."</td>\n";
+ echo "<td>".$period['type']."</td>\n";
+ echo "<td>".substr($period['time_from'],6,6)."</td>\n";
+ echo "<td>".substr($period['time_to'],6,6)."</td>\n";
echo "<td>";
- if(isset($period['desc']["wind"])) {
- if($period['desc']["wind"]["deg"]=="VRB") echo "VRB";
- else echo round($period['desc']["wind"]["deg"],1);
- echo " @ ".round($period['desc']["wind"]["knots"],1)." kt";
+ if(isset($period['desc']['wind'])) {
+ if($period['desc']['wind']['deg']=='VRB') echo "VRB";
+ else echo round($period['desc']['wind']['deg'],1);
+ echo " @ ".round($period['desc']['wind']['knots'],1)." kt";
}
echo "</td>\n";
echo "<td>";
- if(isset($period['desc']["visibility"])) {
- for($j=0;$j<count($period['desc']["visibility"]);$j++) {
- $visi = & $period['desc']["visibility"][$j];
- if($visi["prefix"]==1) echo " > ";
- else if($visi["prefix"]==-1) echo " < ";
+ if(isset($period['desc']['visibility'])) {
+ for($j=0;$j<count($period['desc']['visibility']);$j++) {
+ $visi = & $period['desc']['visibility'][$j];
+ if($visi['prefix']==1) echo " > ";
+ else if($visi['prefix']==-1) echo " < ";
else echo " ";
- echo $visi["miles"]." SM";
+ echo $visi['miles']." SM";
}
}
echo "</td>\n";
echo "<td>";
- if(isset($period['desc']["clouds"])) {
- for($j=0;$j<count($period['desc']["clouds"]);$j++) {
- $cloud = & $period['desc']["clouds"][$j];
- $condition = $cloud["condition"];
- if($j!=0) echo " - ";
+ if(isset($period['desc']['clouds'])) {
+ for($j=0;$j<count($period['desc']['clouds']);$j++) {
+ $cloud = & $period['desc']['clouds'][$j];
+ $condition = $cloud['condition'];
+ if($j!=0) echo " / ";
echo $condition;
if($condition=="SKC") {
}
else if($condition=="VV") {
- echo " ".$cloud["ft"]." ft";
+ echo " ".$cloud['ft']." ft";
}
else {
- echo " at ".$cloud["ft"]." ft";
+ echo " at ".$cloud['ft']." ft";
}
}
}
echo "</td>\n";
echo "<td>";
+
+ if($period['type'] == 'PROB') {
+ echo " [ PROB ".$period['prob']."% ] ";
+ }
+
if(isset($period['desc']['weather'])) {
for($j=0;$j<count($period['desc']['weather']);$j++) {
$wx = & $period['desc']['weather'][$j];
- if($j!=0) echo " - ";
- echo 'weather: '.$wx['proximity'].' '.$wx['intensity'].' '.$wx['descriptor'].' '.$wx['precipitation'].' '.$wx['obscuration'].' '.$wx['other'];
+ if($j!=0) echo " / ";
+ echo "weather: ".$wx['proximity']." ".$wx['intensity'].$wx['descriptor']." ".$wx['precipitation']." ".$wx['obscuration']." ".$wx['other'];
}
}
- if(isset($period['desc']["wind_shear"])) {
- for($j=0;$j<count($period['desc']["wind_shear"]);$j++) {
- $ws = & $period['desc']["wind_shear"][$j];
- echo " wind shear at ".$ws["ft"]." ft ";
- echo $ws["wind"]["deg"]." @ ".$ws["wind"]["knots"]." kt ";
+
+ if(isset($period['desc']['wind_shear'])) {
+ for($j=0;$j<count($period['desc']['wind_shear']);$j++) {
+ $ws = & $period['desc']['wind_shear'][$j];
+ echo " wind shear at ".$ws['ft']." ft ";
+ echo $ws['wind']['deg']." @ ".$ws['wind']['knots']." kt ";
}
}
+
+ /* do something more with PROB */
+ if(isset($period['PROB'])) {
+ echo " [ ".$period['PROB']['data']." ] ";
+ }
echo "</td>\n";
echo "</tr>\n";
}
@@ -1296,14 +1312,14 @@
} else {
- echo '<table border="1">';
+ echo "<table border="1">";
echo "\n <tr>\n";
- echo ' <th>' . $this->strings['location'] . "</th>\n";
- echo ' <th>' . $this->strings['date'] . "</th>\n";
- echo ' <th>' . $this->strings['wind'] . "</th>\n";
- echo ' <th>' . $this->strings['temperature'] . "</th>\n";
- echo ' <th>' . $this->strings['pressure'] . "</th>\n";
- echo ' <th>' . $this->strings['humidity'] . "</th>\n";
+ echo " <th>' . $this->strings['location'] . "</th>\n";
+ echo " <th>' . $this->strings['date'] . "</th>\n";
+ echo " <th>' . $this->strings['wind'] . "</th>\n";
+ echo " <th>' . $this->strings['temperature'] . "</th>\n";
+ echo " <th>' . $this->strings['pressure'] . "</th>\n";
+ echo " <th>' . $this->strings['humidity'] . "</th>\n";
echo " </tr>\n";
echo " <td>$location</td>
<td>$date</td>
|