Response/Polyline.pm

filter: Statementstmt 100% 28 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 100% 35 / 35 CC 2 SCAR 2.2
CC
2
Cov
100%
_decode_points
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Types.pm ↑ Summary Response.pm »
1 package Google::Directions::Response::Polyline;
2 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use Google::Directions::Types 'ArrayRefOfPoints';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Google::Directions::Response::Coordinates;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Algorithm::GooglePolylineEncoding;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Google::Directions::Response::Polyline - sequence of points making a polyline
11  
12 =head1 SYNOPSIS
13  
14 my $poly = $route->overview_polyline();
15 foreach( @{ $poly->points } ){
16 # Do something with the coordinates...
17 }
18  
19 =cut
20  
21 3 subtype ArrayRefOfPoints,
22 as 'ArrayRef';
23  
24 coerce ArrayRefOfPoints,
25 from 'Str',
26 36 ▶ via { _decode_points( $_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
27  
28  
29 =head1 ATTRIBUTES
30  
31 =over 4
32  
33 =item I<points> ArrayRef of L<Google::Directions::Response::Coordinates>
34  
35 =back
36  
37 =cut
38  
39 3 has 'points' => ( is => 'ro', isa => ArrayRefOfPoints, coerce => 1 );
40  
41 36 ▶sub _decode_points{
Subroutine _decode_points: called CC=2 SCAR=6.9
42 36 my $quintets = shift;
43 36 my @coordinates = ();
44 36 my @coords;
45
46 36 @coords = Algorithm::GooglePolylineEncoding::decode_polyline($quintets);
47 36 my $ccnt = 0;
48 36 foreach my $pt(@coords){
49 push( @coordinates, Google::Directions::Response::Coordinates->new(
50 lat => $pt->{lat},
51 lng => $pt->{lon},
52 303 ) );
53 }
54 36 return \@coordinates;
55  
56 }
57  
58  
59 3 1;
60  
61 =head1 AUTHOR
62  
63 Robin Clarke, C<< <perl at robinclarke.net> >>
64  
65 =head1 LICENSE AND COPYRIGHT
66  
67 Copyright 2012 Robin Clarke.
68  
69 This program is free software; you can redistribute it and/or modify it
70 under the terms of either: the GNU General Public License as published
71 by the Free Software Foundation; or the Artistic License.
72  
73 See http://dev.perl.org/licenses/ for more information.
74  
75 =cut
« Types.pm ↑ Summary Response.pm »