From: Ian Jackson Date: Sat, 17 Oct 2009 19:27:08 +0000 (+0100) Subject: routesearch: support circular routes X-Git-Tag: 5.0^2~18 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=a1fb96b672d234f5961a397215c19c2c631c5cc3 routesearch: support circular routes --- diff --git a/yarrg/TODO b/yarrg/TODO index f625803..b202aad 100644 --- a/yarrg/TODO +++ b/yarrg/TODO @@ -1,9 +1,3 @@ -query_routesearch: - - circular routes - routes ending in specific place(s) - - UPLOADER -------- @@ -37,3 +31,4 @@ initial/final stocks feature printable voyage trading plan query_routesearch should show capital for each voyage +query_routesearch should support ending in specific place(s) diff --git a/yarrg/web/lookup b/yarrg/web/lookup index 15f341a..2f67760 100755 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -80,6 +80,12 @@ my %styles; [ 1, 'Show individual stalls' ], ], QuerySpecific => 1, + }, { Name => 'RouteSearchType', + Before => 'Type of routes to search for: ', + Values => [ [ 0, 'Open-ended' ], + [ 1, 'Circular' ], + ], + QuerySpecific => 1, }); foreach my $var (@vars) { @@ -248,7 +254,7 @@ $debug => 0
<& "query_$styles{Query}", %baseqf, %queryqf, %styles, - quri => $quri, dbh => $dbh, queryqf => \%queryqf, + quri => $quri, dbh => $dbh, queryqf => \%queryqf, allargs => \%ARGS, prselector => $prselector, someresults => $someresults, emsgokorprint => sub { diff --git a/yarrg/web/query_routesearch b/yarrg/web/query_routesearch index fadc20e..65f57f8 100644 --- a/yarrg/web/query_routesearch +++ b/yarrg/web/query_routesearch @@ -42,8 +42,10 @@ $capacitystring => ''; $lossperleague => ''; $capitalstring => ''; $distance => ''; +$prselector $someresults $emsgokorprint +$allargs <%perl> @@ -70,6 +72,8 @@ my $maxcountea=15; This feature is not available from the "drop down menus" interface. % } else { +% $prselector->('RouteSearchType'); +
<& enter_route, qa=>$qa, dbh=>$dbh, emsg_r=>\$emsg, warningfs_r=>\@warningfs, @@ -106,6 +110,7 @@ if (!$emsg && $maxdist > $maxmaxdist) { $emsgokorprint->($emsg) or return; @islandids or return; +$allargs->{'submit'} or return; defined $routeparams->{MaxMass} or defined $routeparams->{MaxVolume} or return; #---------- prepare island names ---------- @@ -137,7 +142,9 @@ foreach my $k (qw(MaxMass MaxVolume MaxCapital)) { push @rsargs, defined $routeparams->{LossPerLeaguePct} ? $routeparams->{LossPerLeaguePct}*0.01 : 1e-9; push @rsargs, '0'; -push @rsargs, 'search',$maxdist, $maxcountea,$maxcountea, 'any', @islandids; +push @rsargs, 'search',$maxdist, $maxcountea,$maxcountea; +push @rsargs, $ARGS{RouteSearchType} ? 'circ' : 'any'; +push @rsargs, @islandids; m/[^-.0-9a-zA-Z]/ and die "$_ $& ?" foreach @rsargs;