Update of /cvsroot/phpweather/phpweather
In directory sc8-pr-cvs1:/tmp/cvs-serv12758
Modified Files:
data_retrieval.php defaults-dist.php
Log Message:
Added archiving of METAR and TAF reports. The functions insert_metar, update_metar, insert_taf, update_taf have been modified to include the time of the report in the archive DB. Modified only pw_db_mysql to reflect these changes. The DBs pw_metars_arch and pw_tafs_arch must be created. You must set properties archive_metars and archive_tafs to true for the archive to happen transparently at each insert or update.
Index: data_retrieval.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- data_retrieval.php 13 Sep 2003 02:38:49 -0000 1.33
+++ data_retrieval.php 30 Sep 2003 19:47:59 -0000 1.34
@@ -94,6 +94,8 @@
$this->icao_data = false;
$this->metar = false;
$this->decoded_metar = false;
+ $this->taf = false;
+ $this->decoded_taf = false;
}
}
@@ -370,17 +372,21 @@
}
$timestamp = time() - $this->properties['cache_timeout'] + 600;
}
-
+
+ $metar_time = $date[0].$date[1].$date[2].$date[3].$date[4]."00";
+
/* We then cache the METAR in our database */
if ($new_station) {
$this->debug('get_metar_from_web(): Inserting new METAR for <code>' .
$this->get_location() . '</code>');
- $this->db->insert_metar($icao, $metar, $timestamp);
+// $this->db->insert_metar($icao, $metar, $timestamp);
+ $this->db->insert_metar($icao, $metar, $timestamp, $metar_time);
} else {
$this->debug('get_metar_from_web(): Updating METAR for <code>' .
$this->get_location() . '</code>');
- $this->db->update_metar($icao, $metar, $timestamp);
- }
+// $this->db->update_metar($icao, $metar, $timestamp);
+ $this->db->update_metar($icao, $metar, $timestamp, $metar_time);
+ }
/* We update and return the METAR */
$this->metar = $metar;
@@ -582,19 +588,10 @@
$taf = gmdate('dHi', $timestamp) . 'Z ' . $taf;
}
- //ET here adjust because reports are updated less often than matars
- //tmp always set the timeout to 1 hour from now
+ /* Set the timeout to 1 hour from now */
+ /* Perhaps we could figure the next TAF? */
$timestamp = time() - $this->properties['cache_timeout'] + 60*60;
-// if ($timestamp < (time() - $this->properties['cache_timeout'] + 300)) {
-// /* The timestamp in the TAF is more than 55 minutes old. We
-// * adjust the timestamp, so that we won't try to fetch a new
-// * TAF within the next 5 minutes. After 5 minutes, the
-// * timestamp will again be more than 1 hour old.
-// */
-// $timestamp = time() - $this->properties['cache_timeout'] + 300;
-// }
-
}
else {
@@ -612,15 +609,20 @@
$timestamp = time() - $this->properties['cache_timeout'] + 600;
}
+ $taf_time = $date[0].$date[1].$date[2].$date[3].$date[4]."00";
+
/* We then cache the TAF in our database */
if ($new_station) {
$this->debug('get_taf_from_web(): Inserting new TAF for <code>' .
$this->get_location() . '</code>');
- $this->db->insert_taf($icao, $taf, $timestamp);
+// $this->db->insert_taf($icao, $taf, $timestamp);
+ $this->db->insert_taf($icao, $taf, $timestamp, $taf_time);
} else {
$this->debug('get_taf_from_web(): Updating TAF for <code>' .
$this->get_location() . '</code>');
- $this->db->update_taf($icao, $taf, $timestamp);
+// $this->db->update_taf($icao, $taf, $timestamp);
+ $this->db->update_taf($icao, $taf, $timestamp, $taf_time);
+
}
/* We update and return the TAF */
$this->taf = $taf;
Index: defaults-dist.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/defaults-dist.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- defaults-dist.php 8 Sep 2003 08:02:33 -0000 1.19
+++ defaults-dist.php 30 Sep 2003 19:48:00 -0000 1.20
@@ -38,6 +38,10 @@
$this->properties['db_tafs'] = 'pw_tafs';
$this->properties['db_stations'] = 'pw_stations';
$this->properties['db_countries'] = 'pw_countries';
+$this->properties['archive_metars']= false; /* archiving of data */
+$this->properties['db_metars_arch']= 'pw_metars_arch';
+$this->properties['archive_tafs'] = false;
+$this->properties['db_tafs_arch'] = 'pw_tafs_arch';
$this->properties['db_type'] = 'null'; /* db_layer.php */
|