Skip Menu |

This queue is for tickets about the Geo-METAR CPAN distribution.

Report information
The Basics
Id: 14242
Status: resolved
Priority: 0/
Queue: Geo-METAR

People
Owner: koos [...] kzdoos.xs4all.nl
Requestors: knotty [...] ailleurs.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Wind direction error
Hi Jeremy, I think there is a problem with the wind direction. I join a script where I put your code in the TEST sub. There is 2 anothers subs that compute the wind direction. sub Sector that return direction like N, N/NE, NE, E/NE.. sub Sector_HR that return dir in more readable form the script call the 3 subs for each angle by step of 10 degres, that is the metar standard, and print the result of each computation. If you want you can patch with my subs. I hope that will be usefull. Thanks for this module. -- Karl Y. Pradene
#!/usr/bin/perl -w # # Copyright 2005, Karl Y. Pradene <knotty@cpan.org> All rights reserved. use strict; use warnings; for my $foo (0..36) { $foo *= 10; printf "%3s %-4s .%15s. .%-15s.\n", $foo, Sector($foo), Sector_HR($foo), TEST($foo); } sub Sector { my $sAlpha = shift() / 10 ; my %hSectors = ( 1=>'N', 3=>'N/NE', 5=>' NE', 7=>'E/NE', 10=>'E', 12=>'E/SE', 14=>' SE', 16=>'S/SE', 19=>'S', 21=>'S/SW', 23=>' SW', 25=>'W/SW', 28=>'W', 30=>'W/NW', 32=>' NW', 34=>'N/NW', 36=>'N'); until ( $hSectors{$sAlpha++} ) {} ; return $hSectors{--$sAlpha}; } sub Sector_HR { # Human Readable $_ = Sector(shift()); s!N!North!g ; s!S!South!g ; s!^E!East! ; s!E$!east! ; s!^W!West! ; s!W$!west! ; return $_; } sub TEST{ my $dir_deg = shift; my $dir_eng=''; if ($dir_deg < 15) { $dir_eng = "North"; } elsif ($dir_deg < 30) { $dir_eng = "North/Northeast"; } elsif ($dir_deg < 60) { $dir_eng = "Northeast"; } elsif ($dir_deg < 75) { $dir_eng = "East/Northeast"; } elsif ($dir_deg < 105) { $dir_eng = "East"; } elsif ($dir_deg < 120) { $dir_eng = "East/Southeast"; } elsif ($dir_deg < 150) { $dir_eng = "Southeast"; } elsif ($dir_deg < 165) { $dir_eng = "South/Southeast"; } elsif ($dir_deg < 195) { $dir_eng = "South"; } elsif ($dir_deg < 210) { $dir_eng = "South/Southwest"; } elsif ($dir_deg < 240) { $dir_eng = "Southwest"; } elsif ($dir_deg < 265) { $dir_eng = "West/Southwest"; } elsif ($dir_deg < 285) { $dir_eng = "West"; } elsif ($dir_deg < 300) { $dir_eng = "West/Northwest"; } elsif ($dir_deg < 330) { $dir_eng = "Northwest"; } elsif ($dir_deg < 345) { $dir_eng = "North/Northwest"; } else { $dir_eng = "North"; } return $dir_eng; } exit 0;
On Sat Aug 20 10:19:10 2005, KNOTTY wrote: Show quoted text
> I think there is a problem with the wind direction.
There is. Or rather: was, I (Koos van den Hout) took over maintainership of Geo::METAR. Today I uploaded a new version (1.15) to CPAN which should (in my opinion) fix this bug. The new version also has a better parser which should work for METARs from most parts of the world.