ReadGRIB/Place.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 83.3% 10 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 6 / 6 totaltotal 95.1% 59 / 62 CC 7 SCAR 7.0
CC
7
Cov
94%
data
3.1
types
2.0
thisTime
2.0
CRAP 2.0
« ReadGRIB/PlaceIterator.pm ↑ Summary
1 #
2 #===============================================================================
3 #
4 # FILE: Place.pm
5 #
6 # DESCRIPTION: creates Geo::ReadGRIB::Place objects
7 #
8 # FILES: ---
9 # BUGS: ---
10 # NOTES: ---
11 # AUTHOR: Frank Lyon Cox (Dr), <frank@pwizardry.com>
12 # COMPANY: Practial Wizardry
13 # VERSION: 1.0
14 # CREATED: 2/3/2009 10:42:57 PM Pacific Standard Time
15 # REVISION: ---
16 #===============================================================================
17  
18 package Geo::ReadGRIB::Place;
19  
20 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 13 our $VERSION = 1.0;
24  
25 #--------------------------------------------------------------------------
26 # new( )
27 #--------------------------------------------------------------------------
28 605 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
29 605 my $class = shift;
30 605 my $self = {};
31 605 bless $self, $class;
32 605 return $self;
33 }
34  
35 #--------------------------------------------------------------------------
36 # thisTime( )
37 #--------------------------------------------------------------------------
38 2418 ▶sub thisTime {
Subroutine thisTime: called CC=2 SCAR=6.9
Pod documented
39 2418 my $self = shift;
40 2418 my $arg = shift;
41 2418 ▶ $self->{time} = $arg if defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg 604 1814 2418
42 2418 return $self->{time};
43 }
44  
45 #--------------------------------------------------------------------------
46 # lat( )
47 #--------------------------------------------------------------------------
48 1813 ▶sub lat {
Subroutine lat: called CC=2 SCAR=6.9
Pod documented
49 1813 my $self = shift;
50 1813 my $arg = shift;
51 1813 ▶ $self->{lat} = $arg if defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg 604 1209 1813
52 1813 return $self->{lat};
53 }
54  
55 #--------------------------------------------------------------------------
56 # long( )
57 #--------------------------------------------------------------------------
58 1813 ▶sub long {
Subroutine long: called CC=2 SCAR=6.9
Pod documented
59 1813 my $self = shift;
60 1813 my $arg = shift;
61 1813 ▶ $self->{long} = $arg if defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg 604 1209 1813
62 1813 return $self->{long};
63 }
64  
65 #--------------------------------------------------------------------------
66 # types( )
67 #
68 # returns an array ref of type names
69 #--------------------------------------------------------------------------
70 604 ▶sub types {
Subroutine types: called CC=2 SCAR=7.0
Pod documented
71 604 my $self = shift;
72 604 my $arg = shift;
73 604 ▶ push @{$self->{types}}, $arg if defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg 604 0 604
74 604 return $self->{types};
75 }
76  
77 #--------------------------------------------------------------------------
78 # data( type_name )
79 #
80 # takes a type_name and returns the associated data
81 #--------------------------------------------------------------------------
82 1208 ▶sub data {
Subroutine data: called CC=3 SCAR=11.2
Pod documented
83 1208 my $self = shift;
84 1208 my $type = shift;
85 1208 my $data = shift;
86  
87 1208 ▶ $self->{data}->{$type} = $data if defined $data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $data 604 604 1208
88  
89 1208 ▶ if ( not defined $self->{data}->{$type} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"data"}{$type}) 0 1208 1208
90 0 warn "Place: Not a valid type: $type\n";
91 }
92  
93 1208 return $self->{data}->{$type};
94 }
95  
96  
97 =head1 NAME
98  
99 Geo::ReadGRIB::Place - Contains the value of a one or more data type at a given
100 time and geographic location.
101  
102 =head1 VERSION
103  
104 This documentation refers to Geo::ReadGRIB::Place version 1.0 as returned by
105 a call to Geo::ReadGRIB::PlaceIterator::Current()
106  
107  
108 =head1 SYNOPSIS
109  
110 use Geo::ReadGRIB;
111  
112 $w = new Geo::ReadGRIB "grib-file";
113 $w->getFullCatalog;
114  
115 print $w->show,"\n";
116
117 $plit = $w->extractLaLo(data_type, lat1, long1, lat2, long2, time);
118 die $w->getError if $w->getError;
119  
120 # $plit is a Geo::ReadGRIB::PlaceIterator
121  
122 while ( $place = $plit->current() and $plit->next ) {
123  
124 # $place is a Geo::ReadGRIB::Place object
125  
126 $time = $place->thisTime;
127 $latitude = $place->lat;
128 $longitude = $place->long;
129 $data_types = $place->types; # an array ref of type names
130  
131 $data = $place->data( data_type );
132  
133 # process data...
134 }
135  
136  
137 =head1 DESCRIPTION
138  
139 Objects of this class are returned by the current() method of a
140 PlaceIterator object which itself has been returned by the
141 extractLaLo() or extract() methods of a Geo::ReadGRIB object. A place
142 object has a unique latitude and longitude for one time and has data
143 for one or more data types.
144  
145 =head1 METHODS
146  
147 Objects of this class are read only and all parameters may be
148 accessed by the following methods.
149  
150 =over 4
151  
152 =item $object->new;
153  
154 =item $object->thisTime;
155  
156 =item $object->lat;
157  
158 =item $object->long;
159  
160 =item $object->types;
161  
162 =item $object->data(type);
163  
164 =back
165  
166 =head1 BUGS AND LIMITATIONS
167  
168 There are no known bugs in this module. Please report problems through
169  
170 http://rt.cpan.org
171  
172 or contact Frank Cox, <frank.l.cox@gmail.com> Patches are welcome.
173  
174 =head1 AUTHOR
175  
176 Frank Cox, E<lt>frank.l.cox@gmail.comE<gt>
177  
178 =head1 COPYRIGHT AND LICENSE
179  
180 Copyright (C) 2009 by Frank Cox
181  
182 This library is free software; you can redistribute it and/or modify
183 it under the same terms as Perl itself, either Perl version 5.8.4 or,
184 at your option, any later version of Perl 5 you may have available.
185  
186  
187  
188 =cut
189  
190  
191  
192 13 1;
193  
194  
« ReadGRIB/PlaceIterator.pm ↑ Summary