| 1 | package Weather::NWS::NDFDgen; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use LWP::Simple; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use SOAP::DateTime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Class::Std; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =pod | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Weather::NWS::NDFDgen - Object interface to the NWS NDFDgen Web Service. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 VERSION | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | Version 0.02 | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 3 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =pod | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | use Weather::NWS::NDFDgen; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | my $NDFDgen = Weather::NWS::NDFDgen->new(); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | my $NDFDgen = Weather::NWS::NDFDgen->new( | ||||||||||||||||||||||||||||
| 36 | 'Product' => 'Time-Series', | ||||||||||||||||||||||||||||
| 37 | 'Latitude' => 42, | ||||||||||||||||||||||||||||
| 38 | 'Longitude' => -88, | ||||||||||||||||||||||||||||
| 39 | 'Weather Parameters' => { | ||||||||||||||||||||||||||||
| 40 | 'Maximum Temperature' => 1, | ||||||||||||||||||||||||||||
| 41 | 'Minimum Temperature' => 0, | ||||||||||||||||||||||||||||
| 42 | }, | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | my $latitude = 42; | ||||||||||||||||||||||||||||
| 46 | $NDFDgen->set_latitude($latitude); | ||||||||||||||||||||||||||||
| 47 | $latitude = $NDFDgen->get_latitude(); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | my $longitude = -88; | ||||||||||||||||||||||||||||
| 50 | $NDFDgen->set_longitude($longitude); | ||||||||||||||||||||||||||||
| 51 | $longitude = $NDFDgen->get_longitude(); | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | my $product = 'Time-Series'; | ||||||||||||||||||||||||||||
| 54 | $NDFDgen->set_product($product); | ||||||||||||||||||||||||||||
| 55 | $product = $NDFDgen->get_product(); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | my $start_time = scalar localtime; | ||||||||||||||||||||||||||||
| 58 | $NDFDgen->set_start_time($start_time); | ||||||||||||||||||||||||||||
| 59 | $start_time = $NDFDgen->get_start_time(); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | my $end_time = scalar localtime; | ||||||||||||||||||||||||||||
| 62 | $NDFDgen->set_end_time($end_time); | ||||||||||||||||||||||||||||
| 63 | $end_time = $NDFDgen->get_end_time(); | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | $NDFDgen->set_weather_parameters( | ||||||||||||||||||||||||||||
| 66 | 'Maximum Temperature' => 1, | ||||||||||||||||||||||||||||
| 67 | 'Minimum Temperature' => 0, | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | my @weather_parameters = $NDFDgen->get_weather_parameters( | ||||||||||||||||||||||||||||
| 70 | 'Maximum Temperature', | ||||||||||||||||||||||||||||
| 71 | 'Minimum Temperature', | ||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | my $xml = $NDFDgen->get_forecast_xml(); | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | my $xml = $NDFDgen->get_forecast_xml( | ||||||||||||||||||||||||||||
| 77 | 'Product' => 'Time-Series', | ||||||||||||||||||||||||||||
| 78 | 'Latitude' => 42, | ||||||||||||||||||||||||||||
| 79 | 'Longitude' => -88, | ||||||||||||||||||||||||||||
| 80 | 'Weather Parameters' => { | ||||||||||||||||||||||||||||
| 81 | 'Maximum Temperature' => 1, | ||||||||||||||||||||||||||||
| 82 | 'Minimum Temperature' => 0, | ||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | my @products = $NDFDgen->get_available_products(); | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | my @weather_parameters = $NDFDgen->get_available_weather_parameters(); | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =pod | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head1 NDFDgen | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | The NDFDgen web service is provided by the National Weather Service as part | ||||||||||||||||||||||||||||
| 97 | of their National Digital Forecast Database. Official NWS documentation for | ||||||||||||||||||||||||||||
| 98 | the XML web service can be found at | ||||||||||||||||||||||||||||
| 99 | L<http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php>. | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | The service allows for users to request custom weather forecasts based on | ||||||||||||||||||||||||||||
| 102 | the following parameters. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head2 Latitude | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | The latitude of the point for which you want NDFD data. For Northern | ||||||||||||||||||||||||||||
| 107 | latituded, this will be a positive decimal value, such as 42.011. | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =head2 Longitude | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | The longitude of the point for which you want NDFD data. For Western | ||||||||||||||||||||||||||||
| 112 | longitudes, this will be a negative decimal value, such as -88.81. | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head2 Product | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | There are two products presented by NDFDgen. These are the time-series and | ||||||||||||||||||||||||||||
| 117 | glance products. The time-series product returns all data between the start | ||||||||||||||||||||||||||||
| 118 | and end times for the selected weather parameters. The glance product returns | ||||||||||||||||||||||||||||
| 119 | all data between the start and end times for maximum temperature, minimum | ||||||||||||||||||||||||||||
| 120 | temperature, cloud cover, weather and weather icons elements. | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | For this object, 'Time-Series' and 'Glance' are used to identify the products. | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head2 Start Time | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | The beginning time for which you want NDFD data. The format for this date is | ||||||||||||||||||||||||||||
| 127 | and XSD DateTime, which is represented like '2004-01-01T00:00:00'. You can | ||||||||||||||||||||||||||||
| 128 | really pass almost any date format in as the start time though because the | ||||||||||||||||||||||||||||
| 129 | date is passed through L<SOAP::DateTime> before use. | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =head2 End Time | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | The ending time for which you want NDFD data. The format for this date is | ||||||||||||||||||||||||||||
| 134 | and XSD DateTime, which is represented like '2004-01-01T00:00:00'. You can | ||||||||||||||||||||||||||||
| 135 | really pass almost any date format in as the end time though because the | ||||||||||||||||||||||||||||
| 136 | date is passed through L<SOAP::DateTime> before use. | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =head2 Weather Parameters | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | You can request any set of multiple weather parameters. These parameters | ||||||||||||||||||||||||||||
| 141 | are listed below. The definitions are taken from the NWS at | ||||||||||||||||||||||||||||
| 142 | L<http://www.nws.noaa.gov/ndfd/definitions.htm>. | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | =head3 Maximum Temperature | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | Maximum temperature is the daytime max or the overnight min temperature. | ||||||||||||||||||||||||||||
| 147 | Verifying observations are deduced via a comprehensive algorithm that examines | ||||||||||||||||||||||||||||
| 148 | reported max/min and hourly temperatures. Daytime is defined as 0700-1900 Local | ||||||||||||||||||||||||||||
| 149 | Standard Time, and overnight as 1900-0800 Local Standard Time. | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =head3 Minimum Temperature | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | Minimum temperature is the daytime max or the overnight min temperature. | ||||||||||||||||||||||||||||
| 154 | Verifying observations are deduced via a comprehensive algorithm that examines | ||||||||||||||||||||||||||||
| 155 | reported max/min and hourly temperatures. Daytime is defined as 0700-1900 Local | ||||||||||||||||||||||||||||
| 156 | Standard Time, and overnight as 1900-0800 Local Standard Time. | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =head3 3 Hourly Temperature | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 3 Hourly temperature is the expected temperature valid for the indicated hour. | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =head3 Dewpoint Temperature | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | Dewpoint temperature is the expected dew point temperature for the indicated | ||||||||||||||||||||||||||||
| 165 | hour. | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =head3 Apparent Temperature | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | Apparent temperature is the perceived temperature derived from either a | ||||||||||||||||||||||||||||
| 170 | combination of temperature and wind (Wind Chill), or temperature and humidity | ||||||||||||||||||||||||||||
| 171 | (Heat Index) for the indicated hour. Apparent temperature grids will signify | ||||||||||||||||||||||||||||
| 172 | the Wind Chill when temperatures fall to 50 °F or less, and the Heat Index | ||||||||||||||||||||||||||||
| 173 | when temperatures rise above 80 °F. Between 51 and 80 °F the Apparent | ||||||||||||||||||||||||||||
| 174 | Temperature grids will be populated by the ambient air temperature. | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =head3 12 Hour Probability of Precipitation | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 12 hour probability of precipitation is defined as the likelihood, expressed as | ||||||||||||||||||||||||||||
| 179 | a percent, of a measurable precipitation event (1/100th of an inch or more ) | ||||||||||||||||||||||||||||
| 180 | during the 12-hour valid period. The 12-hour periods begin and end at 0000 and | ||||||||||||||||||||||||||||
| 181 | 1200 UTC. | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =head3 Liquid Precipitation Amount | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | Liquid precipitation amount is the total amount of expected liquid | ||||||||||||||||||||||||||||
| 186 | precipitation during a 6-hour period. The 6-hour periods begin and end at | ||||||||||||||||||||||||||||
| 187 | 0600, 1200, 1800, and 0000 UTC. | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | =head3 Cloud Cover Amount | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | Cloud cover amount is the expected amount of all opaque clouds (in percent) | ||||||||||||||||||||||||||||
| 192 | covering the sky for the indicated hour. | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | =head3 Snowfall Amount | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | Snowfall amount is the expected total accumulation of new snow during a 6-hour | ||||||||||||||||||||||||||||
| 197 | period. The 6-hour periods begin and end at 0600, 1200, 1800, and 0000 UTC. | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | =head3 Wind Speed | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | Wind speed is the expected sustained 10 meter wind speed for the indicated hour. | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | =head3 Wind Direction | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | Wind direction is the expected sustained 10 meter wind direction for the | ||||||||||||||||||||||||||||
| 206 | indicated hour, using 36 points of a compass. | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =head3 Weather | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | Weather is the expected weather (precipitating or non-precipitating) valid at | ||||||||||||||||||||||||||||
| 211 | the indicated hour. Precipitating weather includes type, probability, and | ||||||||||||||||||||||||||||
| 212 | intensity information. In cases of convective weather, coverage may be | ||||||||||||||||||||||||||||
| 213 | substituted for probability. | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | =head3 Wave Height | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | Wave height (significant) is the average height (trough to crest) of the | ||||||||||||||||||||||||||||
| 218 | one-third highest waves for the indicated 12-hour period. The 12-hour periods | ||||||||||||||||||||||||||||
| 219 | begin and end at 0000 and 1200 UTC. | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | =head3 Weather Icons | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | Weather icons are links to images from the NWS that illustrate weather | ||||||||||||||||||||||||||||
| 224 | conditions at specific time points. | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =head3 Relative Humidity | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | Relative humidity is the expected Relative Humidity (RH) for the indicated hour. | ||||||||||||||||||||||||||||
| 229 | RH is derived from the associated Temperature and Dew Point grids for the | ||||||||||||||||||||||||||||
| 230 | indicated hour. | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | =cut | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 3 | Readonly my $SERVICE => | |||||||||||||||||||||||||||
| 235 | 'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl'; | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 3 | Readonly my %NAME_TO_ARGUMENT => ( | |||||||||||||||||||||||||||
| 238 | 'Latitude' => 'latitude', | ||||||||||||||||||||||||||||
| 239 | 'Longitude' => 'longitude', | ||||||||||||||||||||||||||||
| 240 | 'Product' => 'product', | ||||||||||||||||||||||||||||
| 241 | 'Start Time' => 'startTime', | ||||||||||||||||||||||||||||
| 242 | 'End Time' => 'endTime', | ||||||||||||||||||||||||||||
| 243 | 'Weather Parameters' => 'weatherParameters', | ||||||||||||||||||||||||||||
| 244 | ); | ||||||||||||||||||||||||||||
| 245 | 3 | Readonly my @ARGUMENTS => keys %NAME_TO_ARGUMENT; | |||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 3 | Readonly my %NAME_TO_PRODUCT => ( | |||||||||||||||||||||||||||
| 248 | 'Time-Series' => 'time-series', | ||||||||||||||||||||||||||||
| 249 | 'Glance' => 'glance', | ||||||||||||||||||||||||||||
| 250 | ); | ||||||||||||||||||||||||||||
| 251 | 3 | Readonly my @PRODUCTS => keys %NAME_TO_PRODUCT; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 3 | Readonly my %NAME_TO_WEATHER_PARAMETER => ( | |||||||||||||||||||||||||||
| 254 | 'Maximum Temperature' => 'maxt', | ||||||||||||||||||||||||||||
| 255 | 'Minimum Temperature' => 'mint', | ||||||||||||||||||||||||||||
| 256 | '3 Hourly Temperature' => 'temp', | ||||||||||||||||||||||||||||
| 257 | 'Dewpoint Temperature' => 'dew', | ||||||||||||||||||||||||||||
| 258 | 'Apparent Temperature' => 'appt', | ||||||||||||||||||||||||||||
| 259 | '12 Hour Probability of Precipitation' => 'pop12', | ||||||||||||||||||||||||||||
| 260 | 'Liquid Precipitation Amount' => 'qpf', | ||||||||||||||||||||||||||||
| 261 | 'Cloud Cover Amount' => 'sky', | ||||||||||||||||||||||||||||
| 262 | 'Snowfall Amount' => 'snow', | ||||||||||||||||||||||||||||
| 263 | 'Wind Speed' => 'wspd', | ||||||||||||||||||||||||||||
| 264 | 'Wind Direction' => 'wdir', | ||||||||||||||||||||||||||||
| 265 | 'Weather' => 'wx', | ||||||||||||||||||||||||||||
| 266 | 'Wave Height' => 'waveh', | ||||||||||||||||||||||||||||
| 267 | 'Weather Icons' => 'icons', | ||||||||||||||||||||||||||||
| 268 | 'Relative Humidity' => 'rh', | ||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||
| 270 | 3 | Readonly my @WEATHER_PARAMETERS => keys %NAME_TO_WEATHER_PARAMETER; | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 3 | Readonly my $DEFAULT_PRODUCT => 'Time-Series'; | |||||||||||||||||||||||||||
| 273 | 3 | Readonly my $DEFAULT_START_TIME => ConvertDate( scalar localtime ); | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | =pod | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | =head1 METHODS | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =cut | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||
| 282 | 3 | my %forecaster : ATTR; | |||||||||||||||||||||||||||
| 283 | 3 | my %forecast_xml : ATTR; | |||||||||||||||||||||||||||
| 284 | 3 | my %default_latitude : ATTR; | |||||||||||||||||||||||||||
| 285 | 3 | my %default_longitude : ATTR; | |||||||||||||||||||||||||||
| 286 | 3 | my %default_product : ATTR; | |||||||||||||||||||||||||||
| 287 | 3 | my %default_start_time : ATTR; | |||||||||||||||||||||||||||
| 288 | 3 | my %default_end_time : ATTR; | |||||||||||||||||||||||||||
| 289 | 3 | my %default_weather_parms : ATTR; | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | =pod | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | =head2 BUILD (new) | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | Constructor for new NDFDgen objects. If called with no parameters, it will | ||||||||||||||||||||||||||||
| 296 | return a new object initialized with the 'Time-Series' product and the | ||||||||||||||||||||||||||||
| 297 | current time as the start time. All other parameters are left unintialized. | ||||||||||||||||||||||||||||
| 298 | Values can be provided for 'Latitude', 'Longitude', 'Product', 'Start Time', | ||||||||||||||||||||||||||||
| 299 | 'End Time', and 'Weather Parameters'. | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =cut | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 1 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=8 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||
| 304 | 1 | my ( $self, $ident, $arg_ref ) = @_; | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 1 | my %args = %{$arg_ref}; | |||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 1 | map { $default_weather_parms{$ident}{$_} = 0 } @WEATHER_PARAMETERS; | |||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 1 | ▶ | $self->set_latitude( $args{'Latitude'} || undef ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{'Latitude'} || undef
MC/DC0%0/1
$args{'Latitude'} || undef
$args{'Latitude'}
Truth table50%1/2
A
A= $args{'Latitude'}
| |||||||||||||||||||||||||||||
| 311 | 1 | ▶ | $self->set_longitude( $args{'Longitude'} || undef ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{'Longitude'} || undef
MC/DC0%0/1
$args{'Longitude'} || undef
$args{'Longitude'}
Truth table50%1/2
A
A= $args{'Longitude'}
| |||||||||||||||||||||||||||||
| 312 | 1 | ▶ | $self->set_product( $args{'Product'} || $DEFAULT_PRODUCT ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$args{'Product'} || $DEFAULT_PRODUCT
MC/DC0%0/2
$args{'Product'} || $DEFAULT_PRODUCT
$args{'Product'}
$DEFAULT_PRODUCT
Truth table33%1/3
A || B
A= $args{'Product'}B= $DEFAULT_PRODUCT
| |||||||||||||||||||||||||||||
| 313 | 1 | ▶ | $self->set_start_time( $args{'Start Time'} || $DEFAULT_START_TIME ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$args{'Start Time'} || $DEFAULT_START_TIME
MC/DC0%0/2
$args{'Start Time'} || $DEFAULT_START_TIME
$args{'Start Time'}
$DEFAULT_START_TIME
Truth table33%1/3
A || B
A= $args{'Start Time'}B= $DEFAULT_START_TIME
| |||||||||||||||||||||||||||||
| 314 | 1 | ▶ | $self->set_end_time( $args{'End Time'} || undef ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{'End Time'} || undef
MC/DC0%0/1
$args{'End Time'} || undef
$args{'End Time'}
Truth table50%1/2
A
A= $args{'End Time'}
| |||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 1 | ▶ | if ( $args{'Weather Parameters'} and ref $args{'Weather Parameters'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"Weather Parameters"} and ref $args{"Weather Parameters"}
MC/DC0%0/2
$args{"Weather Parameters"} and ref $args{"Weather Parameters"}
$args{"Weather Parameters"}
ref $args{"Weather Parameters"}
Truth table33%1/3
A and B
A= $args{"Weather Parameters"}B= ref $args{"Weather Parameters"}
| |||||||||||||||||||||||||||||
| 317 | 0 | $self->set_weather_parameters( %{ $args{'Weather Parameters'} } ); | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =pod | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | =head2 set_latitude | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | Sets the latitude for the object. This is a decimal value. | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | =cut | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 2 | ▶ | sub set_latitude { | ||||||||||||||||||||||||||
|
Subroutine
set_latitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 330 | 2 | my ( $self, $new_latitude ) = @_; | |||||||||||||||||||||||||||
| 331 | 2 | return $default_latitude{ ident $self} = $new_latitude; | |||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | =pod | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | =head2 get_latitude | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | Returns the latitude stored in the object. | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | =cut | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 2 | ▶ | sub get_latitude { | ||||||||||||||||||||||||||
|
Subroutine
get_latitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 343 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 344 | 2 | return $default_latitude{ ident $self}; | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | =pod | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | =head2 set_longitude | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | Sets the longitude for the object. This is a decimal value. | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | =cut | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 2 | ▶ | sub set_longitude { | ||||||||||||||||||||||||||
|
Subroutine
set_longitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 356 | 2 | my ( $self, $new_longitude ) = @_; | |||||||||||||||||||||||||||
| 357 | 2 | return $default_longitude{ ident $self} = $new_longitude; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | =pod | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | =head2 get_longitude | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | Returns the longitude stored in the object. | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | =cut | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 2 | ▶ | sub get_longitude { | ||||||||||||||||||||||||||
|
Subroutine
get_longitude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 369 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 370 | 2 | return $default_longitude{ ident $self}; | |||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | =pod | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | =head2 set_product | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | Sets the product for the object. This is either 'Time-Series' or 'Glance'. | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | =cut | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | 4 | ▶ | sub set_product { | ||||||||||||||||||||||||||
|
Subroutine
set_product: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 382 | 4 | my ( $self, $new_product ) = @_; | |||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | die("Invalid product ($new_product)") | ||||||||||||||||||||||||||||
| 385 | 4 | ▶ | unless ( grep { /^${new_product}$/ } @PRODUCTS ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 3 | return $default_product{ ident $self} = $new_product; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | =pod | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | =head2 get_product | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | Returns the product stored in the object. | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | =cut | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 2 | ▶ | sub get_product { | ||||||||||||||||||||||||||
|
Subroutine
get_product: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 399 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 400 | 2 | return $default_product{ ident $self}; | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | =pod | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | =head2 set_start_time | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | Sets the start time for the object. | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | =cut | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 2 | ▶ | sub set_start_time { | ||||||||||||||||||||||||||
|
Subroutine
set_start_time: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 412 | 2 | my ( $self, $new_start_time ) = @_; | |||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 2 | ▶ | return unless $new_start_time; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 2 | return $default_start_time{ ident $self} = ConvertDate($new_start_time); | |||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | =pod | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | =head2 get_start_time | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | Gets the start time stored in the object. | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | =cut | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | 1 | ▶ | sub get_start_time { | ||||||||||||||||||||||||||
|
Subroutine
get_start_time: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 428 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 429 | 1 | return $default_start_time{ ident $self}; | |||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | =pod | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | =head2 set_end_time | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | Sets the end time for the object. | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | =cut | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | 2 | ▶ | sub set_end_time { | ||||||||||||||||||||||||||
|
Subroutine
set_end_time: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 441 | 2 | my ( $self, $new_end_time ) = @_; | |||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | 2 | ▶ | return unless $new_end_time; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 1 | return $default_end_time{ ident $self} = ConvertDate($new_end_time); | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | =pod | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | =head2 get_end_time | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | Gets the end time stored in the object. | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | =cut | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 1 | ▶ | sub get_end_time { | ||||||||||||||||||||||||||
|
Subroutine
get_end_time: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 457 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 458 | 1 | return $default_end_time{ ident $self}; | |||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =pod | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | =head2 set_weather_parameters | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | Sets the weather parameters for the object. These parameters are passed in | ||||||||||||||||||||||||||||
| 466 | as a list of key-value pairs where the key is the weather parameter and the | ||||||||||||||||||||||||||||
| 467 | value is a 1 or 0 indicating wether or not the parameter is going to be | ||||||||||||||||||||||||||||
| 468 | requested or not. | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | =cut | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | 47 | ▶ | sub set_weather_parameters { | ||||||||||||||||||||||||||
|
Subroutine
set_weather_parameters: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 473 | 47 | my ( $self, @params ) = @_; | |||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 47 | ▶ | return unless @params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 476 | 46 | ▶ | return unless $#params % 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 46 | my %params = @params; | |||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 46 | ▶ | while ( my ( $parameter, $value ) = each %params ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 481 | die("Invalid weather parameter ($parameter)") | ||||||||||||||||||||||||||||
| 482 | 60 | ▶ | unless ( grep { /^$parameter$/ } @WEATHER_PARAMETERS ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 60 | ▶ | die("Invalid value ($value) for weather parameter ($parameter)") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 485 | unless ( $value =~ /^[01]$/ ); | ||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | 31 | my $stored_params = $default_weather_parms{ ident $self}; | |||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | 31 | ▶ | while ( my ( $parameter, $value ) = each %params ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 491 | 45 | $stored_params->{$parameter} = $value; | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | 31 | return @params; | |||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | =pod | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | =head2 get_weather_parameters | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | Returns the requested weather parameters stored in the object as key-value | ||||||||||||||||||||||||||||
| 501 | pairs where the key is the weather parameter and the value is a 1 or 0 | ||||||||||||||||||||||||||||
| 502 | indicating wether or not the parameter is going to be requested or not. | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | A list of parameter names can be passed to this method so that only those | ||||||||||||||||||||||||||||
| 505 | parameters are returned. If no arguments are passed to this method, all | ||||||||||||||||||||||||||||
| 506 | parameters will be returned. | ||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | =cut | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 16 | ▶ | sub get_weather_parameters { | ||||||||||||||||||||||||||
|
Subroutine
get_weather_parameters: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 511 | 16 | my ( $self, @params ) = @_; | |||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | 16 | my $stored_params = $default_weather_parms{ ident $self}; | |||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | 16 | ▶ | return %{$stored_params} unless @params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 15 | my @results; | |||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | 15 | for my $parameter (@params) { | |||||||||||||||||||||||||||
| 520 | die("Invalid weather parameter ($parameter)") | ||||||||||||||||||||||||||||
| 521 | 15 | ▶ | unless ( grep { /^$parameter$/ } @WEATHER_PARAMETERS ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | 15 | push @results, $parameter, $stored_params->{$parameter}; | |||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | 15 | return @results; | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | =pod | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | =head2 get_available_products | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | Return a list of all products available through this service. | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | =cut | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | 1 | ▶ | sub get_available_products { | ||||||||||||||||||||||||||
|
Subroutine
get_available_products: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 538 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 539 | 1 | return @PRODUCTS; | |||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | =pod | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | =head2 get_available_weather_parameters | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | Return a list of all weather parameters that can be requested through this | ||||||||||||||||||||||||||||
| 547 | service. | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | =cut | ||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | 1 | ▶ | sub get_available_weather_parameters { | ||||||||||||||||||||||||||
|
Subroutine
get_available_weather_parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 552 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 553 | 1 | return @WEATHER_PARAMETERS; | |||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | =pod | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | =head2 get_forecast_xml | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | Return the NWS NDFD XML as described in | ||||||||||||||||||||||||||||
| 561 | L<http://products.weather.gov/PDD/Extensible_Markup_Language.pdf>. The data | ||||||||||||||||||||||||||||
| 562 | returned depends on the state of the NDFDgen object at the time of the call | ||||||||||||||||||||||||||||
| 563 | to this method. Any parameters can be overridden by being passed in as | ||||||||||||||||||||||||||||
| 564 | arguments to this method. | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | =cut | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | 1 | ▶ | sub get_forecast_xml { | ||||||||||||||||||||||||||
|
Subroutine
get_forecast_xml: called CC=18 SCAR=32.9
Pod
documented
| |||||||||||||||||||||||||||||
| 569 | 1 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | 1 | my ($ident) = ident $self; | |||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | my ( | ||||||||||||||||||||||||||||
| 574 | 1 | $latitude, $longitude, $product, | |||||||||||||||||||||||||||
| 575 | $start_time, $end_time, %weather_params | ||||||||||||||||||||||||||||
| 576 | ); | ||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | die("Latitude required") | ||||||||||||||||||||||||||||
| 579 | 1 | ▶ | unless $latitude = $args{'Latitude'} || $default_latitude{$ident}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{'Latitude'} || $default_latitude{$ident}
MC/DC0%0/2
$args{'Latitude'} || $default_latitude{$ident}
$args{'Latitude'}
$default_latitude{$ident}
Truth table33%1/3
A || B
A= $args{'Latitude'}B= $default_latitude{$ident}
| |||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | die("Longitude required") | ||||||||||||||||||||||||||||
| 582 | 1 | ▶ | unless $longitude = $args{'Longitude'} || $default_longitude{$ident}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{'Longitude'} || $default_longitude{$ident}
MC/DC0%0/2
$args{'Longitude'} || $default_longitude{$ident}
$args{'Longitude'}
$default_longitude{$ident}
Truth table33%1/3
A || B
A= $args{'Longitude'}B= $default_longitude{$ident}
| |||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | die("Product required") | ||||||||||||||||||||||||||||
| 585 | 1 | ▶ | unless $product = $args{'Product'} || $default_product{$ident}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{'Product'} || $default_product{$ident}
MC/DC0%0/2
$args{'Product'} || $default_product{$ident}
$args{'Product'}
$default_product{$ident}
Truth table33%1/3
A || B
A= $args{'Product'}B= $default_product{$ident}
| |||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | die("Start time required") | ||||||||||||||||||||||||||||
| 588 | unless $start_time = $args{'Start Time'} | ||||||||||||||||||||||||||||
| 589 | 1 | ▶ | || $default_start_time{$ident}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{'Start Time'} || $default_start_time{$ident}
MC/DC0%0/2
$args{'Start Time'} || $default_start_time{$ident}
$args{'Start Time'}
$default_start_time{$ident}
Truth table33%1/3
A || B
A= $args{'Start Time'}B= $default_start_time{$ident}
| |||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | die("End time required") | ||||||||||||||||||||||||||||
| 592 | 1 | ▶ | unless $end_time = $args{'End Time'} || $default_end_time{$ident}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{'End Time'} || $default_end_time{$ident}
MC/DC0%0/2
$args{'End Time'} || $default_end_time{$ident}
$args{'End Time'}
$default_end_time{$ident}
Truth table33%1/3
A || B
A= $args{'End Time'}B= $default_end_time{$ident}
| |||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | 1 | %weather_params = %{ $default_weather_parms{$ident} }; | |||||||||||||||||||||||||||
| 595 | 1 | ▶ | if ( exists $args{'Weather Parameters'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 596 | 1 | ▶ | while ( my ( $param, $value ) = | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 597 | 16 | each %{ $args{'Weather Parameters'} } ) | |||||||||||||||||||||||||||
| 598 | { | ||||||||||||||||||||||||||||
| 599 | die("Invalid weather parameter ($param) found") | ||||||||||||||||||||||||||||
| 600 | 15 | ▶ | unless exists $weather_params{$param}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 601 | 15 | $weather_params{$param} = $value; | |||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | 1 | my $url = | |||||||||||||||||||||||||||
| 606 | 'http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdXMLclient.php?'; | ||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||
| 608 | 1 | $url .= '&lat=' . $latitude; | |||||||||||||||||||||||||||
| 609 | 1 | $url .= '&lon=' . $longitude; | |||||||||||||||||||||||||||
| 610 | 1 | $url .= '&product=' . $NAME_TO_PRODUCT{$product}; | |||||||||||||||||||||||||||
| 611 | 1 | ▶ | $url .= '&begin=' . $start_time if $start_time; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 612 | 1 | ▶ | $url .= '&end=' . $end_time if $end_time; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | 1 | for my $param ( keys %weather_params ) { | |||||||||||||||||||||||||||
| 615 | 15 | ▶ | if ( $weather_params{$param} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 616 | $url .= '&' | ||||||||||||||||||||||||||||
| 617 | . $NAME_TO_WEATHER_PARAMETER{$param} . '=' | ||||||||||||||||||||||||||||
| 618 | 2 | . $NAME_TO_WEATHER_PARAMETER{$param}; | |||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 1 | $forecast_xml{$ident} = get $url; | |||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | 1 | return $forecast_xml{$ident}; | |||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||
| 629 | =pod | ||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||
| 631 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||
| 633 | Josh McAdams, C<< <josh dot mcadams at gmail dot com> >> | ||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||
| 635 | =head1 BUGS | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||
| 638 | C<bug-weather-nws-ndfdgen at rt.cpan.org>, or through the web interface at | ||||||||||||||||||||||||||||
| 639 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Weather-NWS-NDFDgen>. | ||||||||||||||||||||||||||||
| 640 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||||||||||||||||||||
| 641 | your bug as I make changes. | ||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||
| 643 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | perldoc Weather::NWS::NDFDgen | ||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||
| 649 | You can also look for information at: | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | =over 4 | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | L<http://annocpan.org/dist/Weather-NWS-NDFDgen> | ||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||
| 659 | L<http://cpanratings.perl.org/d/Weather-NWS-NDFDgen> | ||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||
| 661 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Weather-NWS-NDFDgen> | ||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||
| 665 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | L<http://search.cpan.org/dist/Weather-NWS-NDFDgen> | ||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | =back | ||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||
| 671 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | Copyright 2006 Josh McAdams, all rights reserved. | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 678 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||
| 680 | =cut | ||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||
| 682 | 3 | 1; # End of Weather::NWS::NDFDgen | |||||||||||||||||||||||||||