summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-03-27 13:43:03 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2024-03-27 13:43:03 +0100
commit4329fde714614c28e12f45892c486c0989c85886 (patch)
tree901a7a5e360b0345c327e137022c97822a405415 /lib
parent15fa71dbca78899ec4214178440312dd024a5931 (diff)
Remove zugbildungsplan.json support
I doubt we're gonna see new open data releases any time soon
Diffstat (limited to 'lib')
-rw-r--r--lib/DBInfoscreen.pm31
-rw-r--r--lib/DBInfoscreen/Controller/Stationboard.pm54
-rw-r--r--lib/DBInfoscreen/Controller/Wagenreihung.pm120
3 files changed, 9 insertions, 196 deletions
diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm
index 9dcc2d0..a3f22bf 100644
--- a/lib/DBInfoscreen.pm
+++ b/lib/DBInfoscreen.pm
@@ -103,36 +103,6 @@ sub startup {
);
$self->attr(
- ice_type_map => sub {
- if ( -r 'share/zugbildungsplan.json' ) {
- my $ice_type_map = JSON->new->utf8->decode(
- scalar read_file('share/zugbildungsplan.json') );
- my $ret = {};
- while ( my ( $k, $v ) = each %{ $ice_type_map->{train} } ) {
- if ( $v->{type} ) {
- $ret->{$k} = [
- $v->{type}, $v->{shortType},
- exists $v->{wagons} ? 1 : 0
- ];
- }
- }
- return $ret;
- }
- return {};
- }
- );
-
- $self->attr(
- train_details_db => sub {
- if ( -r 'share/zugbildungsplan.json' ) {
- return JSON->new->utf8->decode(
- scalar read_file('share/zugbildungsplan.json') )->{train};
- }
- return {};
- }
- );
-
- $self->attr(
dbdb_wagon => sub {
return JSON->new->utf8->decode(
scalar read_file('share/dbdb_wagen.json') );
@@ -323,7 +293,6 @@ sub startup {
$r->get('/dyn/:av/autocomplete.js')->to('stationboard#autocomplete');
$r->get('/_wr/:train/:departure')->to('wagenreihung#wagenreihung');
- $r->get('/wr/:train')->to('wagenreihung#zugbildung_db');
$r->get('/w/*wagon')->to('wagenreihung#wagen');
$r->get('/_ajax_mapinfo/:tripid/:lineno')->to('map#ajax_route');
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm
index 77b0f8d..79a2505 100644
--- a/lib/DBInfoscreen/Controller/Stationboard.pm
+++ b/lib/DBInfoscreen/Controller/Stationboard.pm
@@ -915,30 +915,6 @@ sub render_train {
}
)->wait;
- $departure->{composition}
- = $self->app->train_details_db->{ $departure->{train_no} };
- if ( not $departure->{arrival}
- and $departure->{composition}{prepTime}
- and $departure->{composition}{prepAt} eq $station_name )
- {
- $departure->{prep_time} = $departure->{composition}{prepTime};
- $departure->{arrival_hidden} = 1;
- }
- if ( $self->param('detailed') ) {
- my @cycle_from;
- my @cycle_to;
- for my $pred ( @{ $departure->{composition}{predecessors} // [] } ) {
- push( @cycle_from, $pred->[1] );
- }
- for my $succ ( @{ $departure->{composition}{successors} // [] } ) {
- push( @cycle_to, $succ->[1] );
- }
- $departure->{cycle_from}
- = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_from ];
- $departure->{cycle_to}
- = [ map { [ $_, $self->app->train_details_db->{$_} ] } @cycle_to ];
- }
-
# Defer rendering until all requests have completed
Mojo::Promise->all(@requests)->then(
sub {
@@ -952,12 +928,8 @@ sub render_train {
$departure->{origin} // q{},
$departure->{destination} // 'unbekannt'
),
- departure => $departure,
- linetype => $linetype,
- icetype => $self->app->ice_type_map->{ $departure->{train_no} },
- details => $self->param('detailed')
- ? $departure->{composition} // {}
- : {},
+ departure => $departure,
+ linetype => $linetype,
dt_now => DateTime->now( time_zone => 'Europe/Berlin' ),
station_name => $station_name,
nav_link =>
@@ -1290,25 +1262,6 @@ sub train_details {
$res->{details} = [@him_details];
}
- if ( $self->param('detailed') ) {
- $res->{composition}
- = $self->app->train_details_db->{ $res->{train_no} };
- my @cycle_from;
- my @cycle_to;
- for my $pred ( @{ $res->{composition}{predecessors} // [] } ) {
- push( @cycle_from, $pred->[1] );
- }
- for my $succ ( @{ $res->{composition}{successors} // [] } ) {
- push( @cycle_to, $succ->[1] );
- }
- $res->{cycle_from}
- = [ map { [ $_, $self->app->train_details_db->{$_} ] }
- @cycle_from ];
- $res->{cycle_to}
- = [ map { [ $_, $self->app->train_details_db->{$_} ] }
- @cycle_to ];
- }
-
$self->render(
$self->param('ajax') ? '_train_details' : 'train_details',
description => sprintf(
@@ -1321,8 +1274,6 @@ sub train_details {
),
departure => $res,
linetype => $linetype,
- icetype => $self->app->ice_type_map->{ $res->{train_no} },
- details => {}, #$departure->{composition} // {},
dt_now => DateTime->now( time_zone => 'Europe/Berlin' ),
);
}
@@ -1809,7 +1760,6 @@ sub handle_result {
api_text => $api_text,
api_icon => $api_icon,
departures => \@departures,
- ice_type => $self->app->ice_type_map,
station => $station_name,
version => $self->config->{version},
title => $via ? "$station_name → $via" : $station_name,
diff --git a/lib/DBInfoscreen/Controller/Wagenreihung.pm b/lib/DBInfoscreen/Controller/Wagenreihung.pm
index 5e5f653..35df7a2 100644
--- a/lib/DBInfoscreen/Controller/Wagenreihung.pm
+++ b/lib/DBInfoscreen/Controller/Wagenreihung.pm
@@ -13,126 +13,20 @@ use utf8;
use Travel::Status::DE::DBWagenreihung;
use Travel::Status::DE::DBWagenreihung::Wagon;
-sub get_zugbildung_db {
- my ( $self, $train_no ) = @_;
-
- my $details = $self->app->train_details_db->{$train_no};
-
- if ( not $details ) {
- return;
- }
-
- my @wagons;
-
- for my $wagon ( @{ $details->{wagons} } ) {
- my $wagon_type = $wagon->{type};
- my $wagon_number = $wagon->{number};
- my %wagon = (
- fahrzeugnummer => "",
- fahrzeugtyp => $wagon_type,
- kategorie => $wagon_type =~ m{^[0-9.]+$} ? 'LOK' : '',
- train_no => $train_no,
- wagenordnungsnummer => $wagon_number,
- positionamhalt => {
- startprozent => 0,
- endeprozent => 0,
- startmeter => 0,
- endemeter => 0,
- }
- );
- my $wagon = Travel::Status::DE::DBWagenreihung::Wagon->new(%wagon);
-
- if ( $details->{type} ) {
- $wagon->set_traintype( $details->{type} );
- }
- push( @wagons, $wagon );
- }
-
- my $pos = 0;
- for my $wagon (@wagons) {
- $wagon->{position}{start_percent} = $pos;
- $wagon->{position}{end_percent} = $pos + 5;
- $pos += 5;
- }
-
- my $train_type = $details->{rawType};
- $train_type =~ s{ - .* }{}x;
-
- my $route_start = $details->{route}{start} // $details->{route}{preStart};
- my $route_end = $details->{route}{end} // $details->{route}{postEnd};
- my $route = "${route_start} → ${route_end}";
-
- return {
- route => $route,
- train_type => $train_type,
- wagons => [@wagons]
- };
-}
-
-sub zugbildung_db {
- my ($self) = @_;
-
- my $train_no = $self->param('train');
-
- my $details = $self->get_zugbildung_db($train_no);
-
- if ( not $details ) {
- $self->render( 'not_found',
- message => "Keine Daten zu Zug ${train_no} bekannt" );
- return;
- }
+sub handle_wagenreihung_error {
+ my ( $self, $train_no, $err ) = @_;
$self->render(
- 'zugbildung_db',
- description => sprintf(
- 'Soll-Wagenreihung %s %s',
- $details->{train_type} // 'Zug', $train_no
- ),
- wr_error => undef,
- title => $details->{train_type} . ' ' . $train_no,
- route => $details->{route},
- zb => $details,
+ 'wagenreihung',
+ title => "Zug $train_no",
+ wr_error => $err,
train_no => $train_no,
- wagons => $details->{wagons},
+ wr => undef,
+ wref => undef,
hide_opts => 1,
);
}
-sub handle_wagenreihung_error {
- my ( $self, $train_no, $err ) = @_;
-
- my $details = $self->get_zugbildung_db($train_no);
- if ( $details and @{ $details->{wagons} } ) {
- my $wr_error
- = "${err}. Ersatzweise werden die Solldaten laut Fahrplan angezeigt.";
- $self->render(
- 'zugbildung_db',
- description => sprintf(
- 'Soll-Wagenreihung %s %s',
- $details->{train_type} // 'Zug', $train_no
- ),
- wr_error => $wr_error,
- title => $details->{train_type} . ' ' . $train_no,
- route => $details->{route},
- zb => $details,
- train_no => $train_no,
- wagons => $details->{wagons},
- hide_opts => 1,
- );
- }
- else {
- $self->render(
- 'wagenreihung',
- title => "Zug $train_no",
- wr_error => $err,
- train_no => $train_no,
- wr => undef,
- wref => undef,
- hide_opts => 1,
- );
- }
-}
-
sub wagenreihung {
my ($self) = @_;
my $train = $self->stash('train');