-
-
-
-
-
-
- {#each Object.keys(brouterProfiles) as profile}
- {$_(`toolbar.routing.activities.${profile}`)}
- {/each}
-
-
+
+
+
+
+
+ {$_('toolbar.routing.use_routing_tooltip')}
+
+ {#if $routing}
+
+
+
+
+
+
+
+
+ {#each Object.keys(brouterProfiles) as profile}
+ {$_(`toolbar.routing.activities.${profile}`)}
+ {/each}
+
+
+
+
+
+
+
+
+ {/if}
+
+
+
+ {$_('toolbar.routing.reverse_tooltip')}
+
+
+
+ {$_('toolbar.routing.route_back_to_start_tooltip')}
+
+
+
+ {$_('toolbar.routing.round_trip_tooltip')}
+
-
-
-
-
-
-
-
-
-
-
-
- {#if $selectedFiles.size > 1}
- {$_('toolbar.routing.help_multiple_files')}
- {:else if $selectedFiles.size == 0}
- {$_('toolbar.routing.help_no_file')}
- {:else}
- {$_('toolbar.routing.help')}
- {/if}
-
-
+
+ {#if $selectedFiles.size > 1}
+ {$_('toolbar.routing.help_multiple_files')}
+ {:else if $selectedFiles.size == 0}
+ {$_('toolbar.routing.help_no_file')}
+ {:else}
+ {$_('toolbar.routing.help')}
+ {/if}
+
diff --git a/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts b/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts
index eeb354aa..d5905494 100644
--- a/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts
+++ b/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts
@@ -315,13 +315,17 @@ export class RoutingControls {
}
async appendAnchor(e: mapboxgl.MapMouseEvent) { // Add a new anchor to the end of the last segment
+ this.appendAnchorWithCoordinates({
+ lat: e.lngLat.lat,
+ lon: e.lngLat.lng
+ });
+ }
+
+ async appendAnchorWithCoordinates(coordinates: Coordinates) { // Add a new anchor to the end of the last segment
let lastAnchor = this.anchors[this.anchors.length - 1];
let newPoint = new TrackPoint({
- attributes: {
- lat: e.lngLat.lat,
- lon: e.lngLat.lng
- }
+ attributes: coordinates
});
newPoint._data.anchor = true;
newPoint._data.zoom = 0;
@@ -345,6 +349,36 @@ export class RoutingControls {
await this.routeBetweenAnchors([lastAnchor, newAnchor], [lastAnchor.point.getCoordinates(), newAnchor.point.getCoordinates()]);
}
+ routeToStart() {
+ let segments = get(this.file).getSegments();
+ if (segments.length === 0) {
+ return;
+ }
+
+ let segment = segments[segments.length - 1];
+ let firstAnchor = this.anchors.find((anchor) => anchor.segment === segment);
+
+ if (!firstAnchor) {
+ return;
+ }
+
+ this.appendAnchorWithCoordinates(firstAnchor.point.getCoordinates());
+ }
+
+ createRoundTrip() {
+ let segments = get(this.file).getSegments();
+ if (segments.length === 0) {
+ return;
+ }
+
+ dbUtils.applyToFile(this.fileId, (file) => {
+ let segment = file.getSegments()[segments.length - 1];
+ let newSegment = segment.clone();
+ newSegment.reverse(undefined, undefined);
+ segment.replace(segment.trkpt.length, segment.trkpt.length, newSegment.trkpt);
+ });
+ }
+
getNeighbouringAnchors(anchor: Anchor): [Anchor | null, Anchor | null] {
let previousAnchor: Anchor | null = null;
let nextAnchor: Anchor | null = null;
diff --git a/website/src/locales/en.json b/website/src/locales/en.json
index ab440928..776f2edf 100644
--- a/website/src/locales/en.json
+++ b/website/src/locales/en.json
@@ -40,8 +40,12 @@
"routing": {
"tooltip": "Edit the route",
"activity": "Activity",
- "use_routing": "Routing (follow roads)",
+ "use_routing": "Routing",
+ "use_routing_tooltip": "Connect anchor points through the road network. Disable to draw straight lines.",
"allow_private": "Allow private roads",
+ "reverse_tooltip": "Reverse the direction",
+ "route_back_to_start_tooltip": "Route back to start",
+ "round_trip_tooltip": "Create round trip",
"help_no_file": "Select a file to use the routing tool, or create a new file from the menu",
"help_multiple_files": "Select a single file to use the routing tool",
"help": "Click on the map to add a new point, or drag existing points to change the route",
@@ -93,7 +97,6 @@
}
},
"time_tooltip": "Change the time and speed data",
- "reverse_tooltip": "Reverse the direction",
"merge_tooltip": "Merge files together",
"extract_tooltip": "Extract inner tracks or segments",
"waypoint_tooltip": "Create a new point of interest",