NAME

Weather::NHC::TropicalCyclone::Storm

SYNOPSIS

   use strict;
   use warnings;
   use Weather::NHC::TropicalCyclone ();
   
   my $nhc = Weather::NHC::TropicalCyclone->new;
   $nhc->fetch;
   
   my $storms_ref = $nhc->active_storms;
   my $count = @$storms_ref;
   
   print qq{$count storms found\n};
   
   foreach my $storm (@$storms_ref) {
     print $storm->name . qq{\n};
     my ($text, $advNum, $local_file) = $storm->fetch_publicAdvisory($storm->id.q{.fst});
     print qq{$local_file saved for Advisory $advNum\n};
     rename $local_file, qq{$advNum.$local_file};
   }

DESCRIPTION

Given JSON returned by the NHC via https://www.nhc.noaa.gov/CurrentStorms.json, this module creates a covenient object for encapsulating each storm and fetching the data associated with them.

METHODS

Each storm instances provides an accessor for each field. In addition to this, each field that represents data (text extractible via .shtml or a downloadable file) also provides a fetch_* method.

Text Extracted from .shtml

Optional parameter naming a file to save the extracted text to.

Returns a list of 3 values: extracted text, advisory number, and local file (if optional parameter is provided to the called method.

Provided methods include:

fetch_publicAdvisory
fetch_forecastAdvisory
fetch_forecastDiscussion
fetch_windspeedProbabilities
_get_text

Internal method used by all of the fetch methods that extract text from the linked .shtml files.

Directly Downloadable Files

Optional parameter naming a file to save the extracted text to.

Returns a list of 2 values: name of saved local file and advisory (if provided).

Provided methods include:

fetch_forecastTrack
fetch_windWatchesWarnings
fetch_trackCone
fetch_initialWindExtent
fetch_forecastWindRadiiGIS
fetch_earliestArrivalTimeTSWindsGIS
fetch_mostLikelyTimeTSWindsGIS
fetch_windSpeedProbabilitiesGIS
fetch_stormSurgeWatchWarningGIS
fetch_potentialStormSurgeFloodingGIS
fetch_bestTrackGIS

Note: This resource doesn't provide an advisory. N/A is returned in its place.

_get_file

Internal method used by all of the fetch methods that downloads files.

fetch_forecastGraphics

Uses the URL provided by the forecastGraphics fields to determine the location of the base graphics directory. The default index page returned by the web server is scraped to get a fully resolved list of all graphics available for the storm.

Returns list of graphics URLs as an array reference. A method to download all of the graphics is not provided at this time. But give the list of URLs, it's trivial to write a loop to download any number of these images using HTTP::Tiny's mirror method. See perldoc HTTP::Tiny for more information.

ENVIRONMENT

Package variable, $DEFAULT_GRAPHICS_ROOT, defines the base URL used to determine the list of graphics available for the storm.

COPYRIGHT and LICENSE

This module is distributed under the same terms as Perl itself.