V2/Visible.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 91.6% 11 / 12 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 92.9% 66 / 71 CC 9 SCAR 11.9
CC
9
Cov
95%
_stringify_locations
6.1
locations
3.0
initialize
2.0
CRAP 3.3
« V2.pm ↑ Summary
1 package Geo::Google::StaticMaps::V2::Visible;
2 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use base qw{Package::New};
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 our $VERSION = '0.12';
6 10 our $PACKAGE = __PACKAGE__;
7  
8 =head1 NAME
9  
10 Geo::Google::StaticMaps::V2::Visible - Generate Images from Google Static Maps V2 API
11  
12 =head1 SYNOPSIS
13  
14 use Geo::Google::StaticMaps::V2;
15 my $map=Geo::Google::StaticMaps::V2->new;
16 my $visible=$map->visible(locations=>["Clifton, VA", "Pag, Croatia"]); #isa Geo::Google::StaticMaps::V2::Visible
17 print $map->url, "\n";
18  
19 =head1 DESCRIPTION
20  
21 The packages generates images from the Google Static Maps V2 API which can be saved locally for use in accordance with your license with Google.
22  
23 =head1 USAGE
24  
25 use Geo::Google::StaticMaps::V2;
26 my $map=Geo::Google::StaticMaps::V2->new;
27 my $visible=$map->visible(location=>"Clifton, VA"); #isa Geo::Google::StaticMaps::V2::Visible
28  
29 =head2 initialize
30  
31 Sets all passed in arguments and folds location parameter into the locations array.
32  
33 =cut
34  
35 12 ▶sub initialize {
Subroutine initialize: called CC=2 SCAR=6.9
Pod documented
36 12 my $self=shift;
37 12 %$self=@_;
38 12 ▶ $self->addLocation(delete $self->{"location"}) if exists $self->{"location"};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"location"} 4 8 12
39 }
40  
41 =head2 stringify
42  
43 Handles various formats for locations seamlessly.
44  
45 =cut
46  
47 48 ▶sub stringify {
Subroutine stringify: called CC=1 SCAR=0.0
Pod documented
48 48 my $self=shift;
49 48 my @p=();
50 48 push @p, $self->_styles;
51 48 push @p, $self->_stringify_locations;
52 48 return join "|", @p;
53 }
54  
55 48 ▶sub _stringify_locations {
Subroutine _stringify_locations: called CC=6 SCAR=18.2
56 48 my $self = shift;
57 48 ▶ if ($self->can("encode") and $self->encode == 1) { #polygon encode support
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can('encode') and $self->encode == 1) { } 0 48 48
Condition66%2/3
$self->can("encode") and $self->encode == 1
!ll&&!rl&&r
24240
MC/DC0%0/2
$self->can("encode") and $self->encode == 1
$self->can("encode") $self->encode == 1
Truth table66%2/3
A and B
A= $self->can("encode")B= $self->encode == 1
ABresult
0X0
100
111
58 0 return $self->_encode_locations;
59 } else {
60 48 my @strings = ();
61 48 foreach my $location ($self->locations) {
62 139 ▶ if (ref($location) eq "HASH") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $location eq 'HASH') { } 2 137 139
elsif (ref $location eq 'ARRAY') { } 4 133 137
63 2 push @strings, sprintf("%0.6f,%0.6f", $location->{"lat"}, $location->{"lon"});
64 } elsif (ref($location) eq "ARRAY") {
65 4 push @strings, sprintf("%0.6f,%0.6f", @$location); #[$lat,$lon]
66 } else {
67 133 push @strings, "$location"; #or any object that overloads
68 }
69 }
70 48 return join "|", @strings;
71 }
72 }
73  
74 =head2 locations
75  
76 Returns the locations array which can be set upon construction.
77  
78 =cut
79  
80 62 ▶sub locations {
Subroutine locations: called CC=3 SCAR=11.0
Pod documented
81 62 my $self=shift;
82 62 ▶ $self->{"locations"}=[] unless ref($self->{"locations"}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"locations"} eq "ARRAY" 4 58 62
83 62 ▶ return wantarray ? @{$self->{"locations"}} : $self->{"locations"};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 48 14 62
84 }
85  
86 6 ▶sub _styles {
Subroutine _styles: called CC=1 SCAR=0.0
87 6 my $self=shift;
88 6 my @styles=();
89 6 return @styles;
90 }
91  
92 =head1 METHODS
93  
94 =head2 addLocation
95  
96 $marker->addLocation("Clifton, VA");
97 $marker->addLocation({lat=>38.7802903, lon=>-77.3867659});
98 $marker->addLocation([38.7802903, -77.3867659]);
99  
100 =cut
101  
102 14 ▶sub addLocation {
Subroutine addLocation: called CC=1 SCAR=0.0
Pod documented
103 14 my $self=shift;
104 14 push @{$self->locations}, @_;
105 14 return $self;
106 }
107  
108 =head1 BUGS
109  
110 Please log on RT and send an email to the author.
111  
112 =head1 SUPPORT
113  
114 DavisNetworks.com supports all Perl applications including this package.
115  
116 =head1 AUTHOR
117  
118 Michael R. Davis
119 CPAN ID: MRDVT
120 Satellite Tracking of People, LLC
121 mdavis@stopllc.com
122 http://www.stopllc.com/
123  
124 =head1 COPYRIGHT
125  
126 This program is free software licensed under the...
127  
128 The General Public License (GPL) Version 2, June 1991
129  
130 The full text of the license can be found in the LICENSE file included with this module.
131  
132 =head1 SEE ALSO
133  
134 L<Geo::Google::StaticMaps::V2>, L<Geo::Google::StaticMaps::V2::Path>, L<Geo::Google::StaticMaps::V2::Markers>
135  
136 =cut
137  
138 10 1;
« V2.pm ↑ Summary