Skip to content

Commit

Permalink
Merge pull request #5055 from HSLdevcom/DT-6182-scooter-fixes
Browse files Browse the repository at this point in the history
DT-6182 Scooter fixes
  • Loading branch information
vesameskanen authored Sep 2, 2024
2 parents 954e31d + 1846d82 commit cb561f8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
40 changes: 30 additions & 10 deletions app/component/itinerary/ItineraryPageUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,21 +356,41 @@ export function transitEdges(edges) {
}

/**
* Filters away itineraries that don't use scooters
* Filters away itineraries that
* 1. don't use scooters
* 2. only use scooters
* 3. use scooters that are not vehicles
*/
export function scooterEdges(edges) {
if (!edges) {
return [];
}
return edges.filter(
edge =>
edge.node.legs.some(
leg => leg.mode === 'SCOOTER' && leg.from.rentalVehicle,
) &&
edge.node.legs.every(
leg => leg.mode !== 'SCOOTER' || leg.from.rentalVehicle,
),
);

const filteredEdges = [];

edges.forEach(edge => {
let hasScooterLeg = false;
let hasNonScooterLeg = false;
let allScooterLegsHaveRentalVehicle = true;

edge.node.legs.forEach(leg => {
if (leg.mode === 'SCOOTER' && leg.from.rentalVehicle) {
hasScooterLeg = true;
} else if (leg.mode !== 'SCOOTER' && leg.mode !== 'WALK') {
hasNonScooterLeg = true;
}

if (leg.mode === 'SCOOTER' && !leg.from.rentalVehicle) {
allScooterLegsHaveRentalVehicle = false;
}
});

if (hasScooterLeg && hasNonScooterLeg && allScooterLegsHaveRentalVehicle) {
filteredEdges.push(edge);
}
});

return filteredEdges;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/component/map/tile-layer/RentalVehicles.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RentalVehicles {
this.shouldShowRentalVehicle(
feature.properties.id,
feature.properties.network,
feature.properties.isDisabled,
feature.properties.pickupAllowed,
feature.properties.formFactor,
)
) {
Expand Down Expand Up @@ -163,14 +163,14 @@ class RentalVehicles {
);
};

shouldShowRentalVehicle = (id, network, isDisabled, formFactor) =>
shouldShowRentalVehicle = (id, network, pickupAllowed, formFactor) =>
(!this.tile.stopsToShow || this.tile.stopsToShow.includes(id)) &&
(!network ||
(this.config.vehicleRental.networks[network].enabled &&
this.config.vehicleRental.networks[network].showRentalVehicles &&
this.config.vehicleRental.networks[network].type ===
formFactor.toLowerCase())) &&
!isDisabled;
pickupAllowed;

static getName = () => 'scooter';

Expand Down
1 change: 1 addition & 0 deletions app/util/planParamUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export function getPlanParams(
case PLANTYPE.SCOOTERTRANSIT:
access = ['WALK', 'SCOOTER_RENTAL'];
egress = access;
direct = access;
break;
default: // direct modes
direct = [planType];
Expand Down

0 comments on commit cb561f8

Please sign in to comment.