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

Move stations to the master frame

parent 09dc6c25
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -26,7 +26,9 @@ use Data::Printer; ...@@ -26,7 +26,9 @@ use Data::Printer;
use File::BOM; use File::BOM;
use File::Basename; use File::Basename;
use Getopt::Long; use Getopt::Long;
use List::Util qw(any);
use App::Log;
use App::Ts; use App::Ts;
use App::Ressya; use App::Ressya;
use App::Frame; use App::Frame;
...@@ -211,6 +213,8 @@ opendir my $dir, $trains_path or die "Error opening $trains_path"; ...@@ -211,6 +213,8 @@ opendir my $dir, $trains_path or die "Error opening $trains_path";
my @trains = readdir $dir; my @trains = readdir $dir;
closedir $dir; closedir $dir;
# Parsing step.
# Build "temporary" frames for each diagram.
foreach my $file (@trains) foreach my $file (@trains)
{ {
next if ($file =~ /^\.+$/); next if ($file =~ /^\.+$/);
...@@ -240,13 +244,71 @@ foreach my $file (@trains) ...@@ -240,13 +244,71 @@ foreach my $file (@trains)
print "\n"; print "\n";
my %frame = %{ ${$recce->value()} }; my %frame = %{ ${$recce->value()} };
$frame{'id'} = $basename;
Frame::frame_info \%frame; Frame::frame_info \%frame;
# p %frame;
$master{$basename} = \%frame; $master{$basename} = \%frame;
# FrameUtils::hassya_hyou \%frame, 11;
close $dia_file; close $dia_file;
} }
# Processing step 1.
# Bring stations back to the master frame and use unique IDs in children frames.
# Assume stations with the same name are identical.
# TODO cases where different stations have the same names
# TODO cases where the same station has two distinct names
# > maybe use a null footpath?
# TODO overall, find more generic criteria for matching two similar stations
my @master_ekis;
foreach my $frame (values %master)
{
my @old_ekis = @{ $frame->{'eki'} };
my @new_ekis;
my $index = 0;
my $update_index = 1;
for (my $i = 0; $i < $#old_ekis; $i++)
{
$update_index = 1;
my %new_struct;
my $ekimei = $old_ekis[$i];
my @prev = @old_ekis[0..$i-1];
my $restart = 0;
# Run all similarity checks first
# Station occurs twice on the same route (branch line)
foreach my $old (@new_ekis)
{
if ($old->{'ekimei'} eq $ekimei)
{
Log::i "$ekimei has already appeared on this route before, assuming branch line";
push @new_ekis, $old;
$restart = 1;
last;
}
}
if ($restart) { next; }
# TODO Station has already been processed in another route
foreach my $old (@master_ekis)
{
}
my $id = $frame->{'id'} . "_$index";
print "Adding station $ekimei to master frame with id $id\n";
$new_struct{'ekimei'} = $ekimei;
$new_struct{'found_in'} = $frame->{'id'};
push @new_ekis, \%new_struct;
if ($update_index) { $index++; }
}
push @master_ekis, @new_ekis;
}
p @master_ekis;
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