Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/motis/endpoints/initial.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct initial {
api::initial_response operator()(boost::urls::url_view const&) const;

nigiri::timetable const& tt_;
config const& config_;
};

} // namespace motis::ep
24 changes: 24 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,10 @@ paths:
- lat
- lon
- zoom
- routeFootPath
Comment thread
traines-source marked this conversation as resolved.
Outdated
- maxTravelTimeLimit
- maxPrePostTransitTimeLimit
- maxDirectTimeLimit
properties:
lat:
description: latitude
Expand All @@ -1735,6 +1739,26 @@ paths:
zoom:
description: zoom level
type: number
hasElevation:
description: true if elevation is loaded
type: boolean
routeFootPath:
Comment thread
traines-source marked this conversation as resolved.
Outdated
description: enable routing footpaths
type: boolean
maxTravelTimeLimit:
description: limit for maxTravelTime API param
Comment thread
traines-source marked this conversation as resolved.
Outdated
type: number
maxPrePostTransitTimeLimit:
description: limit for maxPre/PostTransitTime API param
type: number
maxDirectTimeLimit:
description: limit for maxDirectTime API param
type: number






/api/v1/map/stops:
get:
Expand Down
26 changes: 23 additions & 3 deletions src/endpoints/initial.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "motis/endpoints/initial.h"
#include "motis/config.h"

#include "utl/erase_if.h"
#include "utl/to_vec.h"
Expand Down Expand Up @@ -51,9 +52,28 @@ api::initial_response initial::operator()(boost::urls::url_view const&) const {
}
}

return {.lat_ = center.lat_,
.lon_ = center.lng_,
.zoom_ = static_cast<double>(zoom)};
auto const onetoall_max_travel_minutes =
config_.limits_->onetoall_max_travel_minutes_;
auto const street_routing_max_direct_seconds =
config_.limits_->street_routing_max_direct_seconds_;
auto const street_routing_max_prepost_transit_seconds =
config_.limits_->street_routing_max_prepost_transit_seconds_;
auto const osr_footpath = config_.osr_footpath_;
auto const has_elevation_data_dir =
config_.get_street_routing().has_value() &&
config_.get_street_routing()->elevation_data_dir_.has_value();

return {
.lat_ = center.lat_,
.lon_ = center.lng_,
.zoom_ = static_cast<double>(zoom),
.hasElevation_ = static_cast<std::optional<bool>>(has_elevation_data_dir),
.routeFootPath_ = osr_footpath,
.maxTravelTimeLimit_ = static_cast<double>(onetoall_max_travel_minutes),
.maxPrePostTransitTimeLimit_ =
static_cast<double>(street_routing_max_prepost_transit_seconds),
.maxDirectTimeLimit_ =
static_cast<double>(street_routing_max_direct_seconds)};
}

} // namespace motis::ep
20 changes: 20 additions & 0 deletions ui/api/openapi/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2463,6 +2463,26 @@ export type InitialResponse = ({
* zoom level
*/
zoom: number;
/**
* true if elevation is loaded
*/
hasElevation?: boolean;
/**
* enable routing footpaths
*/
routeFootPath: boolean;
/**
* limit for maxTravelTime API param
*/
maxTravelTimeLimit: number;
/**
* limit for maxPre/PostTransitTime API param
*/
maxPrePostTransitTimeLimit: number;
/**
* limit for maxDirectTime API param
*/
maxDirectTimeLimit: number;
});

export type InitialError = (Error);
Expand Down
100 changes: 42 additions & 58 deletions ui/src/lib/AdvancedOptions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
import StreetModes from '$lib/StreetModes.svelte';
import TransitModeSelect from '$lib/TransitModeSelect.svelte';
import { type NumberSelectOption } from '$lib/NumberSelect.svelte';
import { generateTimes } from './generateTimes';

let {
useRoutedTransfers = $bindable(),
maxPrePostTransitTimeLimit,
maxDirectTimeLimit,
hasElevation,
routeFootPath,
Comment thread
traines-source marked this conversation as resolved.
Outdated
wheelchair = $bindable(),
requireBikeTransport = $bindable(),
requireCarTransport = $bindable(),
Expand All @@ -44,6 +49,10 @@
additionalComponents
}: {
useRoutedTransfers: boolean;
maxPrePostTransitTimeLimit: number | undefined;
maxDirectTimeLimit: number | undefined;
hasElevation: boolean | undefined;
routeFootPath: boolean;
wheelchair: boolean;
requireBikeTransport: boolean;
requireCarTransport: boolean;
Expand Down Expand Up @@ -72,37 +81,9 @@
label: i.toString()
}));

const possibleDirectDurations = [
5 * 60,
10 * 60,
15 * 60,
20 * 60,
25 * 60,
30 * 60,
35 * 60,
40 * 60,
45 * 60,
50 * 60,
60 * 60,
90 * 60,
120 * 60,
180 * 60,
240 * 60,
300 * 60,
360 * 60
];
const possiblePrePostDurations = [
1 * 60,
5 * 60,
10 * 60,
15 * 60,
20 * 60,
25 * 60,
30 * 60,
40 * 60,
50 * 60,
60 * 60
];
const possibleDirectDurations = $derived(generateTimes(maxDirectTimeLimit, 60 * 60));
const possiblePrePostDurations = $derived(generateTimes(maxPrePostTransitTimeLimit, 60 * 60));

function setModes(mode: PrePostDirectMode) {
return function (checked: boolean) {
if (checked) {
Expand Down Expand Up @@ -150,16 +131,18 @@
<TransitModeSelect bind:transitModes />

<div class="space-y-2">
<Switch
bind:checked={useRoutedTransfers}
label={t.useRoutedTransfers}
id="useRoutedTransfers"
onCheckedChange={(checked) => {
if (wheelchair && !checked) {
wheelchair = false;
}
}}
/>
{#if routeFootPath}
Comment thread
traines-source marked this conversation as resolved.
Outdated
<Switch
bind:checked={useRoutedTransfers}
label={t.useRoutedTransfers}
id="useRoutedTransfers"
onCheckedChange={(checked) => {
if (wheelchair && !checked) {
wheelchair = false;
}
}}
/>
{/if}
<Switch
bind:checked={wheelchair}
label={t.wheelchair}
Expand Down Expand Up @@ -246,24 +229,25 @@
</div>

<!-- Elevation Costs -->
<div class="grid grid-cols-2 items-center">
<div class="text-sm">
{t.selectElevationCosts}
{#if hasElevation}
<div class="grid grid-cols-2 items-center">
<div class="text-sm">
{t.selectElevationCosts}
</div>
<Select.Root disabled={!allowElevationCosts} type="single" bind:value={elevationCosts}>
<Select.Trigger aria-label={t.selectElevationCosts}>
{t.elevationCosts[elevationCosts]}
</Select.Trigger>
<Select.Content sideOffset={10}>
{#each possibleElevationCosts as costs, i (i + costs.value)}
<Select.Item value={costs.value} label={costs.label}>
{costs.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</div>
<Select.Root disabled={!allowElevationCosts} type="single" bind:value={elevationCosts}>
<Select.Trigger aria-label={t.selectElevationCosts}>
{t.elevationCosts[elevationCosts]}
</Select.Trigger>
<Select.Content sideOffset={10}>
{#each possibleElevationCosts as costs, i (i + costs.value)}
<Select.Item value={costs.value} label={costs.label}>
{costs.label}
</Select.Item>
{/each}
</Select.Content>
</Select.Root>
</div>

{/if}
{#if additionalComponents}
{@render additionalComponents()}
{/if}
Expand Down
24 changes: 21 additions & 3 deletions ui/src/lib/IsochronesMask.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { posToLocation, type Location } from '$lib/Location';
import { formatDurationSec } from '$lib/formatDuration';
import type { PrePostDirectMode, TransitMode } from '$lib/Modes';
import { generateTimes } from './generateTimes';

const minutesToSeconds = (minutes: number[]) => {
return minutes.map((m) => m * 60);
Expand All @@ -23,6 +24,11 @@
let {
one = $bindable(),
maxTravelTime = $bindable(),
maxTravelTimeLimit,
maxPrePostTransitTimeLimit,
maxDirectTimeLimit,
hasElevation,
routeFootPath,
geocodingBiasPlace,
time = $bindable(),
useRoutedTransfers = $bindable(),
Expand All @@ -46,6 +52,11 @@
}: {
one: Location;
maxTravelTime: number;
maxTravelTimeLimit: number | undefined;
maxPrePostTransitTimeLimit: number | undefined;
maxDirectTimeLimit: number | undefined;
hasElevation: boolean | undefined;
routeFootPath: boolean;
geocodingBiasPlace?: maplibregl.LngLatLike;
time: Date;
useRoutedTransfers: boolean;
Expand All @@ -68,9 +79,12 @@
directProviderGroups: string[];
} = $props();

const possibleMaxTravelTimes = minutesToSeconds([
1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 75, 80, 90, 120, 150, 180, 210, 240
]).map((s) => ({ value: s.toString(), label: formatDurationSec(s) }));
const possibleMaxTravelTimes = $derived(
minutesToSeconds(generateTimes(maxTravelTimeLimit, 240)).map((s) => ({
value: s.toString(),
label: formatDurationSec(s)
}))
);
const displayLevels = new Map<DisplayLevel, string>([
['OVERLAY_RECTS', t.isochrones.canvasRects],
['OVERLAY_CIRCLES', t.isochrones.canvasCircles],
Expand Down Expand Up @@ -194,6 +208,10 @@
</RadioGroup.Root>
<AdvancedOptions
bind:useRoutedTransfers
{maxPrePostTransitTimeLimit}
{maxDirectTimeLimit}
{hasElevation}
{routeFootPath}
bind:wheelchair={
() => pedestrianProfile === 'WHEELCHAIR',
(v) => (pedestrianProfile = v ? 'WHEELCHAIR' : 'FOOT')
Expand Down
12 changes: 12 additions & 0 deletions ui/src/lib/SearchMask.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

let {
geocodingBiasPlace,
maxPrePostTransitTimeLimit,
maxDirectTimeLimit,
hasElevation,
routeFootPath,
from = $bindable(),
to = $bindable(),
time = $bindable(),
Expand All @@ -39,6 +43,10 @@
directProviderGroups = $bindable()
}: {
geocodingBiasPlace?: maplibregl.LngLatLike;
maxPrePostTransitTimeLimit: number | undefined;
maxDirectTimeLimit: number | undefined;
hasElevation: boolean | undefined;
routeFootPath: boolean;
from: Location;
to: Location;
time: Date;
Expand Down Expand Up @@ -148,6 +156,10 @@
</Label>
</RadioGroup.Root>
<AdvancedOptions
{maxPrePostTransitTimeLimit}
{maxDirectTimeLimit}
{hasElevation}
{routeFootPath}
bind:useRoutedTransfers
bind:wheelchair={
() => pedestrianProfile === 'WHEELCHAIR',
Expand Down
18 changes: 18 additions & 0 deletions ui/src/lib/generateTimes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const generateTimes = (limit: number | undefined, defaultLimit: number): number[] => {
const times: number[] = [];
let t = 1;
const max = limit ?? defaultLimit;
while (t <= max / 60) {
times.push(t * 60);
if (t < 30) {
t += 5;
} else if (t < 60) {
t += 10;
} else if (t < 120) {
t += 30;
} else {
t += 60;
}
}
return times;
};
Loading
Loading