| 1 | package Travel::Status::DE::EFA::Trip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use DateTime::Format::Strptime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Travel::Status::DE::EFA::Stop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use parent 'Class::Accessor'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | our $VERSION = '3.22'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | Travel::Status::DE::EFA::Trip->mk_ro_accessors( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | qw(operator product product_class name line number type id dest_name dest_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my ( $obj, %conf ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my $json = $conf{json}{transportation} // $conf{json}{leg}{transportation}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$conf{"json"}{"transportation"} // $conf{"json"}{"leg"}{"transportation"}
MC/DC0%0/2
$conf{"json"}{"transportation"} // $conf{"json"}{"leg"}{"transportation"}
$conf{"json"}{"transportation"}
$conf{"json"}{"leg"}{"transportation"}
Truth table0%0/3
A // B
A= $conf{"json"}{"transportation"}B= $conf{"json"}{"leg"}{"transportation"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | #say $json->{disassembledName} . ' <-> ' . $json->{number}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | my $ref = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | operator => $json->{operator}{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | product => $json->{product}{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | product_class => $json->{product}{class}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | polyline_raw => $conf{json}{leg}{coords}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | name => $json->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | line => $json->{disassembledName} // $json->{number}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | number => $json->{properties}{trainNumber}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | type => $json->{properties}{trainType} // $json->{product}{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | id => $json->{id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | dest_name => $json->{destination}{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | dest_id => $json->{destination}{id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | route_raw => $json->{locationSequence} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | // $conf{json}{leg}{stopSequence}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | strptime_obj => DateTime::Format::Strptime->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$json->{"disassembledName"} // $json->{"number"}
$json->{"properties"}{"trainType"} // $json->{"product"}{"name"}
$json->{"locationSequence"} // $conf{"json"}{"leg"}{"stopSequence"}
MC/DC0%0/2
$json->{"disassembledName"} // $json->{"number"}
$json->{"disassembledName"}
$json->{"number"}
MC/DC0%0/2
$json->{"properties"}{"trainType"} // $json->{"product"}{"name"}
$json->{"properties"}{"trainType"}
$json->{"product"}{"name"}
MC/DC0%0/2
$json->{"locationSequence"} // $conf{"json"}{"leg"}{"stopSequence"}
$json->{"locationSequence"}
$conf{"json"}{"leg"}{"stopSequence"}
Truth table0%0/3
A // B
A= $json->{"disassembledName"}B= $json->{"number"}
Truth table0%0/3
A // B
A= $json->{"properties"}{"trainType"}B= $json->{"product"}{"name"}
Truth table0%0/3
A // B
A= $json->{"locationSequence"}B= $conf{"json"}{"leg"}{"stopSequence"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | pattern => '%Y-%m-%dT%H:%M:%SZ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | time_zone => 'UTC' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ( ref( $ref->{polyline_raw} ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $ref->{"polyline_raw"} eq "ARRAY" and @{$ref->{"polyline_raw"};} == 1
MC/DC0%0/2
ref $ref->{"polyline_raw"} eq "ARRAY" and @{$ref->{"polyline_raw"};} == 1
ref $ref->{"polyline_raw"} eq "ARRAY"
@{$ref->{"polyline_raw"};} == 1
Truth table0%0/3
A and B
A= ref $ref->{"polyline_raw"} eq "ARRAY"B= @{$ref->{"polyline_raw"};} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | and @{ $ref->{polyline_raw} } == 1 ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $ref->{polyline_raw} = $ref->{polyline_raw}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return bless( $ref, $obj ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub polyline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
polyline: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ( $self, %opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ( $self->{polyline} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return @{ $self->{polyline} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ( not @{ $self->{polyline_raw} // [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"polyline_raw"} // []
MC/DC0%0/1
$self->{"polyline_raw"} // []
$self->{"polyline_raw"}
Truth table0%0/2
A
A= $self->{"polyline_raw"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ( $opt{fallback} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | lat => $_->{latlon}[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | lon => $_->{latlon}[1], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | stop => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } $self->route; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->{polyline} = [ map { { lat => $_->[0], lon => $_->[1] } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | @{ $self->{polyline_raw} } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $distance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | require GIS::Distance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $distance = GIS::Distance->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # Ggf. sollte die Abbildung andersrum laufen: Im zweiten Schritt durch die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # Polyline iterieren und Stops zuordnen (d.h. polyline_i als Key); bei | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # Bedarf Polyline-Indexe duplizieren. Lässt sich wunderbar an der Linie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # 101/106 in Essen testen (3x Helenenstr, davon 2x am Anfang und 1x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # mittendrin). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($distance) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my %min_dist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # A single trip may pass the same stop multiple times, meaning that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # stop IDs alone are not guaranteed to be unique. So we need to use a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # stop's index in the trip's route as key in addition to the stop's ID. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $route_i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | for my $stop ( $self->route ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | for my $polyline_index ( 0 .. $#{ $self->{polyline} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $pl = $self->{polyline}[$polyline_index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | my $dist = $distance->distance_metal( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | $stop->{latlon}[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | $stop->{latlon}[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $pl->{lat}, $pl->{lon} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $key = $route_i . ';' . $stop->{id_code}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ( not $min_dist{$key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $min_dist{$key} or $min_dist{$key}{"dist"} > $dist
MC/DC0%0/2
not $min_dist{$key} or $min_dist{$key}{"dist"} > $dist
not $min_dist{$key}
$min_dist{$key}{"dist"} > $dist
Truth table0%0/3
not(A) or B
A= not $min_dist{$key}B= $min_dist{$key}{"dist"} > $dist
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | or $min_dist{$key}{dist} > $dist ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $min_dist{$key} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | dist => $dist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | index => $polyline_index, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $route_i += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $route_i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | for my $stop ( $self->route ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $key = $route_i . ';' . $stop->{id_code}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ( $min_dist{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if ( defined $self->{polyline}[ $min_dist{$key}{index} ]{stop} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | warn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | "$key: overwriting stop ref at $min_dist{$key}{index} with $key" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # XXX experimental and untested | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # one polyline entry maps to multiple stops → duplicate it; insert $stop after the already-present entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | #$min_dist{$key}{index} += 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | #splice( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # @{ $self->{polyline} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # $min_dist{$key}{index}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # 0, { %{ $self->{polyline}[ $min_dist{$key}{index} ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | #); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | $self->{polyline}[ $min_dist{$key}{index} ]{stop} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | = $stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $route_i += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return @{ $self->{polyline} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub parse_dt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_dt: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $dt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | eval { $dt = $self->{strptime_obj}->parse_datetime($value); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $strp_str = $self->{strptime_obj}->pattern; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | warn( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | "Trip $self->{id}: Cannot parse '$value' with '$strp_str': $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ($dt) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return $dt->set_time_zone('Europe/Berlin'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub route { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
route: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if ( $self->{route} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | return @{ $self->{route} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | for my $stop ( @{ $self->{route_raw} // [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"route_raw"} // []
MC/DC0%0/1
$self->{"route_raw"} // []
$self->{"route_raw"}
Truth table0%0/2
A
A= $self->{"route_raw"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $chain = $stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my ( $platform, $place, $name, $name_full, $id_num, $id_code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | while ( $chain->{type} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ( $chain->{type} eq 'platform' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | $platform = $chain->{properties}{platformName} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | // $chain->{properties}{platform}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$chain->{"properties"}{"platformName"} // $chain->{"properties"}{"platform"}
MC/DC0%0/2
$chain->{"properties"}{"platformName"} // $chain->{"properties"}{"platform"}
$chain->{"properties"}{"platformName"}
$chain->{"properties"}{"platform"}
Truth table0%0/3
A // B
A= $chain->{"properties"}{"platformName"}B= $chain->{"properties"}{"platform"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | elsif ( $chain->{type} eq 'stop' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $name = $chain->{disassembledName}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $name_full = $chain->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $id_code = $chain->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $id_num = $chain->{properties}{stopId}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | elsif ( $chain->{type} eq 'locality' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $place = $chain->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $chain = $chain->{parent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | push( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | @{ $self->{route} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | Travel::Status::DE::EFA::Stop->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sched_arr => $self->parse_dt( $stop->{arrivalTimePlanned} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | sched_dep => $self->parse_dt( $stop->{departureTimePlanned} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | rt_arr => $self->parse_dt( $stop->{arrivalTimeEstimated} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | rt_dep => $self->parse_dt( $stop->{departureTimeEstimated} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | occupancy => $stop->{properties}{occupancy}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | is_cancelled => $stop->{isCancelled}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | latlon => $stop->{coord}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | full_name => $name_full, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | place => $place, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | niveau => $stop->{niveau}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | platform => $platform, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | id_code => $id_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | id_num => $id_num, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | delete $self->{route_raw}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | return @{ $self->{route} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"route"} // []
MC/DC0%0/1
$self->{"route"} // []
$self->{"route"}
Truth table0%0/2
A
A= $self->{"route"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub TO_JSON { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # lazy loading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->route; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # lazy loading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $self->polyline; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $ret = { %{$self} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | delete $ret->{strptime_obj}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||