| 1 | package WWW::MelbourneBikeShare::Terminal; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | our @ATTRIBUTES = qw(coordinates featurename id nbbikes nbemptydoc uploaddate | |||||||||||||||||||||||||||
| 7 | terminalname); | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | our %ATTRIBUTES = ( | |||||||||||||||||||||||||||
| 10 | coordinates => 'coordinates', | ||||||||||||||||||||||||||||
| 11 | id => 'id', | ||||||||||||||||||||||||||||
| 12 | featurename => 'name', | ||||||||||||||||||||||||||||
| 13 | nbbikes => 'bikes', | ||||||||||||||||||||||||||||
| 14 | nbemptydoc => 'empty', | ||||||||||||||||||||||||||||
| 15 | terminalname => 'terminal', | ||||||||||||||||||||||||||||
| 16 | uploaddate => 'update' | ||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | { | ||||||||||||||||||||||||||||
| 20 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | foreach my $attr ( keys %ATTRIBUTES ) { | |||||||||||||||||||||||||||
| 23 | 14 | ▶ | *{ __PACKAGE__ . "::$ATTRIBUTES{ $attr }" } = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | 0 | return $self->{ $ATTRIBUTES{ $attr } } | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | 14 | } | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 0 | my ( $class, $d ) = @_; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | map { $self->{ $ATTRIBUTES{ $_ } } = $d->{ $_ } } keys %ATTRIBUTES; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | return $self | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub lat { $_[0]->__point( 1 ) } | ||||||||||||||||||||||||||
|
Subroutine
lat: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub lon { $_[0]->__point( 0 ) } | ||||||||||||||||||||||||||
|
Subroutine
lon: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub distance { | ||||||||||||||||||||||||||
|
Subroutine
distance: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 0 | my ( $self, $lat, $lon ) = @_; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return unless $lat and $lon; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lat and $lon
MC/DC0%0/2
$lat and $lon
$lat
$lon
Truth table0%0/3
A and B
A= $latB= $lon
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | return $self->__haversine( $lat, $lon ) | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub __point { return $_[0]->{ coordinates }->{ coordinates }->[ $_[1] ] } | ||||||||||||||||||||||||||
|
Subroutine
__point: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub __asin { | ||||||||||||||||||||||||||
|
Subroutine
__asin: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 56 | 0 | my $x = shift; | |||||||||||||||||||||||||||
| 57 | 0 | atan2( $x, sqrt( 1 - $x * $x ) ) | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub __haversine { | ||||||||||||||||||||||||||
|
Subroutine
__haversine: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 61 | 0 | my( $self, $lat, $lon ) = @_; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | my $tlon = $lon; | |||||||||||||||||||||||||||
| 64 | 0 | my $radius = 6372.8; | |||||||||||||||||||||||||||
| 65 | 0 | my $radians = ( 22 / 7 ) / 180; | |||||||||||||||||||||||||||
| 66 | 0 | my $dlat = ( $self->lat - $lat ) * $radians; | |||||||||||||||||||||||||||
| 67 | 0 | my $dlon = ( $self->lon - $lon ) * $radians; | |||||||||||||||||||||||||||
| 68 | 0 | my $a = sin( $dlat / 2 )** 2 | |||||||||||||||||||||||||||
| 69 | + cos( $self->lat * $radians ) | ||||||||||||||||||||||||||||
| 70 | * cos( $lat * $radians ) | ||||||||||||||||||||||||||||
| 71 | * sin( $dlon / 2 )**2; | ||||||||||||||||||||||||||||
| 72 | 0 | my $c = 2 * __asin( sqrt( $a ) ); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | return $radius * $c; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 2 | 1; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||||||||||||