echo 'ERROR - cannot access weather diary';
}else{
if($debug) echo 'Success, database ' . $snowDiary . ' is open' . PHP_EOL;
$data = fread($fh, filesize($snowDiary));
fclose($fh); // close diary, now contents in $data
$converted = iconv("Windows-1250", "UTF-8//IGNORE", $data); // Convert from windows format that Cumulus uses to UTF-8 to match what most scripts now use
$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'];
$oldFalling = $falling;
// novel to SPAWS
$oldFallingoldLying = $fallinglying;
$oldLyingoldDepth = $lyingdepth;
$oldKey $oldDepth = $depthkey;
} // end of loop through XML records ▼
$oldKey = $key;
if($key == $rowMetDayStamp) ▼
▲ } // end of loop through XML records
{
▲ if($key == $rowMetDayStamp)
{
}
if ($debug)
{
$Entry = Null; // Other variables were previously set to values appropriate for the lowest temperature ▼
echo ' ----- Found entry in weather diary for ' . $englishProcessingDate . $lf;
}
}
if($debug) echo ' ----- NO entry in Cumulus 1 weather diary for ' . $englishProcessingDate . $lf . '============================' . $lf;
▲ $Entry = Null; // Other variables were previously set to values appropriate for the lowest temperature
}
snowDone:</pre>
|