mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Merge f837986b6b into 6ed6a4fd89
This commit is contained in:
commit
eeebd31e44
3 changed files with 9 additions and 6 deletions
|
|
@ -96,9 +96,9 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def point_speed(speed)
|
def point_speed(speed)
|
||||||
return speed if speed.to_i <= 0
|
return "–" if speed.nil? || speed.to_f <= 0
|
||||||
|
speed = speed.to_f
|
||||||
speed * 3.6
|
"#{(speed * 3.6).round(1)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def days_left(active_until)
|
def days_left(active_until)
|
||||||
|
|
|
||||||
|
|
@ -90,15 +90,18 @@ export function formatDate(timestamp, timezone) {
|
||||||
return date.toLocaleString(locale, { timeZone: timezone });
|
return date.toLocaleString(locale, { timeZone: timezone });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatSpeed(speedKmh, unit = 'km') {
|
export function formatSpeed(speedMs, unit = 'km') {
|
||||||
|
const speedKmh = speedMs * 3.6; // Convert m/s to km/h
|
||||||
|
|
||||||
if (unit === 'km') {
|
if (unit === 'km') {
|
||||||
return `${Math.round(speedKmh)} km/h`;
|
return `${Math.round(speedKmh)} km/h`;
|
||||||
} else {
|
} else {
|
||||||
const speedMph = speedKmh * 0.621371; // Convert km/h to mph
|
const speedMph = speedKmh * 0.621371;
|
||||||
return `${Math.round(speedMph)} mph`;
|
return `${Math.round(speedMph)} mph`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function haversineDistance(lat1, lon1, lat2, lon2, unit = 'km') {
|
export function haversineDistance(lat1, lon1, lat2, lon2, unit = 'km') {
|
||||||
// Haversine formula to calculate the distance between two points
|
// Haversine formula to calculate the distance between two points
|
||||||
const toRad = (x) => (x * Math.PI) / 180;
|
const toRad = (x) => (x * Math.PI) / 180;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
</td>
|
</td>
|
||||||
<td class='<%= speed_text_color(point.velocity) %>'><%= point.velocity %></td>
|
<td class='<%= speed_text_color(point.velocity) %>'><%= point_speed(point.velocity) %></td>
|
||||||
<td><%= human_datetime_with_seconds(point.recorded_at) %></td>
|
<td><%= human_datetime_with_seconds(point.recorded_at) %></td>
|
||||||
<td><%= point.lat %>, <%= point.lon %></td>
|
<td><%= point.lat %>, <%= point.lon %></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue