journey: show distances below 10km with 100m resolution (and <1km with 1m)
This commit is contained in:
parent
434eb5a18d
commit
04c8d7672a
2 changed files with 16 additions and 2 deletions
|
@ -393,6 +393,20 @@ sub startup {
|
|||
}
|
||||
);
|
||||
|
||||
$self->helper(
|
||||
'sprintf_km' => sub {
|
||||
my ( $self, $km ) = @_;
|
||||
|
||||
if ( $km < 1 ) {
|
||||
return sprintf( '%.f m', $km * 1000 );
|
||||
}
|
||||
if ( $km < 10 ) {
|
||||
return sprintf( '%.1f km', $km );
|
||||
}
|
||||
return sprintf( '%.f km', $km );
|
||||
}
|
||||
);
|
||||
|
||||
$self->helper(
|
||||
'load_icon' => sub {
|
||||
my ( $self, $load ) = @_;
|
||||
|
|
|
@ -130,8 +130,8 @@
|
|||
<%= numify_skipped_stations($journey->{skip_route}) %><br/>
|
||||
% }
|
||||
% if ($journey->{km_route} > 0.1) {
|
||||
ca. <%= sprintf('%.f', $journey->{km_route}) %> km
|
||||
(Luftlinie: <%= sprintf('%.f', $journey->{km_beeline}) %> km)
|
||||
ca. <%= sprintf_km($journey->{km_route}) %>
|
||||
(Luftlinie: <%= sprintf_km($journey->{km_beeline}) %>)
|
||||
% }
|
||||
% else {
|
||||
?
|
||||
|
|
Loading…
Reference in a new issue