updates trail filter and sort with elevation loss
This commit is contained in:
@@ -29,7 +29,7 @@ login() {
|
||||
upload_and_delete() {
|
||||
local file="$1"
|
||||
|
||||
ls $file
|
||||
ls "$file"
|
||||
|
||||
# API call to upload file
|
||||
response=$(curl -b cookie.txt --location --request PUT "$API_URL/trail/upload" --header 'Content-Type: multipart/form-data' -F "file=@$file" -F "name=$base_name")
|
||||
|
||||
@@ -239,17 +239,36 @@
|
||||
>
|
||||
</div>
|
||||
<hr class="my-4 border-separator" />
|
||||
<p class="text-sm font-medium pb-4">{$_("elevation-loss")}</p>
|
||||
<DoubleSlider
|
||||
minValue={filter.elevationLossMin}
|
||||
maxValue={filter.elevationLossLimit}
|
||||
bind:currentMin={filter.elevationLossMin}
|
||||
bind:currentMax={filter.elevationLossMax}
|
||||
on:set={() => update()}
|
||||
></DoubleSlider>
|
||||
<div class="flex justify-between">
|
||||
<span>{formatElevation(filter.elevationLossMin)}</span>
|
||||
<span
|
||||
>{formatElevation(
|
||||
filter.elevationLossMax,
|
||||
)}{filter.elevationLossMax == filter.elevationLossLimit
|
||||
? "+"
|
||||
: ""}</span
|
||||
>
|
||||
</div>
|
||||
<hr class="my-4 border-separator" />
|
||||
|
||||
<div class="space-y-2">
|
||||
<Datepicker
|
||||
name="startDate"
|
||||
label={$_('after')}
|
||||
label={$_("after")}
|
||||
bind:value={filter.startDate}
|
||||
on:change={update}
|
||||
></Datepicker>
|
||||
<Datepicker
|
||||
name="endDate"
|
||||
label={$_('before')}
|
||||
label={$_("before")}
|
||||
bind:value={filter.endDate}
|
||||
on:change={update}
|
||||
></Datepicker>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
{ text: $_("difficulty"), value: "difficulty" },
|
||||
{ text: $_("distance"), value: "distance" },
|
||||
{ text: $_("elevation-gain"), value: "elevation_gain" },
|
||||
{ text: $_("elevation-loss"), value: "elevation_loss" },
|
||||
];
|
||||
|
||||
onMount(() => {
|
||||
|
||||
@@ -108,6 +108,9 @@ interface TrailFilter {
|
||||
elevationGainMin: number;
|
||||
elevationGainMax: number;
|
||||
elevationGainLimit: number;
|
||||
elevationLossMin: number;
|
||||
elevationLossMax: number;
|
||||
elevationLossLimit: number;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
completed?: boolean;
|
||||
@@ -120,6 +123,8 @@ interface TrailFilterValues {
|
||||
max_distance: number,
|
||||
min_elevation_gain: number,
|
||||
max_elevation_gain: number,
|
||||
min_elevation_loss: number,
|
||||
max_elevation_loss: number,
|
||||
min_durtation: number,
|
||||
max_duration: number,
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ export async function trails_show(id: string, loadGPX?: boolean, f: (url: Reques
|
||||
}
|
||||
response.expand.gpx_data = gpxData;
|
||||
|
||||
|
||||
|
||||
for (const log of response.expand.summit_logs ?? []) {
|
||||
const gpxData: string = await fetchGPX(log, f);
|
||||
|
||||
@@ -387,7 +387,7 @@ export async function fetchGPX(trail: { gpx?: string } & Record<string, any>, f:
|
||||
function buildFilterText(filter: TrailFilter, includeGeo: boolean): string {
|
||||
let filterText: string = "";
|
||||
|
||||
filterText += `distance >= ${Math.floor(filter.distanceMin)} AND elevation_gain >= ${Math.floor(filter.elevationGainMin)}`
|
||||
filterText += `distance >= ${Math.floor(filter.distanceMin)} AND elevation_gain >= ${Math.floor(filter.elevationGainMin)} AND elevation_loss >= ${Math.floor(filter.elevationLossMin)}`
|
||||
|
||||
if (filter.distanceMax < filter.distanceLimit) {
|
||||
filterText += ` AND distance <= ${Math.ceil(filter.distanceMax)}`
|
||||
@@ -397,6 +397,10 @@ function buildFilterText(filter: TrailFilter, includeGeo: boolean): string {
|
||||
filterText += ` AND elevation_gain <= ${Math.ceil(filter.elevationGainMax)}`
|
||||
}
|
||||
|
||||
if (filter.elevationLossMax < filter.elevationLossLimit) {
|
||||
filterText += ` AND elevation_loss <= ${Math.ceil(filter.elevationLossMax)}`
|
||||
}
|
||||
|
||||
filterText += ` AND difficulty IN [${filter.difficulty.join(",")}]`
|
||||
|
||||
if (filter.startDate) {
|
||||
|
||||
@@ -20,6 +20,9 @@ export const load: ServerLoad = async ({ params, locals, fetch }) => {
|
||||
elevationGainMin: 0,
|
||||
elevationGainMax: filterValues.max_elevation_gain,
|
||||
elevationGainLimit: filterValues.max_elevation_gain,
|
||||
elevationLossMin: 0,
|
||||
elevationLossMax: filterValues.max_elevation_loss,
|
||||
elevationLossLimit: filterValues.max_elevation_gain,
|
||||
sort: "created",
|
||||
sortOrder: "+",
|
||||
};
|
||||
|
||||
@@ -19,6 +19,9 @@ export const load: ServerLoad = async ({ params, locals, url, fetch }) => {
|
||||
elevationGainMin: 0,
|
||||
elevationGainMax: filterValues.max_elevation_gain,
|
||||
elevationGainLimit: filterValues.max_elevation_gain,
|
||||
elevationLossMin: 0,
|
||||
elevationLossMax: filterValues.max_elevation_loss,
|
||||
elevationLossLimit: filterValues.max_elevation_loss,
|
||||
sort: "created",
|
||||
sortOrder: "+",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user