chiark / gitweb /
routesearch: link to full voyage plans
[ypp-sc-tools.db-live.git] / yarrg / web / query_routesearch
index dc8c230c54767b3b5310004eed0d6b48c495d4db..c45b56a06690f51173d15a918b17121c8dc647ea 100644 (file)
 <%args>
 $quri
 $dbh
+$queryqf
 $islandstring => '';
 $capacitystring => '';
 $lossperleague => '';
 $capitalstring => '';
 $distance => '';
-$someresults
 $emsgokorprint
 </%args>
 
@@ -121,7 +121,7 @@ my $isleinfo = sub {
        my $row= $islandname_stmt->fetchrow_hashref();
        local $_= $row->{'islandname'};
        s/ Island$//;
-       return $_, $row->{'archipelago'};
+       return $_, $row->{'islandname'}, $row->{'archipelago'};
 };
 
 #---------- compute the results ----------
@@ -182,10 +182,11 @@ while (<$fh>) {
        my ($ap,$isles) = (uc $1,$5);
        next if $results{$ap} && %{$results{$ap}} >= $maxcountea;
        my $item= { A => $3, P => $4, Leagues => $2 };
-       my (@i, @a);
+       my (@i, @fi, @a);
        foreach (split / /, $isles) {
-               my ($name,$arch)= $isleinfo->($_);
+               my ($name,$fullname,$arch)= $isleinfo->($_);
                push @i, $name;
+               push @fi, $fullname;
                push @a, $arch unless @a && $a[-1] eq $arch;
        }
        $item->{Isles}= [ @i ];
@@ -197,6 +198,10 @@ while (<$fh>) {
        for ($i=1; $i < @i-1; $i++) {
                push @{ $item->{Vias} }, $i[$i];
        }
+       my %linkqf= %$queryqf;
+       delete $linkqf{'query'};
+       $linkqf{'routestring'}= join ', ', @fi;
+       $item->{Url}= $quri->(%linkqf);
        $results{$ap}{$isles}= $item;
 }
 
@@ -249,7 +254,11 @@ seconds of CPU time so more processing resources should be available soon.
 
 </%perl>
 % foreach my $ap (qw(A P)) {
-<h2>ap=<% $ap %></h2>
+%      if ($ap eq 'A') {
+<h2>Best routes for total profit</h2>
+%      } else {
+<h2>Best routes for profit per league</h2>
+%      }
 <table rules=groups>
 <colgroup span=2>
 <colgroup span=1>
@@ -280,7 +289,7 @@ seconds of CPU time so more processing resources should be available soon.
 <td align=right><% $item->{A} |h %>
 <td align=right><% $item->{P} |h %>
 <td align=right><% $item->{Leagues} |h %>
-<td align=left><% join ', ', @{ $item->{Archs} } |h %>
+<td align=left><a href="<% $item->{Url} |h %>"><% join ', ', @{ $item->{Archs} } |h %></a>
 <td align=left><% $item->{Start} |h %>,
 <td align=left><% join ' ', map { $_.',' } @{ $item->{Vias} } |h %>
 <td align=left><% $item->{Finish} |h %>
@@ -289,6 +298,16 @@ seconds of CPU time so more processing resources should be available soon.
 %      } # $isles
 </table>
 % } # $ap
+
+<p>
+
+<h2>Notes</h2>
+
+Per league values count each island visited as one
+(additional) league; the `Dist.' column is however the actual distance
+to be sailed.  All profit figures are somewhat approximate; get a
+complete trading plan for a route for accurate information.
+
 <%perl>