Skip to content

Commit

Permalink
Merge pull request #890 from stadtnavi/feat/itinerary-page-bike-rent
Browse files Browse the repository at this point in the history
feat(itinerary-page): show bike rent and park only itineraries
  • Loading branch information
andreashelms authored Jan 21, 2025
2 parents ae1e577 + 9e57c16 commit 2dd3c19
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/component/ItineraryListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class ItineraryListContainer extends React.Component {
'onDemandTaxi',
'car',
'scooter',
'bike',
];
const { hash } = this.props.params;
if (modesWithSubpath.includes(hash)) {
Expand Down
27 changes: 18 additions & 9 deletions app/component/ItineraryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class ItineraryPage extends React.Component {
transitItineraries(result.bikeAndPublicPlan?.itineraries),
['BICYCLE'],
);
const bikeRentAndPublicPlan = filterItineraries(
const bikeRentAndPublicItineraries = filterItineraries(
transitItineraries(result.bikeRentAndPublicPlan?.itineraries),
['BICYCLE'],
);
Expand All @@ -288,9 +288,10 @@ class ItineraryPage extends React.Component {
itineraries: [
...bikeParkItineraries.slice(0, 3),
...bikePublicItineraries.slice(0, 3),
...bikeRentAndPublicPlan.slice(0, 3),
...bikeRentAndPublicItineraries.slice(0, 3),
],
};

this.bikeAndParkItineraryCount = Math.min(
bikeParkItineraries.length,
3,
Expand All @@ -302,15 +303,19 @@ class ItineraryPage extends React.Component {
);

this.bikeRentAndPublicItineraryCount = Math.min(
bikeRentAndPublicPlan.length,
bikeRentAndPublicItineraries.length,
3,
);

const bikePlan = {
...result.bikePlan,
itineraries: filterItineraries(result.bikePlan?.itineraries, [
'BICYCLE',
]),
itineraries: filterItineraries(
[
...(result.bikePlan?.itineraries || []),
...(result.bikeRentAndPublicPlan?.itineraries || []),
...(result.bikeParkPlan?.itineraries || []),
],
['BICYCLE'],
).filter(itinerary => itinerary.legs.every(l => !l.transitLeg)),
};

const parkRidePlan = {
Expand All @@ -324,8 +329,12 @@ class ItineraryPage extends React.Component {
walkPlan: result.walkPlan,
bikePlan,
bikeTransitPlan,
bikeRentAndPublicPlan: result.bikeRentAndPublicPlan,
bikeParkPlan: result.bikeParkPlan,
bikeRentAndPublicPlan: {
itineraries: bikeRentAndPublicItineraries,
},
bikeParkPlan: {
itineraries: bikeParkItineraries,
},
scooterRentAndPublicPlan: result.scooterRentAndPublicPlan,
carPlan: result.carPlan,
carRentalPlan: result.carRentalPlan,
Expand Down
3 changes: 2 additions & 1 deletion app/component/ItineraryPageUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export function showDetailView(hash, secondHash, itineraries) {
if (
hash === streetHash.bikeAndVehicle ||
hash === streetHash.parkAndRide ||
hash === streetHash.scooter
hash === streetHash.scooter ||
hash === streetHash.bike
) {
// note that '0' < 1 in javascript, because strings are converted to numbers
return secondHash < itineraries.length;
Expand Down
2 changes: 0 additions & 2 deletions app/util/planParamUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,6 @@ export const preparePlanParams = (config, useDefaultModes) => (
// - include itineraries with rented `BICYCLE` legs
// - include itineraries without any `BICYCLE` legs whatsoever
{ mode: 'BICYCLE', qualifier: 'RENT' },
// TODO: OTP seems to require FLEX DIRECT to return bike rental & transit results, to be checked
{ mode: 'FLEX', qualifier: 'DIRECT' },
...modesAsOTPModes(getBicycleCompatibleModes(config, modesOrDefault)),
],
bannedBicycleParkingTags,
Expand Down

0 comments on commit 2dd3c19

Please sign in to comment.