V2/Path.pm

filter: Statementstmt 98.0% 49 / 50 Branchbran 84.6% 22 / 26 Conditioncond 50.0% 6 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 84.1% 90 / 107 SCAR 30.3
CC
20
Cov
88%
_color
13.8
_styles
6.1
weight
2.0
CRAP 20.8
« V2/Markers.pm ↑ Summary V2/Visible.pm »
1 package Geo::Google::StaticMaps::V2::Path;
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{Geo::Google::StaticMaps::V2::Visible};
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 our $VERSION = '0.08';
6 10 our $PACKAGE = __PACKAGE__;
7  
8 =head1 NAME
9  
10 Geo::Google::StaticMaps::V2::Path - 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 $path=$map->path(locations=>["Clifton, VA", "Pag, Croatia"], geodesic=>1); #isa Geo::Google::StaticMaps::V2::Path
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 =head1 PROPERTIES
26  
27 =cut
28  
29 sub _styles {
30 24 ▶ my $self=shift;
Subroutine _styles: called CC=6 SCAR=18.0
31 24 my @styles=();
32 24 ▶ push @styles, join ":", weight => $self->weight if defined $self->weight;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->weight 0 24 24
33 24 ▶ push @styles, join ":", color => $self->color if defined $self->color;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->color 9 15 24
34 24 ▶ push @styles, join ":", fillcolor => $self->fillcolor if defined $self->fillcolor;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->fillcolor 11 13 24
35 24 ▶ push @styles, join ":", geodesic => $self->geodesic ? "true" : "false" if defined $self->geodesic;
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->geodesic 1 23 24
$self->geodesic ? : 1 0 1
36 24 return @styles;
37 }
38  
39 =head2 weight
40  
41 weight: (optional) specifies the thickness of the path in pixels. If no weight parameter is set, the path will appear in its default thickness (5 pixels).
42  
43 =cut
44  
45 sub weight {
46 24 ▶ my $self=shift;
Subroutine weight: called CC=2 SCAR=7.1
Pod documented
47 24 ▶ $self->{"weight"}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 24 24
48 24 return $self->{"weight"};
49 }
50  
51 =head2 color
52  
53 color: (optional) specifies a color either as a 24-bit (example: color=0xFFFFCC) or 32-bit hexadecimal value (example: color=0xFFFFCCFF), or from the set {black, brown, green, purple, yellow, blue, gray, orange, red, white}.
54  
55 When a 32-bit hex value is specified, the last two characters specify the 8-bit alpha transparency value. This value varies between 00 (completely transparent) and FF (completely opaque). Note that transparencies are supported in paths, though they are not supported for markers.
56  
57 my $color=$path->color("blue");
58 my $color=$path->color("0xFFFFCC");
59 my $color=$path->color({r=>255,g=>0,b=>0,a=>64}); #maps to red 25% returns 0xFF000040
60 my $color=$path->color([0,255,0,"75%"]); #maps to green 75% returns 0x00FF00C0
61  
62 =cut
63  
64 sub _color {
65 85 ▶ my $self=shift;
Subroutine _color: called CC=13 SCAR=26.3
66 85 my $key=shift; #color||fillcolor
67 85 ▶ $self->{$key}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 17 68 85
68 85 ▶ if (ref($self->{$key})) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{$key}) { } 30 55 85
69 30 my $r;
70 my $g;
71 30 my $b;
72 30 my $a;
73 30 ▶ if (ref($self->{$key}) eq "HASH") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self->{$key} eq 'HASH') { } 18 12 30
elsif (ref $self->{$key} eq 'ARRAY') { } 12 0 12
74 18 ▶ $r = $self->{$key}->{"r"} || 0;
Condition50%1/2
$self->{$key}{'r'} || 0
l!l
180
MC/DC0%0/1
$self->{$key}{'r'} || 0
$self->{$key}{'r'}
Truth table50%1/2
A
A= $self->{$key}{'r'}
Aresult
11
00
75 18 ▶ $g = $self->{$key}->{"g"} || 0;
Condition50%1/2
$self->{$key}{'g'} || 0
l!l
018
MC/DC0%0/1
$self->{$key}{'g'} || 0
$self->{$key}{'g'}
Truth table50%1/2
A
A= $self->{$key}{'g'}
Aresult
11
00
76 18 ▶ $b = $self->{$key}->{"b"} || 0;
Condition50%1/2
$self->{$key}{'b'} || 0
l!l
018
MC/DC0%0/1
$self->{$key}{'b'} || 0
$self->{$key}{'b'}
Truth table50%1/2
A
A= $self->{$key}{'b'}
Aresult
11
00
77 18 $a = $self->{$key}->{"a"};
78 } elsif (ref($self->{$key}) eq "ARRAY") {
79 12 ▶ $r = $self->{$key}->[0] || 0;
Condition50%1/2
$self->{$key}[0] || 0
l!l
120
MC/DC0%0/1
$self->{$key}[0] || 0
$self->{$key}[0]
Truth table50%1/2
A
A= $self->{$key}[0]
Aresult
11
00
80 12 ▶ $g = $self->{$key}->[1] || 0;
Condition50%1/2
$self->{$key}[1] || 0
l!l
012
MC/DC0%0/1
$self->{$key}[1] || 0
$self->{$key}[1]
Truth table50%1/2
A
A= $self->{$key}[1]
Aresult
11
00
81 12 ▶ $b = $self->{$key}->[2] || 0;
Condition50%1/2
$self->{$key}[2] || 0
l!l
012
MC/DC0%0/1
$self->{$key}[2] || 0
$self->{$key}[2]
Truth table50%1/2
A
A= $self->{$key}[2]
Aresult
11
00
82 12 $a = $self->{$key}->[3];
83 } else {
84 0 die("Error: Unknown reference type expecting HASH or ARRAY.");
85 }
86 30 ▶ if (defined $a) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $a) { } 24 6 30
87 24 ▶ if ($a =~ m/^(100|\d\d|\d)\%$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ /^(100|\d\d|\d)\%$/) 12 12 24
88 12 $a=int($1/100*255);
89 }
90 24 return sprintf("0x%02X%02X%02X%02X", $r, $g, $b, $a);
91 } else {
92 6 return sprintf("0x%02X%02X%02X", $r, $g, $b);
93 }
94 } else {
95 55 return $self->{$key};
96 }
97 }
98  
99 41 ▶sub color {shift->_color(color=>@_)};
Subroutine color: called CC=1 SCAR=0.0
Pod documented
100  
101 =head2 fillcolor
102  
103 fillcolor: (optional) indicates both that the path marks off a polygonal area and specifies the fill color to use as an overlay within that area. The set of locations following need not be a "closed" loop; the Static Map server will automatically join the first and last points. Note, however, that any stroke on the exterior of the filled area will not be closed unless you specifically provide the same beginning and end location.
104  
105 =cut
106  
107 44 ▶sub fillcolor {shift->_color(fillcolor=>@_)};
Subroutine fillcolor: called CC=1 SCAR=0.0
Pod documented
108  
109 =head2 geodesic
110  
111 geodesic: (optional) indicates that the requested path should be interpreted as a geodesic line that follows the curvature of the Earth. When false, the path is rendered as a straight line in screen space. Defaults to false.
112  
113 =cut
114  
115 sub geodesic {
116 26 ▶ my $self=shift;
Subroutine geodesic: called CC=2 SCAR=6.9
Pod documented
117 26 ▶ $self->{"geodesic"}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 25 26
118 26 return $self->{"geodesic"};
119 }
120  
121 =head1 METHODS
122  
123 =head2 addLocation
124  
125 $marker->addLocation("Clifton, VA");
126  
127 =head1 BUGS
128  
129 Please log on RT and send an email to the author.
130  
131 =head1 SUPPORT
132  
133 DavisNetworks.com supports all Perl applications including this package.
134  
135 =head1 AUTHOR
136  
137 Michael R. Davis
138 CPAN ID: MRDVT
139 Satellite Tracking of People, LLC
140 mdavis@stopllc.com
141 http://www.stopllc.com/
142  
143 =head1 COPYRIGHT
144  
145 This program is free software licensed under the...
146  
147 The General Public License (GPL) Version 2, June 1991
148  
149 The full text of the license can be found in the LICENSE file included with this module.
150  
151 =head1 SEE ALSO
152  
153 L<Geo::Google::StaticMaps::V2>
154  
155 =cut
156  
157 10 1;
« V2/Markers.pm ↑ Summary V2/Visible.pm »