From 89481f60beb210f3dcc9d9e21a3b67baf5040221 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Thu, 5 Sep 2024 11:13:14 -0400 Subject: [PATCH 01/38] refactor: correct comment location --- packages/otp2-tile-overlay/src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/otp2-tile-overlay/src/index.tsx b/packages/otp2-tile-overlay/src/index.tsx index 468c0e5cf..7fbfa8d7f 100644 --- a/packages/otp2-tile-overlay/src/index.tsx +++ b/packages/otp2-tile-overlay/src/index.tsx @@ -26,12 +26,12 @@ const OTP2TileLayerWithPopup = ({ setViewedStop, type }: { + color?: string; /** * Optional configuration item which allows for customizing properties of scooter and * bikeshare companies. If this is provided, scooter/bikeshare company names can be rendered in the * default scooter/bike popup. */ - color?: string; configCompanies?: ConfiguredCompany[] id: string name?: string From 776c10457f6b93a86ac12be624e5092848b53dfb Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Thu, 5 Sep 2024 18:36:30 -0400 Subject: [PATCH 02/38] fix: add `stopsWhitelist` to hide non-selected stops --- packages/otp2-tile-overlay/src/index.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/otp2-tile-overlay/src/index.tsx b/packages/otp2-tile-overlay/src/index.tsx index 7fbfa8d7f..58f0a9a5d 100644 --- a/packages/otp2-tile-overlay/src/index.tsx +++ b/packages/otp2-tile-overlay/src/index.tsx @@ -24,6 +24,7 @@ const OTP2TileLayerWithPopup = ({ onMapClick, setLocation, setViewedStop, + stopsWhitelist, type }: { color?: string; @@ -56,6 +57,11 @@ const OTP2TileLayerWithPopup = ({ * not passed, the stop viewer link will not be shown. */ setViewedStop?: StopEventHandler + /** + * A list of GTFS stop ids (with agency prepended). If specified, all stops that + * are NOT in this list will be HIDDEN. + */ + stopsWhitelist?: string[] /** * Determines which layer of the OTP2 tile data to display. Also determines icon color. */ @@ -135,6 +141,9 @@ const OTP2TileLayerWithPopup = ({ if (type === "stops" || type === "areaStops") { filter = ["all", ["!", ["has", "parentStation"]], ["!=", ["get", "routes"], ["literal", "[]"]]] } + if (stopsWhitelist) { + filter = ["in", ["get", "gtfsId"], ["literal", stopsWhitelist]] + } const isArea = AREA_TYPES.includes(type) return ( @@ -148,6 +157,7 @@ const OTP2TileLayerWithPopup = ({ }} source-layer={type} source={SOURCE_ID} + minzoom={stopsWhitelist ? 2 : 14} type="fill" />} {isArea && } @@ -202,6 +213,7 @@ const OTP2TileLayerWithPopup = ({ * @param endpoint The OTP endpoint to make the requests to * @param setLocation An optional method to make from/to buttons functional. See component for more detail. * @param setViewedStop An optional method to make stop viewer button functional. See component for more detail. + * @param stopsWhitelist An optional list of stops to display singularly. See component for more detail. * @param configCompanies An optional list of companies used to prettify network information. * @returns Array of and components */ @@ -210,6 +222,7 @@ const generateOTP2TileLayers = ( endpoint: string, setLocation?: (location: MapLocationActionArg) => void, setViewedStop?: (stop: Stop) => void, + stopsWhitelist?: string[], configCompanies?: ConfiguredCompany[] ): JSX.Element[] => { return [ @@ -236,6 +249,7 @@ const generateOTP2TileLayers = ( network={network} setLocation={setLocation} setViewedStop={setViewedStop} + stopsWhitelist={stopsWhitelist} type={type} visible={initiallyVisible} /> From 13ad822b624d87a938f8cb0e4959f2a2f2ce4a2b Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 13 Sep 2024 15:09:53 -0400 Subject: [PATCH 03/38] fix: `isFlex` truthy more of the time --- .../core-utils/src/__tests__/itinerary.ts | 16 +++++++ packages/core-utils/src/itinerary.ts | 42 ++++++++++++++----- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/packages/core-utils/src/__tests__/itinerary.ts b/packages/core-utils/src/__tests__/itinerary.ts index ee4a49c7f..0053b7e1e 100644 --- a/packages/core-utils/src/__tests__/itinerary.ts +++ b/packages/core-utils/src/__tests__/itinerary.ts @@ -9,6 +9,7 @@ import { getLegRouteLongName, getLegRouteName, getLegRouteShortName, + isFlex, isTransit, mapOldElevationComponentToNew } from "../itinerary"; @@ -16,6 +17,7 @@ import { const bikeRentalItinerary = require("./__mocks__/bike-rental-itinerary.json"); const tncItinerary = require("./__mocks__/tnc-itinerary.json"); const fareProductItinerary = require("./__mocks__/fare-products-itinerary.json"); +const flexItinerary = require("../../../itinerary-body/src/__mocks__/itineraries/flex-itinerary.json"); const basePlace = { lat: 0, @@ -40,6 +42,20 @@ describe("util > itinerary", () => { }); }); + describe("isFlex", () => { + it("should detect flex if present", () => { + fareProductItinerary.legs.forEach(leg => expect(isFlex(leg)).toBe(false)); + tncItinerary.legs.forEach(leg => expect(isFlex(leg)).toBe(false)); + expect(isFlex(flexItinerary.legs[0])).toBe(false); + expect(isFlex(flexItinerary.legs[1])).toBe(false); + expect(isFlex(flexItinerary.legs[2])).toBe(false); + expect(isFlex(flexItinerary.legs[3])).toBe(false); + expect(isFlex(flexItinerary.legs[4])).toBe(false); + expect(isFlex(flexItinerary.legs[5])).toBe(true); + expect(isFlex(flexItinerary.legs[6])).toBe(false); // Does not exist + expect(isFlex(flexItinerary.legs[7])).toBe(false); // Does not exist + }); + }); describe("isTransit", () => { it("should work", () => { expect(isTransit("CAR")).toBeFalsy(); diff --git a/packages/core-utils/src/itinerary.ts b/packages/core-utils/src/itinerary.ts index aac986a49..282949eee 100644 --- a/packages/core-utils/src/itinerary.ts +++ b/packages/core-utils/src/itinerary.ts @@ -52,7 +52,7 @@ export function isTransit(mode: string): boolean { * property which encodes this info. */ export function isReservationRequired(leg: Leg): boolean { - return leg.boardRule === "mustPhone" || leg.alightRule === "mustPhone"; + return leg?.boardRule === "mustPhone" || leg?.alightRule === "mustPhone"; } /** * Returns true if a user must ask the driver to let the user off @@ -61,25 +61,45 @@ export function isReservationRequired(leg: Leg): boolean { */ export function isCoordinationRequired(leg: Leg): boolean { return ( - leg.boardRule === "coordinateWithDriver" || - leg.alightRule === "coordinateWithDriver" + leg?.boardRule === "coordinateWithDriver" || + leg?.alightRule === "coordinateWithDriver" ); } -/** - * The two rules checked by the above two functions are the only values - * returned by OTP when a leg is a flex leg. - */ -export function isFlex(leg: Leg): boolean { - return isReservationRequired(leg) || isCoordinationRequired(leg); -} +export function containsGeometry(place: Place): boolean { + return ( + place?.stop?.geometries !== null && place?.stop?.geometries !== undefined + ); +} +export function endsWithGeometry(leg: Leg): boolean { + return containsGeometry(leg?.to); +} +export function startsWithGeometry(leg: Leg): boolean { + return containsGeometry(leg?.from); +} +export function legContainsGeometry(leg: Leg): boolean { + return endsWithGeometry(leg) || startsWithGeometry(leg); +} export function isAdvanceBookingRequired(info: FlexBookingInfo): boolean { return info?.latestBookingTime?.daysPrior > 0; } export function legDropoffRequiresAdvanceBooking(leg: Leg): boolean { - return isAdvanceBookingRequired(leg.dropOffBookingInfo); + return isAdvanceBookingRequired(leg?.dropOffBookingInfo); } +/** + * The two rules checked by the above two functions are the only values + * returned by OTP when a leg is a flex leg. + */ +export function isFlex(leg: Leg): boolean { + return ( + isReservationRequired(leg) || + isCoordinationRequired(leg) || + legDropoffRequiresAdvanceBooking(leg) || + isAdvanceBookingRequired(leg?.pickupBookingInfo) || + legContainsGeometry(leg) + ); +} export function isRideshareLeg(leg: Leg): boolean { return !!leg.rideHailingEstimate?.provider?.id; } From 8e3f3e1a858c3d468634208a0c2697577bbee28d Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 13 Sep 2024 20:24:42 +0000 Subject: [PATCH 04/38] chore(release): 1.0.16 [skip ci] # [@opentripplanner/otp2-tile-overlay-v1.0.16](https://github.com/opentripplanner/otp-ui/compare/@opentripplanner/otp2-tile-overlay-v1.0.15...@opentripplanner/otp2-tile-overlay-v1.0.16) (2024-09-13) ### Bug Fixes * add `stopsWhitelist` to hide non-selected stops ([776c104](https://github.com/opentripplanner/otp-ui/commit/776c10457f6b93a86ac12be624e5092848b53dfb)) --- packages/otp2-tile-overlay/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/otp2-tile-overlay/package.json b/packages/otp2-tile-overlay/package.json index 52fd29718..9e5942c84 100644 --- a/packages/otp2-tile-overlay/package.json +++ b/packages/otp2-tile-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@opentripplanner/otp2-tile-overlay", - "version": "1.0.15", + "version": "1.0.16", "description": "Render data from OTP2's vector tile server", "main": "lib/index.js", "module": "esm/index.js", From dc9c14eb538553198d2b5a55e72495d0af653ce0 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 16 Sep 2024 16:29:11 +0000 Subject: [PATCH 05/38] chore(release): 11.4.5 [skip ci] # [@opentripplanner/core-utils-v11.4.5](https://github.com/opentripplanner/otp-ui/compare/@opentripplanner/core-utils-v11.4.4...@opentripplanner/core-utils-v11.4.5) (2024-09-16) ### Bug Fixes * `isFlex` truthy more of the time ([13ad822](https://github.com/opentripplanner/otp-ui/commit/13ad822b624d87a938f8cb0e4959f2a2f2ce4a2b)) --- packages/core-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-utils/package.json b/packages/core-utils/package.json index a6cdeaf1e..f9b3c18ef 100644 --- a/packages/core-utils/package.json +++ b/packages/core-utils/package.json @@ -1,6 +1,6 @@ { "name": "@opentripplanner/core-utils", - "version": "11.4.4", + "version": "11.4.5", "description": "Core functionality that is shared among numerous UI components", "engines": { "node": ">=13" From 708ef0001f0acdca1cb2ba5bd8ee49ba1f4e970b Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:36:24 -0500 Subject: [PATCH 06/38] fix(map-popup): prevent null closepopup, fix ids --- packages/map-popup/src/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/map-popup/src/index.tsx b/packages/map-popup/src/index.tsx index 6f699803e..6f1e03b3e 100644 --- a/packages/map-popup/src/index.tsx +++ b/packages/map-popup/src/index.tsx @@ -101,7 +101,7 @@ function entityIsStation(entity: Entity): entity is Station { /** * Renders a map popup for a stop, scooter, or shared bike */ -export function MapPopup({ closePopup = null, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element { +export function MapPopup({ closePopup = () => null, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element { const intl = useIntl() if (!entity) return <> @@ -115,7 +115,7 @@ export function MapPopup({ closePopup = null, configCompanies, entity, getEntity const stopId = !bikesAvailablePresent && entity?.code || entity.id.split(":")[1] || entity.id // Double quotes make the query invalid, so remove them from the id just in case - const id = `focus-${entity.id}-popup`.replace(/"/g, "") + const id = `focus-${encodeURIComponent(entity.id).replace(/%/g, "")}-popup` return ( From 570c7aef2a1ecb06df4e7b35d0c228b541d35ef5 Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:39:39 -0500 Subject: [PATCH 07/38] fix(otp2-tile-overlay): pass closepopup to map-popup --- packages/otp2-tile-overlay/src/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/otp2-tile-overlay/src/index.tsx b/packages/otp2-tile-overlay/src/index.tsx index 58f0a9a5d..09199b297 100644 --- a/packages/otp2-tile-overlay/src/index.tsx +++ b/packages/otp2-tile-overlay/src/index.tsx @@ -192,6 +192,7 @@ const OTP2TileLayerWithPopup = ({ onClose={() => setClickedEntity(null)} > setClickedEntity(null)} configCompanies={configCompanies} entity={{ ...clickedEntity, id: clickedEntity?.id || clickedEntity?.gtfsId }} setLocation={setLocation ? (location) => { setClickedEntity(null); setLocation(location) } : null} From 455fa204d2c7f3cdbb536560d1e424cc1f47559b Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:45:34 -0500 Subject: [PATCH 08/38] change default close popup map-popup function --- packages/map-popup/src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/map-popup/src/index.tsx b/packages/map-popup/src/index.tsx index 6f1e03b3e..0d4f913e8 100644 --- a/packages/map-popup/src/index.tsx +++ b/packages/map-popup/src/index.tsx @@ -101,7 +101,7 @@ function entityIsStation(entity: Entity): entity is Station { /** * Renders a map popup for a stop, scooter, or shared bike */ -export function MapPopup({ closePopup = () => null, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element { +export function MapPopup({ closePopup = () => {}, configCompanies, entity, getEntityName, setLocation, setViewedStop }: Props): JSX.Element { const intl = useIntl() if (!entity) return <> From bf0af67f36a1dbe1dc9099a1f7546f62308ec055 Mon Sep 17 00:00:00 2001 From: Daniel Heppner Date: Tue, 17 Sep 2024 17:42:48 -0700 Subject: [PATCH 09/38] feat(core-utils): add isTransitLeg function that uses the transitLeg property --- packages/core-utils/src/itinerary.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core-utils/src/itinerary.ts b/packages/core-utils/src/itinerary.ts index 282949eee..ebb287119 100644 --- a/packages/core-utils/src/itinerary.ts +++ b/packages/core-utils/src/itinerary.ts @@ -42,6 +42,10 @@ export function getTransitModes(config: Config): string[] { ); } +export function isTransitLeg(leg: Leg): boolean { + return leg.transitLeg; +} + export function isTransit(mode: string): boolean { return transitModes.includes(mode) || mode === "TRANSIT"; } From 45820a9b826b90182cdcaa1dc83c43ff748666fb Mon Sep 17 00:00:00 2001 From: amy-corson-ibigroup <115499534+amy-corson-ibigroup@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:05:08 -0500 Subject: [PATCH 10/38] update snapshots --- packages/map-popup/src/__snapshots__/MapPopup.story.tsx.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/map-popup/src/__snapshots__/MapPopup.story.tsx.snap b/packages/map-popup/src/__snapshots__/MapPopup.story.tsx.snap index 809b8c3bd..9ba1045f3 100644 --- a/packages/map-popup/src/__snapshots__/MapPopup.story.tsx.snap +++ b/packages/map-popup/src/__snapshots__/MapPopup.story.tsx.snap @@ -59,7 +59,7 @@ exports[`Map Popup FloatingCarEntity smoke-test 1`] = ` exports[`Map Popup FloatingVehicleEntity smoke-test 1`] = `
-