After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 160475 - Visibility data misparsed when low
Visibility data misparsed when low
Status: RESOLVED FIXED
Product: gnome-applets
Classification: Other
Component: gweather
git master
Other Linux
: High normal
: ---
Assigned To: gnome-applets Maintainers
gnome-applets Maintainers
: 160572 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-12-05 02:56 UTC by Frank Solensky
Modified: 2005-01-04 13:12 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
Proposed fix (2.48 KB, patch)
2004-12-05 03:06 UTC, Frank Solensky
none Details | Review
Includes fix for bug #151896 (3.28 KB, patch)
2004-12-05 04:07 UTC, Frank Solensky
none Details | Review
Fixes pressure display (10.67 KB, patch)
2004-12-10 03:35 UTC, Frank Solensky
none Details | Review
Another (10.67 KB, patch)
2004-12-10 04:48 UTC, Frank Solensky
none Details | Review
Additional patch: on top of previous pages (3.85 KB, patch)
2004-12-11 03:09 UTC, Frank Solensky
none Details | Review
Additional patch: on top of 34681 (3.63 KB, patch)
2004-12-11 03:15 UTC, Frank Solensky
committed Details | Review
Condition parsing moved out to separate files (43.79 KB, patch)
2004-12-11 20:07 UTC, Frank Solensky
none Details | Review
New "weather-*.c" files for parsing responses. (8.02 KB, application/x-compressed-tar)
2004-12-11 20:11 UTC, Frank Solensky
  Details
CAVOK sets both visibility and sky fields (6.61 KB, patch)
2004-12-12 16:43 UTC, Frank Solensky
none Details | Review
One line fix to above.. (6.62 KB, patch)
2004-12-13 13:02 UTC, Frank Solensky
none Details | Review
Force ignoring RMK data (7.18 KB, patch)
2004-12-14 03:32 UTC, Frank Solensky
none Details | Review
undo state parsing mechanism (4.91 KB, patch)
2004-12-21 04:09 UTC, Frank Solensky
none Details | Review
patch in testing (6.15 KB, patch)
2004-12-21 05:19 UTC, Danielle Madeley
none Details | Review

Description Frank Solensky 2004-12-05 02:56:42 UTC
An observation from METAR returned the following string:

KBOS 130254Z 34009KT 1 3/4SM R04R/5500VP6000FT -SN BR BKN007 OVC021 00/M01 A3041
RMK AO2 TWR VIS 4 CIG 005V011 SLP298 P0002 60007 T00001011 57003 $

The visibility field, "1 3/4 SM", could not be parsed; the current conditions
window listed the value as "unknown".
Comment 1 Frank Solensky 2004-12-05 03:06:15 UTC
Created attachment 34497 [details] [review]
Proposed fix

The visibility field may include fractions when it is less than 3 statute
miles, not just 1, and may use a numerator other than 1 (e.g.: 3/4).  This
patch is based on the description of the vilibilty field at
http://www.met.tamu.edu/class/METAR/metar-pg7-vis.html
Comment 2 Frank Solensky 2004-12-05 04:07:07 UTC
Created attachment 34500 [details] [review]
Includes fix for bug #151896
Comment 3 Danielle Madeley 2004-12-05 06:24:11 UTC
Woo! This is great work. Committed!
Comment 4 Danielle Madeley 2004-12-08 17:33:16 UTC
Frank,

I have noticed that somehow this patch causes the pressure to be marked as
Unknown, although I can't see why. Not using this patch causes the pressure to
be shown normally.
Comment 5 Frank Solensky 2004-12-09 05:30:29 UTC
I think I've got it narrowed down and should have another update ready tomorrow.
Comment 6 Frank Solensky 2004-12-10 03:35:18 UTC
Created attachment 34678 [details] [review]
Fixes pressure display

The original implementation wouldn't work when visibility was expressed as
units plus fraction since the parsing code assumed that the space was the
delimiter between expressions.	This reworks the parsing so that spaces can be
part of the expression.

It also doesn't reuse regular expressions.  I'm thinking the pressure string
may have also matched one of the earlier expressions as well and stored the
value into the wrong field.
Comment 7 Frank Solensky 2004-12-10 04:48:34 UTC
Created attachment 34681 [details] [review]
Another

Naturally, the first update I received after submitting the patch included
multiple fields for cloud cover.  This fixes that, using the first string (vs.
the last).
Comment 8 Danielle Madeley 2004-12-10 06:53:40 UTC
Ok, that seems to work. Thanks Frank.
Comment 9 Frank Solensky 2004-12-11 03:09:18 UTC
Created attachment 34724 [details] [review]
Additional patch: on top of previous pages

The conditions field can also be set with multiple values and appears before
cloud cover information.  This fix doesn't lose everything after present
weather.
Comment 10 Frank Solensky 2004-12-11 03:15:51 UTC
Created attachment 34725 [details] [review]
Additional patch: on top of 34681

I just noticed that the original report in this bug would have not been
processed correctly due to the runway info.  This should work.
Comment 11 Danielle Madeley 2004-12-11 14:45:10 UTC
Comment on attachment 34725 [details] [review]
Additional patch: on top of 34681

Ok, this is committed too. Thanks for all your work on the parsing code.
Comment 12 Danielle Madeley 2004-12-11 16:16:30 UTC
Hmm, something seems hideously wrong with the parsing code now, all I'm getting
is invalid either with, or without this patch.
Comment 13 Frank Solensky 2004-12-11 17:30:22 UTC
Can you try including the patch to bug #160572 ?  There's a one-line difference
in there that prevents retrying the first three patterns.

If that doesn't work, could you include the reading getting parsed so I can test
with that?
Comment 14 Frank Solensky 2004-12-11 20:07:58 UTC
Created attachment 34743 [details] [review]
Condition parsing moved out to separate files

The file weather.c is getting a bit long.  I'm breaking the response parsing
out into separate files to ease maintenance; the files to be added will follow
momentarily.
Comment 15 Frank Solensky 2004-12-11 20:11:25 UTC
Created attachment 34744 [details]
New "weather-*.c" files for parsing responses.

I'm running into the bug here too.. the problem is the field in the middle for
runway conditions was throwing off the state machine.  I've changed the regex
call so that it will look further into the string but ensure that if it's not
at the start, the previous character is ' '.

This also includes the fix for bug #160572 (windchill error)
Comment 16 Danielle Madeley 2004-12-12 05:39:43 UTC
Ok, this is a significant cleanup, so I'm going to commit it. Although we appear
to be back to the original bug which is it doesn't seem to be parsing visibility
data.
Comment 17 Frank Solensky 2004-12-12 16:43:41 UTC
Created attachment 34766 [details] [review]
CAVOK sets both visibility and sky fields

Parse functions also return the new state.  This avoids the inner loop in the
parser that needed exceptions and makes handling this case easier.
Comment 18 Danielle Madeley 2004-12-12 18:21:37 UTC
I'll test this in the morning after I've slept and my mind has reawoken.

Also Frank, I want to point you towards our work for moving gweather to using a
weather.gnome.org service in the future. Since you have put an amazing amount of
work into fixing up the parsing code, you should be interested in where I hope
we can go with this. See http://live.gnome.org/WeatherApplet
Comment 19 Frank Solensky 2004-12-13 13:02:50 UTC
Created attachment 34795 [details] [review]
One line fix to above..

Minor fix to above: parsing loop needed to actually use the returned value (I
should've waited for my mind to reawake before submitting.. *blush*)

Thanks for the invite -- I'll look into it some more later today.
Comment 20 Frank Solensky 2004-12-14 03:32:47 UTC
Created attachment 34816 [details] [review]
Force ignoring RMK data

Text in the remark field tricked the parser into advancing further than it
should have.  This forces processing to end at RMK by writing a '\0' into the
position.
Comment 21 Danielle Madeley 2004-12-20 09:54:54 UTC
Ok, I'm testing this now. It has fixed an issue I've had for half a day where
the applet was brokenly reporting 'smoke'. Visibility is back. All numbers seem
consistant with values reported by the BOM.
Comment 22 Danielle Madeley 2004-12-20 10:54:09 UTC
Hmm, seems that temperature parsing has broken.
Comment 23 Danielle Madeley 2004-12-20 11:10:33 UTC
Here is my METAR: 201000Z 25014KT CAVOK 24/17 Q1012 FM1200 25010KT 9000 FU BKN010

I see after the visibility field (CAVOK) we go straight to what appears to be
the temperature group.
Comment 24 Danielle Madeley 2004-12-20 11:45:03 UTC
Ok, I have added in workarounds to reorder the the chain parser. I'm going to
test that for a while before I do anything with it. It's hacky, and works by
checking if your location starts with 'YP'. Not the best solution. Perhaps we
should completely rewrite the parser to avoid chaining where possible.
Comment 25 Frank Solensky 2004-12-20 16:31:06 UTC
Yikes!  The transition from visibility to clouds on "CAVOK" was based on the
description of the int'l standard from
http://www.met.tamu.edu/class/METAR/metar-pg3.html, but the description there
suggests that your sky conditions (BKN010) should have been between CAVOK and
the temperature field.

Was it Grace Hopper who said "the nice thing about standards is that there are
so many of them"?

I'll try checking google for some other descriptions to see if I can find one
that's more accurate.
Comment 26 Danielle Madeley 2004-12-20 17:51:42 UTC
Frank, yes also take note of the two visbility fields (one is CAVOK, the other
is 9000). The current observation is:
   YPPH 201600Z 26005KT CAVOK 19/17 Q1012 NOSIG
which the parser can deal with as it is currently.

Searching on randomly scattered locations, it seems non of them really follow
the spec in the specific order listed. Hence it seems that chaining the parser
to parse in a particular order is not a good idea. On the other hand, we should
be able to parse each fragment using a regex of what characters have to appear.

ie. if it ends with a Z it's the time field, if it ends with KT it's the wind
field. CAVOK or a number on it's own is visbility. dd/dd is the temperature dew
point. Numbers starting with Q are pressures etc. The only thing this might
create a problem for is American locations, but if required we'll just use a
different parser for those.

Basically at the moment, it looks like we have a serious regression in the METAR
code, and I've only just realised why. I am loathe to release 2.9.3 without
either getting this fixed or reverting it. What do you think?
Comment 27 Frank Solensky 2004-12-20 21:08:35 UTC
Agreed -- I'll work on it this evening.  (I was looking for an excuse to put off
starting my Christmas shopping anyway :-)
Comment 28 Frank Solensky 2004-12-21 04:09:20 UTC
Created attachment 35071 [details] [review]
undo state parsing mechanism

The quote is by Andrew Tannenbaum.
Comment 29 Danielle Madeley 2004-12-21 05:19:08 UTC
Created attachment 35074 [details] [review]
patch in testing

This is the patch I'm testing against CVS HEAD. It seems to be holding up so
far.
Comment 30 Luis Villa 2005-01-03 03:00:18 UTC
Just to help you guys track, if I understand the current state of the code, this
should be marked 'High', right?
Comment 31 Christoffer Olsen 2005-01-04 00:17:43 UTC
*** Bug 160572 has been marked as a duplicate of this bug. ***
Comment 32 Frank Solensky 2005-01-04 13:12:53 UTC
I think it's closed -- it's in CVS HEAD at any rate.