File Coverage

blib/lib/Geo/GoogleEarth/Pluggable/Folder.pm
Criterion Covered Total %
statement 57 67 85.0
branch 12 16 75.0
condition 4 12 33.3
subroutine 15 17 88.2
pod 8 8 100.0
total 96 120 80.0


line stmt bran cond sub pod time code
1             package Geo::GoogleEarth::Pluggable::Folder;
2 7     7   50 use base qw{Geo::GoogleEarth::Pluggable::Base};
  7         14  
  7         3900  
3 7     7   2915 use XML::LibXML::LazyBuilder qw{E};
  7         323094  
  7         490  
4 7     7   62 use Scalar::Util qw{blessed};
  7         15  
  7         250  
5 7     7   36 use warnings;
  7         16  
  7         188  
6 7     7   35 use strict;
  7         12  
  7         148  
7              
8 7     7   3065 use Module::Pluggable search_path => "Geo::GoogleEarth::Pluggable::Plugin";
  7         65896  
  7         62  
9 7     7   584 use base qw{Method::Autoload};
  7         16  
  7         3087  
10              
11 7     7   18018 use Geo::GoogleEarth::Pluggable::NetworkLink;
  7         17  
  7         70  
12 7     7   2602 use Geo::GoogleEarth::Pluggable::LookAt;
  7         16  
  7         56  
13              
14             our $VERSION='0.17';
15              
16             =head1 NAME
17              
18             Geo::GoogleEarth::Pluggable::Folder - Geo::GoogleEarth::Pluggable::Folder object
19              
20             =head1 SYNOPSIS
21              
22             use Geo::GoogleEarth::Pluggable;
23             my $document=Geo::GoogleEarth::Pluggable->new;
24             my $folder=$document->Folder(name=>"My Folder");
25              
26             =head1 DESCRIPTION
27              
28             Geo::GoogleEarth::Pluggable::Folder is a L with a few other methods.
29              
30             =head1 USAGE
31              
32             my $folder=$document->Folder(); #add folder to $document
33             my $subfolder=$folder->Folder(); #add folder to $folder
34              
35             =head1 METHODS
36              
37             =cut
38              
39             =head2 initialize
40              
41             We overide the default "initialize" method in order to append the "plugins" method from L on to the packages list of the L package.
42              
43             The "packages" property is what is needed by L package. The "plugins" method is what is provided by L. So, the Folder package now has available to it every method in the "Plugins" folder at runtime.
44              
45             =cut
46              
47             sub initialize {
48 8     8 1 956 my $self = shift();
49 8         62 %$self=@_;
50 8         60 $self->pushPackages($self->plugins);
51             }
52              
53             =head2 Folder
54              
55             Constructs a new Folder object and appends it to the parent folder object. Returns the object reference if you need to make any setting changes after construction.
56              
57             my $folder=$folder->Folder(name=>"My Folder");
58             $folder->Folder(name=>"My Folder");
59              
60             =cut
61              
62             sub Folder {
63 1     1 1 2890 my $self=shift;
64 1         6 my $obj=Geo::GoogleEarth::Pluggable::Folder->new(document=>$self->document, @_);
65 1         1738 $self->data($obj);
66 1         4 return $obj;
67             }
68              
69             =head2 NetworkLink
70              
71             Constructs a new NetworkLink object and appends it to the parent folder object. Returns the object reference if you need to make any setting changes after construction.
72              
73             $folder->NetworkLink(name=>"My NetworkLink", url=>"./anotherdoc.kml");
74              
75             =cut
76              
77             sub NetworkLink {
78 0     0 1 0 my $self=shift();
79 0         0 my $obj=Geo::GoogleEarth::Pluggable::NetworkLink->new(document=>$self->document, @_);
80 0         0 $self->data($obj);
81 0         0 return $obj;
82             }
83              
84             =head2 LookAt
85              
86             Constructs a new LookAt object and returns the object reference to assign to other object "lookat" properties.
87              
88             $document->LookAt(
89             latitude => $lat, #decimal degrees
90             longitude => $lon, #decimal degrees
91             range => $range, #meters
92             tilt => $tilt, #decimal degrees from veritical
93             heading => $header, #decimal degrees from North
94             );
95              
96             =cut
97              
98             sub LookAt {
99 0     0 1 0 my $self=shift();
100 0         0 my $obj=Geo::GoogleEarth::Pluggable::LookAt->new(document=>$self->document, @_);
101 0         0 $self->data($obj);
102 0         0 return $obj;
103             }
104              
105             =head2 type
106              
107             Returns the object type.
108              
109             my $type=$folder->type;
110              
111             =cut
112              
113 3     3 1 17 sub type {"Folder"};
114              
115             =head2 node
116              
117             =cut
118              
119             sub node {
120 8     8 1 17 my $self=shift;
121 8         20 my @data=();
122 8 100       60 push @data, E(name=>{}, $self->name) if defined $self->name;
123 8         39 push @data, E(Snippet=>{maxLines=>scalar(@{$self->Snippet})}, join("\n", @{$self->Snippet}));
  8         37  
  8         23  
124 8 50       139 push @data, E(description=>{}, $self->description)
125             if defined $self->description;
126 8 50       43 push @data, E(open=>{}, $self->open) if defined $self->open;
127 8         18 my @style=();
128 8         13 my @stylemap=();
129 8         15 my @element=();
130 8         23 foreach my $obj ($self->data) {
131 6 50 33     86 if (blessed($obj) and $obj->can("type") and $obj->type eq "Style") {
    50 33        
      33        
      33        
132 0         0 push @style, $obj->node;
133             } elsif (blessed($obj) and $obj->can("type") and $obj->type eq "StyleMap") {
134 0         0 push @stylemap, $obj->node;
135             } else {
136 6         40 push @element, $obj->node;
137             }
138             }
139 8         124 return E($self->type=>{}, @data, @style, @stylemap, @element);
140             }
141              
142             =head2 data
143              
144             Pushes arguments onto data array and returns an array or reference that holds folder object content. This is a list of objects that supports a type and structure method.
145              
146             my $data=$folder->data;
147             my @data=$folder->data;
148             $folder->data($placemark);
149              
150             =cut
151              
152             sub data {
153 13     13 1 23 my $self=shift();
154 13 100       48 $self->{'data'} = [] unless ref($self->{'data'}) eq "ARRAY";
155 13         23 my $data=$self->{'data'};
156 13 100       34 if (@_) {
157 5         14 push @$data, @_;
158             }
159 13 100       40 return wantarray ? @$data : $data;
160             }
161              
162             =head2 open
163              
164             =cut
165              
166 8     8 1 27 sub open {shift->{"open"}};
167              
168             =head1 BUGS
169              
170             Please log on RT and send to the geo-perl email list.
171              
172             =head1 LIMITATIONS
173              
174             Due to limitations in Perl hashes, it is not possible to specify the order of certain elements and attributes in the XML.
175              
176             =head1 TODO
177              
178             =head1 SUPPORT
179              
180             Try geo-perl email list.
181              
182             =head1 AUTHOR
183              
184             Michael R. Davis (mrdvt92)
185             CPAN ID: MRDVT
186              
187             =head1 COPYRIGHT
188              
189             This program is free software licensed under the...
190              
191             The BSD License
192              
193             The full text of the license can be found in the
194             LICENSE file included with this module.
195              
196             =head1 SEE ALSO
197              
198             L, L L, L
199              
200             =cut
201              
202             1;