Log.xml
File holding entries created in 'Weather Diary' assessed from Cumulus 1 View menu.
The file can be edited within Cumulus 1 (Weather Diary on Edit menu), and can be viewed (but not edited) using a XML viewer.
This is a piece of PHP code that can read this file and put what it reads (for a particular day) into PHP variables. Since this diary can hold several entries for the same day, a decision has to be made as to which to report. For snow falling, lying, and depth, this code saves the "worst case" of all the entries for that day. For the "entry" field, the one with latest time is retained.
There is a web page using this code written by Czech author Miloš Jirík (https://pocasi.ok5aw.cz) available on the support forum at https://cumulus.hosiene.co.uk/viewtopic.php?p=83888#p83888
//====================================================
// This snippet is used for Cumulus 1 with XML based diary
// =======================================================
$fh = fopen($snowDiary, 'r'); // $snowDiary has to contain full path based on root or relative to where your script is
if ($fh == FALSE)
{
echo 'ERROR - cannot access weather diary';
}else{
if($debug) echo 'Success, database ' . $snowDiary . ' is open' . PHP_EOL;
$data = fread($fh, filesize($snowDiary));
fclose($fh);
$converted = iconv("Windows-1250", "UTF-8//IGNORE", $data);
$xml = simplexml_load_string($converted);
$dayArray = array();
$oldKey = ;
foreach ($xml->xpath('//ROW') as $item)
{
$key = substr($item['EntryDate'],0,4) . '-' . substr($item['EntryDate'],4,2) . '-' . substr($item['EntryDate'],6,2);
if($key > $rowMetDayStamp) break;
$falling = $item['SnowFalling'] == 'TRUE' ? 1 : 0;
$lying = $item['SnowLying'] == 'TRUE' ? 1 : 0;
$depth = $item['SnowDepth'];
if($key == $oldKey) // update to another record for same day, retain worse boolean for falling and lying
{
$falling = $oldFalling == 1 ? 1 : $falling;
$lying = $oldLying == 1 ? 1 : $lying;
$depth = ($depth - $oldDepth) > 0 ? $depth : $oldDepth;
}
$Entry = $item['Entry'];
// novel to SPAWS
$oldFalling = $falling;
$oldLying = $lying;
$oldDepth = $depth;
$oldKey = $key;
} // end of loop through XML records
if($key == $rowMetDayStamp)
{
$snowKnown = true;
if ($debug)
{
echo ' ----- Found entry in weather diary for ' . $englishProcessingDate . $lf;
}
goto snowDone;
}
if($debug) echo ' ----- NO entry in Cumulus 1 weather diary for ' . $englishProcessingDate . $lf . '============================' . $lf;
$snowKnown = false;
$Entry = Null; // Other variables were previously set to values appropriate for the lowest temperature
goto snowDone;
}
snowDone: