From 60be2f65e43e586f488b7fbe6098f8111ab8d5c1 Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Sat, 29 Mar 2025 12:50:59 +0100 Subject: [PATCH] adds routing options --- web/src/lib/components/base/slider.svelte | 9 +- .../trail/routing_options_popup.svelte | 271 ++++++++++++++++++ web/src/lib/i18n/locales/de.json | 17 ++ web/src/lib/i18n/locales/en.json | 17 ++ web/src/lib/i18n/locales/es.json | 17 ++ web/src/lib/i18n/locales/fr.json | 17 ++ web/src/lib/i18n/locales/hu.json | 17 ++ web/src/lib/i18n/locales/it.json | 17 ++ web/src/lib/i18n/locales/nl.json | 17 ++ web/src/lib/i18n/locales/pl.json | 17 ++ web/src/lib/i18n/locales/pt.json | 17 ++ web/src/lib/i18n/locales/zh.json | 17 ++ web/src/lib/models/valhalla.ts | 82 ++++++ web/src/lib/stores/valhalla_store.ts | 18 +- web/src/routes/trail/edit/[id]/+page.svelte | 55 ++-- 15 files changed, 562 insertions(+), 43 deletions(-) create mode 100644 web/src/lib/components/trail/routing_options_popup.svelte diff --git a/web/src/lib/components/base/slider.svelte b/web/src/lib/components/base/slider.svelte index ea640f68..c565925b 100644 --- a/web/src/lib/components/base/slider.svelte +++ b/web/src/lib/components/base/slider.svelte @@ -2,6 +2,7 @@ import noUiSlider from "nouislider"; import "nouislider/dist/nouislider.css"; import { onMount } from "svelte"; + import { type Options as SliderOptions } from "nouislider"; interface Props { minValue?: number; @@ -15,7 +16,8 @@ maxValue = 100, currentValue = $bindable(maxValue / 2), onset, - }: Props = $props(); + ...sliderOptions + }: Props & Partial = $props(); let sliderContainer: any = $state(); @@ -27,6 +29,7 @@ noUiSlider.create(sliderContainer, { start: currentValue, connect: [true, false], + ...sliderOptions, range: { min: minValue, max: maxValue, @@ -39,6 +42,10 @@ onset?.(currentValue); }); }); + + export function set(value: number) { + sliderContainer.noUiSlider.set(value) + }
diff --git a/web/src/lib/components/trail/routing_options_popup.svelte b/web/src/lib/components/trail/routing_options_popup.svelte new file mode 100644 index 00000000..538fb5e5 --- /dev/null +++ b/web/src/lib/components/trail/routing_options_popup.svelte @@ -0,0 +1,271 @@ + + +
+ +
+ + +
+ + {#if showSettings} +
+ {#if options.modeOfTransport === "pedestrian" && options.pedestrianOptions} +

{$_("walking-speed")}

+ +

+ {formatSpeed( + options.pedestrianOptions.walking_speed! / 3.6, + )} +

+
+

{$_("use-hills")}

+ +

+ {options.pedestrianOptions.use_hills?.toFixed(2)} +

+
+

{$_("max-hiking-difficulty")}

+ +

+ {options.pedestrianOptions.max_hiking_difficulty?.toFixed( + 0, + )} +

+
+ + {:else if options.modeOfTransport === "bicycle" && options.bicycleOptions} + +
+

{$_("cycling-speed")}

+ +

+ {formatSpeed(options.bicycleOptions.cycling_speed! / 3.6)} +

+
+

{$_("use-hills")}

+ +

+ {options.bicycleOptions.use_hills?.toFixed(2)} +

+
+

{$_("use-roads")}

+ +

+ {options.bicycleOptions.use_roads?.toFixed(2)} +

+
+

{$_("avoid-bad-surfaces")}

+ +

+ {options.bicycleOptions.avoid_bad_surfaces?.toFixed(0)} +

+
+ + {:else if options.modeOfTransport === "auto" && options.autoOptions} +

{$_("fixed-speed")}

+ +

+ {formatSpeed(options.autoOptions.fixed_speed! / 3.6)} +

+
+

{$_("top-speed")}

+ +

+ {formatSpeed(options.autoOptions.top_speed! / 3.6)} +

+
+

{$_("width")}

+ +

+ {options.autoOptions.width?.toFixed(1)} +

+
+

{$_("height")}

+ +

+ {options.autoOptions.height?.toFixed(1)} +

+
+ + {/if} +
+ {/if} +
diff --git a/web/src/lib/i18n/locales/de.json b/web/src/lib/i18n/locales/de.json index 75a8befc..19d66bd3 100644 --- a/web/src/lib/i18n/locales/de.json +++ b/web/src/lib/i18n/locales/de.json @@ -23,10 +23,12 @@ "author": "Autor", "avatar": "Avatar", "average-speed": "Durchschn. Geschwindigkeit", + "avoid-bad-surfaces": "", "back": "Zurück", "back-to-login": "Zurück zum Login", "basic-info": "Basisinformation", "before": "Vor", + "bike-type": "", "by": "von", "can": "kann", "cancel": "Abbrechen", @@ -55,8 +57,10 @@ "create-new-list": "Neue Liste erstellen", "create-waypoint": "Wegpunkt erstellen", "creation-date": "Erstellungsdatum", + "cross": "", "current-password": "Aktuelles Passwort", "cycling": "Radfahren", + "cycling-speed": "", "danger-zone": "Gefahrenzone", "date": "Datum", "default-category": "Standard Kategorie", @@ -95,6 +99,7 @@ "empty-activities": "{username} hat noch keine Aktivitäten", "empty-bio": "{username} hat noch keine Biographie hinzugefügt", "empty-lists": "{username} hat keine öffentlichen Listen", + "enable-auto-routing": "Enable auto-routing", "english": "Englisch", "entry": "Eintrag", "error-creating-user": "Fehler beim Erstellen des Nutzers", @@ -124,6 +129,7 @@ "filter-difficulty": "Schwierigkeit filtern", "filter-tags": "Tags filtern", "finish": "Ziel", + "fixed-speed": "", "focus-map-on": "Karte fokussieren auf", "follow": "Folgen", "followers": "Follower", @@ -135,6 +141,7 @@ "german": "Deutsch", "get-position-from-exif": "Koordinaten aus EXIF Daten", "grid": "Gitter", + "height": "", "help": "Hilfe", "hero_section_0_text": "Entdecke spannende Routen, speichere deine Favoriten und erlebe die Schönheit der Natur. Finde dein nächstes Abenteuer!", "hero_section_1_heading": "Hier gibt es noch keine Routen.", @@ -143,6 +150,7 @@ "hero_section_2_text": "Wusstest du schon? Du kannst nicht nur deine Routen speichern. Es gibt viele Kategorien für alle deine Abenteuer.", "hiking": "Wandern", "hungarian": "Ungarisch", + "hybrid": "", "icon": "Icon", "imperial": "Amerikanisch", "import": "Importieren", @@ -176,8 +184,10 @@ "make-one": "Neues erstellen!", "make-thumbnail": "Thumbnail festlegen", "map": "Karte", + "max-hiking-difficulty": "", "metric": "Metrisch", "moderate": "Mittel", + "mountain": "", "must-be-at-least-n-characters-long": "Muss mindestens {n} Zeichen lang sein", "must-be-at-most-n-characters-long": "Darf höchstens {n} Zeichen lang sein", "my-account": "Mein Konto", @@ -244,6 +254,7 @@ "removed-trail-from": "Route entfernt aus", "required": "Pflichtfeld", "reset-password": "Passwort zurücksetzen", + "road": "", "route": "{n, plural, =1 {Route} other {Routen}}", "route-point": "Routenpunkt", "save": "Speichern", @@ -276,6 +287,7 @@ "shared": "Geteilt", "shared-by": "Geteilt von", "shared-with": "Geteilt mit", + "shortest": "Shortest", "show-in-overview": "In der Übersicht anzeigen", "show-on-map": "Auf der Karte anzeigen", "slogan": "Speichere deine Abenteuer!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "Text", "tilesets": "Tilesets", + "top-speed": "", "trail": "{n, plural, =1 {Route} other {Routen}}", "trail-not-shared": "Route mit niemandem geteilt", "trail-saved-successfully": "Route gespeichert", @@ -303,10 +316,14 @@ "upload-gpx": "GPX hochladen", "upload-new-file": "Neue Datei hochladen", "uploaded": "hochgeladen", + "use-hills": "Use Hills", + "use-roads": "", "username": "Nutzername", "view": "Ansehen", + "walking-speed": "Walking Speed", "waypoints": "{n, plural, =1 {Wegpunkt} other {Wegpunkte}}", "welcome_to": "Willkommen bei", + "width": "", "wrong-username-or-password": "Falscher Nutzername oder falsches Passwort", "you-can": "Du kannst" } diff --git a/web/src/lib/i18n/locales/en.json b/web/src/lib/i18n/locales/en.json index 0beb4c93..479fd986 100644 --- a/web/src/lib/i18n/locales/en.json +++ b/web/src/lib/i18n/locales/en.json @@ -23,10 +23,12 @@ "author": "Author", "avatar": "Avatar", "average-speed": "Avg. Speed", + "avoid-bad-surfaces": "Avoid Bad Surfaces", "back": "Back", "back-to-login": "Back to Login", "basic-info": "Basic Info", "before": "Before", + "bike-type": "Bike Type", "by": "by", "can": "can", "cancel": "Cancel", @@ -55,8 +57,10 @@ "create-new-list": "Create new list", "create-waypoint": "Create waypoint", "creation-date": "Creation date", + "cross": "Cross", "current-password": "Current password", "cycling": "Cycling", + "cycling-speed": "Cycling Speed", "danger-zone": "Danger zone", "date": "Date", "default-category": "Default category", @@ -95,6 +99,7 @@ "empty-activities": "{username} has no activity yet", "empty-bio": "{username} has not added a bio yet", "empty-lists": "{username} has no public lists", + "enable-auto-routing": "", "english": "English", "entry": "Entry", "error-creating-user": "Error creating user", @@ -124,6 +129,7 @@ "filter-difficulty": "Filter difficulty", "filter-tags": "Filter tags", "finish": "Finish", + "fixed-speed": "Fixed Speed", "focus-map-on": "Focus map on", "follow": "Follow", "followers": "Followers", @@ -135,6 +141,7 @@ "german": "German", "get-position-from-exif": "Get coordinates from EXIF data", "grid": "Grid", + "height": "Height", "help": "Help", "hero_section_0_text": "Explore exciting trails, save your favorites, and experience the beauty of nature. Find your next adventure!", "hero_section_1_heading": "It seems there are no trails here yet.", @@ -143,6 +150,7 @@ "hero_section_2_text": "Did you know? You cannot only save you hiking trails. There are many categories for all your adventures.", "hiking": "Hiking", "hungarian": "Hungarian", + "hybrid": "Hybrid", "icon": "Icon", "imperial": "Imperial", "import": "Import", @@ -176,8 +184,10 @@ "make-one": "Make one!", "make-thumbnail": "Make thumbnail", "map": "Map", + "max-hiking-difficulty": "Max. Hiking Difficulty", "metric": "Metric", "moderate": "Moderate", + "mountain": "Mountain", "must-be-at-least-n-characters-long": "Must be at least {n} characters long", "must-be-at-most-n-characters-long": "Must be at most {n} characters long", "my-account": "My Account", @@ -244,6 +254,7 @@ "removed-trail-from": "Removed trail from", "required": "Required", "reset-password": "Reset Password", + "road": "Road", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", "save": "Save", @@ -276,6 +287,7 @@ "shared": "Shared", "shared-by": "Shared by", "shared-with": "Shared with", + "shortest": "", "show-in-overview": "Show in overview", "show-on-map": "Show on map", "slogan": "Save your adventures!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "Text", "tilesets": "Custom tilesets", + "top-speed": "Top Speed", "trail": "{n, plural, =1 {Trail} other {Trails}}", "trail-not-shared": "Not shared with anyone", "trail-saved-successfully": "Trail saved successfully", @@ -303,10 +316,14 @@ "upload-gpx": "Upload GPX", "upload-new-file": "Upload new file", "uploaded": "uploaded", + "use-hills": "", + "use-roads": "Use Roads", "username": "Username", "view": "View", + "walking-speed": "", "waypoints": "{n, plural, =1 {Waypoint} other {Waypoints}}", "welcome_to": "Welcome to", + "width": "Width", "wrong-username-or-password": "Wrong username or password", "you-can": "You can" } diff --git a/web/src/lib/i18n/locales/es.json b/web/src/lib/i18n/locales/es.json index f8cdede2..880a47ee 100644 --- a/web/src/lib/i18n/locales/es.json +++ b/web/src/lib/i18n/locales/es.json @@ -23,10 +23,12 @@ "author": "Autor", "avatar": "Avatar", "average-speed": "Vel. Promedio", + "avoid-bad-surfaces": "", "back": "Atrás", "back-to-login": "Atrás al acceso", "basic-info": "Información básica", "before": "Antes", + "bike-type": "", "by": "de", "can": "puede", "cancel": "Borrar", @@ -55,8 +57,10 @@ "create-new-list": "Crear una nueva lista", "create-waypoint": "Create waypoint", "creation-date": "Fecha de creación", + "cross": "", "current-password": "Contraseña actual", "cycling": "Ciclismo", + "cycling-speed": "", "danger-zone": "Zona peligrosa", "date": "Fecha", "default-category": "Categoría predefinida", @@ -95,6 +99,7 @@ "empty-activities": "{username} todavía no tiene actividad", "empty-bio": "{username} no ha añadido ninguna Bio todavía", "empty-lists": "{username} no tiene listas públicas", + "enable-auto-routing": "", "english": "Inglés", "entry": "Entrada", "error-creating-user": "Error creando el usuario", @@ -124,6 +129,7 @@ "filter-difficulty": "Filtrar dificultad", "filter-tags": "Filter tags", "finish": "Finish", + "fixed-speed": "", "focus-map-on": "Centrar mapa sobre", "follow": "Seguir", "followers": "Seguidores", @@ -135,6 +141,7 @@ "german": "Alemán", "get-position-from-exif": "Obtener las coordenadas de los datos EXIF", "grid": "Cuadricula", + "height": "", "help": "Ayuda", "hero_section_0_text": "Explorar rutas emocionantes, guarda tus favoritas y disfruta de la belleza de la natura. ¡Encuentra tu próxima aventura!", "hero_section_1_heading": "Parece que todavía no hay rutas.", @@ -143,6 +150,7 @@ "hero_section_2_text": "¿Lo sabías? No solo puedes guardar tus rutas de senderismo. Hay muchas categorías para todas tus aventuras.", "hiking": "Senderismo", "hungarian": "Húngaro", + "hybrid": "", "icon": "Icono", "imperial": "Imperial", "import": "Importar", @@ -176,8 +184,10 @@ "make-one": "¡Crea uno!", "make-thumbnail": "Generar miniaturas", "map": "Mapa", + "max-hiking-difficulty": "", "metric": "Métrica", "moderate": "Medio", + "mountain": "", "must-be-at-least-n-characters-long": "Tiene que tener por lo menos {n} caracteres", "must-be-at-most-n-characters-long": "Must be at most {n} characters long", "my-account": "Mi cuenta", @@ -244,6 +254,7 @@ "removed-trail-from": "Ruta borrada de", "required": "Obligatorio", "reset-password": "Restablecer Contraseña", + "road": "", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", "save": "Guardar", @@ -276,6 +287,7 @@ "shared": "Compartido", "shared-by": "Compartido por", "shared-with": "Compartido con", + "shortest": "", "show-in-overview": "Mostrar en la panorámica", "show-on-map": "Mostrar en mapa", "slogan": "¡Guarda tus aventuras!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "Texto", "tilesets": "Ficha personalizada", + "top-speed": "", "trail": "{n, plural, one {}=1 {Ruta} other {Rutas}}", "trail-not-shared": "No compartida con nadie", "trail-saved-successfully": "Ruta guardada con éxito", @@ -303,10 +316,14 @@ "upload-gpx": "Cargar GPX", "upload-new-file": "Upload new file", "uploaded": "cargado", + "use-hills": "", + "use-roads": "", "username": "Nombre de usuario", "view": "Ver", + "walking-speed": "", "waypoints": "{n, plural, one {}=1 {Punto de Interés} other {Puntos de Interés}}", "welcome_to": "Bienvenid@ a", + "width": "", "wrong-username-or-password": "Usuario o contraseña no correctas", "you-can": "Puedes" } diff --git a/web/src/lib/i18n/locales/fr.json b/web/src/lib/i18n/locales/fr.json index f293f828..dd845717 100644 --- a/web/src/lib/i18n/locales/fr.json +++ b/web/src/lib/i18n/locales/fr.json @@ -23,10 +23,12 @@ "author": "Auteur", "avatar": "Avatar", "average-speed": "Vitesse Moy.", + "avoid-bad-surfaces": "", "back": "Retour", "back-to-login": "Retour à la page de connexion", "basic-info": "Informations de base", "before": "Avant le", + "bike-type": "", "by": "par", "can": "peut", "cancel": "Annuler", @@ -55,8 +57,10 @@ "create-new-list": "Créer une nouvelle liste", "create-waypoint": "Créer un point de passage", "creation-date": "Date de création", + "cross": "", "current-password": "Mot de passe actuel", "cycling": "Vélo", + "cycling-speed": "", "danger-zone": "Zone de danger", "date": "Date", "default-category": "Catégorie par défaut", @@ -95,6 +99,7 @@ "empty-activities": "{username} n'a encore aucune activité", "empty-bio": "{username} n'a pas encore de description", "empty-lists": "{username} n'a pas de liste publique", + "enable-auto-routing": "", "english": "Anglais", "entry": "Entrée", "error-creating-user": "Erreur durant la création de l'utilisateur", @@ -124,6 +129,7 @@ "filter-difficulty": "Filtrer par difficulté", "filter-tags": "Filtrer par étiquettes", "finish": "Arrivée", + "fixed-speed": "", "focus-map-on": "Centrer la carte sur", "follow": "Suivre", "followers": "Abonné(e)s", @@ -135,6 +141,7 @@ "german": "Allemand", "get-position-from-exif": "Obtenir les coordonnées à partir des données EXIF", "grid": "Grille", + "height": "", "help": "Aide", "hero_section_0_text": "Explorez des itinéraires passionnants, sauvegardez vos favoris et découvrez la beauté de la nature. Trouvez votre prochaine aventure !", "hero_section_1_heading": "Il semble qu'il n'y ait pas encore d'itinéraire ici.", @@ -143,6 +150,7 @@ "hero_section_2_text": "Saviez-vous que vous pouvez sauvegarder plus que vos randonnées ? De nombreuses catégories sont disponibles pour toutes vos aventures.", "hiking": "Randonnée", "hungarian": "Hongrois", + "hybrid": "", "icon": "Icône", "imperial": "Impérial", "import": "Importer", @@ -176,8 +184,10 @@ "make-one": "Faites-en un !", "make-thumbnail": "Créer une miniature", "map": "Carte", + "max-hiking-difficulty": "", "metric": "Métrique", "moderate": "Moyenne", + "mountain": "", "must-be-at-least-n-characters-long": "Doit être composé d'au moins {n} caractères", "must-be-at-most-n-characters-long": "Doit être au maximum de {n} caractères", "my-account": "Mon profil", @@ -244,6 +254,7 @@ "removed-trail-from": "Enlever l'itinéraire de", "required": "Requis", "reset-password": "Réinitialiser le mot de passe", + "road": "", "route": "{n, plural, =1 {Itinéraire} other {Itinéraires}}", "route-point": "Étape", "save": "Sauvegarder", @@ -276,6 +287,7 @@ "shared": "Partagé", "shared-by": "Partagé par", "shared-with": "Partagé avec", + "shortest": "", "show-in-overview": "Voir dans l'aperçu", "show-on-map": "Voir sur la carte", "slogan": "Sauvegarder vos aventures !", @@ -293,6 +305,7 @@ "tags": "Étiquettes", "text": "Texte", "tilesets": "Tuiles personnalisés", + "top-speed": "", "trail": "{n, plural, =1 {Itinéraire} other {Itinéraires}}", "trail-not-shared": "L'itinéraire n'a pas été partagé", "trail-saved-successfully": "Itinéraire enregistrée", @@ -303,10 +316,14 @@ "upload-gpx": "Envoyer un GPX", "upload-new-file": "Importer un fichier", "uploaded": "importé", + "use-hills": "", + "use-roads": "", "username": "Nom d'utilisateur", "view": "Afficher", + "walking-speed": "", "waypoints": "{n, plural, =1 {Point de passage} other {Points de passage}}", "welcome_to": "Bienvenue sur", + "width": "", "wrong-username-or-password": "Nom d'utilisateur ou mot de passe incorrect", "you-can": "Vous pouvez" } diff --git a/web/src/lib/i18n/locales/hu.json b/web/src/lib/i18n/locales/hu.json index 84886dba..26284e5e 100644 --- a/web/src/lib/i18n/locales/hu.json +++ b/web/src/lib/i18n/locales/hu.json @@ -23,10 +23,12 @@ "author": "Author", "avatar": "Avatar", "average-speed": "Avg. Speed", + "avoid-bad-surfaces": "", "back": "Back", "back-to-login": "Back to Login", "basic-info": "Alap információk", "before": "Before", + "bike-type": "", "by": "by", "can": "can", "cancel": "Mégsem", @@ -55,8 +57,10 @@ "create-new-list": "Új lista létrehozása", "create-waypoint": "Create waypoint", "creation-date": "létrehozás dátuma", + "cross": "", "current-password": "Current password", "cycling": "Cycling", + "cycling-speed": "", "danger-zone": "Veszélyes zóna", "date": "Dátum", "default-category": "Default category", @@ -95,6 +99,7 @@ "empty-activities": "{username} has no activity yet", "empty-bio": "{username} has not added a bio yet", "empty-lists": "{username} has no public lists", + "enable-auto-routing": "", "english": "Angol", "entry": "Bejegyzés", "error-creating-user": "Hiba felhasználó hozzáadása közben", @@ -124,6 +129,7 @@ "filter-difficulty": "Filter difficulty", "filter-tags": "Filter tags", "finish": "Finish", + "fixed-speed": "", "focus-map-on": "Focus map on", "follow": "Follow", "followers": "Followers", @@ -135,6 +141,7 @@ "german": "Német", "get-position-from-exif": "Get coordinates from EXIF data", "grid": "Grid", + "height": "", "help": "Help", "hero_section_0_text": "Fedezze fel az izgalmas útvonalakat, mentse el kedvenceit, és tapasztalja meg a természet szépségét. Találja meg a következő kalandját!", "hero_section_1_heading": "Úgy tűnik, itt még nincsenek ösvények.", @@ -143,6 +150,7 @@ "hero_section_2_text": "Tudta? Nem csak a túraútvonalakat mentheti el. Számos kategória létezik minden kalandodhoz.", "hiking": "Hiking", "hungarian": "Magyar", + "hybrid": "", "icon": "Ikon", "imperial": "Angolszász", "import": "Import", @@ -176,8 +184,10 @@ "make-one": "Készítsen egyet!", "make-thumbnail": "Készítsen miniatűrképet", "map": "Térkép", + "max-hiking-difficulty": "", "metric": "Metrikus", "moderate": "Mérsékelt", + "mountain": "", "must-be-at-least-n-characters-long": "Legalább {n} karakter hosszúnak kell lennie", "must-be-at-most-n-characters-long": "Must be at most {n} characters long", "my-account": "My Account", @@ -244,6 +254,7 @@ "removed-trail-from": "Eltávolított nyomvonal a", "required": "Kötelező", "reset-password": "Reset Password", + "road": "", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", "save": "Mentés", @@ -276,6 +287,7 @@ "shared": "Shared", "shared-by": "Shared by", "shared-with": "Shared with", + "shortest": "", "show-in-overview": "Áttekintés", "show-on-map": "Mutatás térképen", "slogan": "Mentse el a kalandjait!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "Szöveg", "tilesets": "Custom tilesets", + "top-speed": "", "trail": "{n, plural, =1 {Útvonal} other {Útvonalak}}", "trail-not-shared": "Not shared with anyone", "trail-saved-successfully": "Trail saved successfully", @@ -303,10 +316,14 @@ "upload-gpx": "GPX feltöltése", "upload-new-file": "Upload new file", "uploaded": "uploaded", + "use-hills": "", + "use-roads": "", "username": "Felhasználónév", "view": "View", + "walking-speed": "", "waypoints": "{n, plural, =1 {Waypoint} other {Waypoints}}", "welcome_to": "Üdvözöljük a", + "width": "", "wrong-username-or-password": "Helytelen felhasználónév vagy jelszó", "you-can": "You can" } diff --git a/web/src/lib/i18n/locales/it.json b/web/src/lib/i18n/locales/it.json index acff1fec..3492a92c 100644 --- a/web/src/lib/i18n/locales/it.json +++ b/web/src/lib/i18n/locales/it.json @@ -23,10 +23,12 @@ "author": "Autore", "avatar": "Avatar", "average-speed": "Vel. Media", + "avoid-bad-surfaces": "", "back": "Indietro", "back-to-login": "Indietro al Login", "basic-info": "Informazioni di base", "before": "Prima", + "bike-type": "", "by": "di", "can": "può", "cancel": "Annulla", @@ -55,8 +57,10 @@ "create-new-list": "Crea nuova lista", "create-waypoint": "Create waypoint", "creation-date": "Data di creazione", + "cross": "", "current-password": "Password attuale", "cycling": "Ciclismo", + "cycling-speed": "", "danger-zone": "Zona di pericolo", "date": "Data", "default-category": "Categoria predefinita", @@ -95,6 +99,7 @@ "empty-activities": "{username} non ha ancora attività", "empty-bio": "{username} non ha ancora aggiunto una biografia", "empty-lists": "{username} non ha liste pubbliche", + "enable-auto-routing": "", "english": "Inglese", "entry": "Voce", "error-creating-user": "Errore nella creazione dell'utente", @@ -124,6 +129,7 @@ "filter-difficulty": "Filtrare difficoltà", "filter-tags": "Filter tags", "finish": "Finish", + "fixed-speed": "", "focus-map-on": "Focus sulla mappa", "follow": "Seguire", "followers": "Seguaci", @@ -135,6 +141,7 @@ "german": "Tedesco", "get-position-from-exif": "Ottieni posizione da dati EXIF", "grid": "Griglia", + "height": "", "help": "Aiuto", "hero_section_0_text": "Scopri percorsi emozionanti, salva i tuoi preferiti e vivi la bellezza della natura. Trova la tua prossima avventura!", "hero_section_1_heading": "Non sembra esserci ancora un percorso qui.", @@ -143,6 +150,7 @@ "hero_section_2_text": "Lo sapevi? Non puoi salvare solo i tuoi percorsi. Ci sono molte categorie per tutte le tue avventure.", "hiking": "Escursionismo", "hungarian": "Ungherese", + "hybrid": "", "icon": "Icona", "imperial": "Imperiale", "import": "Importa", @@ -176,8 +184,10 @@ "make-one": "Creane uno!", "make-thumbnail": "Imposta miniatura", "map": "Mappa", + "max-hiking-difficulty": "", "metric": "Metrico", "moderate": "Moderato", + "mountain": "", "must-be-at-least-n-characters-long": "Deve essere lungo almeno {n} caratteri", "must-be-at-most-n-characters-long": "Must be at most {n} characters long", "my-account": "Il mio account", @@ -244,6 +254,7 @@ "removed-trail-from": "Percorso rimosso da", "required": "Obbligatorio", "reset-password": "Ripristinare Password", + "road": "", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", "save": "Salva", @@ -276,6 +287,7 @@ "shared": "Condiviso", "shared-by": "Condiviso da", "shared-with": "Condiviso con", + "shortest": "", "show-in-overview": "Mostra nella panoramica", "show-on-map": "Mostra sulla mappa", "slogan": "Salva le tue avventure!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "Testo", "tilesets": "Riquadri personalizzati", + "top-speed": "", "trail": "{n, plural, =1 {Percorso} other {Percorsi}}", "trail-not-shared": "Percorso non condiviso con nessuno", "trail-saved-successfully": "Percorso salvato con successo", @@ -303,10 +316,14 @@ "upload-gpx": "Carica file GPX", "upload-new-file": "Upload new file", "uploaded": "caricato", + "use-hills": "", + "use-roads": "", "username": "Nome utente", "view": "Visualizza", + "walking-speed": "", "waypoints": "{n, plural, =1 {Punto di passaggio} other {Punti di passaggio}}", "welcome_to": "Benvenuti a", + "width": "", "wrong-username-or-password": "Nome utente o password errati", "you-can": "Puoi" } diff --git a/web/src/lib/i18n/locales/nl.json b/web/src/lib/i18n/locales/nl.json index 377841d6..225bbf62 100644 --- a/web/src/lib/i18n/locales/nl.json +++ b/web/src/lib/i18n/locales/nl.json @@ -23,10 +23,12 @@ "author": "Author", "avatar": "Profielfoto", "average-speed": "Avg. Speed", + "avoid-bad-surfaces": "", "back": "Back", "back-to-login": "Terug naar login", "basic-info": "Algemene informatie", "before": "Before", + "bike-type": "", "by": "by", "can": "can", "cancel": "Annuleren", @@ -55,8 +57,10 @@ "create-new-list": "Nieuwe lijst", "create-waypoint": "Create waypoint", "creation-date": "Aanmaakdatum", + "cross": "", "current-password": "Huidig wachtwoord", "cycling": "Fietsen", + "cycling-speed": "", "danger-zone": "Gevarenzone", "date": "Datum", "default-category": "Standaardcategorie", @@ -95,6 +99,7 @@ "empty-activities": "{username} has no activity yet", "empty-bio": "{username} has not added a bio yet", "empty-lists": "{username} has no public lists", + "enable-auto-routing": "", "english": "Engels", "entry": "Item", "error-creating-user": "Het account kan niet worden aangemaakt", @@ -124,6 +129,7 @@ "filter-difficulty": "Filter difficulty", "filter-tags": "Filter tags", "finish": "Finish", + "fixed-speed": "", "focus-map-on": "Focus map on", "follow": "Follow", "followers": "Followers", @@ -135,6 +141,7 @@ "german": "Duits", "get-position-from-exif": "Get coordinates from EXIF data", "grid": "Rooster", + "height": "", "help": "Help", "hero_section_0_text": "Verken uitdagende wandelroutes, bewaar je favoriete en ervaar de pracht van de natuur. Op naar het volgende avontuur!", "hero_section_1_heading": "Je hebt nog geen wandelroutes.", @@ -143,6 +150,7 @@ "hero_section_2_text": "Wist je dat…? Je kunt niet alleen wandelroutes opslaan: er zijn ook categorieën voor andere avonturen.", "hiking": "Hiking", "hungarian": "Hongaars", + "hybrid": "", "icon": "Pictogram", "imperial": "Imperiaal", "import": "Import", @@ -176,8 +184,10 @@ "make-one": "Maak er een aan!", "make-thumbnail": "Miniatuur maken", "map": "Kaart", + "max-hiking-difficulty": "", "metric": "Metrisch", "moderate": "Gemiddeld", + "mountain": "", "must-be-at-least-n-characters-long": "Minimaal {n} tekens", "must-be-at-most-n-characters-long": "Must be at most {n} characters long", "my-account": "My Account", @@ -244,6 +254,7 @@ "removed-trail-from": "De wandelroute is verwijderd van", "required": "Verplicht", "reset-password": "Reset Password", + "road": "", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", "save": "Bewaren", @@ -276,6 +287,7 @@ "shared": "Shared", "shared-by": "Shared by", "shared-with": "Shared with", + "shortest": "", "show-in-overview": "Tonen op overzicht", "show-on-map": "Tonen op kaart", "slogan": "Bewaar je avonturen!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "Tekst", "tilesets": "Custom tilesets", + "top-speed": "", "trail": "{n, plural, =1 {Wandelroute} other {Wandelroutes}}", "trail-not-shared": "Not shared with anyone", "trail-saved-successfully": "Trail saved successfully", @@ -303,10 +316,14 @@ "upload-gpx": "GPX-bestand uploaden", "upload-new-file": "Upload new file", "uploaded": "uploaded", + "use-hills": "", + "use-roads": "", "username": "Gebruikersnaam", "view": "View", + "walking-speed": "", "waypoints": "{n, plural, =1 {Waypoint} other {Waypoints}}", "welcome_to": "Welkom bij", + "width": "", "wrong-username-or-password": "Onjuiste gebruikersnaam of wachtwoord", "you-can": "You can" } diff --git a/web/src/lib/i18n/locales/pl.json b/web/src/lib/i18n/locales/pl.json index 598668f9..2c65483a 100644 --- a/web/src/lib/i18n/locales/pl.json +++ b/web/src/lib/i18n/locales/pl.json @@ -23,10 +23,12 @@ "author": "Autor", "avatar": "Awatar", "average-speed": "Śr. prędkość", + "avoid-bad-surfaces": "", "back": "Wstecz", "back-to-login": "Powrót do logowania", "basic-info": "Podstawowe informacje", "before": "Przed", + "bike-type": "", "by": "przez", "can": "może", "cancel": "Anuluj", @@ -55,8 +57,10 @@ "create-new-list": "Stwórz nową listę", "create-waypoint": "Create waypoint", "creation-date": "Data dodania", + "cross": "", "current-password": "Obecne hasło", "cycling": "Rower", + "cycling-speed": "", "danger-zone": "Strefa niebezpieczna", "date": "Data", "default-category": "Domyślna kategoria", @@ -95,6 +99,7 @@ "empty-activities": "{username} nie ma jeszcze aktywności", "empty-bio": "{username} jeszcze nie dodał biogramu", "empty-lists": "{username} nie ma publicznych list", + "enable-auto-routing": "", "english": "Angielski", "entry": "Pozycja", "error-creating-user": "Błąd tworzenia użytkownika", @@ -124,6 +129,7 @@ "filter-difficulty": "Filtruj poziom trudności", "filter-tags": "Filter tags", "finish": "Zakończ", + "fixed-speed": "", "focus-map-on": "Skoncentruj mapę na", "follow": "Obserwuj", "followers": "Obserwujący", @@ -135,6 +141,7 @@ "german": "Niemiecki", "get-position-from-exif": "Odczytaj współrzędne z danych EXIF", "grid": "Siatka", + "height": "", "help": "Pomoc", "hero_section_0_text": "Eksploruj ekscytujące szlaki, zapisz swoje ulubione, doświadcz piękna naturalnego świata. Znajdź swoją następną przygodę!", "hero_section_1_heading": "Wygląda na to, że nie ma tutaj szlaków.", @@ -143,6 +150,7 @@ "hero_section_2_text": "Czy wiesz że, możesz zapisywać nie tylko piesze wycieczki ale także inne kategorie wypraw?", "hiking": "Wędrówka", "hungarian": "Język węgierski", + "hybrid": "", "icon": "Ikona", "imperial": "Anglosaskie", "import": "Importuj", @@ -176,8 +184,10 @@ "make-one": "Stwórz ją!", "make-thumbnail": "Zrób miniaturkę", "map": "Mapa", + "max-hiking-difficulty": "", "metric": "Metryczne", "moderate": "Średni", + "mountain": "", "must-be-at-least-n-characters-long": "Długość musi wynosić przynajmniej {n} znaków", "must-be-at-most-n-characters-long": "Must be at most {n} characters long", "my-account": "Moje konto", @@ -244,6 +254,7 @@ "removed-trail-from": "Usunięto szlak z", "required": "Wymagane", "reset-password": "Resetuj hasło", + "road": "", "route": "{n, plural,=1 {Trasa} other {Trasy}}", "route-point": "Punkt trasy", "save": "Zapisz", @@ -276,6 +287,7 @@ "shared": "Udostępniono", "shared-by": "Udostępniony przez", "shared-with": "Udostępniony dla", + "shortest": "", "show-in-overview": "Pokaż w przeglądzie", "show-on-map": "Pokaż na mapie", "slogan": "Zapisz swoją wyprawę!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "Tekst", "tilesets": "Niestandardowe zestawy płytek", + "top-speed": "", "trail": "{n, plural, one {Szlak} few {Szlaki} many {Szlaków}=1 {Szlak} other {Szlaki}}", "trail-not-shared": "Szlak nie udostępniony", "trail-saved-successfully": "Szlak pomyślnie zapisany", @@ -303,10 +316,14 @@ "upload-gpx": "Importuj GPX", "upload-new-file": "Prześlij nowy plik", "uploaded": "wgrany", + "use-hills": "", + "use-roads": "", "username": "Nazwa Użytkownika", "view": "Widok", + "walking-speed": "", "waypoints": "{n, plural, one {Punkt} few {Punkty} many {Punktów}=1 {Punkt} other {Punktów}}", "welcome_to": "Witaj w", + "width": "", "wrong-username-or-password": "Zła nazwa użytkownika lub hasło", "you-can": "Możesz" } diff --git a/web/src/lib/i18n/locales/pt.json b/web/src/lib/i18n/locales/pt.json index 473ce0ba..a482250f 100644 --- a/web/src/lib/i18n/locales/pt.json +++ b/web/src/lib/i18n/locales/pt.json @@ -23,10 +23,12 @@ "author": "Author", "avatar": "Avatar", "average-speed": "Vel. média", + "avoid-bad-surfaces": "", "back": "Back", "back-to-login": "Back to Login", "basic-info": "Informações básicas", "before": "Antes", + "bike-type": "", "by": "by", "can": "pode", "cancel": "Cancelar", @@ -55,8 +57,10 @@ "create-new-list": "Criar nova lista", "create-waypoint": "Create waypoint", "creation-date": "Data de criação", + "cross": "", "current-password": "Senha atual", "cycling": "Ciclismo", + "cycling-speed": "", "danger-zone": "Zona de perigo", "date": "Data", "default-category": "Categoria inicial", @@ -95,6 +99,7 @@ "empty-activities": "{username} has no activity yet", "empty-bio": "{username} has not added a bio yet", "empty-lists": "{username} has no public lists", + "enable-auto-routing": "", "english": "Inglês", "entry": "Entrada", "error-creating-user": "Erro ao criar utilizador", @@ -124,6 +129,7 @@ "filter-difficulty": "Filter difficulty", "filter-tags": "Filter tags", "finish": "Finish", + "fixed-speed": "", "focus-map-on": "Centrar mapa em", "follow": "Follow", "followers": "Followers", @@ -135,6 +141,7 @@ "german": "Alemão", "get-position-from-exif": "Obter coordenadas dos dados EXIF", "grid": "Grelha", + "height": "", "help": "Ajuda", "hero_section_0_text": "Explore trilhas emocionantes, salve seus favoritos e experimente a beleza da natureza. Encontre sua próxima aventura!", "hero_section_1_heading": "Parece que ainda não há trilhas aqui.", @@ -143,6 +150,7 @@ "hero_section_2_text": "Sabias? Você não pode apenas salvá-lo trilhas de caminhada. Há muitas categorias para todas as suas aventuras.", "hiking": "Montanhismo", "hungarian": "Húngaro", + "hybrid": "", "icon": "Ícone", "imperial": "Imperial", "import": "Importar", @@ -176,8 +184,10 @@ "make-one": "Faz um!", "make-thumbnail": "Faça miniatura", "map": "Mapa", + "max-hiking-difficulty": "", "metric": "Métrica", "moderate": "Moderado", + "mountain": "", "must-be-at-least-n-characters-long": "Deve ter pelo menos {n} caracteres", "must-be-at-most-n-characters-long": "Must be at most {n} characters long", "my-account": "A minha conta", @@ -244,6 +254,7 @@ "removed-trail-from": "Trilha removida de", "required": "Obrigatório", "reset-password": "Reset Password", + "road": "", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", "save": "Guardar", @@ -276,6 +287,7 @@ "shared": "Shared", "shared-by": "Partilhado por", "shared-with": "Partilhado com", + "shortest": "", "show-in-overview": "Mostrar na vista geral", "show-on-map": "Mostrar no mapa", "slogan": "Guarde as suas aventuras!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "Texto", "tilesets": "Camada de renderização personalizada", + "top-speed": "", "trail": "{n, plural, =1 {Percurso} other {Percursos}}", "trail-not-shared": "Não partilhado com ninguém", "trail-saved-successfully": "Percurso gravado com sucesso", @@ -303,10 +316,14 @@ "upload-gpx": "Carregar GPX", "upload-new-file": "Upload new file", "uploaded": "carregado", + "use-hills": "", + "use-roads": "", "username": "Nome de utilizador", "view": "Ver", + "walking-speed": "", "waypoints": "{n, plural, =1 {Ponto de passagem} other {Pontos de passagem}}", "welcome_to": "Bem-vindo ao", + "width": "", "wrong-username-or-password": "Nome de utilizador ou palavra-passe errados", "you-can": "Podes" } diff --git a/web/src/lib/i18n/locales/zh.json b/web/src/lib/i18n/locales/zh.json index f66bee47..29fda8dd 100644 --- a/web/src/lib/i18n/locales/zh.json +++ b/web/src/lib/i18n/locales/zh.json @@ -23,10 +23,12 @@ "author": "作者", "avatar": "头像", "average-speed": "平均速度", + "avoid-bad-surfaces": "", "back": "返回", "back-to-login": "Back to Login", "basic-info": "基本信息", "before": "之前", + "bike-type": "", "by": "by", "can": "可以", "cancel": "取消", @@ -55,8 +57,10 @@ "create-new-list": "创建新列表", "create-waypoint": "Create waypoint", "creation-date": "创建日期", + "cross": "", "current-password": "当前密码", "cycling": "骑行", + "cycling-speed": "", "danger-zone": "危险区域", "date": "日期", "default-category": "默认分类", @@ -95,6 +99,7 @@ "empty-activities": "{username} has no activity yet", "empty-bio": "{username} has not added a bio yet", "empty-lists": "{username} has no public lists", + "enable-auto-routing": "", "english": "英语", "entry": "日程", "error-creating-user": "创建用户错误", @@ -124,6 +129,7 @@ "filter-difficulty": "Filter difficulty", "filter-tags": "Filter tags", "finish": "Finish", + "fixed-speed": "", "focus-map-on": "地图聚焦于", "follow": "Follow", "followers": "Followers", @@ -135,6 +141,7 @@ "german": "德语", "get-position-from-exif": "从EXIF数据获取坐标", "grid": "网格", + "height": "", "help": "帮助", "hero_section_0_text": "探索激动人心的探险,收藏最爱行程,体验美丽地大自然。找到你的下一次冒险!", "hero_section_1_heading": "这儿似乎还没有行程。", @@ -143,6 +150,7 @@ "hero_section_2_text": "你知道吗?这里不仅仅可以收藏你的登山路线,还能为您的所有冒险放到相应的类别里面。", "hiking": "徒步", "hungarian": "匈牙利语", + "hybrid": "", "icon": "图标", "imperial": "英制", "import": "导入", @@ -176,8 +184,10 @@ "make-one": "立刻注册!", "make-thumbnail": "生成缩略图", "map": "地图", + "max-hiking-difficulty": "", "metric": "公制", "moderate": "中等", + "mountain": "", "must-be-at-least-n-characters-long": "长度至少 {n} 字符", "must-be-at-most-n-characters-long": "Must be at most {n} characters long", "my-account": "我的账户", @@ -244,6 +254,7 @@ "removed-trail-from": "路线已删除自", "required": "必填", "reset-password": "重置密码", + "road": "", "route": "{n, plural, =1 {Route} other {Routes}}", "route-point": "Route Point", "save": "保存", @@ -276,6 +287,7 @@ "shared": "Shared", "shared-by": "分享自", "shared-with": "分享给", + "shortest": "", "show-in-overview": "详情中展示", "show-on-map": "地图中展示", "slogan": "保存你的冒险!", @@ -293,6 +305,7 @@ "tags": "Tags", "text": "文本", "tilesets": "自定义地图图层", + "top-speed": "", "trail": "{n, plural, =1 {路线} other {路线}}", "trail-not-shared": "未与任何人分享", "trail-saved-successfully": "路线保存成功", @@ -303,10 +316,14 @@ "upload-gpx": "上传 GPX", "upload-new-file": "Upload new file", "uploaded": "已上传", + "use-hills": "", + "use-roads": "", "username": "用户名", "view": "查看", + "walking-speed": "", "waypoints": "{n, plural, =1 {路点} other {路点}}", "welcome_to": "欢迎", + "width": "", "wrong-username-or-password": "用户名或密码无效", "you-can": "你可以" } diff --git a/web/src/lib/models/valhalla.ts b/web/src/lib/models/valhalla.ts index 7de280e6..192f3dc4 100644 --- a/web/src/lib/models/valhalla.ts +++ b/web/src/lib/models/valhalla.ts @@ -1,5 +1,87 @@ import * as M from "maplibre-gl"; + +interface ValhallaCostingOptions { + shortest?: boolean +} + +export interface ValhallaPedestrianCostingOptions extends ValhallaCostingOptions { + use_ferry?: number + use_living_streets?: number + use_tracks?: number + service_penalty?: number + service_factor?: number + use_hills?: number + walking_speed?: number + walkway_factor?: number + sidewalk_factor?: number + alley_factor?: number + driveway_factor?: number + step_penalty?: number + max_hiking_difficulty?: number + use_lit?: number + transit_start_end_max_distance?: number + transit_transfer_max_distance?: number +} + +export interface ValhallaBicycleCostingOptions extends ValhallaCostingOptions { + maneuver_penalty?: number + country_crossing_penalty?: number + country_crossing_cost?: number + use_ferry?: number + use_living_streets?: number + service_penalty?: number + service_factor?: number + bicycle_type?: "Road" | "Hybrid" | "City" | "Cross" | "Mountain" + cycling_speed?: number + use_roads?: number + use_hills?: number + avoid_bad_surfaces?: number + gate_penalty?: number + gate_cost?: number +} + +export interface ValhallaAutoCostingOptions extends ValhallaCostingOptions { + maneuver_penalty?: number + country_crossing_penalty?: number + country_crossing_cost?: number + width?: number + height?: number + use_highways?: number + use_tolls?: number + use_ferry?: number + ferry_cost?: number + use_living_streets?: number + use_tracks?: number + private_access_penalty?: number + ignore_closures?: boolean + ignore_restrictions?: boolean + ignore_access?: boolean + closure_factor?: number + service_penalty?: number + service_factor?: number + exclude_unpaved?: number + exclude_cash_only_tolls?: boolean + top_speed?: number + fixed_speed?: number + toll_booth_penalty?: number + toll_booth_cost?: number + gate_penalty?: number + gate_cost?: number + include_hov2?: boolean + include_hov3?: boolean + include_hot?: boolean + disable_hierarchy_pruning?: boolean +} + +export interface RoutingOptions { + autoRouting: boolean + modeOfTransport: "pedestrian" | "bicycle" | "auto" + pedestrianOptions?: ValhallaPedestrianCostingOptions + bicycleOptions?: ValhallaBicycleCostingOptions + autoOptions?: ValhallaAutoCostingOptions +} + interface ValhallaRouteResponse { trip: { legs: { diff --git a/web/src/lib/stores/valhalla_store.ts b/web/src/lib/stores/valhalla_store.ts index dab6c8b5..1acf5874 100644 --- a/web/src/lib/stores/valhalla_store.ts +++ b/web/src/lib/stores/valhalla_store.ts @@ -2,7 +2,7 @@ import GPX from "$lib/models/gpx/gpx"; import type Track from "$lib/models/gpx/track"; import TrackSegment from "$lib/models/gpx/track-segment"; import Waypoint from "$lib/models/gpx/waypoint"; -import { type ValhallaAnchor, type ValhallaHeightResponse, type ValhallaRouteResponse } from "$lib/models/valhalla"; +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"; @@ -20,19 +20,21 @@ export function setRoute(newRoute: GPX) { route = newRoute } -export async function calculateRouteBetween(startLat: number, startLon: number, endLat: number, endLon: number, costing: string = "pedestrian", autoRoute: boolean = true) { +export async function calculateRouteBetween(startLat: number, startLon: number, endLat: number, endLon: number, options: RoutingOptions) { let shape; - if (autoRoute) { + if (options.autoRouting) { let costingBody; - switch (costing) { + switch (options.modeOfTransport) { case "bicycle": - costingBody = { "costing": "bicycle", "costing_options": { "bicycle": { "bicycle_type": "Hybrid", "use_roads": 0.5, "use_hills": 0.5, "avoid_bad_surfaces": 0.5, "use_ferry": 0 } } } + costingBody = { "costing": options.modeOfTransport, "costing_options": { [options.modeOfTransport]: options.autoOptions } } break; case "auto": - costingBody = { "costing": "auto", "costing_options": { "auto": { "use_ferry": 0 } } } - default: - costingBody = { "costing": costing, "costing_options": { costing: { "max_hiking_difficulty": 6, "use_ferry": 0 } } } + costingBody = { "costing": options.modeOfTransport, "costing_options": { [options.modeOfTransport]: options.bicycleOptions } } + break; + + case "pedestrian": + costingBody = { "costing": options.modeOfTransport, "costing_options": { [options.modeOfTransport]: options.pedestrianOptions } } break; } const requestBody = { diff --git a/web/src/routes/trail/edit/[id]/+page.svelte b/web/src/routes/trail/edit/[id]/+page.svelte index 04542d7f..a223ce84 100644 --- a/web/src/routes/trail/edit/[id]/+page.svelte +++ b/web/src/routes/trail/edit/[id]/+page.svelte @@ -20,7 +20,7 @@ import type { List } from "$lib/models/list"; import { SummitLog } from "$lib/models/summit_log"; import { Trail } from "$lib/models/trail"; - import type { ValhallaAnchor } from "$lib/models/valhalla"; + import type { RoutingOptions, ValhallaAnchor } from "$lib/models/valhalla"; import { Waypoint } from "$lib/models/waypoint"; import { categories } from "$lib/stores/category_store"; import { @@ -56,14 +56,21 @@ import { page } from "$app/state"; import emptyStateTrailDark from "$lib/assets/svgs/empty_states/empty_state_trail_dark.svg"; import emptyStateTrailLight from "$lib/assets/svgs/empty_states/empty_state_trail_light.svg"; + import Combobox, { + type ComboboxItem, + } from "$lib/components/base/combobox.svelte"; import type { DropdownItem } from "$lib/components/base/dropdown.svelte"; import Search, { type SearchItem, } from "$lib/components/base/search.svelte"; + import RoutingOptionsPopup from "$lib/components/trail/routing_options_popup.svelte"; + import { TagCreateSchema } from "$lib/models/api/tag_schema.js"; + import { Tag } from "$lib/models/tag.js"; import { searchLocationReverse, searchLocations, } from "$lib/stores/search_store.js"; + import { tags_index } from "$lib/stores/tag_store.js"; import { theme } from "$lib/stores/theme_store.js"; import { getIconForLocation } from "$lib/util/icon_util.js"; import { @@ -79,13 +86,6 @@ import { backInOut } from "svelte/easing"; import { scale } from "svelte/transition"; import { z } from "zod"; - import Combobox, { - type ComboboxItem, - } from "$lib/components/base/combobox.svelte"; - import { TagCreateSchema } from "$lib/models/api/tag_schema.js"; - import { SvelteSet } from "svelte/reactivity"; - import { Tag } from "$lib/models/tag.js"; - import { tags_index } from "$lib/stores/tag_store.js"; let { data } = $props(); @@ -129,14 +129,10 @@ .optional(), }); - const modesOfTransport = [ - { text: $_("hiking"), value: "pedestrian" }, - { text: $_("cycling"), value: "bicycle" }, - { text: $_("driving"), value: "auto" }, - ]; - let selectedModeOfTransport = $state(modesOfTransport[0].value); - - let autoRouting = $state(true); + let routingOptions: RoutingOptions = $state({ + autoRouting: true, + modeOfTransport: "pedestrian", + }) let savedAtLeastOnce = $state(false); @@ -590,8 +586,7 @@ previousAnchor.lon, lat, lon, - selectedModeOfTransport, - autoRouting, + routingOptions ); insertIntoRoute(routeWaypoints); updateTrailWithRouteData(); @@ -735,8 +730,7 @@ anchor.lon, nextAnchor.lat, nextAnchor.lon, - selectedModeOfTransport, - autoRouting, + routingOptions ); } if (anchorIndex > 0) { @@ -746,8 +740,7 @@ previousAnchor.lon, anchor.lat, anchor.lon, - selectedModeOfTransport, - autoRouting, + routingOptions ); } @@ -809,16 +802,14 @@ previousAnchor.lon, anchor.lat, anchor.lon, - selectedModeOfTransport, - autoRouting, + routingOptions ); const nextRouteSegment = await calculateRouteBetween( anchor.lat, anchor.lon, nextAnchor.lat, nextAnchor.lon, - selectedModeOfTransport, - autoRouting, + routingOptions ); editRoute(data.segment, previousRouteSegment); @@ -1183,17 +1174,13 @@
{#if drawingActive}
- - +
{/if}