adds elevation loss for trails
This commit is contained in:
@@ -114,7 +114,7 @@
|
||||
|
||||
function colorKey(i: number) {
|
||||
return $_(
|
||||
currentMonthArray[i]?.log?.expand.trails_via_summit_logs?.at(0)
|
||||
currentMonthArray[i]?.log?.expand?.trails_via_summit_logs?.at(0)
|
||||
?.expand?.category?.name ?? "",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@
|
||||
type="button"
|
||||
on:click={openMap}
|
||||
class="h-20 aspect-square shrink-0 rounded-xl !bg-background hover:!bg-secondary-hover transition-colors"
|
||||
class:hidden={!log.expand.gpx_data}
|
||||
class:hidden={!log.expand?.gpx_data}
|
||||
id="mini-map-{index}"
|
||||
></button>
|
||||
</td>
|
||||
<td class:py-4={!log.expand.gpx_data}
|
||||
<td class:py-4={!log.expand?.gpx_data}
|
||||
>{new Date(log.date).toLocaleDateString(undefined, {
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
@@ -108,7 +108,7 @@
|
||||
{#if showCategory}
|
||||
<td>
|
||||
{$_(
|
||||
log.expand.trails_via_summit_logs?.at(0)?.expand.category
|
||||
log.expand?.trails_via_summit_logs?.at(0)?.expand?.category
|
||||
?.name ?? "-",
|
||||
)}
|
||||
</td>
|
||||
@@ -117,7 +117,7 @@
|
||||
<td>
|
||||
<a
|
||||
class="btn-icon aspect-square"
|
||||
href="/trail/view/{log.expand.trails_via_summit_logs?.at(0)
|
||||
href="/trail/view/{log.expand?.trails_via_summit_logs?.at(0)
|
||||
?.id ?? ''}"
|
||||
><i class="fa fa-arrow-up-right-from-square px-[3px]"></i></a
|
||||
>
|
||||
|
||||
@@ -75,20 +75,25 @@
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex mt-1 gap-4 text-sm text-gray-500 whitespace-nowrap">
|
||||
<div class="grid grid-cols-2 mt-2 gap-1 text-sm text-gray-500 whitespace-nowrap">
|
||||
<span
|
||||
><i class="fa fa-left-right mr-2"></i>{formatDistance(
|
||||
trail.distance,
|
||||
)}</span
|
||||
>
|
||||
<span
|
||||
><i class="fa fa-up-down mr-2"></i>{formatElevation(
|
||||
><i class="fa fa-clock mr-2"></i>{formatTimeHHMM(
|
||||
trail.duration,
|
||||
)}</span
|
||||
>
|
||||
<span
|
||||
><i class="fa fa-arrow-trend-up mr-2"></i>{formatElevation(
|
||||
trail.elevation_gain,
|
||||
)}</span
|
||||
>
|
||||
<span
|
||||
><i class="fa fa-clock mr-2"></i>{formatTimeHHMM(
|
||||
trail.duration,
|
||||
><i class="fa fa-arrow-trend-down mr-2"></i>{formatElevation(
|
||||
trail.elevation_loss,
|
||||
)}</span
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -246,7 +246,7 @@
|
||||
</section>
|
||||
{#if mode == "overview"}
|
||||
<section
|
||||
class="grid grid-cols-2 sm:grid-cols-4 gap-y-4 justify-around py-8 border-b border-input-border"
|
||||
class="grid grid-cols-2 sm:grid-cols-5 gap-y-4 justify-around py-8 border-b border-input-border"
|
||||
>
|
||||
<div class="flex flex-col items-center">
|
||||
<span>{$_("distance")}</span>
|
||||
@@ -254,6 +254,12 @@
|
||||
>{formatDistance(trail.distance)}</span
|
||||
>
|
||||
</div>
|
||||
<div class="flex flex-col items-center">
|
||||
<span>{$_("est-duration")}</span>
|
||||
<span class="font-semibold text-lg"
|
||||
>{formatTimeHHMM(trail.duration)}</span
|
||||
>
|
||||
</div>
|
||||
<div class="flex flex-col items-center">
|
||||
<span>{$_("elevation-gain")}</span>
|
||||
<span class="font-semibold text-lg"
|
||||
@@ -261,9 +267,9 @@
|
||||
>
|
||||
</div>
|
||||
<div class="flex flex-col items-center">
|
||||
<span>{$_("est-duration")}</span>
|
||||
<span>{$_("elevation-loss")}</span>
|
||||
<span class="font-semibold text-lg"
|
||||
>{formatTimeHHMM(trail.duration)}</span
|
||||
>{formatElevation(trail.elevation_loss)}</span
|
||||
>
|
||||
</div>
|
||||
{#if trail.expand.category}
|
||||
|
||||
@@ -64,13 +64,18 @@
|
||||
)}</span
|
||||
>
|
||||
<span
|
||||
><i class="fa fa-up-down mr-2"></i>{formatElevation(
|
||||
><i class="fa fa-clock mr-2"></i>{formatTimeHHMM(
|
||||
trail.duration,
|
||||
)}</span
|
||||
>
|
||||
<span
|
||||
><i class="fa fa-arrow-trend-up mr-2"></i>{formatElevation(
|
||||
trail.elevation_gain,
|
||||
)}</span
|
||||
>
|
||||
<span
|
||||
><i class="fa fa-clock mr-2"></i>{formatTimeHHMM(
|
||||
trail.duration,
|
||||
><i class="fa fa-arrow-trend-down mr-2"></i>{formatElevation(
|
||||
trail.elevation_loss,
|
||||
)}</span
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@ class SummitLog {
|
||||
date: string;
|
||||
text?: string;
|
||||
gpx?: string;
|
||||
_gpx: File | Blob | null;
|
||||
_gpx: File | null;
|
||||
distance?: number
|
||||
elevation_gain?: number
|
||||
elevation_loss?: number
|
||||
@@ -17,11 +17,15 @@ class SummitLog {
|
||||
trails_via_summit_logs?: Trail[];
|
||||
}
|
||||
|
||||
constructor(date: string, params?: { id?: string, text?: string }) {
|
||||
constructor(date: string, params?: { id?: string, text?: string, distance?: number, elevation_loss?: number, elevation_gain?: number, duration?: number }) {
|
||||
this.date = date;
|
||||
this.id = params?.id;
|
||||
this.text = params?.text ?? "";
|
||||
this.expand = {}
|
||||
this.distance = params?.distance
|
||||
this.elevation_gain = params?.elevation_gain
|
||||
this.elevation_loss = params?.elevation_loss
|
||||
this.duration = params?.duration
|
||||
this._gpx = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ class Trail {
|
||||
public: boolean;
|
||||
distance?: number;
|
||||
elevation_gain?: number;
|
||||
elevation_loss?: number;
|
||||
duration?: number;
|
||||
difficulty?: "easy" | "moderate" | "difficult"
|
||||
lat?: number;
|
||||
@@ -43,6 +44,7 @@ class Trail {
|
||||
public?: boolean,
|
||||
distance?: number,
|
||||
elevation_gain?: number,
|
||||
elevation_loss?: number,
|
||||
duration?: number,
|
||||
difficulty?: "easy" | "moderate" | "difficult",
|
||||
lat?: number,
|
||||
@@ -68,6 +70,7 @@ class Trail {
|
||||
this.public = params?.public ?? false
|
||||
this.distance = params?.distance;
|
||||
this.elevation_gain = params?.elevation_gain;
|
||||
this.elevation_loss = params?.elevation_loss;
|
||||
this.duration = params?.duration;
|
||||
this.difficulty = params?.difficulty ?? "easy";
|
||||
this.lat = params?.lat;
|
||||
|
||||
@@ -58,6 +58,7 @@ export async function gpx2trail(gpxString: string, fallbackName?: string) {
|
||||
|
||||
trail.duration = totals.duration / 1000 / 60
|
||||
trail.elevation_gain = totals.elevationGain;
|
||||
trail.elevation_loss = totals.elevationLoss;
|
||||
trail.distance = totals.distance
|
||||
|
||||
return { gpx: gpx, trail: trail }
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
$: logCategories = $summitLogs.reduce(
|
||||
(acc, log) => {
|
||||
const cat =
|
||||
log.expand.trails_via_summit_logs?.at(0)?.expand.category
|
||||
log.expand?.trails_via_summit_logs?.at(0)?.expand?.category
|
||||
?.name ?? "unknown";
|
||||
acc[$_(cat)] = (acc[$_(cat)] || 0) + 1;
|
||||
return acc;
|
||||
|
||||
Reference in New Issue
Block a user