Re: metar decoding

From: Date: Fri, 09 May 2003 20:58:19 +0000
Subject: Re: metar decoding
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147068@lists.php.net to get a copy of this message
I reckon you could use substr for a lot of it. The identifier isn't a problem because it's always 4 chars. The time/date is a standard length, so if the '091753Z' was put into $metar[1] you could extract with $date=substr($metar[1],0,2) and $time=substr($metar[1],3,4) - and the 'Zulu' you can take as read. The wind is slightly more of a challenge, but if there is wind (you'd have to check for various other conditions first, eg, to see if $metar[2] == "NIL") then the first first chars are easily broken down into direction and speed. Then you've have to check for the existence of 'G'. Basically, I think you're in for a lot of 'if' clauses and string comparisons. For example, if one part of the exploded array starts with 'SCT', 'BKN', 'OVC' etc, then you know it's about cloud. I think the dewpoint/temp string is the only one with five chars with '/' in the middle. Anyway, that's my tuppenceworth... "Bryan Koschmann - Gkt" <gktnews@gktech.net> wrote in message news:Pine.LNX.4.30.0305091222360.1215-100000@penguin.gktech.net... > Hi, > > I was wondering, does anyone here have any experience decoding metar > output? I know ther eis PHP weather, but that is far too much for what I > want (plus i cant get it working anyway). > > I just want to get simple values that I can do what I want with. > > If it helps, this is what the output looks like: > > 2003/05/09 17:53 > KSFF 091753Z 06008G18KT 10SM SCT090 SCT200 16/01 A3000 RMK AO2 SLP158 > T01560011 10156 20044 50002 > > The second line is always on one line. I know I can break it up using > explode, but then I have to get things like this; > > 091753Z I need the 09 and the 1753 separated and do not need the Z > 10SM I need just the 10 > SCT090 I need SCT and 090 separated > SCT200 I need SCT and 200 separated > > There are of course others, but that would at least get me started. > > I'm sure it's just a matter of regular expressions, but my brain is having > trouble grasping those ideas. > > If you have any ideas I'd be happy to hear them! > > Thanks, > > Bryan >

« previous php.general (#147068) next »