move exit direction calculation to a helper function
This commit is contained in:
parent
90dd96e08f
commit
ff75b16bfc
1 changed files with 52 additions and 47 deletions
|
@ -2269,6 +2269,51 @@ sub startup {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$self->helper(
|
||||||
|
'stationinfo_to_direction' => sub {
|
||||||
|
my ( $self, $platform_info, $wagonorder, $prev_stop ) = @_;
|
||||||
|
if ( $platform_info->{kopfgleis} ) {
|
||||||
|
return $platform_info->{direction};
|
||||||
|
}
|
||||||
|
elsif ( $prev_stop
|
||||||
|
and exists $platform_info->{direction_from}{$prev_stop} )
|
||||||
|
{
|
||||||
|
return $platform_info->{direction_from}{$prev_stop};
|
||||||
|
}
|
||||||
|
elsif ($wagonorder) {
|
||||||
|
my $wr;
|
||||||
|
eval {
|
||||||
|
$wr
|
||||||
|
= Travel::Status::DE::DBWagenreihung->new(
|
||||||
|
from_json => $wagonorder );
|
||||||
|
};
|
||||||
|
if ( $wr
|
||||||
|
and $wr->sections
|
||||||
|
and defined $wr->direction )
|
||||||
|
{
|
||||||
|
my $section_0 = ( $wr->sections )[0];
|
||||||
|
my $direction = $wr->direction;
|
||||||
|
if ( $section_0->name eq 'A'
|
||||||
|
and $direction == 0 )
|
||||||
|
{
|
||||||
|
return $platform_info->{direction};
|
||||||
|
}
|
||||||
|
elsif ( $section_0->name ne 'A'
|
||||||
|
and $direction == 100 )
|
||||||
|
{
|
||||||
|
return $platform_info->{direction};
|
||||||
|
}
|
||||||
|
elsif ( $platform_info->{direction} ) {
|
||||||
|
return $platform_info->{direction} eq 'r'
|
||||||
|
? 'l'
|
||||||
|
: 'r';
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$self->helper(
|
$self->helper(
|
||||||
'get_user_status' => sub {
|
'get_user_status' => sub {
|
||||||
my ( $self, $uid ) = @_;
|
my ( $self, $uid ) = @_;
|
||||||
|
@ -2425,53 +2470,13 @@ sub startup {
|
||||||
and exists $in_transit->{data}{stationinfo_arr}
|
and exists $in_transit->{data}{stationinfo_arr}
|
||||||
{$arr_platform_number} )
|
{$arr_platform_number} )
|
||||||
{
|
{
|
||||||
my $platform_info = $in_transit->{data}{stationinfo_arr}
|
$ret->{arr_direction}
|
||||||
{$arr_platform_number};
|
= $self->stationinfo_to_direction(
|
||||||
if ( $platform_info->{kopfgleis} ) {
|
$in_transit->{data}{stationinfo_arr}
|
||||||
$ret->{arr_direction} = $platform_info->{direction};
|
{$arr_platform_number},
|
||||||
}
|
$in_transit->{data}{wagonorder_arr},
|
||||||
elsif ( $stop_before_dest
|
$stop_before_dest
|
||||||
and exists $platform_info->{direction_from}
|
);
|
||||||
{$stop_before_dest} )
|
|
||||||
{
|
|
||||||
$ret->{arr_direction}
|
|
||||||
= $platform_info->{direction_from}
|
|
||||||
{$stop_before_dest};
|
|
||||||
}
|
|
||||||
elsif ( $in_transit->{data}{wagonorder_arr} ) {
|
|
||||||
my $wr;
|
|
||||||
eval {
|
|
||||||
$wr
|
|
||||||
= Travel::Status::DE::DBWagenreihung->new(
|
|
||||||
from_json =>
|
|
||||||
$in_transit->{data}{wagonorder_arr} );
|
|
||||||
};
|
|
||||||
if ( $wr
|
|
||||||
and $wr->sections
|
|
||||||
and defined $wr->direction )
|
|
||||||
{
|
|
||||||
my $section_0 = ( $wr->sections )[0];
|
|
||||||
my $direction = $wr->direction;
|
|
||||||
if ( $section_0->name eq 'A'
|
|
||||||
and $direction == 0 )
|
|
||||||
{
|
|
||||||
$ret->{arr_direction}
|
|
||||||
= $platform_info->{direction};
|
|
||||||
}
|
|
||||||
elsif ( $section_0->name ne 'A'
|
|
||||||
and $direction == 100 )
|
|
||||||
{
|
|
||||||
$ret->{arr_direction}
|
|
||||||
= $platform_info->{direction};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ret->{arr_direction}
|
|
||||||
= $platform_info->{direction} eq 'r'
|
|
||||||
? 'l'
|
|
||||||
: 'r';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue