diff --git a/web/src/lib/components/trail/routing_options_popup.svelte b/web/src/lib/components/trail/routing_options_popup.svelte index 45aafde2..356e5028 100644 --- a/web/src/lib/components/trail/routing_options_popup.svelte +++ b/web/src/lib/components/trail/routing_options_popup.svelte @@ -1,7 +1,7 @@ -
+
@@ -107,10 +109,27 @@ disabled={!options.autoRouting} onclick={() => (showSettings = !showSettings)} aria-label="Toggle routing settings" - > +
+
+ +
- {#if showSettings}
{#if options.modeOfTransport === "pedestrian" && options.pedestrianOptions} diff --git a/web/src/lib/i18n/locales/de.json b/web/src/lib/i18n/locales/de.json index ced44172..0b83c25b 100644 --- a/web/src/lib/i18n/locales/de.json +++ b/web/src/lib/i18n/locales/de.json @@ -278,7 +278,9 @@ "removed-trail-from": "Route entfernt aus", "removed-trails-from": "Routen entfernt aus", "required": "Pflichtfeld", + "reset": "", "reset-password": "Passwort zurücksetzen", + "reverse-direction": "Reverse direction", "road": "Straße", "route": "{n, plural, =1 {Route} other {Routen}}", "route-point": "Punkt auf Route", @@ -349,12 +351,12 @@ "upload-gpx": "GPX hochladen", "upload-new-file": "Neue Datei hochladen", "uploaded": "hochgeladen", - "use-hills": "", + "use-hills": "Hügel einbeziehen", "use-roads": "Nutze Straßen", "username": "Nutzername", "view": "Ansehen", "visibilty-status": "Sichtbarkeit", - "walking-speed": "", + "walking-speed": "Laufgeschwindigkeit", "waypoints": "{n, plural, =1 {Wegpunkt} other {Wegpunkte}}", "welcome_to": "Willkommen bei", "width": "Breite", diff --git a/web/src/lib/i18n/locales/en.json b/web/src/lib/i18n/locales/en.json index d91e3316..bb4e6295 100644 --- a/web/src/lib/i18n/locales/en.json +++ b/web/src/lib/i18n/locales/en.json @@ -278,7 +278,9 @@ "removed-trail-from": "Removed trail from", "removed-trails-from": "Removed trails from", "required": "Required", + "reset": "Reset", "reset-password": "Reset Password", + "reverse-direction": "", "road": "Road", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", @@ -349,12 +351,12 @@ "upload-gpx": "Upload GPX", "upload-new-file": "Upload new file", "uploaded": "uploaded", - "use-hills": "", + "use-hills": "Use hills", "use-roads": "Use Roads", "username": "Username", "view": "View", "visibilty-status": "Visibility status", - "walking-speed": "", + "walking-speed": "Walking speed", "waypoints": "{n, plural, =1 {Waypoint} other {Waypoints}}", "welcome_to": "Welcome to", "width": "Width", diff --git a/web/src/lib/i18n/locales/es.json b/web/src/lib/i18n/locales/es.json index 2258553a..b4a6176e 100644 --- a/web/src/lib/i18n/locales/es.json +++ b/web/src/lib/i18n/locales/es.json @@ -278,7 +278,9 @@ "removed-trail-from": "Ruta borrada de", "removed-trails-from": "Rutas borrada de", "required": "Obligatorio", + "reset": "", "reset-password": "Restablecer Contraseña", + "reverse-direction": "", "road": "Carretera", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", diff --git a/web/src/lib/i18n/locales/eu.json b/web/src/lib/i18n/locales/eu.json index 05dac9c5..587af6e4 100644 --- a/web/src/lib/i18n/locales/eu.json +++ b/web/src/lib/i18n/locales/eu.json @@ -278,7 +278,9 @@ "removed-trail-from": "Removed trail from", "removed-trails-from": "Removed trails from", "required": "Required", + "reset": "", "reset-password": "Reset Password", + "reverse-direction": "", "road": "Road", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", diff --git a/web/src/lib/i18n/locales/fr.json b/web/src/lib/i18n/locales/fr.json index 017ce8d0..12526b22 100644 --- a/web/src/lib/i18n/locales/fr.json +++ b/web/src/lib/i18n/locales/fr.json @@ -278,7 +278,9 @@ "removed-trail-from": "Enlever l'itinéraire de", "removed-trails-from": "Enlever les itinéraires de", "required": "Requis", + "reset": "", "reset-password": "Réinitialiser le mot de passe", + "reverse-direction": "", "road": "Route", "route": "{n, plural, =1 {Itinéraire} other {Itinéraires}}", "route-point": "Étape", diff --git a/web/src/lib/i18n/locales/hu.json b/web/src/lib/i18n/locales/hu.json index 3116983a..d04fe217 100644 --- a/web/src/lib/i18n/locales/hu.json +++ b/web/src/lib/i18n/locales/hu.json @@ -278,7 +278,9 @@ "removed-trail-from": "Eltávolított nyomvonal a", "removed-trails-from": "Eltávolított nyomvonalak a", "required": "Kötelező", + "reset": "", "reset-password": "Reset Password", + "reverse-direction": "", "road": "Road", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", diff --git a/web/src/lib/i18n/locales/it.json b/web/src/lib/i18n/locales/it.json index 92f8ad8c..48f60377 100644 --- a/web/src/lib/i18n/locales/it.json +++ b/web/src/lib/i18n/locales/it.json @@ -278,7 +278,9 @@ "removed-trail-from": "Percorso rimosso da", "removed-trails-from": "Percorsi rimosso da", "required": "Obbligatorio", + "reset": "", "reset-password": "Ripristinare Password", + "reverse-direction": "", "road": "Road", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", diff --git a/web/src/lib/i18n/locales/nl.json b/web/src/lib/i18n/locales/nl.json index 9a309384..0574121b 100644 --- a/web/src/lib/i18n/locales/nl.json +++ b/web/src/lib/i18n/locales/nl.json @@ -278,7 +278,9 @@ "removed-trail-from": "Route verwijderd van", "removed-trails-from": "Routes verwijderd van", "required": "Verplicht", + "reset": "", "reset-password": "Wachtwoord opnieuw instellen", + "reverse-direction": "", "road": "Weg", "route": "{n, plural,=1 {Tocht} other {Tochten}}", "route-point": "Routepunt", diff --git a/web/src/lib/i18n/locales/pl.json b/web/src/lib/i18n/locales/pl.json index 76f535f3..d45379e3 100644 --- a/web/src/lib/i18n/locales/pl.json +++ b/web/src/lib/i18n/locales/pl.json @@ -278,7 +278,9 @@ "removed-trail-from": "Usunięto szlak z", "removed-trails-from": "Usunięto szlaki z", "required": "Wymagane", + "reset": "", "reset-password": "Resetuj hasło", + "reverse-direction": "", "road": "Road", "route": "{n, plural,=1 {Trasa} other {Trasy}}", "route-point": "Punkt trasy", diff --git a/web/src/lib/i18n/locales/pt.json b/web/src/lib/i18n/locales/pt.json index f5de40d5..c0e311e3 100644 --- a/web/src/lib/i18n/locales/pt.json +++ b/web/src/lib/i18n/locales/pt.json @@ -278,7 +278,9 @@ "removed-trail-from": "Trilha removida de", "removed-trails-from": "Trilhos removidos de", "required": "Obrigatório", + "reset": "", "reset-password": "Reset Password", + "reverse-direction": "", "road": "Road", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", diff --git a/web/src/lib/i18n/locales/ru.json b/web/src/lib/i18n/locales/ru.json index 039c66a7..37476156 100644 --- a/web/src/lib/i18n/locales/ru.json +++ b/web/src/lib/i18n/locales/ru.json @@ -278,7 +278,9 @@ "removed-trail-from": "Трек удалён из", "removed-trails-from": "Removed trails from", "required": "Обязательно", + "reset": "", "reset-password": "Сбросить пароль", + "reverse-direction": "", "road": "Шоссе", "route": "{n, plural, =1 {Маршрут} other {Маршрутов}}", "route-point": "Точка маршрута", diff --git a/web/src/lib/i18n/locales/zh.json b/web/src/lib/i18n/locales/zh.json index 9c8db757..be0e7bc4 100644 --- a/web/src/lib/i18n/locales/zh.json +++ b/web/src/lib/i18n/locales/zh.json @@ -278,7 +278,9 @@ "removed-trail-from": "路线已删除自", "removed-trails-from": "路线已删除自", "required": "必填", + "reset": "", "reset-password": "重置密码", + "reverse-direction": "", "road": "Road", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", diff --git a/web/src/lib/models/gpx/gpx.ts b/web/src/lib/models/gpx/gpx.ts index d01301ea..a62c55df 100644 --- a/web/src/lib/models/gpx/gpx.ts +++ b/web/src/lib/models/gpx/gpx.ts @@ -148,7 +148,7 @@ export default class GPX { distance: totalDistance, elevationGain: totalElevationGain, elevationLoss: totalElevationLoss, - duration: totalDuration, + duration: Math.abs(totalDuration), hash: this.generateMinHash(allPoints) } } diff --git a/web/src/lib/stores/valhalla_store.ts b/web/src/lib/stores/valhalla_store.ts index 765ce205..eef3ecf3 100644 --- a/web/src/lib/stores/valhalla_store.ts +++ b/web/src/lib/stores/valhalla_store.ts @@ -5,6 +5,8 @@ import Waypoint from "$lib/models/gpx/waypoint"; import { type RoutingOptions, type ValhallaAnchor, type ValhallaHeightResponse, type ValhallaRouteResponse } from "$lib/models/valhalla"; import { APIError } from "$lib/util/api_util"; import { decodePolyline, encodePolyline } from "$lib/util/polyline_util"; +import { get } from "svelte/store"; +import { _ } from "svelte-i18n"; const emtpyTrack: Track = { trkseg: [] } @@ -100,6 +102,49 @@ export function deleteFromRoute(index: number) { route.features = route.getTotals(); } +export function reverseRoute() { + for (const trk of route.trk ?? []) { + for (const seg of trk.trkseg ?? []) { + seg.trkpt?.reverse() + } + trk.trkseg?.reverse() + } + route.trk?.reverse() + + route.features = route.getTotals(); + + anchors.reverse(); + + anchors.forEach((a, i) => { + if (!a.marker) { + return; + } + a.marker.getElement().textContent = "" + (i + 1); + + const anchorPopupHeading = a.marker + .getPopup() + ._content.getElementsByTagName("h5")[0]; + if (anchorPopupHeading) { + anchorPopupHeading.textContent = + get(_)("route-point") + " #" + (i + 1); + } + }); +} + +export function resetRoute() { + route = new GPX({ trk: [emtpyTrack] }); + + anchors.forEach((a) => { + if(!a.marker) { + return; + } + + a.marker.remove(); + }) + + anchors = [] +} + export function normalizeRouteTime() { let currentTime = new Date(); @@ -114,8 +159,8 @@ export function normalizeRouteTime() { const offset = (wp.time?.getTime() ?? 0) - baseTime; const adjustedTime = new Date(currentTime.getTime() + offset); - wp.time = adjustedTime + wp.time = adjustedTime } currentTime = new Date(seg.trkpt[seg.trkpt.length - 1].time!.getTime()); - } + } } \ No newline at end of file diff --git a/web/src/routes/trail/edit/[id]/+page.svelte b/web/src/routes/trail/edit/[id]/+page.svelte index bb1fbae2..adc69f6b 100644 --- a/web/src/routes/trail/edit/[id]/+page.svelte +++ b/web/src/routes/trail/edit/[id]/+page.svelte @@ -42,6 +42,8 @@ editRoute, insertIntoRoute, normalizeRouteTime, + resetRoute, + reverseRoute, route, setRoute, } from "$lib/stores/valhalla_store"; @@ -854,6 +856,18 @@ } } + function reverseTrail() { + reverseRoute(); + + updateTrailWithRouteData(); + } + + function resetTrail() { + resetRoute(); + + updateTrailWithRouteData(); + } + function updateTrailWithRouteData() { overwriteGPX = true; const totals = route.features; @@ -1120,7 +1134,7 @@ > @@ -1276,9 +1290,12 @@
-
{/if}