Skip to content

Commit

Permalink
Merge pull request #216 from ibi-group/upstream-merge-2024-06-21
Browse files Browse the repository at this point in the history
Upstream merge 2024-06-21
  • Loading branch information
miles-grant-ibigroup authored Jun 21, 2024
2 parents 5be2a13 + 746b530 commit 8bcd4e2
Show file tree
Hide file tree
Showing 42 changed files with 431 additions and 274 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prune-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
# remove all snapshot container images that have not been pulled for over a year
# --keep-semver makes sure that any image with a x.y.z version scheme is unaffected by this
pip install prune-container-repo==0.0.4
prune-container-repo -u ${CONTAINER_REGISTRY_USER} -r ${CONTAINER_REPO} --days=365 --keep-semver --activate
prune-container-repo -u ${CONTAINER_REGISTRY_USER} -r ${CONTAINER_REPO} --days=90 --keep-semver --activate
2 changes: 1 addition & 1 deletion client-next/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_API_URL=/otp/routers/default/transmodel/index/graphql
VITE_API_URL=/otp/transmodel/v3
VITE_DEBUG_STYLE_URL=/otp/routers/default/inspector/vectortile/style.json
2 changes: 1 addition & 1 deletion client-next/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_API_URL=http://localhost:8080/otp/routers/default/transmodel/index/graphql
VITE_API_URL=http://localhost:8080/otp/transmodel/v3
VITE_DEBUG_STYLE_URL=http://localhost:8080/otp/routers/default/inspector/vectortile/style.json
35 changes: 21 additions & 14 deletions client-next/src/components/ItineraryList/ItineraryLegDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@ import { formatDuration } from '../../util/formatDuration.ts';

export function ItineraryLegDetails({ leg, isLast }: { leg: Leg; isLast: boolean }) {
return (
<div style={{ border: '1px dotted grey' }}>
<LegTime aimedTime={leg.aimedStartTime} expectedTime={leg.expectedStartTime} hasRealtime={leg.realtime} />-{' '}
<LegTime aimedTime={leg.aimedEndTime} expectedTime={leg.expectedEndTime} hasRealtime={leg.realtime} />{' '}
<b>{leg.mode}</b>{' '}
{leg.line && (
<>
<u>
{leg.line.publicCode} {leg.toEstimatedCall?.destinationDisplay?.frontText}
</u>
, {leg.authority?.name}
</>
)}{' '}
{formatDistance(leg.distance)}, {formatDuration(leg.duration)}
{leg.mode !== Mode.Foot && <u>from {leg.fromPlace.name}</u>} {!isLast && <u>to {leg.toPlace.name}</u>}
<div className="itinerary-leg-details">
<div className="times">
{formatDistance(leg.distance)}, {formatDuration(leg.duration)}
</div>
<div>
<LegTime aimedTime={leg.aimedStartTime} expectedTime={leg.expectedStartTime} hasRealtime={leg.realtime} /> -{' '}
<LegTime aimedTime={leg.aimedEndTime} expectedTime={leg.expectedEndTime} hasRealtime={leg.realtime} />
</div>
<div className="mode">
<b>{leg.mode}</b>{' '}
{leg.line && (
<>
<u>
{leg.line.publicCode} {leg.toEstimatedCall?.destinationDisplay?.frontText}
</u>
, {leg.authority?.name}
</>
)}{' '}
<div></div>
{leg.mode !== Mode.Foot && <u>{leg.fromPlace.name}</u>} {!isLast && <u>{leg.toPlace.name}</u>}
</div>
</div>
);
}
6 changes: 3 additions & 3 deletions client-next/src/components/ItineraryList/LegTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export function LegTime({
}) {
return aimedTime !== expectedTime ? (
<>
<span style={{ color: 'red' }}>{formatTime(expectedTime)}</span>
<span style={{ textDecoration: 'line-through' }}>{formatTime(aimedTime)}</span>
<span style={{ color: 'red' }}>{formatTime(expectedTime, 'short')}</span>
<span style={{ textDecoration: 'line-through' }}>{formatTime(aimedTime, 'short')}</span>
</>
) : (
<span>
{formatTime(expectedTime)}
{formatTime(expectedTime, 'short')}
{hasRealtime && <span> (on time)</span>}
</span>
);
Expand Down
3 changes: 3 additions & 0 deletions client-next/src/components/MapView/LayerControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class LayerControl implements IControl {
.getLayersOrder()
.map((l) => map.getLayer(l))
.filter((s) => s?.type !== 'raster')
// the polylines of the routing result are put in map layers called jsx-1, jsx-2...
// we don't want them to show up in the debug layer selector
.filter((s) => !s?.id.startsWith('jsx'))
.reverse()
.forEach((layer) => {
if (layer) {
Expand Down
33 changes: 33 additions & 0 deletions client-next/src/hooks/useTripQueryVariables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { useEffect, useState } from 'react';
import { TripQueryVariables } from '../gql/graphql.ts';

const DEFAULT_VARIABLES: TripQueryVariables = {
from: {},
to: {},
dateTime: new Date().toISOString(),
};

const getInitialVariables = () => {
const urlParams = new URLSearchParams(window.location.search);
const variablesJson = urlParams.get('variables');
return variablesJson ? JSON.parse(decodeURIComponent(variablesJson)) : DEFAULT_VARIABLES;
};

const updateUrlWithVariables = (variables: TripQueryVariables) => {
const urlParams = new URLSearchParams(window.location.search);
urlParams.set('variables', encodeURIComponent(JSON.stringify(variables)));
history.pushState({}, '', '?' + urlParams.toString() + window.location.hash);
};

export const useTripQueryVariables = () => {
const [tripQueryVariables, setTripQueryVariables] = useState<TripQueryVariables>(getInitialVariables());

useEffect(() => {
updateUrlWithVariables(tripQueryVariables);
}, [tripQueryVariables]);

return {
tripQueryVariables,
setTripQueryVariables,
};
};
10 changes: 2 additions & 8 deletions client-next/src/screens/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ import { MapView } from '../components/MapView/MapView.tsx';
import { SearchBar } from '../components/SearchBar/SearchBar.tsx';
import { ItineraryListContainer } from '../components/ItineraryList/ItineraryListContainer.tsx';
import { useState } from 'react';
import { TripQueryVariables } from '../gql/graphql.ts';
import { useTripQuery } from '../hooks/useTripQuery.ts';
import { useServerInfo } from '../hooks/useServerInfo.ts';

const INITIAL_VARIABLES: TripQueryVariables = {
from: {},
to: {},
dateTime: new Date().toISOString(),
};
import { useTripQueryVariables } from '../hooks/useTripQueryVariables.ts';

export function App() {
const [tripQueryVariables, setTripQueryVariables] = useState<TripQueryVariables>(INITIAL_VARIABLES);
const { tripQueryVariables, setTripQueryVariables } = useTripQueryVariables();
const [tripQueryResult, loading, callback] = useTripQuery(tripQueryVariables);
const serverInfo = useServerInfo();
const [selectedTripPatternIndex, setSelectedTripPatternIndex] = useState<number>(0);
Expand Down
17 changes: 17 additions & 0 deletions client-next/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@
--bs-accordion-active-bg: pink;
}

.itinerary-leg-details {
border: 1px solid #80808063;
padding: 10px;
border-radius: 3px;
margin-bottom: 3px;
}

.itinerary-leg-details .times {
margin-top: 3px;
float: right;
font-size: 11px;
}

.itinerary-leg-details .mode {
margin-top: 10px;
}

.itinerary-header-itinerary-number {
position: absolute;
}
Expand Down
28 changes: 14 additions & 14 deletions client-next/src/util/getColorForMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { Mode } from '../gql/graphql.ts';

export const getColorForMode = function (mode: Mode) {
if (mode === Mode.Foot) return '#444';
if (mode === Mode.Bicycle) return '#44f';
if (mode === Mode.Scooter) return '#88f';
if (mode === Mode.Bicycle) return '#5076D9';
if (mode === Mode.Scooter) return '#253664';
if (mode === Mode.Car) return '#444';
if (mode === Mode.Rail) return '#b00';
if (mode === Mode.Coach) return '#0f0';
if (mode === Mode.Metro) return '#f00';
if (mode === Mode.Bus) return '#0f0';
if (mode === Mode.Tram) return '#f00';
if (mode === Mode.Trolleybus) return '#0f0';
if (mode === Mode.Water) return '#f0f';
if (mode === Mode.Air) return '#f0f';
if (mode === Mode.Cableway) return '#f0f';
if (mode === Mode.Funicular) return '#f0f';
if (mode === Mode.Monorail) return '#f0f';
if (mode === Mode.Taxi) return '#f0f';
if (mode === Mode.Rail) return '#86BF8B';
if (mode === Mode.Coach) return '#25642A';
if (mode === Mode.Metro) return '#D9B250';
if (mode === Mode.Bus) return '#25642A';
if (mode === Mode.Tram) return '#D9B250';
if (mode === Mode.Trolleybus) return '#25642A';
if (mode === Mode.Water) return '#81304C';
if (mode === Mode.Air) return '#81304C';
if (mode === Mode.Cableway) return '#81304C';
if (mode === Mode.Funicular) return '#81304C';
if (mode === Mode.Monorail) return '#81304C';
if (mode === Mode.Taxi) return '#81304C';
return '#aaa';
};
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle
- Add plan query that follows the relay connection specification [#5185](https://github.com/opentripplanner/OpenTripPlanner/pull/5185)
- Fix debug client after breaking change in dependency graphql-request [#5899](https://github.com/opentripplanner/OpenTripPlanner/pull/5899)
- Remove TravelTime API [#5890](https://github.com/opentripplanner/OpenTripPlanner/pull/5890)
- Improve cancellation of large response in TransModel API [#5908](https://github.com/opentripplanner/OpenTripPlanner/pull/5908)
[](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE)

## 2.5.0 (2024-03-13)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
Expand Down
4 changes: 2 additions & 2 deletions src/client/debug-client-preview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/img/otp-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OTP Debug Client</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/06/2024-06-17T08:43/assets/index-DblAyaea.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/06/2024-06-17T08:43/assets/index-DP6CFc2j.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/06/2024-06-20T21:29/assets/index-c3s7HdOc.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/06/2024-06-20T21:29/assets/index-DAapFGZ4.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static void assertLegFareEquals(
void calculateFareForSingleAgency() {
List<Leg> rides = List.of(getLeg(COMM_TRANS_AGENCY_ID, "400", 0));
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE);
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE);
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.youth, ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, TWO_DOLLARS);
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE);
Expand All @@ -154,18 +154,14 @@ void calculateFareWithNoFreeTransfer() {
getLeg(COMM_TRANS_AGENCY_ID, 2)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(3));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(3));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.plus(usDollars(2.25f)));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(
rides,
FareType.electronicSpecial,
DEFAULT_TEST_RIDE_PRICE.plus(usDollars(1.25f))
);
calculateFare(
rides,
FareType.electronicRegular,
DEFAULT_TEST_RIDE_PRICE.plus(DEFAULT_TEST_RIDE_PRICE)
);
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.electronicSenior, DEFAULT_TEST_RIDE_PRICE.plus(usDollars(1.25f)));
calculateFare(rides, FareType.electronicYouth, Money.ZERO_USD);
}
Expand Down Expand Up @@ -200,7 +196,7 @@ void calculateFareThatExceedsTwoHourFreeTransferWindow() {
);

calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.youth, ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, TWO_DOLLARS);
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(2));
Expand All @@ -227,7 +223,7 @@ void calculateFareThatIncludesNoFreeTransfers() {
calculateFare(
rides,
FareType.senior,
DEFAULT_TEST_RIDE_PRICE.times(2).plus(usDollars(.50f)).plus(HALF_FERRY_FARE)
ONE_DOLLAR.plus(ONE_DOLLAR).plus(HALF_FERRY_FARE).plus(usDollars(0.5f))
);
calculateFare(rides, FareType.youth, Money.ZERO_USD);
// We don't get any fares for the skagit transit leg below here because they don't accept ORCA (electronic)
Expand Down Expand Up @@ -263,7 +259,7 @@ void calculateFareThatExceedsTwoHourFreeTransferWindowTwice() {
getLeg(KITSAP_TRANSIT_AGENCY_ID, 270)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(3));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(3));
calculateFare(rides, FareType.senior, usDollars(3));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(3));
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(3));
Expand All @@ -286,7 +282,7 @@ void calculateFareThatStartsWithACashFare() {
getLeg(KITSAP_TRANSIT_AGENCY_ID, 149)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.plus(ONE_DOLLAR));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, DEFAULT_TEST_RIDE_PRICE.plus(ONE_DOLLAR));
calculateFare(
Expand All @@ -305,7 +301,7 @@ void calculateFareThatStartsWithACashFare() {
void calculateFareForKitsapFastFerry() {
List<Leg> rides = List.of(getLeg(KITSAP_TRANSIT_AGENCY_ID, 0, 4, "404", "east"));
calculateFare(rides, regular, TWO_DOLLARS);
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.senior, ONE_DOLLAR);
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, ONE_DOLLAR);
calculateFare(rides, FareType.electronicRegular, TWO_DOLLARS);
Expand All @@ -314,7 +310,7 @@ void calculateFareForKitsapFastFerry() {

rides = List.of(getLeg(KITSAP_TRANSIT_AGENCY_ID, 0, 4, "404", "west"));
calculateFare(rides, regular, usDollars(10f));
calculateFare(rides, FareType.senior, usDollars(10f));
calculateFare(rides, FareType.senior, usDollars(5f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(5f));
calculateFare(rides, FareType.electronicRegular, usDollars(10f));
Expand Down Expand Up @@ -349,7 +345,7 @@ void calculateFareForSTRail() {
getLeg(SOUND_TRANSIT_AGENCY_ID, "S Line", 100, "King Street Station", "Auburn Station")
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, ORCA_SPECIAL_FARE);
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE);
Expand All @@ -364,7 +360,7 @@ void calculateFareForSTRail() {
void calculateWaterTaxiFares() {
List<Leg> rides = List.of(getLeg(KC_METRO_AGENCY_ID, "973", 1));
calculateFare(rides, regular, WEST_SEATTLE_WATER_TAXI_CASH_FARE);
calculateFare(rides, FareType.senior, WEST_SEATTLE_WATER_TAXI_CASH_FARE);
calculateFare(rides, FareType.senior, usDollars(2.50f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(3.75f));
calculateFare(rides, FareType.electronicRegular, usDollars(5f));
Expand All @@ -374,7 +370,7 @@ void calculateWaterTaxiFares() {
rides = List.of(getLeg(KC_METRO_AGENCY_ID, "975", 1));

calculateFare(rides, regular, VASHON_WATER_TAXI_CASH_FARE);
calculateFare(rides, FareType.senior, VASHON_WATER_TAXI_CASH_FARE);
calculateFare(rides, FareType.senior, usDollars(3f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(4.50f));
calculateFare(rides, FareType.electronicRegular, usDollars(5.75f));
Expand All @@ -395,8 +391,7 @@ void calculateSoundTransitBusFares() {
getLeg(KC_METRO_AGENCY_ID, "550", 240)
);
calculateFare(rides, regular, usDollars(9.75f));
// Sound Transit does not accept senior fares in cash
calculateFare(rides, FareType.senior, usDollars(9.75f));
calculateFare(rides, FareType.senior, usDollars(3.00f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(3f));
calculateFare(rides, FareType.electronicRegular, usDollars(9.75f));
Expand All @@ -410,7 +405,7 @@ void calculateSoundTransitBusFares() {
getLeg(PIERCE_COUNTY_TRANSIT_AGENCY_ID, "501", 60)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(2));
calculateFare(rides, FareType.senior, TWO_DOLLARS);
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(1f));
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE);
Expand All @@ -430,7 +425,7 @@ void calculateCashFreeTransferKCMetroAndKitsap() {
getLeg(KITSAP_TRANSIT_AGENCY_ID, 132)
);
calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE.times(4));
calculateFare(rides, FareType.senior, DEFAULT_TEST_RIDE_PRICE.times(4));
calculateFare(rides, FareType.senior, usDollars(4.25f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(1.25f));
calculateFare(rides, FareType.electronicRegular, DEFAULT_TEST_RIDE_PRICE.times(2));
Expand All @@ -442,12 +437,12 @@ void calculateCashFreeTransferKCMetroAndKitsap() {
void calculateTransferExtension() {
List<Leg> rides = List.of(
getLeg(KITSAP_TRANSIT_AGENCY_ID, 0, 4, "Kitsap Fast Ferry", "east"), // 2.00
getLeg(KC_METRO_AGENCY_ID, 100), // Default ride price, extends transfer
getLeg(KC_METRO_AGENCY_ID, 100), // Default ride price, extends transfer for regular fare
getLeg(KITSAP_TRANSIT_AGENCY_ID, 150, 4, "Kitsap Fast Ferry", "west") // 10.00
);
var regularFare = usDollars(2.00f).plus(DEFAULT_TEST_RIDE_PRICE).plus(usDollars(10f));
calculateFare(rides, regular, regularFare);
calculateFare(rides, FareType.senior, regularFare);
calculateFare(rides, FareType.senior, usDollars(7f));
calculateFare(rides, FareType.youth, Money.ZERO_USD);
calculateFare(rides, FareType.electronicSpecial, usDollars(6f));
calculateFare(rides, FareType.electronicRegular, usDollars(10f)); // transfer extended on second leg
Expand Down
Loading

0 comments on commit 8bcd4e2

Please sign in to comment.