Skip to content

Commit

Permalink
car parking
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Nov 5, 2024
1 parent 813b1ee commit 88b21e1
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[osr]
[email protected]:motis-project/osr.git
branch=master
commit=60eb1ee32698fbe4c2dde2070acb9bceea621257
commit=736ee98b1e4d40335eea901e7fbc1a31374e680c
[utl]
[email protected]:motis-project/utl.git
branch=master
Expand Down
4 changes: 2 additions & 2 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
14560197399935530260
15114411606436118506
cista 950f96f4ded53a6b5753824b280550b722933e55
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 73549ebca677fe6214202a1ab580362b4f80e653
Expand Down Expand Up @@ -39,7 +39,7 @@ sol2 40c7cbc7c5cfed1e8c7f1bbe6fcbe23d7a67fc75
variant 5aa73631dc969087c77433a5cdef246303051f69
tiles 6b6dc45bc904966640c7207ab91950848a8b3f6c
rtree.c 6ed73a7dc4f1184f2b5b2acd8ac1c2b28a273057
osr 60eb1ee32698fbe4c2dde2070acb9bceea621257
osr 736ee98b1e4d40335eea901e7fbc1a31374e680c
yaml-cpp 1d8ca1f35eb3a9c9142462b28282a848e5d29a91
reflect-cpp c54fe66de4650b60c23aadd4a06d9db4ffeda22f
FTXUI dd6a5d371fd7a3e2937bb579955003c54b727233
Expand Down
25 changes: 6 additions & 19 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -893,17 +893,11 @@ components:
description: |
# Street modes
- `WALK`: Walking some or all of the way of the route.
- `BIKE`: Cycling for the entirety of the route or taking a bicycle onto the public transport (if enabled) and cycling from the arrival station to the destination.
- `BIKE_RENTAL`: Taking a rented, shared-mobility bike for part or the entirety of the route.
- `BIKE_TO_PARK`: Leaving the bicycle at the departure station and walking from the arrival station to the destination. This mode needs to be combined with at least one transit mode otherwise it behaves like an ordinary bicycle journey.
- `CAR`: Driving your own car the entirety of the route. This can be combined with transit, where will return routes with a Kiss & Ride component. This means that the car is not parked in a permanent parking area but rather the passenger is dropped off (for example, at an airport) and the driver continues driving the car away from the drop off location.
- `CAR_PARK` | `CAR_TO_PARK`: Driving a car to the park-and-ride facilities near a station and taking publictransport. This mode needs to be combined with at least one transit mode otherwise, it behaves like an ordinary car journey.
- `CAR_HAILING`: Using a car hailing app like Uber or Lyft to get to a train station or all the way to the destination.
- `CAR_PICKUP`: Walking to a pickup point along the road, driving to a drop-off point along the road, and walking the rest of the way. This can include various taxi-services or kiss & ride.
- `CAR_RENTAL`: Walk to a car rental point, drive to a car rental drop-off point and walk the rest of the way. This can include car rental at fixed locations or free-floating services.
- `FLEXIBLE`: Encompasses all types of on-demand and flexible transportation for example GTFS Flex or NeTEx Flexible Stop Places.
- `SCOOTER_RENTAL`: Walking to a scooter rental point, riding a scooter to a scooter rental drop-off point, and walking the rest of the way. This can include scooter rental at fixed locations or free-floating services.
- `WALK`
- `BIKE`
- `BIKE_RENTAL`
- `CAR`
- `CAR_PARKING`
# Transit modes
Expand All @@ -928,14 +922,7 @@ components:
- BIKE
- CAR
- BIKE_RENTAL
- BIKE_TO_PARK
- CAR_TO_PARK
- CAR_HAILING
- CAR_SHARING
- CAR_PICKUP
- CAR_RENTAL
- FLEXIBLE
- SCOOTER_RENTAL
- CAR_PARKING
# === Transit ===
- TRANSIT
- TRAM
Expand Down
4 changes: 2 additions & 2 deletions src/endpoints/graph.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "motis/endpoints/graph.h"

#include "osr/geojson.h"
#include "osr/routing/profiles/bike_sharing.h"
#include "osr/routing/profiles/car_parking.h"
#include "osr/routing/route.h"

namespace json = boost::json;
Expand Down Expand Up @@ -58,7 +58,7 @@ json::value graph::operator()(json::value const& query) const {
}
});

gj.finish(&osr::get_dijkstra<osr::bike_sharing>());
gj.finish(&osr::get_dijkstra<osr::car_parking<false>>());

return gj.json();
}
Expand Down
1 change: 1 addition & 0 deletions src/endpoints/routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ std::pair<std::vector<api::Itinerary>, n::duration_t> routing::route_direct(
auto itineraries = std::vector<api::Itinerary>{};
for (auto const& m : modes) {
if (m == api::ModeEnum::CAR || m == api::ModeEnum::BIKE ||
m == api::ModeEnum::CAR_PARKING ||
(!omit_walk && m == api::ModeEnum::WALK)) {
auto itinerary = route(
*w_, *l_, gbfs, e, from, to, m, wheelchair, start_time, std::nullopt,
Expand Down
2 changes: 1 addition & 1 deletion src/journey_to_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace motis {
api::ModeEnum to_mode(osr::search_profile const m) {
switch (m) {
case osr::search_profile::kCarParkingWheelchair: [[fallthrough]];
case osr::search_profile::kCarParking: return api::ModeEnum::CAR_TO_PARK;
case osr::search_profile::kCarParking: return api::ModeEnum::CAR_PARKING;
case osr::search_profile::kFoot: [[fallthrough]];
case osr::search_profile::kWheelchair: return api::ModeEnum::WALK;
case osr::search_profile::kCar: return api::ModeEnum::CAR;
Expand Down
1 change: 1 addition & 0 deletions src/mode_to_profile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ osr::search_profile to_profile(api::ModeEnum const m, bool const wheelchair) {
: osr::search_profile::kFoot;
case api::ModeEnum::BIKE: return osr::search_profile::kBike;
case api::ModeEnum::CAR: return osr::search_profile::kCar;
case api::ModeEnum::CAR_PARKING: return osr::search_profile::kCarParking;
case api::ModeEnum::BIKE_RENTAL: return osr::search_profile::kBikeSharing;
default: throw utl::fail("unsupported mode");
}
Expand Down
2 changes: 1 addition & 1 deletion src/street_routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ std::optional<osr::path> get_path(osr::ways const& w,
it != end(cache)
? it->second
: osr::route(
w, l, profile, from, to, max, osr::direction::kForward,
w, l, profile, to, from, max, osr::direction::kBackward,
kMaxMatchingDistance,
s ? &set_blocked(e_nodes, e_states, blocked_mem) : nullptr,
sharing);
Expand Down
9 changes: 2 additions & 7 deletions ui/src/lib/AddressTypeahead.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
selected = $bindable(),
placeholder,
class: className,
name,
theme
name
}: {
items?: Array<Location>;
selected: Location;
placeholder?: string;
class?: string;
name?: string;
theme?: 'light' | 'dark';
} = $props();
let inputValue = $state('');
Expand Down Expand Up @@ -115,10 +113,7 @@
{#if items.length !== 0}
<Combobox.Content
sideOffset={12}
class={cn(
'absolute z-10 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md outline-none',
theme
)}
class="absolute z-10 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md outline-none"
>
{#each items as item (item.value)}
<Combobox.Item
Expand Down
9 changes: 1 addition & 8 deletions ui/src/lib/modeStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,14 @@ export type LegLike = Colorable & TripInfo;
export const getModeStyle = (mode: Mode): [string, string, string] => {
switch (mode) {
case 'WALK':
case 'FLEXIBLE':
return ['walk', 'hsl(var(--foreground) / 1)', 'hsl(var(--background) / 1)'];

case 'BIKE':
case 'BIKE_TO_PARK':
case 'BIKE_RENTAL':
case 'SCOOTER_RENTAL':
return ['bike', '#075985', 'white'];

case 'CAR':
case 'CAR_TO_PARK':
case 'CAR_HAILING':
case 'CAR_SHARING':
case 'CAR_PICKUP':
case 'CAR_RENTAL':
case 'CAR_PARKING':
return ['car', '#333', 'white'];

case 'TRANSIT':
Expand Down
18 changes: 6 additions & 12 deletions ui/src/lib/openapi/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,11 @@ export const MatchSchema = {
export const ModeSchema = {
description: `# Street modes
- \`WALK\`: Walking some or all of the way of the route.
- \`BIKE\`: Cycling for the entirety of the route or taking a bicycle onto the public transport (if enabled) and cycling from the arrival station to the destination.
- \`BIKE_RENTAL\`: Taking a rented, shared-mobility bike for part or the entirety of the route.
- \`BIKE_TO_PARK\`: Leaving the bicycle at the departure station and walking from the arrival station to the destination. This mode needs to be combined with at least one transit mode otherwise it behaves like an ordinary bicycle journey.
- \`CAR\`: Driving your own car the entirety of the route. This can be combined with transit, where will return routes with a Kiss & Ride component. This means that the car is not parked in a permanent parking area but rather the passenger is dropped off (for example, at an airport) and the driver continues driving the car away from the drop off location.
- \`CAR_PARK\` | \`CAR_TO_PARK\`: Driving a car to the park-and-ride facilities near a station and taking publictransport. This mode needs to be combined with at least one transit mode otherwise, it behaves like an ordinary car journey.
- \`CAR_HAILING\`: Using a car hailing app like Uber or Lyft to get to a train station or all the way to the destination.
- \`CAR_PICKUP\`: Walking to a pickup point along the road, driving to a drop-off point along the road, and walking the rest of the way. This can include various taxi-services or kiss & ride.
- \`CAR_RENTAL\`: Walk to a car rental point, drive to a car rental drop-off point and walk the rest of the way. This can include car rental at fixed locations or free-floating services.
- \`FLEXIBLE\`: Encompasses all types of on-demand and flexible transportation for example GTFS Flex or NeTEx Flexible Stop Places.
- \`SCOOTER_RENTAL\`: Walking to a scooter rental point, riding a scooter to a scooter rental drop-off point, and walking the rest of the way. This can include scooter rental at fixed locations or free-floating services.
- \`WALK\`
- \`BIKE\`
- \`BIKE_RENTAL\`
- \`CAR\`
- \`CAR_PARKING\`
# Transit modes
Expand All @@ -146,7 +140,7 @@ export const ModeSchema = {
- \`REGIONAL_RAIL\`: regional train
`,
type: 'string',
enum: ['WALK', 'BIKE', 'CAR', 'BIKE_RENTAL', 'BIKE_TO_PARK', 'CAR_TO_PARK', 'CAR_HAILING', 'CAR_SHARING', 'CAR_PICKUP', 'CAR_RENTAL', 'FLEXIBLE', 'SCOOTER_RENTAL', 'TRANSIT', 'TRAM', 'SUBWAY', 'FERRY', 'AIRPLANE', 'METRO', 'BUS', 'COACH', 'RAIL', 'HIGHSPEED_RAIL', 'LONG_DISTANCE', 'NIGHT_RAIL', 'REGIONAL_FAST_RAIL', 'REGIONAL_RAIL', 'OTHER']
enum: ['WALK', 'BIKE', 'CAR', 'BIKE_RENTAL', 'CAR_PARKING', 'TRANSIT', 'TRAM', 'SUBWAY', 'FERRY', 'AIRPLANE', 'METRO', 'BUS', 'COACH', 'RAIL', 'HIGHSPEED_RAIL', 'LONG_DISTANCE', 'NIGHT_RAIL', 'REGIONAL_FAST_RAIL', 'REGIONAL_RAIL', 'OTHER']
} as const;

export const VertexTypeSchema = {
Expand Down
20 changes: 7 additions & 13 deletions ui/src/lib/openapi/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,11 @@ export type type = 'ADDRESS' | 'PLACE' | 'STOP';
/**
* # Street modes
*
* - `WALK`: Walking some or all of the way of the route.
* - `BIKE`: Cycling for the entirety of the route or taking a bicycle onto the public transport (if enabled) and cycling from the arrival station to the destination.
* - `BIKE_RENTAL`: Taking a rented, shared-mobility bike for part or the entirety of the route.
* - `BIKE_TO_PARK`: Leaving the bicycle at the departure station and walking from the arrival station to the destination. This mode needs to be combined with at least one transit mode otherwise it behaves like an ordinary bicycle journey.
* - `CAR`: Driving your own car the entirety of the route. This can be combined with transit, where will return routes with a Kiss & Ride component. This means that the car is not parked in a permanent parking area but rather the passenger is dropped off (for example, at an airport) and the driver continues driving the car away from the drop off location.
* - `CAR_PARK` | `CAR_TO_PARK`: Driving a car to the park-and-ride facilities near a station and taking publictransport. This mode needs to be combined with at least one transit mode otherwise, it behaves like an ordinary car journey.
* - `CAR_HAILING`: Using a car hailing app like Uber or Lyft to get to a train station or all the way to the destination.
* - `CAR_PICKUP`: Walking to a pickup point along the road, driving to a drop-off point along the road, and walking the rest of the way. This can include various taxi-services or kiss & ride.
* - `CAR_RENTAL`: Walk to a car rental point, drive to a car rental drop-off point and walk the rest of the way. This can include car rental at fixed locations or free-floating services.
* - `FLEXIBLE`: Encompasses all types of on-demand and flexible transportation for example GTFS Flex or NeTEx Flexible Stop Places.
* - `SCOOTER_RENTAL`: Walking to a scooter rental point, riding a scooter to a scooter rental drop-off point, and walking the rest of the way. This can include scooter rental at fixed locations or free-floating services.
* - `WALK`
* - `BIKE`
* - `BIKE_RENTAL`
* - `CAR`
* - `CAR_PARKING`
*
* # Transit modes
*
Expand All @@ -136,7 +130,7 @@ export type type = 'ADDRESS' | 'PLACE' | 'STOP';
* - `REGIONAL_RAIL`: regional train
*
*/
export type Mode = 'WALK' | 'BIKE' | 'CAR' | 'BIKE_RENTAL' | 'BIKE_TO_PARK' | 'CAR_TO_PARK' | 'CAR_HAILING' | 'CAR_SHARING' | 'CAR_PICKUP' | 'CAR_RENTAL' | 'FLEXIBLE' | 'SCOOTER_RENTAL' | 'TRANSIT' | 'TRAM' | 'SUBWAY' | 'FERRY' | 'AIRPLANE' | 'METRO' | 'BUS' | 'COACH' | 'RAIL' | 'HIGHSPEED_RAIL' | 'LONG_DISTANCE' | 'NIGHT_RAIL' | 'REGIONAL_FAST_RAIL' | 'REGIONAL_RAIL' | 'OTHER';
export type Mode = 'WALK' | 'BIKE' | 'CAR' | 'BIKE_RENTAL' | 'CAR_PARKING' | 'TRANSIT' | 'TRAM' | 'SUBWAY' | 'FERRY' | 'AIRPLANE' | 'METRO' | 'BUS' | 'COACH' | 'RAIL' | 'HIGHSPEED_RAIL' | 'LONG_DISTANCE' | 'NIGHT_RAIL' | 'REGIONAL_FAST_RAIL' | 'REGIONAL_RAIL' | 'OTHER';

/**
* - `NORMAL` - latitude / longitude coordinate or address
Expand Down Expand Up @@ -669,7 +663,7 @@ export type PlanData = {
*
* Note: Direct connections will only be returned on the first call. For paging calls, they can be omitted.
*
* Note: Transit connections that are slower than the fastest direct walking connection will not show up.
* Note: Transit connections that are slower than the fastest direct connection will not show up.
* This is being used as a cut-off during transit routing to speed up the search.
* To prevent this, it's possible to send two separate requests (one with only `transitModes` and one with only `directModes`).
*
Expand Down
22 changes: 14 additions & 8 deletions ui/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
let timeType = $state<string>('departure');
let wheelchair = $state(false);
let bikeRental = $state(false);
let carParking = $state(false);
const toPlaceString = (l: Location) => {
if (l.value.match?.type === 'STOP') {
Expand All @@ -100,7 +101,11 @@
return `${lngLatToStr(l.value.match!)},0`;
}
};
let modes = $derived(['WALK', ...(bikeRental ? ['BIKE_RENTAL'] : [])] as Mode[]);
let modes = $derived([
...(bikeRental ? ['BIKE_RENTAL'] : []),
...(carParking ? ['CAR_PARKING'] : [])
] as Mode[]);
let postTransitModes = $derived([...(bikeRental ? ['BIKE_RENTAL'] : [])] as Mode[]);
let baseQuery = $derived(
from.value.match && to.value.match
? ({
Expand All @@ -112,8 +117,9 @@
timetableView: true,
wheelchair,
preTransitModes: modes,
postTransitModes: modes,
directModes: modes
postTransitModes,
directModes: modes,
maxPreTransitTime: 2200
}
} as PlanData)
: undefined
Expand Down Expand Up @@ -219,15 +225,15 @@
{/if}

<Control position="top-left">
<Card class="w-[500px] overflow-y-auto overflow-x-hidden bg-background rounded-lg">
<Card class="w-[560px] overflow-y-auto overflow-x-hidden bg-background rounded-lg">
<SearchMask
bind:from
bind:to
bind:time
bind:timeType
bind:wheelchair
bind:bikeRental
{theme}
bind:carParking
/>
</Card>
</Control>
Expand All @@ -237,7 +243,7 @@
{#if !selectedItinerary && routingResponses.length !== 0}
<Control position="top-left">
<Card
class="w-[500px] max-h-[70vh] overflow-y-auto overflow-x-hidden bg-background rounded-lg"
class="w-[560px] max-h-[70vh] overflow-y-auto overflow-x-hidden bg-background rounded-lg"
>
<ItineraryList {baseResponse} {routingResponses} {baseQuery} bind:selectedItinerary />
</Card>
Expand All @@ -246,7 +252,7 @@

{#if selectedItinerary && !selectedStop}
<Control position="top-left">
<Card class="w-[500px] bg-background rounded-lg">
<Card class="w-[560px] bg-background rounded-lg">
<div class="w-full flex justify-between items-center shadow-md pl-1 mb-1">
<h2 class="ml-2 text-base font-semibold">Journey Details</h2>
<Button
Expand Down Expand Up @@ -275,7 +281,7 @@

{#if selectedStop}
<Control position="top-left">
<Card class="w-[500px] bg-background rounded-lg">
<Card class="w-[560px] bg-background rounded-lg">
<div class="w-full flex justify-between items-center shadow-md pl-1 mb-1">
<h2 class="ml-2 text-base font-semibold">
{#if stopArriveBy}
Expand Down
10 changes: 6 additions & 4 deletions ui/src/routes/SearchMask.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ArrowUpDown from 'lucide-svelte/icons/arrow-up-down';
import Accessibility from 'lucide-svelte/icons/accessibility';
import Bike from 'lucide-svelte/icons/bike';
import Parking from 'lucide-svelte/icons/circle-parking';
import AddressTypeahead from '$lib/AddressTypeahead.svelte';
import Button from '$lib/components/ui/button/button.svelte';
import { Label } from '$lib/components/ui/label';
Expand All @@ -17,15 +18,15 @@
timeType = $bindable(),
wheelchair = $bindable(),
bikeRental = $bindable(),
theme
carParking = $bindable()
}: {
from: Location;
to: Location;
time: Date;
timeType: string;
wheelchair: boolean;
bikeRental: boolean;
theme?: 'light' | 'dark';
carParking: boolean;
} = $props();
let fromItems = $state<Array<Location>>([]);
Expand All @@ -39,15 +40,13 @@
placeholder="From"
bind:selected={from}
bind:items={fromItems}
{theme}
/>
<AddressTypeahead
name="to"
class="w-full"
placeholder="To"
bind:selected={to}
bind:items={toItems}
{theme}
/>
<Button
class="absolute z-10 right-12 top-10"
Expand Down Expand Up @@ -89,5 +88,8 @@
<Toggle aria-label="toggle bold" bind:pressed={bikeRental}>
<Bike class="h-6 w-6" />
</Toggle>
<Toggle aria-label="toggle bold" bind:pressed={carParking}>
<Parking class="h-6 w-6" />
</Toggle>
</div>
</div>

0 comments on commit 88b21e1

Please sign in to comment.