Skip to content
Extraits de code Groupes Projets
Valider 5edee6bc rédigé par hieda_kyuko@hpr's avatar hieda_kyuko@hpr
Parcourir les fichiers

Sort departures in timetable + Raptor fixes

parent fe893242
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -53,6 +53,7 @@ sub hassya_hyou
my $rosen_id = $_[0];
my $rosen = MasterUtils::get_rosen_frame $master, $rosen_id;
my @ressyas = @{ $_[1] };
my @sorted_ressyas = ();
my $is_down = $_[3];
my $target_absolute = MasterUtils::get_eki_position $master, $rosen_id, $_[2];
my $target_relative = $is_down
......@@ -61,28 +62,65 @@ sub hassya_hyou
foreach my $ressya (@ressyas)
{
my %data = %{ $ressya };
my @jikoku = @{ $data{'jikoku'} };
my @jikoku = @{ $ressya->{'jikoku'} };
my $pos = 0;
while ($pos != $target_relative) { shift @jikoku; $pos++; }
if (!defined $jikoku[0]) { next; }
my %ts = %{ $jikoku[0] };
my $time = $ts{'hatsu'};
my $ts = $jikoku[0];
my $time = $ts->{'hatsu'};
# Timestamp has no dep time (only arrival time for ex)
if (!defined $time) { next; }
# This service does not stop here
if ($ts{'mode'} != 1) { next; }
if ($ts->{'mode'} != 1) { next; }
my $corrected_time = $time < 300
? $time + 2400
: $time;
my %frame = ( time => $corrected_time, ressya => $ressya );
# Add this service into a new sorted list
$pos = 0;
if ($#sorted_ressyas < 0)
{
push @sorted_ressyas, \%frame;
}
else
{
# Days start at 3:00
while (defined $sorted_ressyas[$pos] &&
$sorted_ressyas[$pos]->{'time'} < $corrected_time)
{
$pos++;
}
splice @sorted_ressyas, $pos, 0, \%frame;
}
}
my $current_hour = -1;
foreach my $frame (@sorted_ressyas)
{
my $time = $frame->{'time'};
$time = $time > 2400
? $time - 2400
: $time;
my $hour = int $time / 100;
if ($hour != $current_hour)
{
print "== $hour ==\n";
$current_hour = $hour;
}
my $ressya = $frame->{'ressya'};
my @jikoku = @{ $ressya->{'jikoku'} };
# Format: time (tab) destination (tab) type (with eventual name)
my $syubetsu = get_syubetsu $master, $rosen_id, $data{'syubetsu'};
my $syubetsu = get_syubetsu $master, $rosen_id, $ressya->{'syubetsu'};
print( (TimeUtils::format_time_simple $time)
. "\tfor "
. (get_destination $master, $rosen_id, \@jikoku, $target_relative, $is_down)
. (get_destination $master, $rosen_id, \@jikoku, 0, $is_down)
. "\t$syubetsu")
;
if (defined $data{'meisyo'})
if (defined $ressya->{'meisyo'})
{
print " $data{'meisyo'}";
print " $ressya->{'meisyo'}";
}
print "\n";
}
......
......@@ -38,13 +38,16 @@ sub Raptor_simple
my %taustar;
my @marked;
# We add two more hashes:
# one to keep track of the last used service to arrive at a station
my %earliest;
# and one to save the station used to board this last used service
my %from;
# We also save the number of times a station was visited
# This may need a demonstration but we consider that the minimal time is already reached if the station is processed two times the number of routes it is served by.
my %visited;
my sub earliest_trip
{
my $k = $_[0];
......@@ -84,6 +87,7 @@ sub Raptor_simple
$taus{$key} = \@a;
$taustar{$key} = ~0;
$earliest{$key} = ();
$visited{$key} = 0;
}
$taus{$from_id}[0] = $dep_time;
......@@ -121,12 +125,13 @@ sub Raptor_simple
}
}
}
if (!$substituted)
if (!$substituted && $visited{$p} < 2 * scalar @rosens)
{
push @Q, [$r, $d, $p];
}
}
Log::d "Unmarking $p_display ($p)";
$visited{$p}++;
}
@marked = ();
......
......@@ -259,7 +259,7 @@ foreach my $file (@trains)
catch ($e) { print "Malformation in .oud file.\n$e\n"; }
print "\n";
print $recce->show_progress();
# print $recce->show_progress();
my %frame = %{ ${$recce->value()} };
$frame{'id'} = $basename;
......@@ -342,6 +342,5 @@ foreach my $frame (values %{ $master{'rosen'} })
$frame->{'eki'} = \@new_ekis;
}
# MasterUtils::get_routes \%master, 'konpoku_9';
# FrameUtils::hassya_hyou \%master, 'konpoku_9';
Navi::Raptor_simple \%master, 'sekihoku1_0', 'senmo_6', 1330;
# FrameUtils::hassya_hyou \%master, 'sekihoku1_28';
Navi::Raptor_simple \%master, 'sibetu_9', 'sibetu_34', 800;
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter