There is a special case when the visibility is very low, something under 1 mile, for example:
$metar_raw_string = 'KBLI 211420Z AUTO 00000KT 1/4SM R16/1800V3500FT FZFG VV001 M03/M04 A3022 RMK AO2';
In this case... we'll get a notice in logs because $metar->visibility_miles will not be initialized.
Everything that is past 1 mile, for example:
$metar_raw_string = 'KBLI 211420Z AUTO 00000KT 1 1/4SM R16/1800V3500FT FZFG VV001 M03/M04 A3022 RMK AO2'; will work.
I think that we can add a quick fix after line 599 in weather_parser.inc file:
instead of:
if ($matches[3] == '/') {
// This is a fractional visibility, we need to convert this
$visibility = $metar->visibility_miles + $matches[2] / $matches[4];
}
we should check if $metar->visibility_miles is set or not, something like:
if ($matches[3] == '/') {
if (!isset($metar->visibility_miles)) {
$metar->visibility_miles = 0;
}
// This is a fractional visibility, we need to convert this
$visibility = $metar->visibility_miles + $matches[2] / $matches[4];
}
Comment | File | Size | Author |
---|---|---|---|
weather.module-visibility_miles-notices.patch | 694 bytes | Cracu |
Comments
Comment #1
toddy CreditAttribution: toddy commentedVery good catch, thanks a lot for reporting this. I'll fix this and release a new version shortly.
Regards,
Toddy
Comment #3
toddy CreditAttribution: toddy commentedApplied a fix for this.
Comment #5
IKE0088 CreditAttribution: IKE0088 commentedI am receiving the same error message:
Notice: Undefined property: stdClass::$visibility_miles in _weather_parse_visibility() (line 601
Did the fix noted above work? From the notes, it looks like it failed testing. Please advise.
Comment #6
toddy CreditAttribution: toddy commentedI've just released version 7.x-1.5 which includes a fix for this.
Regards,
Tobias