[yunqa.de] Re: Can DIRegEx decode metars?

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sun, 23 Mar 2008 21:15:35 +0100

dogo wrote:

>I?m looking to buy DIRegEX, but before I go ahead can you tell me if it can 
>decode weather metar,  details  of the format are here
>http://www.met.tamu.edu/class/METAR/metar-pg3.html, What I am looking to do is 
>connect to ftp://tgftp.nws.noaa.gov/data/observations/metar/decoded/ and 
>download the relevant file, 

Almost all Delphi Internet libraries -- ICS, Indy, Synapse, to name just a few 
-- enable you to download via FTP.

>here what one looks like from the above site.
> 
>2008/03/21 18:50 EGMD 211850Z 31012KT 9999 SCT033 05/03 Q0988

I feel that the data extraction is well possible with DIRegEx, but suggest you 
give it a thorough testing with the DIRegEx demo before your purchase.

Since the complete METAR specification is too comprehensive to cover here, I'd 
like to show how to go on about it by "translating" one piece of the spec 
(http://www.met.tamu.edu/class/METAR/metar-pg12-pres.html) to a regex pattern:

METAR Quote:

"The altimeter group always starts with an A (the international indicator for 
altimeter in inches of mercury). The altimeter shall be coded as a four digit 
group immediately following the A using the tens, units, tenths, and hundredths 
of inches of mercury. The decimal point is not coded."

RegEx Equivalent (remove quotation marks):

  "A\d\d\d\d"  

"A" is the literal letter "A", "\d" stands for a single decimal. Alternatively, 
you can use this syntax, which I think is self-explanatory:

  "A\d{4}"

The METAR Quote continues:

"Note: The WMO standard is to report the altimeter in whole hectopascals. In 
this case, the altimeter setting group will be begin with a Q instead of an A."

This requires to modify the RegEx to allow both "A" and "Q". You can use a 
character class within square brackest for this:

  "[AQ]\d{4}"

To implement the whole METAR specs, you would work along the same line of 
thought and concatentate the individual pieces to a larger pattern.

These DIRegEx help sections are available as pattern syntax references and 
lookup:

  * Syntax Quick Reference
  * Syntax Details

For a beginning, I'd recommend to compile and run the Workbench demo 
application and start coding ...

Ralf 

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: