Хранилища Subversion geo-modmetar

Редакция

Редакция 13 | Редакция 15 | К новейшей редакции | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

Редакция 13 Редакция 14
Строка 325... Строка 325...
325
325
326
my %_sky_types_ru = (
326
my %_sky_types_ru = (
327
    SKC => "ясно",
327
    SKC => "ясно",
328
    CLR => "ясно",
328
    CLR => "ясно",
329
    SCT => "переменная облачность",
329
    SCT => "переменная облачность",
330
    BKN => "переменная облачность",
330
    BKN => "облачно с прояснениями",
331
    FEW => "слабая облачность",
331
    FEW => "слабая облачность",
332
    OVC => "сплошная облачность",
332
    OVC => "сплошная облачность",
333
    NSC => "нет существенной облачности",
333
    NSC => "нет существенной облачности",
334
    NCD => "безоблачно",
334
    NCD => "безоблачно",
335
);
335
);
Строка 350... Строка 350...
350
    LAST => "Last",
350
    LAST => "Last",
351
);
351
);
352
352
353
my $_trend_types_pat = join("|", keys(%_trend_types));
353
my $_trend_types_pat = join("|", keys(%_trend_types));
354
354
-
 
355
my %_trend_types_ru = (
-
 
356
    BLU => "видимость 8 км",
-
 
357
    WHT => "видимость 5 км",
-
 
358
    GRN => "видимость 3.7 км",
-
 
359
    YLO => "видимость 1.6 км",
-
 
360
    AMB => "видимость 800 м",
-
 
361
    RED => "видимость менее 800 м",
-
 
362
    BLACK => "аэропорт закрыт",
-
 
363
    NOSIG => "без существенных изменений",
-
 
364
    TEMPO => "временные изменения",
-
 
365
    NSW => "без существенной погоды",
-
 
366
    PROB => "вероятен",
-
 
367
    BECMG => "становление",
-
 
368
    LAST => "продолжается",
-
 
369
);
-
 
370
-
 
371
my $_trend_types_ru_pat = join("|", keys(%_trend_types_ru));
-
 
372
355
##
373
##
356
## Constructor.
374
## Constructor.
357
##
375
##
358
376
359
sub new
377
sub new
Строка 414... Строка 432...
414
    $self->{WEATHER_RAW}   = [ ];               # RAW data for weather
432
    $self->{WEATHER_RAW}   = [ ];               # RAW data for weather
415
    $self->{WEATHER_RUS}   = [ ];               # current weather in Russian
433
    $self->{WEATHER_RUS}   = [ ];               # current weather in Russian
416
    $self->{SKY_RAW}       = [ ];               # RAW data for sky
434
    $self->{SKY_RAW}       = [ ];               # RAW data for sky
417
    $self->{SKY_RUS}       = [ ];               # current sky in Russian
435
    $self->{SKY_RUS}       = [ ];               # current sky in Russian
418
    $self->{VISIBILITY_RUS}= undef;             # visibility info    
436
    $self->{VISIBILITY_RUS}= undef;             # visibility info    
-
 
437
    $self->{SLP_RUS}       = undef;             # sea level pressure in Russian
419
438
420
    $self->{tokens}        = [ ];               # the "token" list
439
    $self->{tokens}        = [ ];               # the "token" list
421
    $self->{type}          = "METAR";           # the report type (METAR/SPECI)
440
    $self->{type}          = "METAR";           # the report type (METAR/SPECI)
422
                                                # default=METAR
441
                                                # default=METAR
423
    $self->{site}          = undef;             # the site code (4 chars)
442
    $self->{site}          = undef;             # the site code (4 chars)
Строка 1026... Строка 1045...
1026
1045
1027
                ##
1046
                ##
1028
                ## euro type trend?
1047
                ## euro type trend?
1029
                ##
1048
                ##
1030
1049
1031
                elsif (($parsestate >= $expect_modifier) and ($tok =~ /^$_trend_types_pat/)){
1050
                elsif (($parsestate >= $expect_modifier) and ($tok =~ /^$_trend_types_pat/) and ($tok =~ /^$_trend_types_ru_pat/)){
1032
                        print "[$tok] is a trend.\n" if $self->{debug};
1051
                        print "[$tok] is a trend.\n" if $self->{debug};
1033
                        $parsestate = $expect_remarks;
1052
                        $parsestate = $expect_remarks;
1034
                        next;
1053
                        next;
1035
                }
1054
                }
1036
1055
Строка 1064... Строка 1083...
1064
1083
1065
        elsif (($parsestate == $expect_usremarks) and ($tok =~ /^SLP(\d+)/i))
1084
        elsif (($parsestate == $expect_usremarks) and ($tok =~ /^SLP(\d+)/i))
1066
        {
1085
        {
1067
            $self->{slp} = $tok;
1086
            $self->{slp} = $tok;
1068
            $self->{SLP} = "$1 mb";
1087
            $self->{SLP} = "$1 mb";
-
 
1088
            $self->{SLP_RUS} = "$1 мбар";
1069
            print "[$tok] is a sea level pressure.\n" if $self->{debug};
1089
            print "[$tok] is a sea level pressure.\n" if $self->{debug};
1070
            next;
1090
            next;
1071
        }
1091
        }
1072
1092
1073
        ##
1093
        ##
Строка 1076... Строка 1096...
1076
1096
1077
        elsif (($parsestate == $expect_usremarks) and ($tok eq "SLPNO"))
1097
        elsif (($parsestate == $expect_usremarks) and ($tok eq "SLPNO"))
1078
        {
1098
        {
1079
            $self->{slp} = "SLPNO";
1099
            $self->{slp} = "SLPNO";
1080
            $self->{SLP} = "not available";
1100
            $self->{SLP} = "not available";
-
 
1101
            $self->{SLP_RUS} = "нет данных";
1081
            print "[$tok] is a sea level pressure.\n" if $self->{debug};
1102
            print "[$tok] is a sea level pressure.\n" if $self->{debug};
1082
            next;
1103
            next;
1083
        }
1104
        }
1084
1105
1085
        ##
1106
        ##
Строка 1558... Строка 1579...
1558
1579
1559
__END__
1580
__END__
1560
1581
1561
=head1 NAME
1582
=head1 NAME
1562

1583

1563
Mod::Geo::METAR - Process aviation weather reports in the METAR format.
1584
Geo::ModMETAR - Process aviation weather reports in the METAR format.
1564

1585

1565
=head1 SYNOPSIS
1586
=head1 SYNOPSIS
1566

1587

1567
  use Mod::Geo::METAR;
1588
  use Geo::ModMETAR;
1568
  use strict;
1589
  use strict;
1569

1590

1570
  my $m = new Mod::Geo::METAR;
1591
  my $m = new Geo::ModMETAR;
1571
  $m->metar("KFDY 251450Z 21012G21KT 8SM OVC065 04/M01 A3010 RMK 57014");
1592
  $m->metar("KFDY 251450Z 21012G21KT 8SM OVC065 04/M01 A3010 RMK 57014");
1572
  print $m->dump;
1593
  print $m->dump;
1573

1594

1574
  exit;
1595
  exit;
1575

1596

Строка 1584... Строка 1605...
1584

1605

1585
=head1 USAGE
1606
=head1 USAGE
1586

1607

1587
=head2 How you might use this
1608
=head2 How you might use this
1588

1609

1589
Here is how you I<might> use the Geo::METAR module.
1610
Here is how you I<might> use the Geo::ModMETAR module.
1590

1611

1591
One use that I have had for this module is to query the NWS METAR page
1612
One use that I have had for this module is to query the NWS METAR page
1592
(using the LWP modules) at:
1613
(using the LWP modules) at:
1593

1614

1594
I<http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=EHSB>
1615
I<http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=EHSB>
Строка 1601... Строка 1622...
1601
I then pass the METAR into this module and get the info I want. I can
1622
I then pass the METAR into this module and get the info I want. I can
1602
then update my webcam page with the current temperature, sky conditions, or
1623
then update my webcam page with the current temperature, sky conditions, or
1603
whatnot. See for yourself at http://webcam.idefix.net/
1624
whatnot. See for yourself at http://webcam.idefix.net/
1604

1625

1605
See the BUGS section for a remark about multiple passes with the same
1626
See the BUGS section for a remark about multiple passes with the same
1606
Geo::METAR object.
1627
Geo::ModMETAR object.
1607

1628

1608
=head2 Functions
1629
=head2 Functions
1609

1630

1610
The following functions are defined in the METAR module. Most of
1631
The following functions are defined in the METAR module. Most of
1611
them are I<public>, meaning that you're supposed to use
1632
them are I<public>, meaning that you're supposed to use
Строка 1857... Строка 1878...
1857

1878

1858
=item ALT_HP
1879
=item ALT_HP
1859

1880

1860
Altimeter setting in hectopascals.
1881
Altimeter setting in hectopascals.
1861

1882

-
 
1883
=item ALT_PL
-
 
1884

-
 
1885
QFE pressure in mmHg.
-
 
1886

1862
=item REMARKS
1887
=item REMARKS
1863

1888

1864
Any remarks in the report.
1889
Any remarks in the report.
1865

1890

1866
=back
1891
=back
Строка 1872... Строка 1897...
1872
Older versions of this module were installed as "METAR" instaed of
1897
Older versions of this module were installed as "METAR" instaed of
1873
"Geo::METAR"
1898
"Geo::METAR"
1874

1899

1875
=head1 BUGS
1900
=head1 BUGS
1876

1901

1877
The Geo::METAR is only initialized once, which means you'll get left-over
1902
The Geo::ModMETAR is only initialized once, which means you'll get left-over
1878
crud in variables when you call the metar() function twice.
1903
crud in variables when you call the metar() function twice.
1879

1904

1880
What is an invalid METAR in one country is a standard one in the next.
1905
What is an invalid METAR in one country is a standard one in the next.
1881
The standard is interpreted and used by meteorologists all over the world,
1906
The standard is interpreted and used by meteorologists all over the world,
1882
with local variations. This means there will always be METARs that will
1907
with local variations. This means there will always be METARs that will
1883
trip the parser.
1908
trip the parser.
1884

1909

1885
=head1 TODO
1910
=head1 TODO
1886

1911

1887
There is a TODO file included in the Geo::METAR distribution listing
1912
There is a TODO file included in the Geo::ModMETAR distribution listing
1888
the outstanding tasks that I or others have devised. Please check that
1913
the outstanding tasks that I or others have devised. Please check that
1889
list before you submit a bug report or request a new feture. It might
1914
list before you submit a bug report or request a new feture. It might
1890
already be on the TODO list.
1915
already be on the TODO list.
1891

1916

1892
=head1 AUTHORS AND COPYRIGHT
1917
=head1 AUTHORS AND COPYRIGHT