diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-11-25 19:49:43 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-11-25 19:49:43 +0100 |
commit | a6fab60716a8aba9030d60bc821545e7c41f1a46 (patch) | |
tree | 5dac9881d6e66ed7ef062cb955f81209d78031f3 /lib/Travel/Status/DE/DBWagenreihung.pm | |
parent | 481d3f9c20b7d4239b3b09499bec2c63e31bae93 (diff) |
add locomotive/powercar flag and positions
Diffstat (limited to 'lib/Travel/Status/DE/DBWagenreihung.pm')
-rw-r--r-- | lib/Travel/Status/DE/DBWagenreihung.pm | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/Travel/Status/DE/DBWagenreihung.pm b/lib/Travel/Status/DE/DBWagenreihung.pm index 68dbd69..b97e2bd 100644 --- a/lib/Travel/Status/DE/DBWagenreihung.pm +++ b/lib/Travel/Status/DE/DBWagenreihung.pm @@ -67,9 +67,6 @@ sub get_wagonorder { return; } my $json = $self->{json}->decode($content); - if ($self->{developer_mode}) { - say $self->{json}->pretty->encode($json); - } if (exists $json->{error}) { $self->{errstr} = 'Backend error: ' . $json->{error}{msg}; @@ -86,6 +83,27 @@ sub error { return $self->{errstr}; } +sub sections { + my ($self) = @_; + + if (exists $self->{sections}) { + return @{$self->{sections}}; + } + + for my $section (@{$self->{data}{istformation}{halt}{allSektor}}) { + my $pos = $section->{positionamgleis}; + push(@{$self->{sections}}, { + name => $section->{sektorbezeichnung}, + start_percent => $pos->{startprozent}, + end_percent => $pos->{endeprozent}, + start_meters => $pos->{startmeter}, + end_meters => $pos->{endemeter}, + }); + } + + return @{$self->{sections} // []}; +} + sub wagons { my ($self) = @_; @@ -98,6 +116,7 @@ sub wagons { push(@{$self->{wagons}}, Travel::Status::DE::DBWagenreihung::Wagon->new(%{$wagon})); } } + @{$self->{wagons}} = sort { $a->{position}->{start_percent} <=> $b->{position}->{start_percent} } @{$self->{wagons}}; return @{$self->{wagons} // []}; } |