chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-live.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Calculate total distance correctly
[ypp-sc-tools.db-live.git]
/
yarrg
/
web
/
routetrade
diff --git
a/yarrg/web/routetrade
b/yarrg/web/routetrade
index 4885782e58a440b7a773510a049daf363e5e0838..7f7d27f45d26d51a25c20b42ff66003e60d6848a 100644
(file)
--- a/
yarrg/web/routetrade
+++ b/
yarrg/web/routetrade
@@
-205,9
+205,12
@@
$addcols->({ DoReverse => 1, SortColKey => 'MarginSortKey' },
qw( Margin
));
$addcols->({ DoReverse => 1 },
qw( Margin
));
$addcols->({ DoReverse => 1 },
- qw( unitprofit dist MaxQty
- MaxCapital MaxProfit
+ qw( unitprofit MaxQty MaxCapital MaxProfit dist
));
));
+foreach my $v (qw(MaxMass MaxVolume)) {
+ $addcols->({
+ DoReverse => 1, Total => 0, SortColKey => "${v}SortKey" }, $v);
+}
</%perl>
</%perl>
@@
-269,6
+272,12
@@
foreach my $f (@flows) {
$f->{MaxProfit}= $f->{MaxQty} * $f->{'unitprofit'};
$f->{MaxCapital}= $f->{MaxQty} * $f->{'org_price'};
$f->{MaxProfit}= $f->{MaxQty} * $f->{'unitprofit'};
$f->{MaxCapital}= $f->{MaxQty} * $f->{'org_price'};
+ $f->{MaxMassSortKey}= $f->{MaxQty} * $f->{'unitmass'};
+ $f->{MaxVolumeSortKey}= $f->{MaxQty} * $f->{'unitvolume'};
+ foreach my $v (qw(Mass Volume)) {
+ $f->{"Max$v"}= sprintf "%.1f", $f->{"Max${v}SortKey"} * 1e-6;
+ }
+
$f->{MarginSortKey}= sprintf "%d",
$f->{'dst_price'} * 10000 / $f->{'org_price'};
$f->{Margin}= sprintf "%3.1f%%",
$f->{MarginSortKey}= sprintf "%d",
$f->{'dst_price'} * 10000 / $f->{'org_price'};
$f->{Margin}= sprintf "%3.1f%%",
@@
-486,7
+495,7
@@
$addcols->({ Total => 0, DoReverse => 1 }, qw(
<colgroup span=2>
<colgroup span=2>
<colgroup span=2>
<colgroup span=2>
<colgroup span=2>
<colgroup span=2>
-<colgroup span=
1
>
+<colgroup span=
3
>
<colgroup span=3>
% if ($optimise) {
<colgroup span=3>
<colgroup span=3>
% if ($optimise) {
<colgroup span=3>
@@
-499,8
+508,9
@@
$addcols->({ Total => 0, DoReverse => 1 }, qw(
<th colspan=2>Collect
<th colspan=2>Deliver
<th colspan=2>Profit
<th colspan=2>Collect
<th colspan=2>Deliver
<th colspan=2>Profit
-<th colspan=1>
<th colspan=3>Max
<th colspan=3>Max
+<th colspan=1>
+<th colspan=2>Max
% if ($optimise) {
<th colspan=3>Planned
% }
% if ($optimise) {
<th colspan=3>Planned
% }
@@
-516,10
+526,12
@@
$addcols->({ Total => 0, DoReverse => 1 }, qw(
<th>Qty
<th>Margin
<th>Unit
<th>Qty
<th>Margin
<th>Unit
-<th>Dist
<th>Qty
<th>Capital
<th>Profit
<th>Qty
<th>Capital
<th>Profit
+<th>Dist
+<th>Mass
+<th>Vol
% if ($optimise) {
<th>Qty
<th>Capital
% if ($optimise) {
<th>Qty
<th>Capital
@@
-542,7
+554,8
@@
$addcols->({ Total => 0, DoReverse => 1 }, qw(
% foreach my $ci (1..$#cols) {
% my $col= $cols[$ci];
% my $v= $flow->{$col->{Name}};
% foreach my $ci (1..$#cols) {
% my $col= $cols[$ci];
% my $v= $flow->{$col->{Name}};
-% $col->{Total} += $v if defined $col->{Total};
+% $col->{Total} += $v
+% if defined $col->{Total} and not $flow->{Suppress};
% $v='' if !$col->{Text} && !$v;
% my $sortkey= $col->{SortColKey} ?
% $flow->{$col->{SortColKey}} : $v;
% $v='' if !$col->{Text} && !$v;
% my $sortkey= $col->{SortColKey} ?
% $flow->{$col->{SortColKey}} : $v;
@@
-584,11
+597,11
@@
$addcols->({ Total => 0, DoReverse => 1 }, qw(
<tr><td colspan=3>
% $iquery->execute($islandids[$i]);
% my ($islandname) = $iquery->fetchrow_array();
<tr><td colspan=3>
% $iquery->execute($islandids[$i]);
% my ($islandname) = $iquery->fetchrow_array();
-% my $this_dist= $distance->($islandids[$i-1],$islandids[$i]);
-% $total_dist += $this_dist;
% if (!$i) {
<strong>Start at <% $islandname |h %></strong>
% } else {
% if (!$i) {
<strong>Start at <% $islandname |h %></strong>
% } else {
+% my $this_dist= $distance->($islandids[$i-1],$islandids[$i]);
+% $total_dist += $this_dist;
<strong>Sail to <% $islandname |h %></strong>
- <% $this_dist |h %> leagues </td>
% }
<strong>Sail to <% $islandname |h %></strong>
- <% $this_dist |h %> leagues </td>
% }
@@
-630,7
+643,7
@@
$addcols->({ Total => 0, DoReverse => 1 }, qw(
}
my $total;
}
my $total;
- my $dline=
0
;
+ my $dline=
1
;
my $show_flows= sub {
my ($od,$arbitrage,$collectdeliver) = @_;
</%perl>
my $show_flows= sub {
my ($od,$arbitrage,$collectdeliver) = @_;
</%perl>
@@
-686,7
+699,7
@@
$addcols->({ Total => 0, DoReverse => 1 }, qw(
% $total_total += $sign * $total;
% }
% $total= undef;
% $total_total += $sign * $total;
% }
% $total= undef;
-% $dline=
0
;
+% $dline=
1
;
<%perl>
};
<%perl>
};