Unverified Commit 51b52327 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

map: support non-DB HAFAS backends, including ÖBB

parent 4329fde7
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -314,13 +314,26 @@ sub route {
	my ($self)  = @_;
	my $trip_id = $self->stash('tripid');
	my $line_no = $self->stash('lineno');
	my $hafas   = $self->param('hafas');

	my $from_name = $self->param('from');
	my $to_name   = $self->param('to');

	$self->render_later;

	$self->hafas->get_polyline_p( $trip_id, $line_no )->then(
	my $service = 'DB';
	if (    $hafas
		and $hafas ne '1'
		and Travel::Status::DE::HAFAS::get_service($hafas) )
	{
		$service = $hafas;
	}

	$self->hafas->get_polyline_p(
		id      => $trip_id,
		line    => $line_no,
		service => $service
	)->then(
		sub {
			my ($journey) = @_;

@@ -458,12 +471,25 @@ sub ajax_route {
	my ($self)  = @_;
	my $trip_id = $self->stash('tripid');
	my $line_no = $self->stash('lineno');
	my $hafas   = $self->param('hafas');

	delete $self->stash->{layout};

	$self->render_later;

	$self->hafas->get_polyline_p( $trip_id, $line_no )->then(
	my $service = 'DB';
	if (    $hafas
		and $hafas ne '1'
		and Travel::Status::DE::HAFAS::get_service($hafas) )
	{
		$service = $hafas;
	}

	$self->hafas->get_polyline_p(
		id      => $trip_id,
		line    => $line_no,
		service => $service
	)->then(
		sub {
			my ($journey) = @_;

+5 −1
Original line number Diff line number Diff line
@@ -161,11 +161,15 @@ sub get_route_p {
# Input: (HAFAS TripID, line number)
# Output: Promise returning a Travel::Status::DE::HAFAS::Journey instance on success
sub get_polyline_p {
	my ( $self, $trip_id, $line ) = @_;
	my ( $self, %opt ) = @_;

	my $trip_id = $opt{id};
	my $line    = $opt{line};
	my $service = $opt{service};
	my $promise = Mojo::Promise->new;

	Travel::Status::DE::HAFAS->new_p(
		service => $service,
		journey => {
			id   => $trip_id,
			name => $line,
+2 −1
Original line number Diff line number Diff line
@@ -68,7 +68,8 @@ function dbf_anim_fine() {
}

function dbf_map_reload() {
	$.get('/_ajax_mapinfo/' + j_reqid, function(data) {
	const param = new URLSearchParams(window.location.search);
	$.get('/_ajax_mapinfo/' + j_reqid + '?hafas=' + param.get('hafas'), function(data) {
		$('#infobox').html(data);
		dbf_map_parse();
		setTimeout(dbf_map_reload, 61000);
+1 −1
Original line number Diff line number Diff line
<div class="container" id="infobox" style="margin-top: 1ex; margin-bottom: 1ex;">
<div class="journey" id="jdata"
data-req="<%= stash('ajax_req') %>"
data-req="<%= stash('ajax_req') =~ s{#}{%23}gr %>"
data-route="<%= stash('ajax_route') %>"
data-poly="<%= stash('ajax_polyline') %>"
>
+2 −2
Original line number Diff line number Diff line
@@ -139,10 +139,10 @@
    <div class="verbose">
%     if ($departure->{trip_id}) {
%       if (stash('station_name')) {
          <a class="smallbutton" href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>?from=<%= stash('station_name') %>"><i class="material-icons" aria-hidden="true">map</i> <%= l 'Karte' %></a>
          <a class="smallbutton" href="/map/<%= $departure->{trip_id} =~ s{#}{%23}gr %>/<%= $departure->{train_line} // 0 %>?from=<%= stash('station_name') %>"><i class="material-icons" aria-hidden="true">map</i> <%= l 'Karte' %></a>
%       }
%       else {
          <a class="smallbutton" href="/map/<%= $departure->{trip_id} %>/<%= $departure->{train_line} // 0 %>"><i class="material-icons" aria-hidden="true">map</i> <%= l 'Karte' %></a>
          <a class="smallbutton" href="/map/<%= $departure->{trip_id} =~ s{#}{%23}gr %>/<%= $departure->{train_line} // 0 %>"><i class="material-icons" aria-hidden="true">map</i> <%= l 'Karte' %></a>
%       }
%     }
%     if ($departure->{wr_link}) {